Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
2.0k views
in Q2A Core by
I just notice that several of the plugins are locked and will not let me disabale them I cant un check them any ideal what can cause that ?
Q2A version: 1.88 upgrade
by
That's right, I also wonder why this is the case!!
by
Well atleast  iam not the only one having the problem
by
Just change Metadata Json
by
reshown by
Do  not understand what you mean?
by
Still waiting for a fix to this problem

1 Answer

+3 votes
by
If you go to the folder of a plugin and take a look at the metadata.json file, you see that some have the option "load_order" "after_db_init". Plugins without this option are always loaded and cannot be disabled. So, if you want to change the behavior you have to set this values in the metadata.json
by
I do not believe that Had this problem before the upgrade just what exactly am I suppose to change to what in the  metadata.json  file ?
by
This argument was added in 1.8, so it is a new behavior. Just add the line

"load_order": "after_db_init"

to the metadata.json files. You find more information at the bottom of the page https://docs.question2answer.org/plugins/
by
Where exactly would I add it and is that with or without the quotes ?
by
+1
As an example, here is the content of metadata.json for the Tag Cloud Widget that is shipped with question2answer (https://github.com/q2a/question2answer/blob/master/qa-plugin/tag-cloud-widget/metadata.json):

{
    "name": "Tag Cloud Widget",
    "description": "Provides a list of tags with size indicating popularity",
    "version": "1.0.1",
    "date": "2011-12-06",
    "author": "Question2Answer",
    "author_uri": "http://www.question2answer.org",
    "license": "GPLv2",
    "min_q2a": "1.4",
    "load_order": "after_db_init"
}

The last option is what is needed to make a plugin checkable.
by
+2
Additional note:

Some older plugins do not have a metadata.json file. In those cases, all these information are in the beginning of qa_plugin.php. You can create your own metadata.json file by copying the values from qa_plugin.php to the metadata.json
by
edited by
Do I have to do that for all the plugins not letting me un check ?
by
+1
Alternatively just remove the respective plugins from the plugin directory, if you don't want them loaded in the first place.
by
@ ddemuth✊
Thank you for your detailed explanation. I have made the necessary modifications as you indicated and now all the old plugins can be activated or deactivated from admin banel .☺️
by
Note that some plugins require initialization before DB init, in order to work.
If that's the case, you'd be better off by creating a sub-option that serves as a plugin activator/deactivator, and wrap the plugin's code like this. (Some coding will be required):

if(qa_opt('is_my_plugin_active')) {
    // The plugin's code goes here..
}

Here's an example, in a plugin, where this is implemented:
https://github.com/GATEOverflow/q2a-qnumbering/blob/ce2be0dc4207e39a931ccf72aba489a394316df4/qa-qnumbering-layer.php#L8
...