Making WordPress.org


Ignore:
Timestamp:
09/17/2026 04:25:15 PM (8 weeks ago)
Author:
obenland
Message:

Plugins: Tidy up the REST route permission checks

Closes ​https://github.com/WordPress/wordpress.org/pull/930.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-support-reps.php

    r11373 r15212  
    3939                                'methods'             => WP_REST_Server::CREATABLE,
    4040                                'callback'            => array( $this, 'add_support_rep' ),
    41                                 'permission_callback' => function( $request ) {
    42                                         return current_user_can(
    43                                                 'plugin_add_support_rep',
    44                                                 Plugin_Directory::get_plugin_post( $request['plugin_slug'] )
    45                                         );
    46                                 },
     41                                'permission_callback' => array( $this, 'permission_check_action' ),
     42                                'wporg_capability'    => 'plugin_add_support_rep',
     43                                'wporg_action'        => 'add_support_rep',
    4744                                'args'                => array(
    4845                                        'plugin_slug' => array(
    … …  
    5754                        'methods'             => WP_REST_Server::DELETABLE,
    5855                        'callback'            => array( $this, 'remove_support_rep' ),
    59                         'permission_callback' => function( $request ) {
    60                                 return current_user_can(
    61                                         'plugin_remove_support_rep',
    62                                         Plugin_Directory::get_plugin_post( $request['plugin_slug'] )
    63                                 );
    64                         },
     56                        'permission_callback' => array( $this, 'permission_check_action' ),
     57                        'wporg_capability'    => 'plugin_remove_support_rep',
     58                        'wporg_action'        => 'remove_support_rep',
    6559                        'args'                => array(
    6660                                'plugin_slug' => array(
Note: See TracChangeset for help on using the changeset viewer.