get_namespaces example


    protected function match_request_to_handler( $request ) {
        $method = $request->get_method();
        $path   = $request->get_route();

        $with_namespace = array();

        foreach ( $this->get_namespaces() as $namespace ) {
            if ( str_starts_with( trailingslashit( ltrim( $path, '/' ) )$namespace ) ) {
                $with_namespace[] = $this->get_routes( $namespace );
            }
        }

        if ( $with_namespace ) {
            $routes = array_merge( ...$with_namespace );
        } else {
            $routes = $this->get_routes();
        }

        
Home | Imprint | This part of the site doesn't use cookies.