Skip to content

Instantly share code, notes, and snippets.

@ho-nl
Created June 29, 2011 12:25
Show Gist options
  • Save ho-nl/1053729 to your computer and use it in GitHub Desktop.
Save ho-nl/1053729 to your computer and use it in GitHub Desktop.
Update to Decadentwaste_Chromeframe
<?php
class Decadentwaste_Chromeframe_Model_Observer
{
const HEAD_EXPRESSION = '{(<head[^>]*?>)}i';
public function insertMetaTags($observer)
{
$body = $observer->getResponse()->getBody();
if(strpos(strToLower($body), 'x-ua-compatible') === false) {
$body = preg_replace(self::HEAD_EXPRESSION,'$1'.$this->_getTag(),$body);
$observer->getResponse()->setBody($body);
}
}
protected function _getTag()
{
// IE and Google Chrome Frame
if(Mage::getStoreConfig('chromeframe_options/ie_compatibility/use_ua_compatibility') && Mage::getStoreConfig('chromeframe_options/chromeframe_activation/activate_toggle'))
{
$version = Mage::getStoreConfig('chromeframe_options/ie_compatibility/ie_version');
return '<meta http-equiv="X-UA-Compatible" content="IE='.$version.',chrome=1" />';
}
// IE
elseif (Mage::getStoreConfig('chromeframe_options/ie_compatibility/use_ua_compatibility')) {
$version = Mage::getStoreConfig('chromeframe_options/ie_compatibility/ie_version');
return '<meta http-equiv="X-UA-Compatible" content="IE='.$version.'" />';
}
// Google Chrome frame
elseif(Mage::getStoreConfig('chromeframe_options/chromeframe_activation/activate_toggle')) {
return '<meta http-equiv="X-UA-Compatible" content="chrome=1">';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment