/** * * @param $post * @return unknown_type * @todo anything in the html that has dodgy characters in it will make DOM unhappy. * Probably best to hold back errors. */ public static function AutoGenThumbs($post) { $tracker = OnePanelDebug::Track('Trying to autogenerate thumbnails.'); // Wordpress is crazy $post_id = wp_is_post_revision($post); OnePanelDebug::Info('Post id: ' . $post_id); // Create thumbnail module object? OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/module.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/feature.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/thumbnails.php'); $thumbnail_feature_object = new Thumbnails(); // Scan the post for images $dom_doc = new DOMDocument(); @$dom_doc->loadHTML($_POST['content']); // Grab the first image $first_image = $dom_doc->getElementsByTagName('img')->item(0); if (is_null($first_image)) { OnePanelDebug::Info('No images found in post'); return true; } // Get the location of the image $src = str_replace('"', '', $first_image->getAttribute('src')); $src = str_replace('\\', '', $src); // Get the real path $src = str_replace(get_option('siteurl'), '', $src); $location = ABSPATH . $src; $location = str_replace('//', '/', $location); // Generate OnePanelDebug::Info('Calling CreateThumbs with ' . $location . ' ' . $post_id); $thumbnail_feature_object->CreateThumbs($location, $post_id, 'All', false); // All done $tracker->Affirm(); return true; }
/** * Start * * Singleton shortcut to run the constructor without returning the instance * Includes all the necessary files for the config API * * @return boolean */ public static function Start() { $success = OnePanelDebug::Track('Starting Config Engine'); if (!is_object(self::$instance)) { // Load the requirements OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/theme/behaviouralconfigobject.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/theme/onepanelskin.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/theme/onepanelhomepagelayout.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/theme/onepaneladblock.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/theme/adsensecolorpalette.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/theme/onepanelhighlight.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/theme/onepanelbehaviour.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/theme/onepaneloutcome.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/theme/onepanelthumbnailtype.php'); // Create the object self::$instance = new OnePanelConfig(); /* * Try to load the active thees config file * on failiure set the ONE_PANEL_NO_CONFIG flag for later evaluation * TODO if this fails add a message asking to upgrade One Panel */ $config_file = ABSPATH . 'wp-content/themes/' . get_option('template') . '/onepanel_config.php'; if (file_exists($config_file)) { $load_config = OnePanelDebug::Track('Loading theme config'); OnePanelLib::RequireFileOnce($config_file); $load_config->Affirm(); } else { OnePanelDebug::Info('No config file found, setting ONE_PANEL_NO_CONFIG'); define('ONE_PANEL_NO_CONFIG', true); } } $success->Affirm(); return true; }
* TODO consider allowing language terms of One Panel to be editable in future, * the object will need to be started here at that point. */ OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/language.php'); // Include the config class, and create the OnePanelConfig Object OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/onepanelconfig.php'); OnePanelConfig::Start(); // Include Externals //OnePanelLib::RequireFileOnce( ONE_PANEL_DIR .'/onepanelexternals.php' ); //OnePanelExternals::AddActions(); // THESE ARE BROKEN /* * Create one of two objects depending on which environment we appear * to be using. The OnePanelTheme has methods that should be available to * theme developers, but do not need to be present in the backend. */ if (is_admin() || OnePanelLib::InAjaxMode()) { // Log OnePanelDebug::Info('Running non AJAX mode in OnePanel.'); // Instantiate the OnePanel Object OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/onepanel.php'); OnePanel::Start(); } else { /* * TODO There is no reason to load the OnePanelTheme object if a config file * isnt present in the theme folder. */ // Instantiate the OnePanelTheme Object OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/onepaneltheme.php'); OnePanelTheme::Start(); }
/** * IncludeClasses * * Includes all the class files for the modules and features. * * @return boolean */ private function IncludeClasses() { $success = OnePanelDebug::Track('Including OnePanel integrals'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/feature.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/module.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/skin.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/highlights.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/contentcontrol.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/thumbnails.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/postheader.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/postfooter.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/hotconversation.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/feedburner.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/seo.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/advertising.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/featuredvideo.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/menulinks.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/stats.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/homepagelayouts.php'); OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/localization.php'); $success->Affirm(); return true; }
public static function GetRawOutput() { $html = ''; foreach (self::$entries as $key => &$entry) { $html .= $entry->Report() . '<br />'; } $html .= '------<br />'; $html .= 'Script complete in ' . round(self::$finish_time - self::$start_time, 2) . ' seconds<br />'; $html .= 'Starting memory usage: ' . OnePanelLib::ConvertBytes(self::$start_mu) . '<br />'; $html .= 'Ending memory usage: ' . OnePanelLib::ConvertBytes(self::$finish_mu) . '<br />'; $html .= 'Plugin initiation memory usage ' . OnePanelLib::ConvertBytes(self::$finish_mu - self::$start_mu) . '<br />'; return $html; }