[theme-reviewers] Question about ob_start and ob_get_clean (Vicky Arulsingam)
scribu
mail at scribu.net
Sun Jul 3 01:27:09 UTC 2011
On Sun, Jul 3, 2011 at 4:08 AM, Chip Bennett <chip at chipbennett.net> wrote:
> 1) Anything hooked in using *wp_enqueue_style()* or *wp_enqueue_script()*can be undone by calling
> *wp_dequeue_style()* and *wp_dequeue_script()*, respectively.
>
> 2) Anything hooked in using *add_action( 'wp_head', 'some_custom_function'
> )* can be undone by calling *remove_action( 'wp_head',
> 'some_custom_function' )*
>
>
> Am I missing any options? Are there any other ways for Plugins to inject
> content into the HTML document head?
>
(Playing devil's advocate here) I can think of a case where remove_action()
could not be used:
class My_Class {
function __construct() {
add_action( 'wp_head', array( $this, 'output_some_html' ) );
}
}
new My_Class;
Since you can't get to the instance of My_Class, you can't unhook it.
Even if the last line read:
$GLOBALS['my_class'] = new My_Class;
remove_action() still won't work:
http://core.trac.wordpress.org/ticket/10535
That's why I use static methods:
class My_Class {
static function init() {
add_action( 'wp_head', array( __CLASS__, 'output_some_html' ) );
}
}
My_Class::init();
Then you could confidently call remove_action( 'wp_head', array( 'My_Class',
'output_some_html' ) );
--
http://scribu.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20110703/31f5df5e/attachment-0001.htm>
More information about the theme-reviewers
mailing list