wp/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
   207 	 *
   207 	 *
   208 	 * @param string $plugin The plugin file to check.
   208 	 * @param string $plugin The plugin file to check.
   209 	 * @return true|WP_Error True if can read, a WP_Error instance otherwise.
   209 	 * @return true|WP_Error True if can read, a WP_Error instance otherwise.
   210 	 */
   210 	 */
   211 	protected function check_read_permission( $plugin ) {
   211 	protected function check_read_permission( $plugin ) {
       
   212 		require_once ABSPATH . 'wp-admin/includes/plugin.php';
       
   213 
   212 		if ( ! $this->is_plugin_installed( $plugin ) ) {
   214 		if ( ! $this->is_plugin_installed( $plugin ) ) {
   213 			return new WP_Error( 'rest_plugin_not_found', __( 'Plugin not found.' ), array( 'status' => 404 ) );
   215 			return new WP_Error( 'rest_plugin_not_found', __( 'Plugin not found.' ), array( 'status' => 404 ) );
   214 		}
   216 		}
   215 
   217 
   216 		if ( ! is_multisite() ) {
   218 		if ( ! is_multisite() ) {
   582 
   584 
   583 		$response = new WP_REST_Response( $data );
   585 		$response = new WP_REST_Response( $data );
   584 		$response->add_links( $this->prepare_links( $item ) );
   586 		$response->add_links( $this->prepare_links( $item ) );
   585 
   587 
   586 		/**
   588 		/**
   587 		 * Filters the plugin data for a response.
   589 		 * Filters plugin data for a REST API response.
   588 		 *
   590 		 *
   589 		 * @since 5.5.0
   591 		 * @since 5.5.0
   590 		 *
   592 		 *
   591 		 * @param WP_REST_Response $response The response object.
   593 		 * @param WP_REST_Response $response The response object.
   592 		 * @param array            $item     The plugin item from {@see get_plugin_data()}.
   594 		 * @param array            $item     The plugin item from {@see get_plugin_data()}.
   658 	 * @since 5.5.0
   660 	 * @since 5.5.0
   659 	 *
   661 	 *
   660 	 * @param string $plugin         The plugin file to update.
   662 	 * @param string $plugin         The plugin file to update.
   661 	 * @param string $new_status     The plugin's new status.
   663 	 * @param string $new_status     The plugin's new status.
   662 	 * @param string $current_status The plugin's current status.
   664 	 * @param string $current_status The plugin's current status.
   663 	 *
       
   664 	 * @return true|WP_Error
   665 	 * @return true|WP_Error
   665 	 */
   666 	 */
   666 	protected function plugin_status_permission_check( $plugin, $new_status, $current_status ) {
   667 	protected function plugin_status_permission_check( $plugin, $new_status, $current_status ) {
   667 		if ( is_multisite() && ( 'network-active' === $current_status || 'network-active' === $new_status ) && ! current_user_can( 'manage_network_plugins' ) ) {
   668 		if ( is_multisite() && ( 'network-active' === $current_status || 'network-active' === $new_status ) && ! current_user_can( 'manage_network_plugins' ) ) {
   668 			return new WP_Error(
   669 			return new WP_Error(
   768 	 *
   769 	 *
   769 	 * @since 5.5.0
   770 	 * @since 5.5.0
   770 	 *
   771 	 *
   771 	 * @param WP_REST_Request $request The request to require the plugin matches against.
   772 	 * @param WP_REST_Request $request The request to require the plugin matches against.
   772 	 * @param array           $item    The plugin item.
   773 	 * @param array           $item    The plugin item.
   773 	 *
       
   774 	 * @return bool
   774 	 * @return bool
   775 	 */
   775 	 */
   776 	protected function does_plugin_match_request( $request, $item ) {
   776 	protected function does_plugin_match_request( $request, $item ) {
   777 		$search = $request['search'];
   777 		$search = $request['search'];
   778 
   778