WP_REST_Font_Faces_Controller
- Source
wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php:13
Class to access font faces through the REST API.
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).
Hooks and filters fired · 2
Every hook that fires from inside WP_REST_Font_Faces_Controller, in the order it appears in the class, grouped by the method that fires it.
Properties · 1
$allow_batchfalseprotected- Whether the controller supports batching.
Methods · 22
- register_routes()Registers the routes for posts.
- get_items_permissions_check()Checks if a given request has access to font faces.
- get_item_permissions_check()Checks if a given request has access to a font face.
- validate_create_font_face_settings()Validates settings when creating a font face.
- sanitize_font_face_settings()Sanitizes the font face settings when creating a font face.
- get_items()Retrieves a collection of font faces within the parent font family.
- get_item()Retrieves a single font face within the parent font family.
- create_item()Creates a font face for the parent font family.
- delete_item()Deletes a single font face.
- prepare_item_for_response()Prepares a single font face output for response.
- get_item_schema()Retrieves the post's schema, conforming to JSON Schema.
- get_public_item_schema()Retrieves the item's schema for display / public consumption purposes.
- get_collection_params()Retrieves the query params for the font face collection.
- get_create_params()Get the params used when creating a new font face.
- get_parent_font_family_post()Get the parent font family, if the ID is valid.
- prepare_links()Prepares links for the request.
- prepare_item_for_database()Prepares a single font face post for creation.
- sanitize_src()Sanitizes a single src value for a font face.
- handle_font_file_upload()Handles the upload of a font file using wp_handle_upload().
- handle_font_file_upload_error()Handles file upload error.
- relative_fonts_path()Returns relative path to an uploaded font file.
- get_settings_from_post()Gets the font face's settings from the post.
Source code
class WP_REST_Font_Faces_Controller extends WP_REST_Posts_Controller { /** * The latest version of theme.json schema supported by the controller. * * @since 6.5.0 * @var int */ const LATEST_THEME_JSON_VERSION_SUPPORTED = 3; /** * Whether the controller supports batching. * * @since 6.5.0 * @var false */ protected $allow_batch = false; /** * Registers the routes for posts. * * @since 6.5.0 * * @see register_rest_route() */ public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( 'args' => array( 'font_family_id' => array( 'description' => __( 'The ID for the parent font family of the font face.' ), 'type' => 'integer', 'required' => true, ), ), 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, 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), 'args' => $this->get_create_params(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( 'args' => array( 'font_family_id' => array( 'description' => __( 'The ID for the parent font family of the font face.' ), 'type' => 'integer', 'required' => true, ), 'id' => array( 'description' => __( 'Unique identifier for the font face.' ), 'type' => 'integer', 'required' => true, ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), array( 'methods' => WP_REST_Server::DELETABLE, 'callback' => array( $this, 'delete_item' ),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 7.1.0 tag, from
src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-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.