Thread Starter
mlaw93
(@mlaw93)
I found a way, although now I have to be careful with upgrades – I added a method called aFhfc_execute_php. I call it before returning the final html.
/*
F R O N T E N D O U T P U T
===============================
Outputs the head and footer code for individual posts
*/
function aFhfc_execute_php($html){
if(strpos($html,"<"."?php")!==false){ ob_start(); eval("?".">".$html);
$html=ob_get_contents();
ob_end_clean();
}
return $html;
}
function aFhfc_head_output( $post ) {
$aFhfc_head_code = get_post_meta( get_the_ID(), 'aFhfc_head_code', true );
echo aFhfc_execute_php($aFhfc_head_code)."\n";
}
add_action('wp_head', 'aFhfc_head_output');
function aFhfc_footer_output( $post ) {
$aFhfc_footer_code = get_post_meta( get_the_ID(), 'aFhfc_footer_code', true );
echo aFhfc_execute_php($aFhfc_footer_code)."\n";
}
add_action('wp_footer', 'aFhfc_footer_output');
Well done! Yeah, there is no way as is, so an implementation such as this one would be necessary. If you want to avoid update notifications so you don’t accidentally update it, you can do this:
- Backup the code you have in all of the AddFunc Head & Footer Code fields (in a text document), don’t forget individual Page/Post meta fields
- Rename the plugin directory (whatever you want, but no spaces)
- Rename the main plugin file (addfunc-head-footer-code.php in this case), giving it the exact same name you gave the directory
- Paste your code back into their respective fields
This basic procedure works with all plugins and you will no longer see update notifications. However, some plugins may not function properly afterwards.