if (empty($css)) { require $wpUnited->get_plugin_path() . 'css-magic.php'; if ($pkg == 'phpbb') { $packagePath = $wpUnited->get_setting('phpbb_path'); $packageUrl = $phpbbForum->get_board_url(); } else { $packagePath = $wpUnited->get_wp_path(); $packageUrl = $wpUnited->get_wp_base_url(); } $processImports = $useTV == -1; $cssMagic = new CSS_Magic($processImports, $packageUrl, $packagePath); if ($cssMagic->parseFile($cssFileToFix)) { if ($pos == 'inner') { // Apply Template Voodoo if ($useTV > -1) { if (!apply_template_voodoo($cssMagic, $useTV)) { // set useTV to -1 so that cache name reflects that we weren't able to apply TemplateVoodoo $useTV = -1; $tvFailed = true; } } // Apply CSS Magic $cssMagic->makeSpecificByIdThenClass('wpucssmagic', false); } if ($islandBlock) { $cssMagic->makeSpecificByClass('wpuisle2', false); $cssMagic->makeSpecificByClass('wpuisle', false); } $cssMagic->fix_urls(); $desc = $pos == 'inner' ? 'modified to make it more specific' : 'parsed and cached so the style fixer can read it'; $now = date("F j, Y, g:i a");
/** * CSS Magic actions in style.php. */ public function css_magic($cssIn) { global $phpbb_root_path, $phpEx, $wpUnited, $phpbbForum; define('WPU_STYLE_FIXER', true); require $phpbb_root_path . 'includes/hooks/hook_wp-united.' . $phpEx; if (!isset($wpUnited) || !$wpUnited->is_enabled()) { return $cssIn; } require_once $wpUnited->get_plugin_path() . 'functions-css-magic.php'; $wpuCache = WPU_Cache::getInstance(); if (!isset($_GET['usecssm'])) { return $cssIn; } $pos = request_var('pos', 'outer') == 'inner' ? 'inner' : 'outer'; $islandBlock = request_var('island', 0) == 1; $cacheLocation = ''; $tvFailed = false; $cssIdentifier = request_var('cloc', 0); $cssIdentifier = $wpUnited->get_style_key($cssIdentifier); $useTV = -1; if (isset($_GET['tv']) && $pos == 'inner') { $useTV = request_var('tv', -1); } /** * First check cache */ $css = ''; if ($useTV > -1) { // template voodoo-modified CSS already cached? if ($cacheLocation = $wpuCache->get_css_magic($cssIdentifier, $pos, $useTV, $islandBlock)) { $css = @file_get_contents($cacheLocation); } } else { // Try loading CSS-magic-only CSS from cache if ($cacheLocation = $wpuCache->get_css_magic($cssIdentifier, $pos, -1, $islandBlock)) { $css = @file_get_contents($cacheLocation); } } if (!empty($css)) { return $css; } // Apply or load css magic include $wpUnited->get_plugin_path() . 'css-magic.php'; $packagePath = $wpUnited->get_setting('phpbb_path'); $packageUrl = $phpbbForum->get_board_url(); $processImports = !($useTV > -1); $cssMagic = new CSS_Magic($processImports, $packageUrl, $packagePath); if (!$cssMagic->parseString($cssIn)) { return $cssIn; } // if pos= outer, we just need to cache the CSS so that Template Voodoo can get at it if ($pos == 'inner') { // Apply Template Voodoo if ($useTV > -1) { if (!apply_template_voodoo($cssMagic, $useTV)) { // set useTV to -1 so that cache name reflects that we weren't able to apply TemplateVoodoo $useTV = -1; $tvFailed = true; } } // Apply CSS Magic $cssMagic->makeSpecificByIdThenClass('wpucssmagic', false); } if ($islandBlock) { $cssMagic->makeSpecificByClass('wpuisle2', false); $cssMagic->makeSpecificByClass('wpuisle', false); } $desc = $pos == 'inner' ? 'modified to make it more specific' : 'parsed and cached so the style fixer can read it'; $now = date("F j, Y, g:i a"); $preHeader = <<<COUT /** \tThis CSS Stylesheet has been parsed with WP-United. The source is phpBB's style.php. \t-------------------------------------------------------------------------- \tThe CSS in this file has been {$desc}. \tYou should refer to the original CSS files for the underlying style rules. \tPurge the phpBB cache to re-generate this CSS. \tDate/Time generated: {$now} \t \tWP-United (c) John Wells, licensed under the GNU GPL v2. Underlying CSS copyright not affected. **/\t COUT; $css = $preHeader . $cssMagic->getCSS(); $cssMagic->clear(); //cache fixed CSS if (!$tvFailed) { $wpuCache->save_css_magic($css, $cssIdentifier, $pos, $useTV, $islandBlock); } return $css; }