Skip to content

Instantly share code, notes, and snippets.

@cori
Created October 8, 2011 13:55
Show Gist options
  • Save cori/1272309 to your computer and use it in GitHub Desktop.
Save cori/1272309 to your computer and use it in GitHub Desktop.
Wordpress Custom hook problem
class hook_client {
static function start() {
//logging here shows that this function is being called
add_filter('custom_filter', array(__CLASS__, 'filter_handler'), 1, 2 );
//logging here shows that the custom_filter hook is being hooked to
}
static function filter_handler($content, $postdata) {
//logging here shows that this method is never entered
//do stuff with $content
return $content
}
}
hook_client::start();
class plugin {
function do_stuff() {
// do some stuff with $content
$postdata['content'] = apply_filters('custom_filter', $content, &$postdata);
// logging $postdata['content'] returns null here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment