Being a framework, it is important that Piklist not be deactivated by accident. In most cases, Piklist is providing core functionality to a website, and deactivating it would remove that functionality possibly rendering the site useless.
Kevin and I have gone back and forth on this quite a bit. The mu-plugins folder was an option, but we just didn’t think it was the right one. If installed in mu-plugins, Piklist could not take advantage of automatic upgrades, and if a user really wanted to disable Piklist, it would not be that easy. Even the WordPress MU Domain Mapping plugin, which is core to any site running it, specifies using Network Activation over mu-plugins in it’s installation instructions.
A few weeks ago in our support Forums, @kattagami, mentioned that Piklist did not even work correctly in mu-plugins. At this point, Kevin and I needed to make a decision. Do we support mu-plugins, or figure out another way to lock down Piklist?
Then last week, in the same forum thread, @emzo reminded us of a post Mark Jaquith wrote when he built “Have Baby. Need Stuff!”. In this post, Mark shared some code to stop plugins from being deactivated. Though Marks code was designed for the mu-plugins folder, it gave us an idea (and some rock solid code), on how to implement something similar for Piklist. So here’s what we got:
On the Piklist settings page there is an option for Piklist Deactivation.
You have two choices:
- Allow Deactivation
If you select, “Allow Deactivation”, nothing changes. Piklist can be deactivated like any other plugin.
However, if you select “Lock”, then two things happen. First, Piklist is locked down and cannot be deactivated, thanks to the WordPress filter option_active_plugins. Second, Piklist replaces it’s own “Deactivate” link, with a link to it’s “Settings” page. If the user clicks on this link, they are brought to the Piklist settings page where they are warned about deactivating Piklist. There are also instructions on how to deactivate if they wish.
A site Administrator should have complete control over their site. However, pressing a Deactivate link is way too easy, and with Piklist it can cause havoc. This new setting makes deactivating Piklist a four-click process, instead of one. The Administrator can deactivate Pikist if they choose, but they are presented with a warning first.
We’re not sure this is the best solution, and would love your feedback. This setting is in Piklist v0.7.0 and does not yet work for Network Activation. Let us know what you think in the comments.