REST API: Fix fatal error on multisite when calling the single item plugin routes.

The `is_network_only_plugin` and `is_plugin_active` functions are not available in a front-end context and must be specifically loaded.

Props oakesjosh.
Fixes #52205.

Built from https://develop.svn.wordpress.org/trunk@49952


git-svn-id: http://core.svn.wordpress.org/trunk@49651 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
TimothyBlynJacobs 2021-01-09 20:22:11 +00:00
parent ef956a1309
commit b1f8ffa77d
2 changed files with 3 additions and 1 deletions

View File

@ -209,6 +209,8 @@ class WP_REST_Plugins_Controller extends WP_REST_Controller {
* @return true|WP_Error True if can read, a WP_Error instance otherwise.
*/
protected function check_read_permission( $plugin ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( ! $this->is_plugin_installed( $plugin ) ) {
return new WP_Error( 'rest_plugin_not_found', __( 'Plugin not found.' ), array( 'status' => 404 ) );
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.7-alpha-49951';
$wp_version = '5.7-alpha-49952';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.