WP_REST_Font_Faces_Controller::get_parent_font_family_post( int $font_family_id ): WP_Post|WP_Error

In this article

Get the parent font family, if the ID is valid.

Parameters

$font_family_idintrequired
Supplied ID.

Return

WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.

Source

protected function get_parent_font_family_post( $font_family_id ) {
	$error = new WP_Error(
		'rest_post_invalid_parent',
		__( 'Invalid post parent ID.', 'default' ),
		array( 'status' => 404 )
	);

	if ( (int) $font_family_id <= 0 ) {
		return $error;
	}

	$font_family_post = get_post( (int) $font_family_id );

	if ( empty( $font_family_post ) || empty( $font_family_post->ID )
	|| 'wp_font_family' !== $font_family_post->post_type
	) {
		return $error;
	}

	return $font_family_post;
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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