Yoast/wordpress-seo — pull request #176 by GaryJones (2013-08-19 12:40:53+00:00)
Title: Make closing comment marker unhookable.

The opening and closing comment (debug) markers are unhookable via the following:

~~~php
add_action( 'init', 'prefix_init', 15 );
/**
* Remove WordPress SEO comment markers.
*/
function prefix_init() {
global $wpseo_front;
remove_action( 'wpseo_head', array( $wpseo_front, 'debug_marker' ), 2 ); // Remove opening WP SEO comment
remove_action( 'wp_head', array( $wpseo_front, 'head' ), 1 ); // Remove closing WPSEO comment
add_action( 'wp_head', 'gamajo_wpseo_head', 1 ); // Reinstate custom WPSEO head action
}

function prefix_wpseo_head() {
global $wp_query;

$old_wp_query = null;

if ( ! $wp_query->is_main_query() ) {
$old_wp_query = $wp_query;
wp_reset_query();
}

do_action( 'wpseo_head' );

// Closing comment marker removed from here

if ( ! empty( $old_wp_query ) ) {
$GLOBALS['wp_query'] = $old_wp_query;
unset( $old_wp_query );
}

return;
}
~~~

If the `echo "\n\n";` line in `WPSEO_Frontend::head()` was hooked in to `wpseo_head` at a very late priority (it already immediately follows the hook), then it could be unhooked without having to define a clone of `head()` instead, with something like:

~~~php
add_action( 'init', 'prefix_init', 15 );
/**
* Remove WordPress SEO comment markers.
*/
function prefix_init() {
global $wpseo_front;
remove_action( 'wpseo_head', array( $wpseo_front, 'debug_marker' ), 2 ); // Remove opening WP SEO comment
remove_action( 'wpseo_head', array( $wpseo_front, 'debug_closing_marker' ), 999 ); // Remove closing WPSEO comment
}
~~~