WP_REST_Server::register_route( string $route_namespace, string $route, array $route_args, bool $override = false )
- Since
- 4.4.0
- Source
wp-includes/rest-api/class-wp-rest-server.php:899
Registers a route to the server.
Parameters
$route_namespacestring- Namespace.
$routestring- The REST route.
$route_argsarray- Route arguments.
$overridebooloptional- Whether the route should be overridden if it already exists. Default false.Default:
false
Uses · 1
- WP_REST_Server::register_route()Registers a route to the server.
Used by · 1
- WP_REST_Server::register_route()Registers a route to the server.
Source
public function register_route( $route_namespace, $route, $route_args, $override = false ) { if ( ! isset( $this->namespaces[ $route_namespace ] ) ) { $this->namespaces[ $route_namespace ] = array(); $this->register_route( $route_namespace, '/' . $route_namespace, array( array( 'methods' => self::READABLE, 'callback' => array( $this, 'get_namespace_index' ), 'args' => array( 'namespace' => array( 'default' => $route_namespace, ), 'context' => array( 'default' => 'view', ), ), ), ) ); } // Associative to avoid double-registration. $this->namespaces[ $route_namespace ][ $route ] = true; $route_args['namespace'] = $route_namespace; if ( $override || empty( $this->endpoints[ $route ] ) ) { $this->endpoints[ $route ] = $route_args; } else { $this->endpoints[ $route ] = array_merge( $this->endpoints[ $route ], $route_args ); } }History
Introduced in 4.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/rest-api/class-wp-rest-server.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.