proweb
2/19/2013 - 12:59 PM

Remoove Mootools for Unregistered users in Joomla

Remoove Mootools for Unregistered users in Joomla

//Removing Mootools
$head = $doc->getHeadData();
//Unset Mootools for unregistered users
if($user->guest){
$head=$this->getHeadData();
   reset($head['scripts']);
    unset($head['scripts'][$this->baseurl . '/media/system/js/core.js']);
    unset($head['scripts'][$this->baseurl . '/media/system/js/mootools.js']);
    unset($head['scripts'][$this->baseurl . '/plugins/system/mtupgrade/mootools.js']);
    unset($head['scripts'][$this->baseurl . '/media/system/js/mootools-core.js']);
    unset($head['scripts'][$this->baseurl . '/media/system/js/mootools-more.js']);
    unset($head['scripts'][$this->baseurl . '/media/system/js/caption.js']);  
$this->setHeadData($head); 
    // Removing JCaption
$this->_script = preg_replace('%window\.addEvent\(\'load\',\s*function\(\)\s*{\s*new\s*JCaption\(\'img.caption\'\);\s*}\);\s*%', '', $this->_script);
if (empty($this->_script['text/javascript'])) unset($this->_script['text/javascript']);

} else {
$head=$this->getHeadData();
    reset($head['scripts']);
    unset($head['scripts'][$this->baseurl . '/media/system/js/mootools-more.js']);
$this->setHeadData($head); }