WP_REST_Font_Faces_Controller::get_settings_from_post( WP_Post $post ): array

In this article

Gets the font face’s settings from the post.

Parameters

$postWP_Postrequired
Font face post object.

Return

array Font face settings array.

Source

protected function get_settings_from_post( $post ) {
	$settings   = json_decode( $post->post_content, true );
	$properties = $this->get_item_schema()['properties']['font_face_settings']['properties'];

	// Provide required, empty settings if needed.
	if ( null === $settings ) {
		$settings = array(
			'fontFamily' => '',
			'src'        => array(),
		);
	}

	// Only return the properties defined in the schema.
	return array_intersect_key( $settings, $properties );
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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