Official plugin enable/disable option - By the plugin authors

In some cases it makes sense to have a plugin activated on localhost but not on the live server, or the other way around.

Many plugins have an activated option like:

c:set('plugin.my-plugin.active', false);
c:set('plugin.my-other-plugin.active', true);
c:set('plugin.another-plugin.active', true);

Then the above have different syntax on every plugin.

If we could set a standard it would be easier, like this:

Localhost

Just an example:

c::set('plugins.deactivate', array(
  'kirby-bricks',
  'kirby-panel-brand',
  'kirby-snippetfield'
));

Live

Just an example:

c::set('plugins.deactivate', array(
  'kirby-panel-brand',
));

What it takes - A best practice page

For it to work it perfectly it would take every plugin to support this syntax. For those who doesn’t we could still use their syntax.

To have the plugin makers support it would probably need a “best practice” page in the docs where it’s recommended to set the plugins.deactivate in the plugin.

  • What do you think about this suggestion?
  • What do you think of general common best practices for plugins?

If it make sense to have it on localhost but not on the live server can’t you just not upload it to the live server?

Personally I like to have the same setup of files, independent of the enviroment. The only thing that is different right now is the htaccess file and I don’t think I can get them to be generic.

Yes but what I mean is, why should you upload something on a production site if you don’t need it?
I, for example, don’t upload the sass files or the uncompressed js version on a server. Those things belong to the git repo. Same thing for development tools, in this case, plugins. If I need it while in dev phase I’ll keep it on the repo but once you’re done you upload only the things you need to make the site run.

Does this make sense to you or do you usually follow a different workflow?

I’m on a shared server so I don’t have Git access.

Yes but you can use a 3rd party service to host your projects which is also a nice backup copy just in case.

There is some plugin-toggle option, but it doesn’t look at the server-environment. :’(

I don’t think plugins would even need to support this option, Kirby would just not load them if the option is set.
However I agree with @manuelmoreale. Just not uploading is safer and less complex.

Leaving this topic open for further discussion though.

1 Like

I don’t think plugins would even need to support this option, Kirby would just not load them if the option is set.

If this option would be built into the core, yes, then the plugin developers would not need to add a support for it. :slight_smile: Why I added it as a plugin developer suggestion is because in a previous topic we (not me included) decided that it was a bad idea to have an option like that in the core.

But I still think it would be best to have an option like this… in the core:

  • It’s probably really easy to add it to the core, like 2 extra lines of code?
  • Some people (not just me) like this idea.
  • It’s not pluggable so in order to make it work, it needs to be a core feature (or add a core component).

I don’t know how the core looks here but just an example:

if(!in_array($plugin_name, c::get('plugins.deactivate')) {
  load_plugin($plugin_name);
}

Sure we can use Git to exclude plugins on upload to different domains, but not everyone is using Git. From my point of view Git plugin exclusion would be more complex. :slight_smile: