Is that possible for overwriting a plugin templates via making a folder in theme file and copy the file in that folder and altering the content [both folder and file name have the same name as arranged in plugin ].
Generally we altering the woocommerce page templates by following these system .Woothemes has implemented something similar for their woocommerce plugin. You copy files from /wp-content/plugins/woocommerce <–>to<–> /wp-content/themes/yourthemes/woocommerce and WP automatically uses the files in the theme folder rather than the plugin folder. This way users can make customizations to their plugins without losing them to a plugin update..Is that possible for all plugin ?
If no , what code that make woocommerce plugin to change the style based on the file inside our theme folders woocoomerce folder ?
or What about CHILD PLUGIN concept ?
is there any possible way ?
Woocommerce checks first does file
/wp-content/themes/yourthemes/woocommerce
exists and reqire it. If not it require general template from/wp-content/plugins/woocommerce
Simple possible solution in your plugin, you can use.
And now you can use as you want your
loadTemplate()
function like so:Of course remember to prefix your functions or put it in a Class. This is just simple example.
Not tested. May be some errors.
EDIT:
Just to answer all questions. Here is precisely how woocommerce is doing this
EDIT2:
It’s possible for all plugins which have this feature implemented.
There is no general answer. If plugin provide an API to its functionallities, you could create such child plugin. But depending directly on current plugin code is bad idea. When your
parent plugin
(1) is gonna change, your plugin will break if you are using function that has been removed or edited.But as I said, if plugin provide consistent API, and it’s enough to write such functionaliity, then yes. But not for all plugins. At least without editing plugins itself.
(1) There is no such thing like
child plugin
orparent plugin
oficially.