is it possible to force a plugin in a specific theme ?
for exemple : - I wish to force the colorbox plugin in the configuration of zpArdoise - I wish to force the print_album_menu plugin in the configuration of i-feel-dirty
That is what I was referring to. The difference between setOption and setOptionDefault is that the 2nd sets the default(!) values on first creation. You can use setOption even to change options temporarily with the right parameter (does not work for all options though).
More to the point. `setOptionDefault()` makes no change if there already exists a value for the option. `setOption()` will always change the option. The `persistent` parameter controls whether the database gets updated or only the local copy of the option.
for me, a problem is setOptionDefault has no effect if the option have already a value (set by another theme, or set by the user for example) maybe, it should be an option to force the default value...
for my personnal needs, I wrote this line in my theme : `setOption('zp_plugin_colorbox', 129, true);`
fyi, in zenpage/themeoptions.php, I have found this `setOptionDefault('zp_plugin_colorbox', 1);` in the database, to have this plugin active, you should have the value 129. so, this line seems to have no effect...
As said, if the option already has a value, `setOptionDefault()` does nothing. In addition, the value of the options is used in plugin loading. So `1` may not be the correct value.
If the plugin has a statement like `$plugin_is_filter = 9|THEME_PLUGIN;` (the one for colorbox) that is the value that should be set for the option.
The other approach you can take is to have your plugin do a `require_once` on the colorbox script.
[edit] Of course, `setOption(x, y)` will force the value. There is no "recorded" default value so it is not possible to make a function that would set to that.
The line is zenpage does in fact work, although it is not in general the correct code. It works because the colorbox plugin is a "theme plugin" as we have implemented it. the value `1` is equivalent to `1|THEME_PLUGIN` so the only issue here is that the load priority of colorbox is "wrong" (And that priority is changed on the 1.4.2 release.)
Just fyi, `setOption(x, y, true)` is identical to `setOption(x, y)` as `true` is the default for the `persistent` parameter. Perhaps you wanted `setOption('zp_plugin_colorbox', 129, false);` Which sets the option only for the duration of your script. The themes probably should not be setting this option's default anyway, though. They really should be ambivalent to its value.
Comments
my question was incorrect : is it possible to force a plugin in a specific theme by the theme itself (in themeoptions.php for exemple) ?
it seems to be possible by using setOption() and setOptionDefault, that's true ?
can you explain what are the differences between this 2 functions ?
for me, a problem is setOptionDefault has no effect if the option have already a value (set by another theme, or set by the user for example)
maybe, it should be an option to force the default value...
for my personnal needs, I wrote this line in my theme :
`setOption('zp_plugin_colorbox', 129, true);`
fyi, in zenpage/themeoptions.php, I have found this
`setOptionDefault('zp_plugin_colorbox', 1);`
in the database, to have this plugin active, you should have the value 129.
so, this line seems to have no effect...
If the plugin has a statement like `$plugin_is_filter = 9|THEME_PLUGIN;` (the one for colorbox) that is the value that should be set for the option.
The other approach you can take is to have your plugin do a `require_once` on the colorbox script.
[edit] Of course, `setOption(x, y)` will force the value. There is no "recorded" default value so it is not possible to make a function that would set to that.
The line is zenpage does in fact work, although it is not in general the correct code. It works because the colorbox plugin is a "theme plugin" as we have implemented it. the value `1` is equivalent to `1|THEME_PLUGIN` so the only issue here is that the load priority of colorbox is "wrong" (And that priority is changed on the 1.4.2 release.)
Just fyi, `setOption(x, y, true)` is identical to `setOption(x, y)` as `true` is the default for the `persistent` parameter. Perhaps you wanted `setOption('zp_plugin_colorbox', 129, false);` Which sets the option only for the duration of your script. The themes probably should not be setting this option's default anyway, though. They really should be ambivalent to its value.