Bonne façon de modifier le plugin
-
-
Cochez ** "Prolonger sansmodifier" **.Je considère que c'est la solutionpratiquementmeilleure.Consultez ce lienpourplus de détails - [Labonnefaçon depersonnaliser unplugin WordPress] (https://iandunn.name/the-right-way-to-customize-a-wordpress-plugin/)Check on **"Extend Without Modifying"**. I consider this is the practically better solution. Check this link for details - [The Right Way to Customize a WordPress Plugin](https://iandunn.name/the-right-way-to-customize-a-wordpress-plugin/)
- 1
- 2015-09-17
- Eugine Joseph
-
5 réponses
- votes
-
- 2011-07-14
Àmon humble avis,lameilleure approcheest soit defourcher leplug-inpourmaintenir vosmodifications,soit de soumettre des correctifs au développeur duplug-in,pour que vosmodifications soientintégrées auplug-in d'origine.
Créer un "Plugin Enfant"n'est vraimentpasfacile.Le concept "Thèmeenfant" s'applique vraiment aux fichiers demodèle qui sont utilisés,plus que lesfonctions dethème (eten fait,lefichier
functions.php
à lafois Parentet Enfantêtre chargé,ce qui cause desproblèmespour lesfichiersfunctions.php
mal codés dans lethèmeenfant ouparent).IMHO, the best approach is either to fork the Plugin to maintain your changes, or else submit patches to the Plugin developer, to have your changes made a part of the original Plugin.
Creating a "Child Plugin" really isn't easy. The "Child Theme" concept really applies to the template files that get used, moreso than the Theme functions (and in fact, the
functions.php
file from both Parent and Child get loaded, which does cause problems for improperly codedfunctions.php
files in either the Child or Parent Theme).-
Lestypes demodifications quej'apporte sont spécifiques au siteet jene pense doncpas que lafourchette ou la soumission de correctifs serait appropriée.Je vais certainementgarder cela à l'espritpour des améliorationsplusgénérales desplugins.The types of changes I'm making are site-specific and so I don't think forking or submitting patches would be appropriate. I'll definitely keep those in mind for more general improvements to plugins.
- 0
- 2011-07-14
- Mike Wheaton
-
Maisbifurquerestessentiellement ce que vousfaites * déjà *.Engros,ce sont vos options:fork oupatch.@Chris_O offre unbonmoyen depouvoirextraire desmises àjour automatiquesen amont,touten conservant votreplug-inforké.But forking is basically what you're *already doing*. Basically, those are your options: fork, or patch. @Chris_O gives a good way to be able to pull in automatic updates from upstream, while maintaining your forked Plugin.
- 0
- 2011-07-14
- Chip Bennett
-
- 2011-07-19
La "bonne"manière dépend évidemment duplugin.Certainsplugins sontplusfaciles àmodifier que d'autres,mais laplupart despluginspeuventen fait êtremodifiéspar d'autresplugins.
Parexemple,si unplugin a unefonction connectée à WordPress avec une action,il vous suffit de créer un autreplugin qui décroche cettefonction avec remove_action,puis ajoute votrefonction de remplacement à laplace.Cetype deméthode vouspermettra de remplacer desfonctionsindividuelles dans despluginspar vospropres versionsmodifiées,sansmodifier leplugin d'origine.
Lemême conceptfonctionne avec lesfiltres,évidemment.
The "right" way obviously depends on the plugin. Some plugins are easier to edit than others, but most plugins can actually be modified by other plugins.
For example, if a plugin has a function hooked into WordPress with an action, then it's a simple matter for you to make another plugin that unhooks that function with remove_action, and then adds your replacement function in instead. This sort of method will let you replace individual functions in plugins with your own modified versions, without modifying the original plugin.
Same concept works with filters, obviously.
-
- 2011-07-14
Lemeilleurmoyen serait de simplement le cloneret de changer lenom duplugin dans l'en-têteet de changer lenom du répertoire.De cettefaçon,vouspourriez également avoir l'originalinstallémaispas activé afin que vous recevieztoujours des alertes lorsque desmises àjour serontpubliées.
<?php /* Plugin Name: Name Of The Plugin Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates Description: A brief description of the Plugin. Version: The Plugin's Version Number, e.g.: 1.0 Author: Name Of The Plugin Author Author URI: http://URI_Of_The_Plugin_Author License: A "Slug" license name e.g. GPL2 */ ?>
The best way would be to just clone it and change the Plugin Name in the header and change the directory name. This way you could also have the original installed but not activated so you will still get alerts when updates are released.
<?php /* Plugin Name: Name Of The Plugin Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates Description: A brief description of the Plugin. Version: The Plugin's Version Number, e.g.: 1.0 Author: Name Of The Plugin Author Author URI: http://URI_Of_The_Plugin_Author License: A "Slug" license name e.g. GPL2 */ ?>
-
Celanécessitetoujours depasserpar denouvelles versions dupluginpourtrouver lesmodifications (je suppose qu'un outil de comparaison de versions aiderait),puis de copier cesmodifications surmonpluginpersonnalisé. Je suppose queje pourraistélécharger lepluginet utiliser SVNpourfusionner lesmodifications avecma versionpersonnalisée.This still requires going through new versions of the plugin to find changes (I suppose a version comparison tool would help) and then copying those changes over to my custom plugin. I suppose I could download the plugin and use SVN to merge the changes with my custom version.
- 0
- 2011-07-14
- Mike Wheaton
-
Il y a un lien direct vers lefichier diff sur le lien dujournal de développement sur lapage desplugins.Parexemple,voici un diffgénéré àpartir de [W3 Total Cache] (http://plugins.trac.wordpress.org/changeset/406303/w3-total-cache/trunk/wp-content/db.php)There is a direct link to the diff file on the development log link on the plugins page. For example here is diff generated from [W3 Total Cache](http://plugins.trac.wordpress.org/changeset/406303/w3-total-cache/trunk/wp-content/db.php)
- 2
- 2011-07-14
- Chris_O
-
- 2011-07-17
C'est relativementfacile si lepluginest sous contrôle de source Giten raison de lanature distribuée de Git,mais denombreuxplugins WordPress (ettous ceux du dépôt officiel) sont dans Subversion.J'utilise branches defournisseurs et svn_load_dirs.php sije vraiment besoin demodifier unplugin,mais celanécessite unniveau de confort raisonnablement élevé avec Subversion.
Si lepluginn'expose aucun référentiel,je vous recommande de letransformer vous-mêmeen référentiel Gitet d'appliquermanuellement lesnouvelles versions.
Enfin de compte,les systèmes de contrôle de version sont le seulmoyen sensé de réappliquer lesmodifications auxnouvelles versionsen amont.
This is relatively easy if the plugin is under Git source control due to Git's distributed nature, but many WordPress plugins (and all of those in the official repository) are in Subversion. I use vendor branches and svn_load_dirs.php if I really need to modify a plugin, but this requires a reasonably high comfort level with Subversion.
If the plugin exposes no repository, I'd recommend turning it into a Git repository yourself and manually applying new versions.
In the end, version control systems are the only sane way to reapply changes to new upstream versions.
-
- 2011-07-19
Je suis d'accord avec la réponse d'Annika Backstrom ,maisjeJe souhaitepartagerma solutionpréférée.
Comme laplupart desplugins sont sous svn,j'utilise un outil appelégit-svnpour créer unmiroirgit.
Ensuite,je créejuste unebrancheet j'y validemesmodifications.
Lorsque lepluginestmis àjouren amont,je viens de sortir du repo svnet defusionner dansmabranchepersonnalisée.
I agree with Annika Backstrom's answer, but I'd like to share my preferred solution.
Since most plugins are under svn, I use a tool called git-svn to make a git mirror.
Then, I just make a branch and commit my changes there.
When the plugin is updated upstream, I just pull from the svn repo and merge into my custom branch.
Quelleest lameilleurefaçon demodifier unplugin?Je souhaite souvent apporter depetitesmodifications à une ou deuxfonctions dans ungrosplugin.Cela sefaitfacilement,maisje dois utiliser des commentairespourmarquermesmodificationset modifier ànouveau leplugin après unemise àjour.Idéalement,j'aimerais laisser leplugin seulet apportermesmodifications ailleurs,unpeu commenous lefaisons avec lesthèmeset lesthèmesenfants.Puis-je créer unplugin quinécessite lepluginparentet qui le remplacera?