WP_REST_Font_Families_Controller::get_settings_from_post()
Gets the font family's settings from the post.
Method of the class: WP_REST_Font_Families_Controller{}
No Hooks.
Return
Array
. Font family settings array.
Usage
// protected - for code of main (parent) or child class $result = $this->get_settings_from_post( $post );
- $post(WP_Post) (required)
- Font family post object.
Changelog
Since 6.5.0 | Introduced. |
WP_REST_Font_Families_Controller::get_settings_from_post() WP REST Font Families Controller::get settings from post code WP 6.7.1
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'] : '', ); }