Changeset 4503
- Timestamp:
- 12/08/2016 12:20:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php
r4502 r4503 2 2 3 3 namespace WordPressdotorg\Forums; 4 5 use WP_Error; 4 6 5 7 class Performance_Optimizations { … … 31 33 // Redirect search results. 32 34 add_action( 'bbp_template_redirect', array( $this, 'redirect_search_results_to_google_search' ) ); 35 36 // REST API. 37 add_filter( 'rest_endpoints', array( $this, 'disable_rest_api_users_endpoint' ) ); 38 } 39 40 /** 41 * Disables REST API endpoint for users listing. 42 * 43 * @link https://core.trac.wordpress.org/ticket/38878 44 * 45 * @param array $endpoints The available endpoints. 46 * @return array The filtered endpoints. 47 */ 48 public function disable_rest_api_users_endpoint( $endpoints ) { 49 foreach ( $endpoints['/wp/v2/users'] as &$handler ) { 50 if ( isset( $handler['methods'] ) && 'GET' === $handler['methods'] ) { 51 $handler['permission_callback'] = function() { 52 return new WP_Error( 53 'rest_not_implemented', 54 __( 'Sorry, you are not allowed to list users.' ), 55 array( 'status' => 501 ) 56 ); 57 }; 58 59 break; 60 } 61 } 62 63 return $endpoints; 33 64 } 34 65
Note: See TracChangeset
for help on using the changeset viewer.