vincent3569 / zpBootstrap

zpBootstrap is a « Responsive » theme for ZenPhoto (http://www.zenphoto.org), based on Bootstrap framework.
https://www.vincentbourganel.fr/news/zpbootstrap-a-responsive-theme-zenphoto/
Other
7 stars 9 forks source link

zpBootstrap disables colorbox and others #10

Closed sbillard closed 6 years ago

sbillard commented 6 years ago

There is code in the zpBootstrap themeoptions constructor line 42-46 that disables colrobox_js, slideshow, and slideshow2. While it may well be that zpBootstrap does not want these plugins disabled other themes may not feel the same. This code gets run each time that setup runs and whenever one views the zpBootstrap options on the admin pages. Thus, these actions will disable those plugins even if zpBootstrap is not the active theme. This is insidious since the site administrator will likely not even notice the change. His site will simply not work as he intended.

I am not clear as to why zpBootstrap needs these plugins disabled. But there should be a more site friendly disabling if that is needed. For instance the them functions.php script can disable them temporarily by calling enableExtension() with the optional third parameter set to false to make the change not persistent. Another option would be to set the scripts not to load via setOption('colorbox_zpBootstrap_scripts', serialize(array())); in the themeoptions constructor.

vincent3569 commented 6 years ago

Hi Stephen

I wrote this code to disable unneeded scripts for zpBoostrap theme to avoid load of unneeded js and css files. And I did that in themeoptions.php to avoid to have to do that each time in functions.php.

If you have a look on inc_header.php, you will see that I enabled googlemap plugin on albums page only and a specific page called "map".

I do that to simply get the theme faster, and because I don't know how to do that with other way. Maybe it is not the good way to do that, but I am not as expert as required (especially on filters and plugins functionnalities of zenphoto).

According to me, it makes trouble only if admin user changes theme or use theme_switcher plugin. Most of time, admin choose a theme and then configures plugins as needed.

I will consider your solution with setOption('colorbox_zpBootstrap_scripts', serialize(array()));

If you can help me to solve my trouble with googlemap (with a plugin for example), I would remove this code in the theme and would manage it with a plugin on my own website.

sbillard commented 6 years ago

The problem is that if the zpBootstrap theme is included in a site's theme folder these plugins are disabled each time setup is run even if zpBootstrap is not the selected theme. So for themes that use the plugins they go away on the administrator when he installs the next version of zenphoto, for instance.

I had a user report this problem (the plugin being disabled) and it was quite difficult to trace the problem down to this cause.

I am not aware of the trouble with the googlemap plugin. Can you provide the details?

vincent3569 commented 6 years ago

ah OK, it causes troubles because zpBoostrap is included in zenphoto20. I saw the issue on your github. I will consider your issue.

vincent3569 commented 6 years ago

with googlemap: with zenphoto (I don't have a look on zenphoto20), googlemap plugin doesn't manage the pages of each theme where it is enabled (this is the behavior of colorbox plugin).

so, googlemap is enabled on all pages of website and I had problems with slow loading with this unnecessary plugin on all pages.

as a workouround, I add this filter to enable it only when needed.

sbillard commented 6 years ago

I understand. This is the same on ZenPhoto20.

The "standard" technique for this kind of thing is to disable the plugin temporarily via setting the persistent parameter to FALSE for those pages you do not want it loaded.

Maybe there is a better way to handle these plugins. I have to look more closely, but googlemap seems to load only javascript. That decision could be delayed until the function is called. Colorbox loads css which is "supposed" to be loaded in the page head. But maybe it can also be loaded on demand if colorbox is used. Some research is necessary.

sbillard commented 6 years ago

So, for all but colorbox_js the support scripts can be delay loaded when the "print" function is called. So only the server side will load the plugin script, no client side overhead if the plugin is not used. But because there is no "print" function equivalent for the colorbox css, that has to remain with the option selectors. But there is no need to disable the plugin as the css will only be loaded on pages where it has been specified by the theme.

These changes are in commit 61443a1fd5e9e4aed4c7030581e4f33fd018a60f of ZenPhoto20-DEV (https://github.com/sbillard/ZenPhoto20-DEV/)

vincent3569 commented 6 years ago

no easy solutions with zenphoto. see this topic on zenphoto forum.

I simply remove the code via https://github.com/vincent3569/zpBootstrap/commit/ef54c29f5ae639662c4e7210645c87fe8f0e1c75