public static function Shutdown() { /* * Break out of this function if we do not need to run it. * This is important when we are not in AJAX mode and the * user is not looking at OnePanel * */ if (!OnePanelLib::InConsole()) { return true; } /* * TODO * Ive got a feeling that printing <script> tags outside the html tags is a bad idea * perhaps this function should only be used as a last ditch attempt to scrape data in * the case of a fatal php error and another shutdown function should be run after the * plugin has completed whatever hook is being called. * */ // Discern whether a fatal error occured TODO handle non fatals $last_error = error_get_last(); if ($last_error['type'] === E_ERROR || $last_error['type'] === E_USER_ERROR || $last_error['type'] === E_COMPILE_ERROR || $last_error['type'] === E_CORE_ERROR || $last_error['type'] === E_RECOVERABLE_ERROR) { // Fail the last entry self::FailIncompleteTrackers(); // Store the log if necessary // Stop the clock self::$finish_time = microtime(true); // Record memory usage self::$finish_mu = memory_get_usage(); // Output the apppropriate data depending on running environment (AJAX or normal) echo self::GetRawOutput(); } else { // Stop the clock self::$finish_time = microtime(true); // Record memory usage self::$finish_mu = memory_get_usage(); // Script completed. Send the jacascript to populate the error console if (!OnePanelLib::InAjaxMode()) { echo self::GetOutput(); // TODO, devise a strategy to append the return ajax data with the error console data. } } return true; }
/** * Add Admin Styles * * Add the stylesheets and JavaScript to wp_head for the control panel. * */ public function AddAdminStyles() { // Set Paths $css_path = get_option('home') . '/wp-content/plugins/OnePanel'; $global_js_path = get_option('home') . '/wp-includes/js'; // Add Admin Styles echo '<link rel="stylesheet" href="' . $css_path . '/admin.css" type="text/css" />' . "\n"; // Add Prototype & Scriptaculous echo '<script src="' . $global_js_path . '/prototype.js" type="text/javascript"></script>' . "\n"; echo '<script src="' . $global_js_path . '/scriptaculous/scriptaculous.js" type="text/javascript"></script>' . "\n"; echo '<script src="' . $global_js_path . '/scriptaculous/effects.js" type="text/javascript"></script>' . "\n"; // Add One Panel JavaScript echo '<script src="' . $css_path . '/onepanel.js" type="text/javascript"></script>' . "\n"; if (OnePanelLib::InConsole()) { echo '<script type="text/javascript">op_admin.run_news = true;</script>' . "\n"; } // Add IE6 Javascript echo '<!--[if lt IE 7]>' . "\n"; echo '<script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"></script>' . "\n"; echo '<![endif]-->' . "\n"; // Add IE7 Styles echo '<!--[if IE 7]>' . "\n"; echo '<link href="' . $css_path . '/ie7.css" rel="stylesheet" type="text/css">' . "\n"; echo '<![endif]-->' . "\n"; // Add IE6 Styles echo '<!--[if IE 6]>' . "\n"; echo '<link href="' . $css_path . '/ie6.css" rel="stylesheet" type="text/css">' . "\n"; echo '<![endif]-->' . "\n"; }