Every week we are asked to undo a fork of a popular plugin. The fork worked once, then the plugin updated and the fix silently stopped applying. There is a better way.
Never edit vendor files
Any change you make inside a plugin folder disappears on the next update. If the file is gone, the change is gone, and so is any behaviour you depended on.
Use the plugin’s own extension points
Hooks, filters and template overrides exist for this. A small child theme or a focused mu-plugin using documented hooks is upgrade-proof.
When you truly need a different behaviour
- Check whether a settings screen or a filter already does it.
- If not, write it as a small plugin that depends on the target plugin.
- Guard every hook so your code is a no-op if the other plugin is deactivated.
- Document which plugin and version it was written against.
add_action( 'woocommerce_before_checkout_form', 'mplus_checkout_note' );
function mplus_checkout_note() {
if ( ! function_exists( 'WC' ) ) { // no-op if Woo is gone
return;
}
echo '<p class="mplus-note">Orders placed before 2pm ship today.</p>';
}
One plugin, one job. Small focused plugins are easier to review, easier to delete and much easier to hand over.