Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Child Plugin for wordpress

Actually I have changed some code in WordPress Store Locator. I want it to remain when plugin will update. So I want to create a child plugin for that. Any ideas on how I could manage it?

like image 977
Jalaj Kumar Avatar asked Jun 08 '18 18:06

Jalaj Kumar


People also ask

Can you make a child plugin WordPress?

The first thing you want to do is install and activate the Child Theme Configurator plugin. You can do this from the plugin repository located in your WordPress admin dashboard. Once the plugin has been install and activated, click on Tools > Child Themes. This will take you to the Child Theme Configurator main page.

Should I create a child theme WordPress?

Child themes are the best way to customize a WordPress theme because they save time and effort. The parent theme already contains lots of formatting and functionality, so you don't have to code everything from scratch. They also make it safe to update your WordPress themes.


1 Answers

This varies plugin to plugin, and it sometimes isn't even possible, other times plugins have documentation to extend them easily (such as WooCommerce and Gravity Forms). Some of them create Action Hooks with do_action() that let you extend the functionality easily. A common example is updating a post after a Gravity Form is submitted with their gform_after_submission hook.

Effectively, it depends on what you want to do, and how the plugin implements the functionality you want to change. If they add text with a Closure or Anonymous Function, it will be harder to modify said text, and you may have to look at something strange like doing a run-time find and replace using Output Buffering, typically on the template_redirect hook.

If you want to remove something a plugin does, you can often unhook it with remove_action. This can be a bit tricky depending on how the plugin is instantiated, sometimes its as simple as:

remove_action( 'some_hook', 'function_to_remove' );

Other times it's more complicated like:

global $plugin_class_var;
remove_action( 'some_hook', array($plugin_class_var, 'function_to_remove') );

Those are the basics of extending (or even 'shrinking'?) a plugin's functionality, and it's not always doable appropriately. Unfortunately the narrow answer to your question is outside of the scope of what we can provide from StackOverflow.

From here, you'll need to figure out exactly what you want to do with the plugin, and dig through the plugin's files to see if there's an appropriate hook or function you can use. If you're still stuck, you'll need to post a new question (don't update this one) with your exact desired result and anything you've tried, and the relevant code that goes along with it. "I want to change a plugin without editing core files" isn't nearly specific enough. "I want to replace an icon with a custom icon in this plugin, here's what I've tried" is specific enough to possibly answer.

Good luck!

like image 119
Xhynk Avatar answered Oct 18 '22 05:10

Xhynk