pasayev Posted February 26, 2015 Share Posted February 26, 2015 Hello, I get following error: Fatal error: Call to undefined method Media::deferInlineScripts() in /home/byzesyac/public_html/classes/controller/Controller.php on line 410 Website: www.byzesya.com Can you help please? Link to comment Share on other sites More sharing options...
NemoPS Posted February 28, 2015 Share Posted February 28, 2015 Prestashop version?Add this to the Media class since it's missing (this is 1.6.0.9, you might need your own version) public static function deferInlineScripts($output) { /* Try to enqueue in js_files inline scripts with src but without conditionnal comments */ $dom = new DOMDocument(); libxml_use_internal_errors(true); @$dom->loadHTML(($output)); libxml_use_internal_errors(false); $scripts = $dom->getElementsByTagName('script'); if (is_object($scripts) && $scripts->length) foreach ($scripts as $script) if ($src = $script->getAttribute('src')) { if (substr($src, 0, 2) == '//') $src = Tools::getCurrentUrlProtocolPrefix().substr($src, 2); $patterns = array( '#code\.jquery\.com/jquery-([0-9\.]+)(\.min)*\.js$#Ui', '#ajax\.googleapis\.com/ajax/libs/jquery/([0-9\.]+)/jquery(\.min)*\.js$#Ui', '#ajax\.aspnetcdn\.com/ajax/jquery/jquery-([0-9\.]+)(\.min)*\.js$#Ui', '#cdnjs\.cloudflare\.com/ajax/libs/jquery/([0-9\.]+)/jquery(\.min)*\.js$#Ui', '#/jquery-([0-9\.]+)(\.min)*\.js$#Ui' ); foreach($patterns as $pattern) { $matches = array(); if (preg_match($pattern, $src, $matches)) { $minifier = $version = false; if (isset($matches[2]) && $matches[2]) $minifier = (bool)$matches[2]; if (isset($matches[1]) && $matches[1]) $version = $matches[1]; if ($version) { if ($version != _PS_JQUERY_VERSION_) Context::getContext()->controller->addJquery($version, null, $minifier); array_push(Media::$inline_script_src, $src); } } } if (!in_array($src, Media::$inline_script_src)) Context::getContext()->controller->addJS($src); } $output = preg_replace_callback('/<script[^>]*>(.*)<\s*\/script\s*[^>]*>/Uims', array('Media', 'deferScript'), $output); return $output; } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now