Make WordPress Core

Changeset 51349


Ignore:
Timestamp:
07/06/2021 03:41:35 PM (3 years ago)
Author:
desrosj
Message:

REST API: Add the $request parameter to methods checking permissions.

This adds the $request parameter to the permissions_check() methods within WP_REST_Widgets_Controller and adds $request as an allowed parameter to the permissions_check() method within WP_REST_Templates_Controller.

Even when this parameter is not used by default, it should be implemented to support the class being extended and the method overidden.

Props johnbillion, timothyblynjacobs.
Fixes #53593.

Location:
trunk/src/wp-includes/rest-api/endpoints
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php

    r51298 r51349  
    110110     * @since 5.8.0
    111111     *
     112     * @param WP_REST_Request $request Full details about the request.
    112113     * @return true|WP_Error True if the request has read access, WP_Error object otherwise.
    113114     */
    114     protected function permissions_check() {
     115    protected function permissions_check( $request ) {
    115116        // Verify if the current user has edit_theme_options capability.
    116117        // This capability is required to edit/view/delete templates.
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php

    r51289 r51349  
    9898     */
    9999    public function get_items_permissions_check( $request ) {
    100         return $this->permissions_check();
     100        return $this->permissions_check( $request );
    101101    }
    102102
     
    140140     */
    141141    public function get_item_permissions_check( $request ) {
    142         return $this->permissions_check();
     142        return $this->permissions_check( $request );
    143143    }
    144144
     
    177177     */
    178178    public function create_item_permissions_check( $request ) {
    179         return $this->permissions_check();
     179        return $this->permissions_check( $request );
    180180    }
    181181
     
    221221     */
    222222    public function update_item_permissions_check( $request ) {
    223         return $this->permissions_check();
     223        return $this->permissions_check( $request );
    224224    }
    225225
     
    284284     */
    285285    public function delete_item_permissions_check( $request ) {
    286         return $this->permissions_check();
     286        return $this->permissions_check( $request );
    287287    }
    288288
     
    399399     * @since 5.8.0
    400400     *
     401     * @param WP_REST_Request $request Full details about the request.
    401402     * @return true|WP_Error
    402403     */
    403     protected function permissions_check() {
     404    protected function permissions_check( $request ) {
    404405        if ( ! current_user_can( 'edit_theme_options' ) ) {
    405406            return new WP_Error(
Note: See TracChangeset for help on using the changeset viewer.