/** * Cache the customizer's options in a static array (converted from an given json) * * @param $json */ static function set_customizer_options($json) { if (empty(self::$customizer_options)) { $options = json_decode(wp_unslash($json), true); $theme_key = self::shortname() . '_options'; $options[$theme_key] = array(); foreach ($options as $key => $opt) { $new_key = ''; if (stripos($key, $theme_key) === 0 && stripos($key, $theme_key) !== false) { $new_key = str_replace($theme_key . '[', '', $key); $new_key = rtrim($new_key, ']'); $options[$theme_key][$new_key] = $opt; } } self::$customizer_options = $options[$theme_key]; } }