Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.6k views
in Plugins by

@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

3 Answers

+3 votes
by

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. 

Conclusion:
sitemap plugin can not be enabled by default.

by
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
by
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
by
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.
by
Also check before_db_init etc. at http://docs.question2answer.org/plugins/
by
Thanks q2apro. I will read that again.
+1 vote
by
It may be backward compatibility issue.
by
Not sure, I'm checking on fresh installation of v1.8.
by
am not sure on that too. Please Check the PluginManager class under "qa-include/Q2A/Plugin/PluginManager.php for more details
by
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).
+1 vote
by

I've just seen this and it seems you still haven't solved the issue. I bet you have updated the metadata.json file and then replaced the file with a new Q2A release so the changes got lost. In order not to rely on having to modify core files you can just do what Q2A does in order to remember the enabled plugins.

1. Enable all the plugins you want to have enabled

2. Run this query against the database:

SELECT content FROM ^options WHERE title = 'enabled_plugins';

The output should look like this (note the xml-sitemap plugin will be there):

basic-adsense;event-logger;example-page;facebook-login;mouseover-layer;opensearch-support;recaptcha-captcha;tag-cloud-widget;wysiwyg-editor;xml-sitemap

3. Configure that string to be applied to the enabled_plugins key of the options table after initialization. For example, you could do something like this:

qa_opt('enabled_plugins', 'basic-adsense;event-logger;example-page;facebook-login;mouseover-layer;opensearch-support;recaptcha-captcha;tag-cloud-widget;wysiwyg-editor;xml-sitemap');

If this works after the first refresh or after the second will depend on how you reset your site.

by
@pupi1985, thanks for the detail explanation, will try this.
...