Skip to content

Instantly share code, notes, and snippets.

@proweb
Created February 19, 2013 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save proweb/4985650 to your computer and use it in GitHub Desktop.
Save proweb/4985650 to your computer and use it in GitHub Desktop.
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); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment