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.

This commit brings the changes from [49952] to the 5.6 branch.

Props oakesjosh, johnbillion, TimothyBlynJacobs.

Fixes #52205.

Built from https://develop.svn.wordpress.org/branches/5.6@50046


git-svn-id: http://core.svn.wordpress.org/branches/5.6@49747 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2021-01-28 00:34:59 +00:00
parent 5e3f9c3b31
commit ed54a900e3
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.6.1-alpha-50045';
$wp_version = '5.6.1-alpha-50046';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.