WP_REST_Font_Families_Controller::get_settings_from_post( WP_Post $post ): array

In this article

Gets the font family’s settings from the post.

Parameters

$postWP_Postrequired
Font family post object.

Return

array Font family settings array.

Source

protected function get_settings_from_post( $post ) {
	$settings_json = json_decode( $post->post_content, true );

	// Default to empty strings if the settings are missing.
	return array(
		'name'       => isset( $post->post_title ) && $post->post_title ? $post->post_title : '',
		'slug'       => isset( $post->post_name ) && $post->post_name ? $post->post_name : '',
		'fontFamily' => isset( $settings_json['fontFamily'] ) && $settings_json['fontFamily'] ? $settings_json['fontFamily'] : '',
		'preview'    => isset( $settings_json['preview'] ) && $settings_json['preview'] ? $settings_json['preview'] : '',
	);
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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