Tag Archives: design

WordPress Controller Design Overview

I’ve been thinking about this and I really do think that the code could be improved for the Model-View-Controller implementation. My focus is more on the model and view and not the model however. There is code which exists in different files, which I would like to combine in some areas and split up in others. Some areas do things that it probably shouldn’t be required to do.

Rewrite Component

The rewrite component tries to find, or query what controller is needed to be run. The difficult parts are figuring out what method is being used. Is the page being accessed using URL query vars, or for example index.php?p=## is it the path info method (index.php?/2007/10/5/1) or finally is it the mod rewrite method or permalinks.

It is highly possible that the code might be an combination of the query vars and permalinks. The rewrite module must enable the plugin or code to transform their code to use one or the other. It still must support query vars along with path info or permalinks.

There will be several support classes along with the Rewrite Component. The first will determine whether or not mod_rewrite is even enabled (probably use an option like now). Another component to test each of the methods described above and return the one that makes the most sense. Finally, the last support class will extract the URL useful information based on the query vars and, or URL path.

The main component class will be the WordPress_Rewrite class, which will be used to push to the controller to handle the code.

Mod_Rewrite Component

This component, I want to seriously overhaul to simplify the code base and try out some fluid interface design. It will most likely use most of the same code, but split up into multiple classes.

Controller Component

Ah, the catch with this is that the Controller just needs to be an object or function, which loads the correct template or plugin file. So I mean, you could very well say that the Rewrite class is the controller, but the hook or object will be expected and run.

Possibly Related Posts: