I\'m having problems finding the right hook to use for my plugin. I\'m trying to add a message to the top of each page by having my plugin add a function. What\'s the best h
I searched the internet for answers to the same question but found nothing. I figured out away to to work around it. My plugin infinite Ad Pay is based on this method.
You need two hooks wp_head and wp_footer hook
add_action( 'wp_head', 'my_buffer_holder_fxn');
function my_buffer_holder_fxn(){
ob_start()
}
function my_buffer_pour_out_fxn(){
$get_me_buffers = ob_get_clean();
$pattern ='/<[bB][oO][dD][yY]\s[A-Za-z]{2,5}[A-Za-z0-9 "_=\-\.]+>|/';
ob_start();
if(preg_match($pattern, $get_me_buffers, $get_me_buffers_return)){
$d_new_body_plus =$get_me_buffers_return[0]." This is below the body text or image or anything you want ";
echo preg_replace($pattern, $d_new_body_plus, $get_me_buffers);
}
ob_flush();
}
}
add_action( 'wp_footer', 'my_buffer_pour_out_fxn');
// You can also use the method above to place anything in other sections of WordPress
//No Javascript used