Making WordPress.org

Changeset 9952


Ignore:
Timestamp:
06/03/2020 02:44:14 PM (6 years ago)
Author:
Otto42
Message:

Support: Revert [4503]. This seems to have been at least partially remedied in core since the original issue, and I'm not seeing any particular scaling issues with it at present. Avoids an error in the browser when using the block editor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php

    r9722 r9952  
    4040        add_action( 'bbp_template_redirect', array( $this, 'redirect_attachments' ) );
    4141
    42         // REST API.
    43         add_filter( 'rest_endpoints', array( $this, 'disable_rest_api_users_endpoint' ) );
    44 
    4542        // Disable post meta key lookup, see https://core.trac.wordpress.org/ticket/33885.
    4643        add_filter( 'postmeta_form_keys', '__return_empty_array' );
     
    6865            remove_filter( 'template_redirect', 'redirect_canonical' );
    6966        }
    70     }
    71 
    72     /**
    73      * Disables REST API endpoint for users listing.
    74      *
    75      * @link https://core.trac.wordpress.org/ticket/38878
    76      *
    77      * @param array $endpoints The available endpoints.
    78      * @return array The filtered endpoints.
    79      */
    80     public function disable_rest_api_users_endpoint( $endpoints ) {
    81         if ( ! isset( $endpoints['/wp/v2/users'] ) ) {
    82             return $endpoints;
    83         }
    84 
    85         foreach ( $endpoints['/wp/v2/users'] as &$handler ) {
    86             if ( isset( $handler['methods'] ) && 'GET' === $handler['methods'] ) {
    87                 $handler['permission_callback'] = function() {
    88                     return new WP_Error(
    89                         'rest_not_implemented',
    90                         __( 'Sorry, you are not allowed to list users.' ),
    91                         array( 'status' => 501 )
    92                     );
    93                 };
    94 
    95                 break;
    96             }
    97         }
    98 
    99         return $endpoints;
    10067    }
    10168
Note: See TracChangeset for help on using the changeset viewer.