W3cubDocs

/WordPress

WP_REST_Template_Revisions_Controller::__construct( string $parent_post_type )

Constructor.

Parameters

$parent_post_typestringrequired
Post type of the parent.

Source

public function __construct( $parent_post_type ) {
	parent::__construct( $parent_post_type );
	$this->parent_post_type = $parent_post_type;
	$post_type_object       = get_post_type_object( $parent_post_type );
	$parent_controller      = $post_type_object->get_rest_controller();

	if ( ! $parent_controller ) {
		$parent_controller = new WP_REST_Templates_Controller( $parent_post_type );
	}

	$this->parent_controller = $parent_controller;
	$this->rest_base         = 'revisions';
	$this->parent_base       = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
	$this->namespace         = ! empty( $post_type_object->rest_namespace ) ? $post_type_object->rest_namespace : 'wp/v2';
}

Changelog

Version Description
6.4.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/__construct