Can I get the post ID during the 'init' or 'plugins_loaded' action?
-
I REALLY need to get the post ID during the plugins_loaded action if possible due to the nature of the code. You see, the code itself is sending header information! code below
function wpcwv2_plugins_loaded() { global $post; $pageID = $post->ID; if(is_admin() || is_feed() || is_login_page()) return; $wpcwv2_request = (isset($_GET['wpcwv2']) && !empty($_GET['wpcwv2']) ) ? strtolower($_GET['wpcwv2']) : null; if(!$wpcwv2_request) return; // Switch Requests switch($wpcwv2_request) { case 'js': header('Content-type: application/x-javascript'); //header('Content-type: application/octet-stream'); //header('Content-Length: ' . filesize($file)); header('Content-Disposition: inline; filename="wpcwv2.js"'); // Echo PATH echo 'var wpcwv2_wpurl = "'.get_bloginfo('wpurl').'";'."\n"; echo 'var wpcwv2_url = "'.WP_PLUGIN_URL.'/content-warning";'."\n"; echo 'var tb_pathToImage = "'.get_bloginfo('wpurl').'/wp-includes/js/thickbox/loadingAnimation.gif";'."\n"; echo 'var tb_closeImage = "'.get_bloginfo('wpurl').'/wp-includes/js/thickbox/tb-close.png";'."\n"; exit; break; case 'message': wpcwv2_build_message(); break; case 'log': wpcwv2_log($pageID); break; default: return; } } add_action('plugins_loaded', wpcwv2_plugins_loaded);
Before you say “use the $post global”, i have to say I already did, and I even var_dump’d it to see what it was giving me, it was all NULL…. aside from a few insignificant integers. I haven’t found a fix for this in the four hours I’ve been pounding on it so if any of you have a solution please let me know. I’m stumped lol…
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Can I get the post ID during the 'init' or 'plugins_loaded' action?’ is closed to new replies.