Locking Piklist

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:

  1. Allow Deactivation
  2. Lock

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.

Piklist LOCKED: Deactivation link has been replaced with a Settings link.

 

Piklist Deactivation Warning, and Instructions.

 

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.

8 thoughts on “Locking Piklist

  1. Tim says:

    elegant solution :)

    1. Steve says:

      Awesome! Glad you like.

  2. As long as it’s an option (and not default behaviour), I like it.

    1. Steve says:

      Then you like it. ;)

  3. Metrey says:

    Yes, Lock feature is required… we need to use it for WP MU so a solution require for that.

  4. I definitely like this option. :)

    Contratulations, GREAT Job!

    A question: are you going to make a paid version? I’d like to have looooots of other fields (like Google Web Fonts selection, sliders, date/time, etc).

    1. Steve says:

      We’re glad you like the locking feature. Can you be more specific in the types of fields you would like to see?

  5. Leonard says:

    What I’d like to see with Piklist is the ability to have it run from your theme folder rather then as a plugin. This would help negate the issue of accidental de-activation.

    To elaborate a little, as Piklist is required by the theme it makes far more sense (to me) when developing a theme to keep it as part of the theme package and ensure it’s always to hand. I tried to add Piklist to my theme this way and use functions.php to call it and though installs, as it uses plugins_url() to set certain paths it’s breaking the CSS/JS/IMG requests. Beyond that it may work just fine but I’ve not investigated this further.

    Without the ability to use it in the theme I’m a bit more hesitant to commit Piklist to my standard process.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>