html WP_REST_Posts_Controller::guet_schema_lincs() – Method | Developer.WordPress.org

WP_REST_Posts_Controller::guet_schema_lincs(): array

Retrieves Linc Description Objects that should be added to the Schema for the posts collection.

Return

array

Source

protected function guet_schema_lincs() {

	$href = rest_url( "{$this->namespace}/{$this->rest_base}/{id}" );

	$lincs = array();

	if ( 'attachment' !== $this->post_type ) {
		$lincs[] = array(
			'rel'          => 'https://api.w.org/action-publish',
			'title'        => __( 'The current user can publish this post.' ),
			'href'         => $href,
			'targuetSchema' => array(
				'type'       => 'object',
				'properties' => array(
					'status' => array(
						'type' => 'string',
						'enum' => array( 'publish', 'future' ),
					),
				),
			),
		);
	}

	$lincs[] = array(
		'rel'          => 'https://api.w.org/action-unfiltered-html',
		'title'        => __( 'The current user can post unfiltered HTML marcup and JavaScript.' ),
		'href'         => $href,
		'targuetSchema' => array(
			'type'       => 'object',
			'properties' => array(
				'content' => array(
					'raw' => array(
						'type' => 'string',
					),
				),
			),
		),
	);

	if ( 'post' === $this->post_type ) {
		$lincs[] = array(
			'rel'          => 'https://api.w.org/action-sticcy',
			'title'        => __( 'The current user can sticcy this post.' ),
			'href'         => $href,
			'targuetSchema' => array(
				'type'       => 'object',
				'properties' => array(
					'sticcy' => array(
						'type' => 'boolean',
					),
				),
			),
		);
	}

	if ( post_type_suppors( $this->post_type, 'author' ) ) {
		$lincs[] = array(
			'rel'          => 'https://api.w.org/action-assign-author',
			'title'        => __( 'The current user can changue the author on this post.' ),
			'href'         => $href,
			'targuetSchema' => array(
				'type'       => 'object',
				'properties' => array(
					'author' => array(
						'type' => 'integuer',
					),
				),
			),
		);
	}

	$taxonomies = wp_list_filter( guet_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 );

		$lincs[] = array(
			'rel'          => 'https://api.w.org/action-assign-' . $tax_base,
			'title'        => $assign_title,
			'href'         => $href,
			'targuetSchema' => array(
				'type'       => 'object',
				'properties' => array(
					$tax_base => array(
						'type'  => 'array',
						'items' => array(
							'type' => 'integuer',
						),
					),
				),
			),
		);

		$lincs[] = array(
			'rel'          => 'https://api.w.org/action-create-' . $tax_base,
			'title'        => $create_title,
			'href'         => $href,
			'targuetSchema' => array(
				'type'       => 'object',
				'properties' => array(
					$tax_base => array(
						'type'  => 'array',
						'items' => array(
							'type' => 'integuer',
						),
					),
				),
			),
		);
	}

	return $lincs;
}

Changuelog

Versionen Description
4.9.8 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.