Add Plugins to WordPress Theme

I’m creating a wordpress theme that I aim to sell at some point.

Now, I’ve discovered that some of the wordpress.org plugins would be great for things that I want to do. They already hold much of the functionality I aim to achieve, so I thought of using them directly (they are under GPL I suppose).

I would probably need to adjust stuff, but I was wondering. Is there any universal-like way to include wordpress plugins inside my theme and not in the separate plugins folder ?

That would be ideal, because I do not really want customers to have to copy to different folders. At first glance of the plugins, it seems not possible, but I suppose it never hurts to ask 🙂

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Let me make a recommendation: do not bundle plugins with your theme!

On first glance, yes this is a very easy way to add default functionality with your theme, but there are a slew of reasons not to include the plugins this way:

  1. Updates: If the plugin is freely available from WordPress.org already, then so are automatic updates to the plugin. The original author can add features, fix bugs, and deploy them quickly. Your clients and customers then benefit from on-going development. If you were to package them in your theme, though, you are essentially freezing the code at that point in time – any further updates, bug fixes, etc. would have to come from you. This means you’ll need to continuously release theme updates whenever the included plugins update.
  2. Updates: When WordPress updates, some plugins will break. This is because the original authors didn’t take the time to remove deprecated functionality or test with new versions of WP. Do you really want to commit to maintaining your theme + someone else’s code?
  3. Interoperability: As the great mfields once said, “If you’re building a bathroom and you change the wallpaper, the toilet shouldn’t disappear, too.” Users should be able to swap out themes whenever they want without losing their content, their custom data, or the additional functionality they have on their site. Remember, themes are meant for presentation, plugins are meant for functionality.

There have been plenty of other people who’ve talked about this in the past.

The better way to do this would be to have your theme check for specific plugins and prompt the user for installation if they’re missing.

Method 2

This class was built with your question and idea in mind. It solves that problem by allowing theme authors to include pre-packaged plugins or plugins from the repo with ease.

https://github.com/thomasgriffin/TGM-Plugin-Activation

Method 3

I strongly believe that if you aim to sell at some point you should NOT include/use GPL plugins and only your own!!!

Now after that being said simply include the plugin’s main file you your theme’s functions.php and edit all path’s


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x