Automattic\WooCommerce\StoreApi
RoutesController::get_all_routes()
Get a route path without instantiating the corresponding RoutesController object.
Метод класса: RoutesController{}
Хуков нет.
Возвращает
Строку[]
. List of route paths.
Использование
$RoutesController = new RoutesController(); $RoutesController->get_all_routes( $version, $controller );
- $version(строка)
- API Version being requested.
По умолчанию: 'v1' - $controller(строка)
- Whether to return controller name. If false, returns empty array. Note: When $controller param is true, the output should not be used directly in front-end code, to prevent class names from leaking. It's not a security issue necessarily, but it's not a good practice. When $controller param is false, it currently returns and empty array. But it can be modified in future to return include more details about the route info that can be used in frontend.
По умолчанию: false
Код RoutesController::get_all_routes() RoutesController::get all routes WC 9.6.1
public function get_all_routes( $version = 'v1', $controller = false ) { $routes = array(); foreach ( $this->routes[ $version ] as $key => $route_class ) { if ( ! method_exists( $route_class, 'get_path_regex' ) ) { throw new \Exception( esc_html( "{$route_class} route does not have a get_path_regex method" ) ); } $route_path = '/' . trailingslashit( self::$api_namespace ) . $version . $route_class::get_path_regex(); $routes[ $route_path ] = $controller ? $route_class : array(); } return $routes; }