0


I have build an app which, amongst other stuff deals with plugins for multiple WP sites.

I copy plugin folders & files from the "master" app into the wp-content/plugins folder of a freshly created WP site with just the bare wp_options:
- Copy of the folders & files runs properly, with chmod at 0755 for folders & 0644 for files, to mimick the standard akismet plugin install ;

  • serialize the plugin data & update the 'active_plugins' field with it, and the serialized data is well formed:

a:4:{i:0;s:14:"classic-editor";i:1;s:17:"increase_rest_get";i:2;s:34:"jwt-authentication-for-wp-rest-api";i:3;s:17:"myDashboardWidget";}

array (
0 => 'classic-editor',
1 => 'increase_rest_get',  
2 => 'jwt-authentication-for-wp-rest-api',  
3 => 'myDashboardWidget',
)

But, when I go to the admin, I get the below, All the activated plugins are deactivated:
enter image description here

Why is this ? Am I missing something in the activation / copying process ?
Many thanks,
JM

1 Answer 1

1

The active_plugins data is incorrect. Here's a sample from one of my test sites:

a:3:{i:0;s:34:"advanced-custom-fields-pro/acf.php";i:4;s:31:"code-snippets/code-snippets.php";i:21;s:24:"wordpress-seo/wp-seo.php";}

Or:

Array
(
    [0] => advanced-custom-fields-pro/acf.php
    [4] => code-snippets/code-snippets.php
    [21] => wordpress-seo/wp-seo.php
)

Notice that the plugins are referred to by the path to the main plugin file, relative to the plugins folder. The main plugin folder is what contains the plugin header (example from here):

/**
 * Plugin Name:       My Basics Plugin
 * Plugin URI:        https://example.com/plugins/the-basics/
 * Description:       Handle the basics with this plugin.
 * Version:           1.10.3
 * Requires at least: 5.2
 * Requires PHP:      7.2
 * Author:            John Smith
 * Author URI:        https://author.example.com/
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       my-basics-plugin
 * Domain Path:       /languages
 */

Since /wp-content/plugins/classic-editor is a directory, not a file, it doesn't have a plugin header, so gets deactivated.

1
  • Hey ! Many thanks for this headsup… So stupid of me :I knew the form of the plugin data should have been folder / file !
    – JMB
    Commented Feb 21, 2020 at 5:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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