On Sun, Jul 3, 2011 at 4:08 AM, Chip Bennett <span dir="ltr"><<a href="mailto:chip@chipbennett.net">chip@chipbennett.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>1) Anything hooked in using <b>wp_enqueue_style()</b> or <b>wp_enqueue_script()</b> can be undone by calling <b><font color="#ff0000">wp_dequeue_style()</font></b> and <b><font color="#ff0000">wp_dequeue_script()</font></b>, respectively.</div>
<div><br></div><div>2) Anything hooked in using <b>add_action( 'wp_head', 'some_custom_function' )</b> can be undone by calling <b><font color="#ff0000">remove_action( 'wp_head', 'some_custom_function' )</font></b></div>
</blockquote><div><br></div><div>Am I missing any options? Are there any other ways for Plugins to inject content into the HTML document head? </div></blockquote><div><br>(Playing devil's advocate here) I can think of a case where remove_action() could not be used:<br>
<br><div style="margin-left: 40px;">class My_Class {<br> function __construct() {<br> add_action( 'wp_head', array( $this, 'output_some_html' ) );<br> }<br>}<br><br>new My_Class;<br></div><br>Since you can't get to the instance of My_Class, you can't unhook it.<br>
<br>Even if the last line read:<br><br><div style="margin-left: 40px;">$GLOBALS['my_class'] = new My_Class;<br></div><br>remove_action() still won't work: <a href="http://core.trac.wordpress.org/ticket/10535">http://core.trac.wordpress.org/ticket/10535</a><br>
<br>That's why I use static methods:<br><br>
<div style="margin-left: 40px;">class My_Class {<br>
static function init() {<br>
add_action( 'wp_head', array( __CLASS__, 'output_some_html' ) );<br>
}<br>
}<br>
<br>
My_Class::init();</div><br>Then you could confidently call remove_action( 'wp_head', array( 'My_Class', 'output_some_html' ) );<br><br><br></div></div>-- <br><a href="http://scribu.net" target="_blank">http://scribu.net</a><br>