Changeset 47260 for trunk/src/wp-includes/rest-api/class-wp-rest-server.php
- Timestamp:
- 02/11/2020 03:20:05 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r47239 r47260 745 745 * 746 746 * @since 4.4.0 747 * 747 * @since 5.4.0 Add $namespace parameter. 748 * 749 * @param string $namespace Optionally, only return routes in the given namespace. 748 750 * @return array `'/path/regex' => array( $callback, $bitmask )` or 749 751 * `'/path/regex' => array( array( $callback, $bitmask ), ...)`. 750 752 */ 751 public function get_routes() { 753 public function get_routes( $namespace = '' ) { 754 $endpoints = $this->endpoints; 755 756 if ( $namespace ) { 757 $endpoints = wp_list_filter( $endpoints, array( 'namespace' => $namespace ) ); 758 } 752 759 753 760 /** … … 761 768 * `'/path/regex' => array( array( $callback, $bitmask ). 762 769 */ 763 $endpoints = apply_filters( 'rest_endpoints', $ this->endpoints );770 $endpoints = apply_filters( 'rest_endpoints', $endpoints ); 764 771 765 772 // Normalise the endpoints. … … 873 880 $path = $request->get_route(); 874 881 875 foreach ( $this->get_routes() as $route => $handlers ) { 882 $routes = array(); 883 884 foreach ( $this->get_namespaces() as $namespace ) { 885 if ( 0 === strpos( ltrim( $path, '/' ), $namespace ) ) { 886 $routes = $this->get_routes( $namespace ); 887 break; 888 } 889 } 890 891 if ( ! $routes ) { 892 $routes = $this->get_routes(); 893 } 894 895 foreach ( $routes as $route => $handlers ) { 876 896 $match = preg_match( '@^' . $route . '$@i', $path, $matches ); 877 897
Note: See TracChangeset
for help on using the changeset viewer.