Member
Member
vincent3569   2017-07-21, 10:23
#1

hi

I have to enable a plugin from my theme (tags_extrats).
I know how disable a plugin but I am not sure to enable it.

How manage $priority, especially for this plugin ?

function enableExtension($extension, $priority, $persistent = true) { setOption('zp_plugin_' . $extension, $priority, $persistent); }

Administrator
Administrator
acrylian   2017-07-21, 15:18
#2

You are not meant to enable plugins via the theme. There are plugins that are and need to be loaded earlier.

If your theme has dependencies on plugins, add checks for it. I have a feeling with your goolgemaps topic that you are overcomplicating things a bit currently.

Member
Member
sbillard   2017-07-21, 16:10
#3

You need to copy the priority from the plugin's $plugin_is_filter line of code. If there is no such line, then use 5 | THEME_PLUGIN

But maybe you don't have to enable it. You can always just require the plugin script in your theme head. That may not work with all plugins, though. Which plugins are you interested to do this with?

Member
Member
vincent3569   2017-07-23, 19:37
#4

hi

I try to create a custom album page with isotope layout.
it enables filter of pictures based on the tags of the pictures of the album (a working example here: http://test.vincentbourganel.fr/fetes-des-lumieres-de-lyon/ )

so I need to use tag_extras plugin to access on albums tags.

the way I found to do that is to enable plugin in function.php.
of course, if you have a best way to do that, I will apply your suggestion or code with pleasure.

thanks in advance for your help.

Administrator
Administrator
acrylian   2017-07-24, 10:26
#5

But why don't you just put out a note to users that they have to enable the plugin first? You coudl do that on the plugin options for example or on that specific theme page as well. For that custom album layout you probably need the mutliple_layout plugins anyway. If you don't use it you should instead of using a switch on album.php as it is much cleaner codewise).

Again, Zenphoto leaves you the freedom to do things different way. I would do it that way. A user using Zenphoto should naturally know about plugins and how to enable them. Especially since that is not complicated if support is built into a theme already.

You should avoid such hard requirements of plugins because what if the plugin is not included anymore in the future? Then people even need to install it first (no plan to remove it though).

Member
Member
vincent3569   2017-07-24, 16:01
#6

of course, there are 3 different ways (at least):

  • I can ask users to allow the plugin
  • theme can allow itself the plugin without asking to users
  • theme can use the plugin functions without enable it, by using require_once.

finaly, that is the 3rd way I use for my need.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.