I knew that we can create child themes for wordpress. But i want to know can we create child plugins. The reason for this is i want to insert some text or something to the existing plugin without touching the plugin files. So my changes will not be affected while upgrading the plugin. Please advice it is possible or not. Thanks
Use hooks & filters to modify your plugin function from your theme's functions.php. So it won't be affected at plugin upgrade time.
Have a look # PluginAPI
there is no "child" plugin in wordpress... just create a separate plugin to do what you want it to do. It sounds like you would need to use a filter.
Related
I am new to Wordpress/WooCommerce and PHP, although I have experience in other web platforms and languages.
I have read numerous articles about adding code to WooCommerce and where to place your code, and of course there are many different answers.
It seems that the most common answers are to place you code in the child themes functions file, while others say that you should create your own plug-in and place the code there.
I am leaning toward my own plug-in so that if the theme is updated or changed, the code wont be lost.
Can a hook (created by calling add_action()) and it's associated function be
created in my own plug-in?
Thanks,
Eric
Yes, you can override actions/filters of wordpress or any other plugin via your plugin.
Apart from that, if you use child theme (inheriting parent theme) you do not loose the customization you have made via child theme even when the parent theme is updated.
If the theme is changed all together, there is possibility that your customization may behave different as the actions/hooks can be used differently in themes.
Hope this helps.
I'm making a web with a Wordpress and modifying some things with a child and css theme. The problem is that the theme uses a folder with the name "Wp-less-Cache" and inside it introduces a "theme-less.css" that it generates automatically. The problem is that now when I try to modify something by css the my mytheme.css (in the child) does not leave me because it tells me that what I want to retouch belongs to the file "theme-less.css" .... and if I tweak the CSS directly in that, it works but when this file is generated again automatically after a while it deletes the modifications that I had made in it.
I would like to know:
Can you disable the wp-less-cache? it is not in my list of plugins or among the plugin folders ...
Can I do something so that my modifications of the child theme are effective if he is active?
Thank you very much
It is used by one plugin called tlg_framework which is a built in plugin with themes that developed by http://www.themelogi.com/
The WordPress plugin WooCommerce allows me to overwrite any of its files by making a copy of that file and placing it in my child theme directory. This does not work for other plugins.
How does this functionality work for WooCommerce?
Why doesn't it work for other plugins?
How can I make it work for other plugins?
Not all plugins need this functionality so it is not standard, it's just something you can allow your plugins users to do if it is relevant to its functionality / theming.
There is a great article here on how to achieve it for your own plugins, however you cannot apply this to existing plugins unless you want your copy of an existing authors work to fall out of date.
http://jeroensormani.com/how-to-add-template-files-in-your-plugin/
How does this functionality work for WooCommerce?
The magic is in the coding of Woocommerce. They have added functionalities in to cater for this because of the technicality of their system and the demand for customization.
Why doesn't it work for other plugins?
Woocommerce have added this functionality within their development to cater for this functionality, simply said other plugins have not added this functionality to extend or customize their add-ons.
How can I make it work for other plugins?
The answer to this is hooks. The same way plugins "HOOK" onto wordpress, you can create a hook to do the same for the plugin. Have a search at "custom hooks"
This is because WooCommerce has implemented this functionality in their plugin.
Overwriting plugins is not a Wordpress core functionnality.
You can't overwrite a custom plugin, the only way is to duplicate his content creating a new plugin, and customize this new plugin made by yourself..
I am working on a WordPress website, with WooCommerce functionality.
I am currently trying to remove the social sharing feature, which is displayed on the Product Pages. I am trying to achieve this through the removal of the Action from its Hook, by placing the following code in the functions.php file:
<?php
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
?>
Said functions.php is placed within the Child Theme I have created.
Unfortunately, this is not removing the social sharing feature. Does anyone know why? To see if there was an issue with the Hooks, I added an Action to the same Hook, to which this worked.
Could it be possible that the Social Sharing feature has been placed in some parent folder which overrides/has higher priority over the functions.php file in the Child theme? If this is the case, what would be my options in getting said feature removed. I can only think of placing the affected file in the Child theme and then manually removing the relevant coding. This is a last resort as it may cause problems, at a later date, when parent files are updated etc.
woocommerce_template_single_sharing() calls the Woocommerce template located at woocommerce/templates/single-product/share.php where there's a do_action call for other plugins & themes to add social sharing. If you want to "block" plugins from using that, your best bet (if you're building a theme) would be to use the built-in Woocommerce template override feature and simply prevent this do_action from firing. This would not cause any problems unless Woocommerce did a massive, structural rework. But otherwise, updating Woocommerce and any other plugins or a parent theme wouldn't affect your child theme.
In your child theme, create a directory called woocommerce, add a sub-directory called single-product, and then copy the share.php file from the above location in the plugin to that location in your theme.
Comment out the do_action and voila! No more social sharing and anything that hooks into that do_action won't run.
As an alternative...if you know exactly what's hooking into that do_action, you would run a remove_action on that bad boy, but then you need to hunt these things down and manually update your call any time a plugin tries to hook into it.
You could use https://codex.wordpress.org/Function_Reference/remove_all_actions
add_action('plugins_loaded', function(){
remove_all_actions('woocommerce_share_hook');
});
I should edit the dynamic_sidebar() function on wordpress (hiding some categories, editing the template).
Is it possible? I read "you need to edit the core", but I don't have understand where is this "core" :)
Never edit the core. The reason is that if you change the default behaviour, themes you install might not work and updates to the wordpress engine will break your changes.
To change the way your wordpress behaves, create a child theme. Then add a functions.php file and in it create a widget that has your desired behaviour.
You can also register a new type of sidebar and a page templates that shows only that type of sidebar.
See: http://codex.wordpress.org/Child_Themes and https://codex.wordpress.org/Function_Reference/register_sidebar_widget
Personally, you sound like your just starting out so I will give you some advice. Never edit the core.
It's tempting for a quick fix. Everyone has done it when they didn't know any better, but you have the opportunity to learn the right way.
Approach your problem logically. What are you trying to edit it for? Hiding some categories? Use the internal widget system in the CMS and take them off. Delete the categories, or hide them with CSS {display:none;}.
Good luck my young Padawan. I hope you take some advice and heed it well.
Best way is to probably make a Child template using the plugin One-click child theme. Copy the file containing the function to the child template (using ftp) and edit it there. This way you can update your template and still keep your changes.