mercredi 21 octobre 2015

Structure/Design Pattern Solution

I am attempting to create a WordPress plugin and ran into a road block. I am creating a settings page that will need to be extended by child classes. The main class will look something like this.

class SettingsPage {

    // Properties

    // Methods

   public function metaboxes() {
       add_meta_box( //metabox params );
   }   

}

This class will handle the main settings page. I now want to be able to crete meta boxes from within several child classes. Basically extending/appending to the metaboxes() method.

class MetaBoxOne extends SettingsPage {

    public function metabox() {

         // add another metabox

    }

}

What would be the best solution for this problem? I've been staring at my code editor for a few hours trying to figure it out with no luck. Any help would be greatly appreciated.

Is inheritance the best route?

Aucun commentaire:

Enregistrer un commentaire