DevinVinson / WordPress-Plugin-Boilerplate

[WordPress] A foundation for WordPress Plugin Development that aims to provide a clear and consistent guide for building your plugins.
http://wppb.io
7.62k stars 2.25k forks source link

Best Practice for Managing Free/Freemium and Pro/Premium Code #553

Open spuddick opened 3 years ago

spuddick commented 3 years ago

Hi, I have been using this plugin boilerplate for many years, it is great. I plan on creating some new plugins soon and want to set a good foundational architecture, as well as make my life easy in terms of version control. There will be both a free and pro (paid) version. The pro version will contain a lot of the functionality of the free version. In some cases the pro version will need to override some hooks that were set in the free version. Essentially this is my plan:

I am wondering if others agree with the approach I plan on taking or have any other suggestions, specifically related to how WPPB is structured. I think others may benefit from seeing this conversation too. Thanks!

UVLabs commented 3 years ago

I recommend building the base plugin as a normal free plugin and adding a folder called pro to include pro related classes that extend the free classes.

So when releasing the free version you simply remove that pro folder. I plan on using freemius to automatically take care of this for me and I've started implementing it.

The pro folder is automatically removed as well as some pro-related code in the free version that calls pro methods. Such as my settings page.

More settings are pulled from the pro folder if the class exists. But after running the plugin through freemius this code is completely removed for the free version