[wp-hackers] Detecting and fixing non-compliant themes

Andy Skelton skeltoac at gmail.com
Thu Dec 28 15:55:55 GMT 2006


On 12/21/06, Dan Kuykendall <dan at kuykendall.org> wrote:
> For podPress I have to hook into the wp_head() call which should be in
> the header.php and the wp_footer() in the footer.php

This was a problem for me almost two years ago when I wrote my first
plugins (CMC and BOTD) and the most common support request was from
people with non-compliant themes.

Here's an alternate idea for testing themes on activation. Similar to
the way we call wp-cron, request home?hooktest=1.

if ( isset($_GET['hooktest']) ) {
  add_action('wp_head', 'wp_head_test', 99999);
  add_action('shutdown', 'wp_hook_test');
}

function wp_head_test() {
  define('WP_HEAD', true);
}

function wp_hook_test() {
  update_option('hook_wp_head', constant('WP_HEAD'));
}

Thereafter, test get_option('hook_wp_head').

Adding wp_footer is left as an exercise for the reader.

Feel free to use this in your plugin or suggest a core implementation.

Andy


More information about the wp-hackers mailing list