October 7, 2008

I’ve been working on a new theme, which will be applied to this site after all the others, and because of the way I have created it I have had to call a lot of the hooks manually. For example, I am not using the template tag the_content, instead I am using apply_filters( ‘the_content’ , $this->post->post_content ); inside a function. This has made me think about the types of filters and actions we should expect to see in plugins.

There are conceivably three things that I might want to override with someone else plugin:

These can be achieved in a few different ways.

Assuming the data is retrieved using standard WordPress functions then being able to filter an array of default values before the query goes ahead should do the trick. This would allow plugins to be expanded to do things that weren’t originally intended.

Using callbacks to process data, and then filtering the name of that callback would allow significant parts of a plugin to be overriden; for example:

[php]
$callback = apply_filters('my_plugin_function_callback',array($this,'myfunction'));
$returned_data = array_filter ( $input , $callback );

Finally, using templates to output content, checking the current theme to see if there is an alternative template in the theme folder, and sending the template path through a filter before hand would give maximum flexibility.

How difficult or easy all this would be very much depends on the plugin. My question is whether we should built in this way and more importantly whether we should expect plugins to be as configurable as the core itself.

In my next post I will write a plugin that uses all of these techniques, and then modify it with a second plugin to demonstrate the benefits of this.



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 plugin post separator?
no comment on page 1371

Wordpress pictue cache lschen?
9 comments on page 1310

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

Css login screen?
no comment on page 128

Comments by intensedebate?
7 comments on page 1175

Image gallery html 5?
6 comments on page 1305

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

Photoshop frameworks?
3 comments on page 296

Html5 gallery?
6 comments on page 1305

Login screen css template?
no comment on page 128

Html5 photo gallery code?
6 comments on page 1305

Wordpress post multiple images?
24 comments on page 1065

Html 5 photo gallery?
6 comments on page 1305
  every 1983s, 1s ago, in 0.02s.
 __
(__)
   `
 Configurable Plugins | WP FUN

[...] should plugins should be written to be as extensible, if not more, as the core WordPress code; i.e. should we expect a plugin to be written with the expectation that someone will write a plugin to fur… I promised an example so here it [...]


0s