'; private static $jsComment = ''; protected $js = ''; protected $css = ''; /** * @var OutputBuffer */ protected $outputBuffer; private $headTokens = array(); private $useAlternativeAction = false; protected function init() { if (is_admin()) { $this->useAlternativeAction = true; } if (defined('WP_CLI') && WP_CLI) { //Do not start output buffering while WP_CLI active } else { $this->outputBuffer = OutputBuffer::getInstance(); if (defined('SMART_SLIDER_OB_START') && SMART_SLIDER_OB_START >= 0) { $this->outputBuffer->setExtraObStart(SMART_SLIDER_OB_START); } $this->addInjectCSSJSComment(); add_filter('wordpress_prepare_output', array( $this, 'prepareOutput' )); } } public function prepareOutput($buffer) { static $once = false; if (!$once) { $once = true; $this->finalizeCssJs(); if (!empty($this->css)) { $n2cssPos = strpos($buffer, self::$cssComment); if ($n2cssPos !== false) { $buffer = substr_replace($buffer, $this->css, $n2cssPos, strlen(self::$cssComment)); $this->css = ''; } else { $parts = preg_split('/<\/head[\s]*>/i', $buffer, 2); // There might be no head and it would result a notice. if (count($parts) == 2) { list($head, $body) = $parts; /** * We must tokenize the HTML comments in the head to prepare for condition CSS/scripts * Eg.: */ $head = preg_replace_callback('//s', array( $this, 'tokenizeHead' ), $head); $head = preg_replace_callback('/