register_rest_route example



    /** * Registers the routes for taxonomies. * * @since 4.7.0 * * @see register_rest_route() */
    public function register_routes() {

        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                    'args'                => $this->get_collection_params(),
                ),
                'schema' => array( $this, 'get_public_item_schema' ),
            )
        );
$this->rest_base = 'themes';
    }

    /** * Registers the routes for themes. * * @since 5.0.0 * * @see register_rest_route() */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                    'args'                => $this->get_collection_params(),
                ),
                'schema' => array( $this, 'get_item_schema' ),
            )
        );
$this->rest_base = 'menu-locations';
    }

    /** * Registers the routes for the objects of the controller. * * @since 5.9.0 * * @see register_rest_route() */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                    'args'                => $this->get_collection_params(),
                ),
                'schema' => array( $this, 'get_public_item_schema' ),
            )
        );


    /** * Registers the routes for block types. * * @since 5.5.0 * * @see register_rest_route() */
    public function register_routes() {

        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                    'args'                => $this->get_collection_params(),
                ),
                'schema' => array( $this, 'get_public_item_schema' ),
            )
        );

    public function __construct() {
        $this->namespace = 'wp/v2';
        $this->rest_base = 'block-directory';
    }

    /** * Registers the necessary REST API routes. */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base . '/search',
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                    'args'                => $this->get_collection_params(),
                ),
                'schema' => array( $this, 'get_public_item_schema' ),
            )
        );
public function __construct() {
        $this->namespace = 'wp/v2';
        $this->rest_base = 'block-patterns/categories';
    }

    /** * Registers the routes for the objects of the controller. * * @since 6.0.0 */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                ),
                'schema' => array( $this, 'get_public_item_schema' ),
            )
        );
    }


    /** * Registers the routes for users. * * @since 4.7.0 * * @see register_rest_route() */
    public function register_routes() {

        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                    'args'                => $this->get_collection_params(),
                ),
                array(
                    'methods'             => WP_REST_Server::CREATABLE,
                    


    /** * Registers the routes for the site's settings. * * @since 4.7.0 * * @see register_rest_route() */
    public function register_routes() {

        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_item' ),
                    'args'                => array(),
                    'permission_callback' => array( $this, 'get_item_permissions_check' ),
                ),
                array(
                    'methods'             => WP_REST_Server::EDITABLE,
                    
$this->namespace = 'wp/v2';
        $this->rest_base = 'global-styles';
        $this->post_type = 'wp_global_styles';
    }

    /** * Registers the controllers routes. * * @since 5.9.0 */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base . '/themes/(?P<stylesheet>[\/\s%\w\.\(\)\[\]\@_\-]+)/variations',
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_theme_items' ),
                    'permission_callback' => array( $this, 'get_theme_items_permissions_check' ),
                    'args'                => array(
                        'stylesheet' => array(
                            'description' => __( 'The theme identifier' ),
                            'type'        => 'string',
                        ),
public function __construct() {
        $this->namespace = 'wp/v2';
        $this->rest_base = 'sidebars';
    }

    /** * Registers the controllers routes. * * @since 5.8.0 */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                    'args'                => array(
                        'context' => $this->get_context_param( array( 'default' => 'view' ) ),
                    ),
                ),
                
public function __construct() {
        $this->namespace = 'wp/v2';
        $this->rest_base = 'block-patterns/patterns';
    }

    /** * Registers the routes for the objects of the controller. * * @since 6.0.0 */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                ),
                'schema' => array( $this, 'get_public_item_schema' ),
            )
        );
    }
$this->namespace            = ! empty( $post_type_object->rest_namespace ) ? $post_type_object->rest_namespace : 'wp/v2';
    }

    /** * Registers the routes for autosaves. * * @since 5.0.0 * * @see register_rest_route() */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->parent_base . '/(?P<id>[\d]+)/' . $this->rest_base,
            array(
                'args'   => array(
                    'parent' => array(
                        'description' => __( 'The ID for the parent of the autosave.' ),
                        'type'        => 'integer',
                    ),
                ),
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    

    }

    /** * Registers the routes for the search controller. * * @since 5.0.0 * * @see register_rest_route() */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permission_check' ),
                    'args'                => $this->get_collection_params(),
                ),
                'schema' => array( $this, 'get_public_item_schema' ),
            )
        );
public function __construct() {
        $this->namespace = 'wp-block-editor/v1';
        $this->rest_base = 'url-details';
    }

    /** * Registers the necessary REST API routes. * * @since 5.9.0 */
    public function register_routes() {
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'parse_url_details' ),
                    'args'                => array(
                        'url' => array(
                            'required'          => true,
                            'description'       => __( 'The URL to process.' ),
                            'validate_callback' => 'wp_http_validate_url',
                            


    /** * Registers the routes for post statuses. * * @since 4.7.0 * * @see register_rest_route() */
    public function register_routes() {

        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base,
            array(
                array(
                    'methods'             => WP_REST_Server::READABLE,
                    'callback'            => array( $this, 'get_items' ),
                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
                    'args'                => $this->get_collection_params(),
                ),
                'schema' => array( $this, 'get_public_item_schema' ),
            )
        );
Home | Imprint | This part of the site doesn't use cookies.