25

I've just disabled a plugin on my site and it's now giving me the dreaded white screen of death. I know the site will be fine if I reactivate the plugin.

Is there a way to manually activate a plugin through PHPMyAdmin or over FTP?

1
  • probably be useful to tell the plugin owner that this happened. Maybe the plugin needs a bit of work
    – user10914
    Commented Aug 27, 2015 at 8:26

4 Answers 4

42

I fixed this by going through PHPMyAdmin to the table "Options" and then the row active_plugins.

I had the following stored there (formatted for readability):

a:10:{
    i:0;s:49:"1and1-wordpress-wizard/1and1-wordpress-wizard.php";
    i:1;s:29:"acf-repeater/acf-repeater.php";
    i:2;s:30:"advanced-custom-fields/acf.php";
    i:3;s:45:"limit-login-attempts/limit-login-attempts.php";
    i:4;s:27:"redirection/redirection.php";
    i:6;s:33:"w3-total-cache/w3-total-cache.php";
    i:7;s:41:"wordpress-importer/wordpress-importer.php";
    i:8;s:24:"wordpress-seo/wp-seo.php";
    i:9;s:34:"wpml-string-translation/plugin.php";
    i:10;s:38:"wpml-translation-management/plugin.php";
}

I added a new line (for the missing plugin) and incremented the a:10 to a:11 to indicate that there are now 11 items in the array:

a:11:{
    i:0;s:49:"1and1-wordpress-wizard/1and1-wordpress-wizard.php";
    i:1;s:29:"acf-repeater/acf-repeater.php";
    i:2;s:30:"advanced-custom-fields/acf.php";
    i:3;s:45:"limit-login-attempts/limit-login-attempts.php";
    i:4;s:27:"redirection/redirection.php";
    i:5;s:40:"sitepress-multilingual-cms/sitepress.php";
    i:6;s:33:"w3-total-cache/w3-total-cache.php";
    i:7;s:41:"wordpress-importer/wordpress-importer.php";
    i:8;s:24:"wordpress-seo/wp-seo.php";
    i:9;s:34:"wpml-string-translation/plugin.php";
    i:10;s:38:"wpml-translation-management/plugin.php";
}

i: appears to be item number, and thanks to JHoffmann's comment, it appears s: is the length of the string that follows.

The site now works as before!

10
  • 3
    The s stands for string and the number following is the length of the string.
    – JHoffmann
    Commented Aug 26, 2015 at 16:37
  • @JHoffmann Thanks for that! Updated my answer. Can you tell me where you learned that? Is there a good resource anywhere that explains such things? Thanks. Commented Aug 26, 2015 at 16:40
  • i actually means integer value, s means string and the number next to s is the lenght of the string Commented Aug 27, 2015 at 8:25
  • 1
    That is serialized data. I don't have an exact source, but you can look into serialized data. You can also look at JSON as this is more where serialized data is used Commented Aug 27, 2015 at 11:18
  • 1
    @DjangoReinhardt As Pieter Goosen said this is serialized data as it is generated by php's serialize function. In wordpress there is also a wrapper function called maybe_serialize
    – JHoffmann
    Commented Aug 27, 2015 at 23:25
19
//Using this code you can activate your plugin from the functions.php
    function activate_plugin_via_php() {
        $active_plugins = get_option( 'active_plugins' );
        array_push($active_plugins, 'unyson/unyson.php'); /* Here just replace unyson plugin directory and plugin file*/
        update_option( 'active_plugins', $active_plugins );    
    }
    add_action( 'init', 'activate_plugin_via_php' );
5
  • If you would like to activate more than one plugin then just repeat... Commented Jul 16, 2016 at 18:49
  • array_push($active_plugins, 'unyson/unyson.php'); Commented Jul 16, 2016 at 18:49
  • 2
    you could also add an if(!in_array('unyson/unyson.php',$active_plugins)) to make sure it's not added more than once
    – Pierre
    Commented May 28, 2018 at 11:00
  • Where can I find functions.php? Is it in the theme folder or in wp-includes? Commented May 11, 2020 at 3:06
  • 1
    My gut says, even though the answer marked correct works, that this should be the one marked correct, since it's entirely from within wordpress, doesn't involve messing directly with the database, and generally is less likely to be error-prone to do. functions.php is in the theme folder, generally you should create a child theme and edit it in there, since the parent functions.php will lose your edits next time the theme updates.
    – John Smith
    Commented Feb 25 at 4:42
6

Just another answer for a different approach that could benefit someone else in the future. You could also move the plugin folder to the Must Use folder (which you will probably need to create if not used before. This path is usually:

wp-content/mu-plugins

Plugins in this folder will always run. Refer to the following for more info:

https://codex.wordpress.org/Must_Use_Plugins

Note: The only thing to consider is that these plugins are loaded before others in the plugins folder. Also refer to the caveats in the above link as there may be other issues that could prevent your plugin working correctly.

3
  • 1
    It saved my life on a 5 year old website created by another developer and which installed 2 plugins dependent on each other and on which I accidentaly disabled one of them.
    – Meloman
    Commented Jul 3, 2020 at 6:32
  • Haha - glad to hear it worked for you! :)
    – TomC
    Commented Jul 3, 2020 at 6:33
  • A very nice fallback solution, thanks for posting this, I just learned something new. :-)
    – Trisha
    Commented Jul 5, 2022 at 20:08
3

You can simply rename the plugin folder, for example:

"_aksimet" to deactive it and than back to "aksimet" to activate it again (if was active)

you can do that with all "plugins" folder together.

Otherwise, go to MySQL and have a look at this step by step manual, in short:

  1. MYSQL > wp_options
  2. search for active_plugins entry (both steps can be done by SELECT * FROM wp_options WHERE option_name = 'active_plugins';)
  3. and than write your plugin there as the other plugins are written (i is index, s is for the length of string).

Hope it helps

4
  • Thanks. I tried deactivating and it turns out the code for the plugin is far too ingrained across the entire site. I need a way to reactivate it :( Commented Aug 26, 2015 at 15:57
  • What do you mean by that? For reactivation simply rename it back. Do you have any errors or so? Commented Aug 26, 2015 at 16:28
  • The plugin was deactivated through the WP Admin interface. Once it was deactivated I could no longer access my site. There was nothing to "rename" as I didn't deactivate it by renaming it over FTP. Commented Aug 26, 2015 at 16:33
  • I've updated my answer, but that definitely weird. Which plugin it was? Maybe you can switch back to twentyfifteen (renaming your theme) activate it and check what went wrong and than going back to your theme. Commented Aug 27, 2015 at 8:20

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