/** * Prepare JSON for Customizer * * Turns JSON options back into their array * equivalent so that they can be used by * the WP_Customize_Setting class. This allows * the customizer to preserve the state of any * font controls that the user has edited even * when they navigate to a different page in the * customizer. * * @param array $options - The options either as JSON or as an array * @return array $options - The options as an array * * @since 1.3.2 * @version 1.3.2 * */ public function prep_option_for_customizer($options = array()) { remove_filter('option_tt_font_theme_options', array($this, 'prep_option_for_customizer'), 5); if (empty($options)) { $options = array(); } // Return the options if we are not in the customizer foreach ($options as $option) { /** * Add font color and background color for this * option to prevent errors parsing JSON when the * user navigates to another page in the customizer. * */ $option['font_color'] = ''; $option['background_color'] = ''; // Convert option to array if it is in JSON format if (is_string($option)) { $option = json_decode($option); } // Convert option to array if it is a StdClass Object if (is_object($option)) { $option = Easy_Google_Fonts::object_to_array($option); } } add_filter('option_tt_font_theme_options', array($this, 'prep_option_for_customizer'), 5); return $options; }