admin管理员组

文章数量:1122797

When I load the plugins page in the WordPress admin interface, I see this notice displayed to the user at the top of the page:

Some required plugins are missing or inactive.

How can I use code to find out which required plugins are missing or inactive?

When I load the plugins page in the WordPress admin interface, I see this notice displayed to the user at the top of the page:

Some required plugins are missing or inactive.

How can I use code to find out which required plugins are missing or inactive?

Share Improve this question asked May 17, 2024 at 11:35 FlimmFlimm 7107 silver badges25 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

To find out which plugins don't have their required dependencies installed and activated, load the plugins page in the WordPress admin interface, and look for the plugin that has this message next to it (use ctrl-f):

This plugin is active but may not function correctly because required plugins are missing or inactive.

You can see which plugins it requires by looking at the field named "Requires:", for example:

Requires: bbPress

More details

WordPress 6.5 introduced plugin dependencies. In the main PHP file of a plugin, you can now use the new header Requires Plugins, like this:

/**
 * Plugin Name: Express Payment Gateway Checkout for Shop
 * Requires Plugins: shop, payment-gateway
 */

When WordPress loads the plugins admin page, it calls WP_Plugin_Dependencies::display_admin_notice_for_unmet_dependencies() , which displays the general error message if it finds that some required plugins are missing or inactive.

You can find out which ones using this code:

<?php

require_once "/var/www/ct/wp-includes/class-wp-plugin-dependencies.php";

class Foobar extends WP_Plugin_Dependencies {
    public static function debug_plugins() {
        self::initialize();
        $filepaths = self::get_dependency_filepaths();
        var_export($filepaths);

    }
}

Foobar::debug_plugins();

Put that in a file named debug_plugins.php, and then run it using the WP CLI like this:

$ wp eval-file debug_plugins.php
array (
  'bbpress' => false,
)

It prints out a list of required plugins that are missing or inactive.

本文标签: How do I resolve quotSome required plugins are missing or inactivequot