January 23, 2009

One of the big strengths of WordPress is that there are thousands of themes available, a significant number of which contain similar solutions to similar problems. So why is it that it was even necessary to add something like wp_page_menu which is, at best, a tame solution to a very simple problem?

There are a lot of themes with really excellent solutions, but once you look under the hood you very often find that the entire solution is built as a one time only function into functions.php, or worse, into the template itself. If you want to take a menu and add a new item to it you need to hard code it, modify the code directly, or hook into the functions that output the pages in the first place. Needless to say you might be better off writing your own, and so many do.

I have long advocated the use of plugins with themes. It is a real shame that WordPress won’t look in the theme folder for plugins, but despite this, I think the ability to disable parts of the theme is a beneficial one.

First of all it is nice to be able to remove menu items that will never be used. Not essential, but nice.

Secondly, even with the UI removed the theme might still be making unnecessary database calls to verify that something doesn’t exist. It is an excellent idea to build a theme so the user has the option to override the defaults, for example the option to create a page that contains the content for the 404 response, but with a lot of these things there could be a lot of extra database calls.

Finally, of course, the ability to take a GPL theme and create a new one using some of its parts is fundamental to the success of WordPress. If you can simply state that a particular plugin is required for some of the base functions then you are already a winner.

Despite these good points the fact remains that WordPress is now a consumer product that actively discourages direct access to files and code, so if you can’t bundle plugins with the theme and rely on users to move the files above, the chances are high that they will never get installed anyway unless the theme simply cannot function without it. Even then I suspect many users will simply ditch the theme and find something that does work. Back to square one.

Even if you can’t offer the option to turn off the functions you can still code in a way that makes it modular. By abstracting functions into platform generic classes you make them as modular as it is possible to be. Is there any reason why all the presentation code for a menu should directly tap into the WordPress API to get the page details when functions.php can transfer it into a more generic class?

Wouldn’t it be better if the great developers from other platforms could contribute toward code for WordPress, and vice versa?

Navigation is the obvious area that jumps out for me because every site needs menus and once you have a generic menu class you can begin to do a lot more with it. Soon, I will let you have a look at a menu class I am developing for a theme on another platform. It will work perfectly with WordPress as well, not because it is coded for both platforms, but because it is coded for neither. There are many other areas that would do as well. What about a generic text processing class?, tag clouds, archive navigation (although that could be done via a generic navigation class anyway).

I don’t know how much of your theme code you want to share with others, or how much you want to take from others, but next time you are creating some relatively complex code to format something in your theme consider how necessary it is to connect that code directly to WordPress, and if you can, separate it, and share it.

That, after all, is the idea behind open source and community development, isn’t it?



Wordpress feature image page?
24 comments on page 1065

Addsettingsfield?
3 comments on page 793

Shorter link?
4 comments on page 1190

Shorter link?
4 comments on page 1190

Cssimageforlogin?
no comment on page 128

Cssimageforlogin?
no comment on page 128

Get featured image url wordpress?
24 comments on page 1065

How to clear wpcache?
9 comments on page 1310

Photo gallry code html5?
6 comments on page 1305

Wordpress get image size?
24 comments on page 1065

Sitecouk wptheme?
2 comments on page 1376

Wordpress chat disqus?
no comment on page 1308

Howtocreategoodsizelayout?
4 comments on page 1026

Friend connect profile?
6 comments on page 1364

Get medium image from post?
24 comments on page 1065

Tabbed widgets wp?
no comment on page 333

Wordpress pictue cache lschen?
9 comments on page 1310

Wordpress plugin post separator?
no comment on page 1371

Display photos html 5?
6 comments on page 1305

Fun wordpress themes?
2 comments on page 1376

Wp featured image without size?
24 comments on page 1065

Wordpress get url global?
4 comments on page 1190

Wp unlimited?
3 comments on page 1141

Html5 image gallery?
6 comments on page 1305

Wordpress exif plugin?
12 comments on page 230

Css login screen?
no comment on page 128

Htlm 5 photo gallery?
6 comments on page 1305

Image gallery html 5?
6 comments on page 1305

Css login screen?
no comment on page 128

Comments by intensedebate?
7 comments on page 1175

Wordpress andrew rickmann?
2 comments on page 1376

Wordpress medium large?
24 comments on page 1065

Fun with uninstallation wordpress?
53 comments on page 100

How to clear wp cache?
9 comments on page 1310

Html5 gallery?
6 comments on page 1305

Photoshop frameworks?
3 comments on page 296

Wordpress post multiple images?
24 comments on page 1065

Html 5 photo gallery?
6 comments on page 1305

Login screen css template?
no comment on page 128

Html5 photo gallery code?
6 comments on page 1305
  every 2003s, 1s ago, in 0.02s.
 __
(__)
   `
 Andrew Rickmann Spotlight Special – Word Press Magazine

[...] How modular should a theme be? – Instead of providing a summary, I’ll provide a teaser for you as this is a pretty interesting question: I don

 __
(__)
   `
 donnacha | WordSkill

Interesting ideas and I look forward to seeing your menu class.

 __
(__)
   `
 Andrew Rickmann

Well, in fairness it does follow the WordPress model of wrapping fairly simply code in functions to create template tags. Is the_title actually any better than echo $post->title, for example.

That said, I have always felt it was a half-hearted attempt. Perhaps it does actually do what the majority want, which is to just output pages as a menu, but I want more, by default.

 __
(__)
   `
 WordPress links week 4 – 2009 | WPStart.org – WordPress themes, plugins and news

[...] How modular should a theme be? [...]

 __
(__)
   `
 Ryan

Is there any logical reason for wp_page_menu existing? It seems utterly pointless to me.


0s