Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I don't want clients to deactivate woocommerce plugin even by mistake. And I have recently come across a concept called must use plugins in wordpress. (http://codex.wordpress.org/Must_Use_Plugins)

Just want to know if there is possibility to use woocommerce as a must use plugin.

share|improve this question
1  
This may be interesting: wordpress.stackexchange.com/q/53866/12615 –  brasofilo Mar 25 '13 at 11:25
add comment

3 Answers

This is a classic XY problem question, the original problem you face is:

"How do I prevent a client from disabling the woocommerce plugin"

For which mu-plugins was your solution, to which you are now asking for a fix for your solution, aka a fix for a fix, never a good sign.

So addressing your original problem we have three approaches:

Fail gracefully and make it clear how to fix things

If WooCommerce is disabled, warn the user that it has been disabled, fail gracefully, and put links to the reactivation button here there and everywhere. The client should very quickly get the message that what they did will break the site

Disable the disable link

e.g. for the facebook open graph plugin:

test

add_filter( 'plugin_action_links', 'disable_plugin_deactivation', 10, 4 );
function disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
    // Remove edit link for all
    if ( array_key_exists( 'edit', $actions ) )
        unset( $actions['edit'] );
    // Remove deactivate link for crucial plugins
    if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, array(
        'facebook-open-graph-meta-in-wordpress/fbogmeta.php'
    )))
        unset( $actions['deactivate'] );
    return $actions;
}

Disable The Plugin Menu Itself

The client can't disable a plugin if they cant see the plugins page:

function remove_menus () {
    global $menu;
    $restricted = array( __('Plugins') );
    end ($menu);
    while (prev($menu)){
        $value = explode(' ',$menu[key($menu)][0]);
        if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
    }
}
add_action('admin_menu', 'remove_menus');

I would recommend both failing gracefully, and disabling the plugins menu. Fail gracefully and your code will be more robust, and robust code is profitable code ( those hours you saved turn into days worth of painful support and mysterious bugs ). A client won't know you can disable a plugin if they're unaware there is a plugin menu to begin with.

share|improve this answer
add comment

I don't think it would be a good idea.

There are some limitations with mu-plugins:

  1. You won't get notifications for automatic updates
  2. Plugin activation hooks are not executed. In other words, any setup operation that the plugin uses when you activate them won't be triggered
  3. WordPress won't find functions declared in subfolders of the mu-plugins folder

A better way will be give not to give the activate_plugins capability to your client.

share|improve this answer
    
1. I am responsible for handling updates - I will do it myself. 2. What if I activate the plugin normally and then move the whole directory to the mu-plugins folder. 3. a simple loader file will help in solving that. –  Mayur Karwa Mar 25 '13 at 17:23
    
It will be more work for you. What if you gave your client an editor account? He won't get access to the plugin menu. –  RRikesh Mar 25 '13 at 17:55
add comment

Must-use plugins (a.k.a. mu-plugins) are plugins installed in a special directory inside the content folder and which are automatically enabled on all sites in the installation.

Must-use plugins do not show in the Plugins page of wp-admin and cannot be disabled except by removing the plugin file from the must-use directory, which is found in wp-content/mu-plugins by default.

Features

Always-on, no need to enable via admin and users cannot disable by accident.
Can be enabled simply by uploading file to the mu-plugins directory, without having to log-in.

Codex

share|improve this answer
    
This should answer your question. –  Aliyah Mar 25 '13 at 10:29
    
The Question is not "what is a mu plugin". And they do show in the Plugins page (in its own tab). –  brasofilo Mar 25 '13 at 11:28
    
@brasofilo are you debating with ME or the WordPress codex? –  Aliyah Mar 25 '13 at 16:38
    
As noted above by Tom J Nowell, mu-plugins is the original solution to the original problem, -- "Just want to know if there is possibility to use woocommerce as a must use plugin." -- so why was I downvoted twice for my answer? purely rhetorical –  Aliyah Mar 26 '13 at 5:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.