Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

[v1.8 Github latest] How to enable by default plugin

+3 votes
asked Apr 15 in Plugins by ProThoughts

@Scott, I would like to enable by default sitemap plugin....similar to WYSIWYG Editor plugin(which can not be disabled), how to enable that? Thanks!

Q2A version: 1.8 Github latest

2 Answers

+2 votes
answered Apr 18 by jaksiro

Okay I have taken considerable amount of time to examine the issue because for me it was not a bother at all till I saw your question. When I look at the metadata of Xml Site Plugin verses that of WYSIWYG Editor plugin I see the reason why you see this situation. I installed one of my plugin and saw it getting enabled which I cant disable which I found intresting. Okay the plugin manager checks if a plugin has a "load_order" in its metadata. If it doesn't have like the case of the WYSIWYG Editor plugin it enabled status is true and permanent (can't be changed).

In summary:

  1. Disabling a plugin is not optional when
    • load_order is set to before_db_init in the plugin's metadata
    • or load_order is not set at all in the plugin's metadata
    • or plugin is missing metadata which is the case with most plugins.
  2. Enabling/Disabling a plugin is optional only when
    • load_order is set to after_db_init in the plugin's metadata.

To prove this: add the following line in xml-site-plugin's metadata

,"load_order": "before_db_init"

then reload Plugin's page. 

sitemap plugin can not be enabled by default.

commented Apr 18 by ProThoughts
Thank you for the detail explanation. This is happening for two plugins event logger and wysiwyg-editor, you can see here http://demo18.question2answer.info
commented Apr 19 by jaksiro
No it happens to any plugin which does not have metadata or rather which does not have "load_order set to after_db_init" in its metadata
commented Apr 21 by Scott
This is correct. To prevent a plugin from being disabled (i.e. it's always on) remove the 'load_order' from the metadata.

For your demo, why not put the plugin config in the backup that you restore from every hour.
+1 vote
answered Apr 18 by sama55
It may be backward compatibility issue.
commented Apr 19 by ProThoughts
Not sure, I'm checking on fresh installation of v1.8.
commented Apr 19 by jaksiro
am not sure on that too. Please Check the PluginManager class under "qa-include/Q2A/Plugin/PluginManager.php for more details
commented Apr 19 by sama55
Plugin switch feature must also work properly with old (There is no "load_order") plugins. It is correct to enable plugins which "load_order" is not defined just after upgrading operation. However, it is incorrect to disable at the same time. Currently, we can not disable and re-enable old plugins. This is the backward compatibility issue I point out. Anyway, it will be necessary to change program specifications (basic archtecture).