I have created a system plugin for onAfterRender event however I'm unable to make it execute. I'm on Joomla 3.9
Here's the sample code of the plugin
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* @copyright Copyright (c) 2018 myvendorcustomscripts. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
-->
<extension type="plugin" version="1.0" group="content" method="upgrade">
<name>plg_system_myvendorcustomscripts</name>
<author>myvendor</author>
<creationDate>October 2018</creationDate>
<copyright>Copyright (c) 2018 myvendorcustomscripts. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail></authorEmail>
<authorUrl></authorUrl>
<version>1.0.0</version>
<description>
<![CDATA[
]]>
</description>
<files>
<filename plugin="myvendorcustomscripts">myvendorcustomscripts.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_myvendorcustomscripts.ini</language>
<language tag="en-GB">en-GB.plg_system_myvendorcustomscripts.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
</fieldset>
</fields>
</config>
</extension>
And
<?php
/**
* @copyright Copyright (c) 2018 myvendorcustomscripts. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
/**
* content - MyVendorCustomScripts Plugin
*
* @package Joomla.Plugin
* @subpakage myvendorcustomscripts.MyVendorCustomScripts
* @since
*/
class plgSystemMyVendorCustomScripts extends JPlugin
{
/**
* Constructor.
*
* @param $subject
* @param array $config
* @since
*/
public function __construct(&$subject, $config = array())
{
// call parent constructor
parent::__construct($subject, $config);
}
public function onAfterRender()
{
$app = JFactory::getApplication();
}
public function onBeforeCompileHead()
{
$app = JFactory::getApplication();
$document = $app->getDocument();
foreach ($document->_styleSheets as $index => $value) {
if (strpos($index, 'fonts.googleapis.com')) {
unset($document->_styleSheets[$index]);
}
if (strpos($index, 'simple-line-icons')) {
unset($document->_styleSheets[$index]);
}
// $styleSheet = $styleSheet;
}
}
}
However the functions never get executed when I'm browsing the frontend but they do get executed when browsing the backend. It's really strange and I can't understand the reason. It seems on the documentation that this even should trigger always