wppaste
WordPress

WP_REST_Posts_Controller::get_schema_links(): array

Since
4.9.8
Source
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:2782
Retrieves Link Description Objects that should be added to the Schema for the posts collection.

Return

array

Uses · 5

  • rest_url()Retrieves the URL to a REST endpoint.
  • __()Retrieves the translation of $text.
  • post_type_supports()Checks a post type's support for a given feature.
  • wp_list_filter()Filters a list of objects, based on a set of key => value arguments.
  • get_object_taxonomies()Returns the names or objects of the taxonomies which are registered for the requested object or object type, such as a post object or post type name.

Used by · 2

Source

	protected function get_schema_links() { 		$href = rest_url( "{$this->namespace}/{$this->rest_base}/{id}" ); 		$links = array(); 		if ( 'attachment' !== $this->post_type ) {			$links[] = array(				'rel'          => 'https://api.w.org/action-publish',				'title'        => __( 'The current user can publish this post.' ),				'href'         => $href,				'targetSchema' => array(					'type'       => 'object',					'properties' => array(						'status' => array(							'type' => 'string',							'enum' => array( 'publish', 'future' ),						),					),				),			);		} 		$links[] = array(			'rel'          => 'https://api.w.org/action-unfiltered-html',			'title'        => __( 'The current user can post unfiltered HTML markup and JavaScript.' ),			'href'         => $href,			'targetSchema' => array(				'type'       => 'object',				'properties' => array(					'content' => array(						'raw' => array(							'type' => 'string',						),					),				),			),		); 		if ( 'post' === $this->post_type ) {			$links[] = array(				'rel'          => 'https://api.w.org/action-sticky',				'title'        => __( 'The current user can sticky this post.' ),				'href'         => $href,				'targetSchema' => array(					'type'       => 'object',					'properties' => array(						'sticky' => array(							'type' => 'boolean',						),					),				),			);		} 		if ( post_type_supports( $this->post_type, 'author' ) ) {			$links[] = array(				'rel'          => 'https://api.w.org/action-assign-author',				'title'        => __( 'The current user can change the author on this post.' ),				'href'         => $href,				'targetSchema' => array(					'type'       => 'object',					'properties' => array(						'author' => array(							'type' => 'integer',						),					),				),			);		} 		$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) ); 		foreach ( $taxonomies as $tax ) {			$tax_base = ! empty( $tax->rest_base ) ? $tax->rest_base : $tax->name; 			/* translators: %s: Taxonomy name. */			$assign_title = sprintf( __( 'The current user can assign terms in the %s taxonomy.' ), $tax->name );			/* translators: %s: Taxonomy name. */			$create_title = sprintf( __( 'The current user can create terms in the %s taxonomy.' ), $tax->name );

History

Introduced in 4.9.8. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/rest-api/endpoints/class-wp-rest-posts-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.