WP_REST_Font_Faces_Controller::get_settings_from_post()protectedWP 6.5.0

Gets the font face's settings from the post.

Method of the class: WP_REST_Font_Faces_Controller{}

No Hooks.

Return

Array. Font face settings array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_settings_from_post( $post );
$post(WP_Post) (required)
Font face post object.

Changelog

Since 6.5.0 Introduced.

WP_REST_Font_Faces_Controller::get_settings_from_post() code WP 6.6.2

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 );
}