WP_REST_Global_Styles_Controller::register_routes() – Registers the controllers routes.

You appear to be a bot. Output may be restricted

Description

Registers the controllers routes.

Usage

$void = WP_REST_Global_Styles_Controller::register_routes();

Parameters

Returns

void

Source

File name: wordpress/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php


Lines:

1 to 74 of 74
  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',
            ),
          ),
        ),
      )
    );

    // List themes global styles.
    register_rest_route(
      $this->namespace,
      // The route.
      sprintf(
        '/%s/themes/(?P<stylesheet>%s)',
        $this->rest_base,
        // Matches theme's directory: `/themes/<subdirectory>/<theme>/` or `/themes/<theme>/`.
        // Excludes invalid directory name characters: `/:<>*?"|`.
        '[^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?'
      ),
      array(
        array(
          'methods'             => WP_REST_Server::READABLE,
          'callback'            => array( $this, 'get_theme_item' ),
          'permission_callback' => array( $this, 'get_theme_item_permissions_check' ),
          'args'                => array(
            'stylesheet' => array(
              'description'       => __( 'The theme identifier' ),
              'type'              => 'string',
              'sanitize_callback' => array( $this, '_sanitize_global_styles_callback' ),
            ),
          ),
        ),
      )
    );

    // Lists/updates a single global style variation based on the given id.
    register_rest_route(
      $this->namespace,
      '/' . $this->rest_base . '/(?P<id>[\/\w-]+)',
      array(
        array(
          'methods'             => WP_REST_Server::READABLE,
          'callback'            => array( $this, 'get_item' ),
          'permission_callback' => array( $this, 'get_item_permissions_check' ),
          'args'                => array(
            'id' => array(
              'description'       => __( 'The id of a template' ),
              'type'              => 'string',
              'sanitize_callback' => array( $this, '_sanitize_global_styles_callback' ),
            ),
          ),
        ),
        array(
          'methods'             => WP_REST_Server::EDITABLE,
          'callback'            => array( $this, 'update_item' ),
          'permission_callback' => array( $this, 'update_item_permissions_check' ),
          'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
        ),
        'schema' => array( $this, 'get_public_item_schema' ),
      )
    );
  }
 

 View on GitHub View on Trac