Ticket #45265: 45265.diff
File 45265.diff, 1.1 KB (added by , 6 years ago) |
---|
-
src/wp-includes/rest-api.php
18 18 * Registers a REST API route. 19 19 * 20 20 * @since 4.4.0 21 * @since 5.1.0 Enforce requirement to use on the rest_api_init hook. 22 * 21 23 * 22 24 * @param string $namespace The first URL segment after core prefix. Should be unique to your package/plugin. 23 25 * @param string $route The base URL for route you are adding. … … 28 30 * @return bool True on success, false on error. 29 31 */ 30 32 function register_rest_route( $namespace, $route, $args = array(), $override = false ) { 31 if ( empty( $namespace ) ) { 33 if ( ! doing_action( 'rest_api_init' ) ) { 34 _doing_it_wrong( 'register_rest_route', __( 'REST API routes must be registered on the rest_api_init action.'), '5.1.0' ); 35 return false; 36 } else if ( empty( $namespace ) ) { 32 37 /* 33 38 * Non-namespaced routes are not allowed, with the exception of the main 34 39 * and namespace indexes. If you really need to register a