Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mu_footer_filter(){
- function my_start_footer_ob() {
- ob_start("my_end_footer_ob_callback");
- }
- add_action('wp_footer', 'my_start_footer_ob');
- function my_end_footer_ob() {
- ob_end_flush();
- }
- add_action('wp_footer', 'my_end_footer_ob', 1000);
- function my_end_footer_ob_callback($buffer) {
- /** The Following Preg replace / Buffer Does Not Work **/
- //$buffer = preg_replace('/<div id=\"test\">.*<\/div>/', 'asdf', $buffer);
- //return $buffer;
- /** The HTML Portion does not work **/
- $doc = new DOMDocument;
- $doc->loadHTML($buffer);
- $docElem = $doc->getElementById("test");
- if($docElem !== NULL) // if it exists
- $docElem->parentNode->removeChild($docElem);
- return $doc->getElementsByTagName('body')->firstChild->nodeValue;
- }
- }
- add_action('muplugins_loaded', 'mu_footer_filter');
- function test(){
- $test = '<div id="test">test</div>';
- // $test = preg_replace('/<div id=\"test\">.*<\/div>/', '', $test); // This Preg Replace is functional.
- echo $test;
- }
- add_action('wp_footer', 'test');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement