WP_REST_Global_Styles_Controller::get_available_actions()protectedWP 5.9.0

Get the link relations available for the post and current user.

Method of the class: WP_REST_Global_Styles_Controller{}

No Hooks.

Return

Array. List of link relations.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_available_actions( $post, $request );
$post(WP_Post) (required)
Post object.
$request(WP_REST_Request) (required)
Request object.

Changelog

Since 5.9.0 Introduced.
Since 6.2.0 Added 'edit-css' action.
Since 6.6.0 Added $post and $request parameters.

WP_REST_Global_Styles_Controller::get_available_actions() code WP 6.6

protected function get_available_actions( $post, $request ) {
	$rels = array();

	$post_type = get_post_type_object( $post->post_type );
	if ( current_user_can( $post_type->cap->publish_posts ) ) {
		$rels[] = 'https://api.w.org/action-publish';
	}

	if ( current_user_can( 'edit_css' ) ) {
		$rels[] = 'https://api.w.org/action-edit-css';
	}

	return $rels;
}