-
Notifications
You must be signed in to change notification settings - Fork 1
/
dd_disable_bootstrap.php
78 lines (67 loc) · 2.08 KB
/
dd_disable_bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* @package DD_Disable_Bootstrap
*
* @author HR IT-Solutions Florian Häusler <[email protected]>
* @copyright Copyright (C) 2011 - 2017 Didldu e.K. | HR IT-Solutions
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
**/
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
jimport('joomla.access.access');
/**
* Joomla! system plugin to disable Bootstrap from the front end!
*/
class plgSystemDD_Disable_Bootstrap extends JPlugin
{
protected $app;
/**
* onBeforeCompileHead
*
* @since Version 1.0.0.0
*/
public function onBeforeCompileHead()
{
// Front end
if ($this->app instanceof JApplicationSite)
{
$doc = JFactory::getDocument();
// Remove default bootstrap
unset($doc->_scripts[JURI::root(true) . '/media/jui/js/bootstrap.min.js']);
}
}
/**
* onAfterRender
*
* @since Version 1.0.0.0
*/
public function onAfterRender()
{
// Front end
if ($this->app instanceof JApplicationSite)
{
// Check plugin parameter to replace
if ($this->params->get('remove_hastooltip_class', 1)
&& $this->params->get('toreplace') !== '{"html": true,"container": "body"}')
{
// Securety fix, remove braces
$value = array("(",")");
$toreplace = str_replace($value, "", $this->params->get('toreplace'));
// Remove bootstrap associated .tooltip global from <head> which is added by JHtml::_('behavior.tooltip');
$html = str_replace('jQuery(\'.hasTooltip\').tooltip(' . $toreplace . ');', '', $this->app->getBody());
}
else
{
// Remove bootstrap associated .tooltip global from <head> which is added by JHtml::_('behavior.tooltip');
$html = preg_replace("/jQuery(.+)\.tooltip\(.+\)\;/i", "<!-- Removed tooltip -->", $this->app->getBody());
}
// Check plugin parameter to remove hasTooltip CSS class
if ($this->params->get('remove_hastooltip_class', 1))
{
// Try to remove all associated JS CSS .tooltip classes to avoid TypeError: $(...).tooltip is not a function.
$html = preg_replace("/\shasTooltip\"/", ' "', $html);
}
$this->app->setBody($html);
}
}
}