• Hi,

    Let’s say I developed this existing plugin (free) with basic functionality. I would like to add extra functionality and make it a paid plugin.

    So what’s the best way to maintain these 2 plugins?

    I think there are 2 ways to do it, it’s just I’m not sure which way is the best.

    1. extends class or
    2. apply_filters

    Method 1.

    class MySetting {
    
    public function somefunction() {
    }
    
    }
    
    class PremiumSettings extends MySetting {
          public function somefunction() {
               parent::somefunction();
               //add some extra functionality here
          }
    }
    
    $settings = PremiumSettings();

    or Method 2.

    instead of extending MySetting class, I’ll add do_action or apply_filters to all of my functions in MySetting, then I’ll just call add_action, add_filter and use the hook to add functionality.

    So which way is the best? Please advise

Viewing 3 replies - 1 through 3 (of 3 total)
  • Best for who?
    You as developer, maintaining two codebases, or users switching from one to the other, or other developers that want to add functionality?

    Perhaps you need to use a mixture of both, so you don’t have to be changing the free version so that another thing can happen in the paid version (or other plugins).

    It’s not just about settings, but activation and deactivation and updates and default values and the action that the settings cause.

    Thread Starter redjersey

    (@redjersey)

    @joyously what I meant is which method will be the easiest to maintain 2 codebases.

    Dion

    (@diondesigns)

    I’ve maintained “basic” and “premium” versions of a plugin for the past 4+ years. What worked for me was to build the “premium” plugin from the “basic” codebase, and then do all development on the “premium” plugin. If a new premium feature made sense to go into the basic version, it has been added, but no time has been spent trying to add/change/delete features specific to the basic codebase. The above has also applied to bugfixes.

    In terms of actually starting the dev work for your premium plugin, do what works best for the plugin. In my case, I took the basic plugin and added code where it was required. Extending classes would not have worked, nor would adding action/filter hooks. The base code itself needed to change in order for most of the new features to work the way I wanted. For example, if your basic plugin has some sort of admin interface, it’s unlikely you will be able to extend it via the two methods you listed. It will probably require adding code to the current admin interface.

    Anyway, I hope this helps. Good luck!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Best way to add extra functionality to an existing plugin?’ is closed to new replies.