How can I override ANY plugin in my wordpress child theme - wordpress

There are some plugins that I can override in my child theme (e.g. woocommerce, BuddyPress, bbpress, etc). Usually creating a folder named the same as the plugin in the child theme root and making changes there. However, that doesn't always work for ANY plugin. I'd rather not make any structural changes in the plugin itself since it will be all gone on a plugin update. But I made a copy of the plugin in the child theme and it didn't do anything. How can I do this so that I can still get all the functionality I need from the main plugin and still have my alterations prevail?

Related

Css modified after wordpress update

I have updated my WordPress version. The style of the css is modified. I have a backup version. Should I take the oldest file for plugins and theme in order to resolve that issue?
you should have a child theme and put your custom css in the css-file from your child-theme.
Your child-theme would not touch from any update and your custom code is save
Taken from the WordPress Codex:
WARNING: The upgrade process will affect all files and folders included in the main WordPress installation. This includes all the core files used to run WordPress. If you have made any modifications to those files, your changes will be lost.
When you do any theme changes you should always put your changes in either a custom theme you have made yourself (so only you update it), or if you're using someone else's theme, create a child theme.
More information about child themes can be found here:
A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way of modifying an existing theme.
As for plugins, they don't work in the same way so you'll need to make sure that any plugins you change are your own otherwise you'll lose the changes when you update them.
Lastly, you can also use the WordPress Customiser (Appearance > Customize in the dashboard) if you don't want a child theme but want to insert custom CSS. That allows you to edit CSS safely within the dashboard and keep your changes safe even when you update things.

Overwriting Builder WooCommerce Templates from Child Theme

I'm having some issues overwriting a Builder WooCommerce (a Themify plugin that interacts with WooCommerce http://themify.me/addons/woocommerce) template from with a child theme. My child theme is set up and working, and I can successfully overwrite the WooCommerce product page images from (childTheme/woocommerce/single-product/product-image.php). That all works great, but when I try and overwrite a template within the Builder WooCommerce Plugin (product listing template) nothing seems to happen.
I've copied the appropriate template file into (childTheme/builder-woocommerce/template-products-list.php) and made modifications, but they are not coming through at all. Is it for some reason why overriding this plugin doesn't work?
I contacted Themify support, and was told:
Child theme can only save theme files. Builder woocommerce is a addon/plugin. It is not possible to save plugin files through child theme. You can copy customized files manually and replace it with the updated file after plugin update.
Unfortunately, it doesn't seem possible to make changes to any template file within this plugin from a child theme.

How use theme's function into plugin's file in Wordpress

I am building a simple plugin of wordpress, and trying to use theme's function into plugin's file, but it is saying "Call to undefined function", while that function exists in themes.php of current active theme.that function is in use in theme's files but can't accessible in plugin's file, can anyone guide what to do?
while I have to attach plugin with theme as mandatory plugin.
Thank you
Plugins are loaded before the theme so the function hasn't been defined at the time you're calling it. Execute your code on a hook such as init instead.
E.g.
function wpse_my_plugin_init() {
myPreviouslyUndefinedThemeFunction();
}
add_action( 'init', 'wpse_my_plugin_init' );
See here for a list of hook options: https://codex.wordpress.org/Plugin_API/Action_Reference
The earliest opportunity you have to call this code would be after_setup_theme.
On another note I'd suggest rethinking this approach. A plugin should be an independent module; it shouldn't be tied to your theme.
Your approach/design is serious flawed. Plugin functionality should never rely on theme functionality. As already pointed out by #NathanDawson, plugins get loaded first, then child theme functions then parent theme functions, so your approach will never work as indented or without a lot of unnecessary bloated code
Plugins are meant to extend site functionality, and not theme functionality. I think this is where your idea is seriously flawed, and most probably due to a lack of knowledge on who should do what and when
As I have stated, plugins should give functionality to the site. Functionalities like favicons, custom post types, custom taxonomies, shortcodes, widgets, related posts and rewrite rules should be in a plugin. This gives functionality to your site, which simply mean, when you change the theme, these functionalities won't change or they won't be affected. Also, if the plugin is removed, it doesn't change the way how the theme looks and operate.
Theme specific functions are functions that gives functionality to the theme itself. Without these functions, the theme looses functionality or its looks. It simply means thant the theme changes. These functions includes functions to enqueue your stylesheets and scripts, theme suppport functions, sidebars, custom headers and backgrounds and registering image sizes.
If you are going to make a plugin rely on theme code, you should be looking to create a child theme, as child themes are meant to extend the main theme. Child themes inherit all functionalities from the parent theme, and can extend, modify or add new functionality to the parent theme.
To conclude, by making a plugin rely on theme code, you are making your site very vulnerable to breakage. If you change your theme, you will break your site as you will break your plugin. This is not how plugins and themes were made to interact. By creating a child theme instead, you void that risk as child themes cannot be activated without the parent theme being in the theme's folder and neither can any two themes be activated at the same time.

How to make a custom theme with plugins in WordPress?

I have created my own theme in WordPress. In that theme i'm using other plugins ( jQuery Photo slider ). Now I want to use this theme for a different website. Can i save plugins with the theme? First off, is this even possible?
This is my first attempt in WordPress.
You are not allowed to add plugins along with your theme, but you can always send a readme along with the theme, telling the user what plugins you want them to use, or you could just zip the plugins located in the plugin folder and make that as a custom extra choice to apply when using your theme.

Unable to install bbpress themes

I am having an issue with a wordpress and a bbpress plugin. I need to install a bbpress theme, but I can't seem to have them show up in admin, although I put it in the right directory. I have also tried with other themes, same result.
This is a bit hacky, but I was able to theme bbpress by building a child theme. By making a child theme instead of altering the plugin theme directly, you will make sure that your style changes won’t be overwritten if and when you update the plugin.
Start by copying the bbpress theme out of the plugin folder (I started working off the bbp-twentyten theme), and pasting it into the Wordpress themes folder. Rename it with whatever you want your new bbpress theme to be called. Go into themes > your child theme's name > style.css and add this in the header:
#import url('../ the name of your parent theme /style.css');
Theme Name: Name of your Child theme
Description: Description of child theme.
Author: Your name
Template: The name of your parent theme
Go in to the appearance > theme area of your Wordpress dashboard and see if your new theme appears. If it does, install it.
Your site should look exactly like it did before. What happens is that #import url allows the theme to pull all the styles from the parent theme, which you can then override without messing up the original.
Now edit the style.css file in themes > your-child-theme. Just be aware that if you make a change that doesn’t seem to load, you may need to add an !important to the style.

Resources