Since you ruled out remove_action
there is only one way you can do it. And you’ve guessed it: preg_repalce
, substr
mixture but with a little help and PHP DOM
add_action('wp_footer', 'my_start_footer_ob', 1);
function my_start_footer_ob() {
ob_start("my_end_footer_ob_callback");
}
add_action('wp_footer', 'my_end_footer_ob', 1000);
function my_end_footer_ob() {
ob_end_flush();
}
function my_end_footer_ob_callback($buffer) {
// remove what you need from he buffer
return $buffer;
}
Within my_end_footer_ob_callback
you edit the $buffer
to your needs. The $buffer
parameters should have all the contents of the footer after all actions and filters have been call to action. If it does not simply edit 1000
to a bigger number so that my_end_footer_ob
is called last.
Now, I do not know what HTML contents that action produces but you can use pre_replace
or a sequence of substr
s to remove it.
If you want to use PHP DOM do it like this:
function my_end_footer_ob_callback($buffer) {
// remove what you need from he buffer
$doc = new DOMDocument;
$doc->loadHTML($buffer);
$docElem = $doc->getElementById("theID");
if($docElem !== NULL) // if it exists
$docElem->parentNode->removeChild($docElem);
return $doc->getElementsByTagName('body')->firstChild->nodeValue;
}
Tell me if this works for you.