@@ -47,17 +47,29 @@ class PlgSystemCfi extends CMSPlugin
4747 private $ file = null ;
4848 private $ cp ;
4949 private $ fieldPlugins ;
50+ private $ isAdmin ;
5051
5152 protected $ autoloadLanguage = true ;
5253
5354 public function __construct (&$ subject , $ config )
5455 {
5556 parent ::__construct ($ subject , $ config );
57+
58+ if (Version::MAJOR_VERSION > 3 ) {
59+ $ this ->isAdmin = Factory::$ application ->getName () === 'administrator ' ;
60+ } else {
61+ $ this ->isAdmin = Factory::getApplication ()->isClient ('administrator ' );
62+ }
63+
5664 $ this ->initConstruct ();
5765 }
5866
5967 private function initConstruct ($ ajax = false )
6068 {
69+ if (!$ this ->isAdmin ) {
70+ return ;
71+ }
72+
6173 if (Version::MAJOR_VERSION > 3 ) {
6274 $ this ->app = Factory::getContainer ()->get (Joomla \CMS \Application \AdministratorApplication::class);
6375 $ this ->appConfig = $ this ->app ->getConfig ();
@@ -70,10 +82,6 @@ private function initConstruct($ajax = false)
7082 $ this ->db = Factory::getDbo ();
7183 }
7284
73- if (!$ this ->app ->isClient ('administrator ' )) {
74- return ;
75- }
76-
7785 $ this ->doc = Factory::getDocument ();
7886
7987 if ($ ajax ) {
@@ -117,7 +125,7 @@ private function initConstruct($ajax = false)
117125
118126 public function onBeforeRender ()
119127 {
120- if (!$ this ->app -> isClient ( ' administrator ' ) || $ this ->doc ->getType () != 'html ' ) {
128+ if (!$ this ->isAdmin || $ this ->doc ->getType () != 'html ' ) {
121129 return ;
122130 }
123131
@@ -138,7 +146,7 @@ public function onBeforeRender()
138146
139147 public function onAfterRender ()
140148 {
141- if (!$ this ->app -> isClient ( ' administrator ' ) || $ this ->doc ->getType () != 'html ' ) {
149+ if (!$ this ->isAdmin || $ this ->doc ->getType () != 'html ' ) {
142150 return ;
143151 }
144152
0 commit comments