WP_REST_Global_Styles_Controller
- Source
wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php:13
Base Global Styles REST API Controller.
Compatibility
- WordPress
- core
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Properties · 1
$allow_batcharrayprotected- Whether the controller supports batching.
Methods · 18
- __construct()Constructor.
- register_routes()Registers the controllers routes.
- _sanitize_global_styles_callback()Sanitize the global styles stylesheet to decode endpoint.
- get_post()Get the post, if the ID is valid.
- get_item_permissions_check()Checks if a given request has access to read a single global style.
- check_read_permission()Checks if a global style can be read.
- update_item_permissions_check()Checks if a given request has access to write a single global styles config.
- prepare_item_for_database()Prepares a single global styles config for update.
- prepare_item_for_response()Prepare a global styles config output for response.
- prepare_links()Prepares links for the request.
- get_available_actions()Get the link relations available for the post and current user.
- get_collection_params()Retrieves the query params for the global styles collection.
- get_item_schema()Retrieves the global styles type' schema, conforming to JSON Schema.
- get_theme_item_permissions_check()Checks if a given request has access to read a single theme global styles config.
- get_theme_item()Returns the given theme global styles config.
- get_theme_items_permissions_check()Checks if a given request has access to read a single theme global styles config.
- get_theme_items()Returns the given theme global styles variations.
- validate_custom_css()Validate style.css as valid CSS.
Source code
class WP_REST_Global_Styles_Controller extends WP_REST_Posts_Controller { /** * Whether the controller supports batching. * * @since 6.6.0 * @var array */ protected $allow_batch = array( 'v1' => false ); /** * Constructor. * * @since 6.6.0 * * @param string $post_type Post type. */ public function __construct( $post_type = 'wp_global_styles' ) { parent::__construct( $post_type ); } /** * 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', ), ), 'allow_batch' => $this->allow_batch, ), ) ); // 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' ), ), ), 'allow_batch' => $this->allow_batch, ), ) ); // Lists/updates a single global style variation based on the given id. register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\/\d+]+)', array(Changelog
Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.