WordPress Plugin Development In MVC Architecture, How?

You could definitely use an MVC philosophy in the development of a plugin, but you would be really silly to try to incorporate CI or Cake in addition to WP.

For instance, you could build out a plugin using the following pseudo structure (FYI, there are a ton of ways to build this, depending on your interpretation of MVC. This is just the quick example that pops into mind):

class Plugin(){
    function __construct(){ // controller?
        run conditionals/determine query
        process model
        process view
    }
    function model(){ 
        get query from database 
        return variables
    }
    function view(){
        echo html
    }
}

This might be a horrible example of a plugin structure, or even of MVC, but it is simply to illustrate that MVC architecture !== MVC frameworks and that MVC can be used in plugin design. Widget classes and other functionality throughout WP are similar, although without any explicit separation of concerns.

Leave a Comment