/** * @param int $post_id * @param string $multi_key 'abc' or 'ab/c/def' * @param bool|null $get_original_value Original value from db, no changes and translations * @return mixed|null */ public static function get($post_id, $multi_key, $get_original_value = null) { if ($get_original_value === null) { $get_original_value = is_admin(); } if (empty($multi_key)) { trigger_error('Key not specified', E_USER_WARNING); return null; } $multi_key = explode('/', $multi_key); $key = array_shift($multi_key); $multi_key = implode('/', $multi_key); $cache_key = self::$cache_key . '/' . $post_id . '/' . $key; try { $values = FW_Cache::get($cache_key); } catch (FW_Cache_Not_Found_Exception $e) { $values = array(); $values['original'] = get_post_meta($post_id, $key, true); $values['prepared'] = fw_prepare_option_value($values['original']); FW_Cache::set($cache_key, $values); } if (empty($multi_key)) { return $values[$get_original_value ? 'original' : 'prepared']; } else { return fw_akg($multi_key, $values[$get_original_value ? 'original' : 'prepared']); } }
/** * Recursively find a key's value in array * * @param string $keys 'a/b/c' * @param array|object $array_or_object * @param null|mixed $default_value * @param string $keys_delimiter * @return null|mixed */ function fw_akg($keys, &$array_or_object, $default_value = null, $keys_delimiter = '/') { if (!is_array($keys)) { $keys = explode($keys_delimiter, (string) $keys); } $key_or_property = array_shift($keys); if ($key_or_property === null) { return $default_value; } $is_object = is_object($array_or_object); if ($is_object) { if (!property_exists($array_or_object, $key_or_property)) { return $default_value; } } else { if (!is_array($array_or_object) || !array_key_exists($key_or_property, $array_or_object)) { return $default_value; } } if (isset($keys[0])) { // not used count() for performance reasons if ($is_object) { return fw_akg($keys, $array_or_object->{$key_or_property}, $default_value); } else { return fw_akg($keys, $array_or_object[$key_or_property], $default_value); } } else { if ($is_object) { return $array_or_object->{$key_or_property}; } else { return $array_or_object[$key_or_property]; } } }
public function after($data = array()) { $update_actions = array('extensions_page' => fw_html_tag('a', array('href' => fw_akg('extensions_page_link', $data, '#'), 'title' => __('Go to extensions page', 'fw'), 'target' => '_parent'), __('Return to Extensions page', 'fw'))); $this->feedback(implode(' | ', (array) $update_actions)); if ($this->result) { // used for popup ajax form submit result $this->feedback('<span success></span>'); } }
/** * @param string $option_name * @param string|null $specific_multi_key 'ab/c/def' * @param null|mixed $default_value If no option found in the database, this value will be returned * @param bool|null $get_original_value REMOVED https://github.com/ThemeFuse/Unyson/issues/1676 * @return mixed|null */ public static function get($option_name, $specific_multi_key = null, $default_value = null, $get_original_value = null) { if (!is_null($get_original_value)) { _doing_it_wrong(__FUNCTION__, '$get_original_value parameter was removed', 'Unyson 2.5.8'); } $value = get_option($option_name, null); if (empty($specific_multi_key) && $specific_multi_key !== '0') { return is_null($value) ? $default_value : $value; } else { return fw_akg($specific_multi_key, $value, $default_value); } }
public function sanitize($value) { $value = json_decode($value, true); if (is_null($value) || !is_array($value)) { return null; } $POST = array(); foreach ($value as $var) { fw_aks(fw_html_attr_name_to_array_multi_key($var['name'], true), $var['value'], $POST); } $value = fw()->backend->option_type($this->fw_option['type'])->get_value_from_input($this->fw_option, fw_akg(fw_html_attr_name_to_array_multi_key($this->id), $POST)); return $value; }
/** * {@inheritdoc} */ protected function _load($id, array $option, $value, array $params) { if ($wp_option = $this->get_wp_option($option, $params)) { if (isset($option['fw-storage']['key'])) { $wp_option_value = get_option($wp_option, array()); return fw_akg($option['fw-storage']['key'], $wp_option_value, $value); } else { return get_option($wp_option, $value); } } else { return $value; } }
public function setting_sanitize_callback($input) { $input = json_decode($input, true); if (is_null($input)) { return null; } $POST = array(); foreach ($input as $var) { fw_aks(fw_html_attr_name_to_array_multi_key($var['name']), $var['value'], $POST); } $value = fw_get_options_values_from_input(array($this->id => $this->fw_option), fw_akg(FW_Option_Type::get_default_name_prefix(), $POST)); $value = array_pop($value); return $value; }
protected function _render($atts, $content = null, $tag = '') { if (!isset($atts['data_provider']['population_method'])) { trigger_error(__('No events provider specified for calendar shortcode', 'fw')); return '<b>Calendar Placeholder</b>'; } $this->load_data(); $provider = $atts['data_provider']['population_method']; if (!isset($this->data[$provider])) { trigger_error(sprintf(__('Unknown events provider "%s" specified for calendar shortcode', 'fw'), $provider)); return '<b>Calendar Placeholder</b>'; } $ajax_params = apply_filters('fw_shortcode_calendar_ajax_params', array(), $provider, fw_akg('data_provider/' . $provider, $atts)); if (is_array($ajax_params)) { $ajax_params = array_merge($ajax_params, array('data_provider' => $provider)); } else { $ajax_params = array('data_provider' => $provider); } $wrapper_atts = array('data-extends-ajax-params' => json_encode($ajax_params), 'data-ajax-url' => admin_url('admin-ajax.php'), 'data-template' => $atts['template'], 'data-template-path' => $this->get_declared_URI('/views/'), 'data-first-day' => $atts['first_week_day']); if ($provider === 'custom') { $rows = fw_akg('data_provider/custom/custom_events', $atts, array()); $event_sources = array(); if (empty($rows) === false) { $key = 0; foreach ($rows as $row) { if (empty($row['calendar_date_range']['from']) || empty($row['calendar_date_range']['to'])) { continue; } $event_sources[$key]['id'] = $key; $start = new DateTime($row['calendar_date_range']['from'], new DateTimeZone('GMT')); $end = new DateTime($row['calendar_date_range']['to'], new DateTimeZone('GMT')); //set end of all_day event time 23:59:59 if ($start == $end and $end->format('H:i') === '00:00') { $end->modify('+23 hour'); $end->modify('+59 minutes'); $end->modify('+59 second'); } $event_sources[$key]['start'] = $start->format('U'); $event_sources[$key]['end'] = $end->format('U'); $event_sources[$key]['title'] = htmlspecialchars_decode($row['title']); $event_sources[$key]['url'] = $row['url']; $key++; } } $wrapper_atts['data-event-source'] = json_encode($event_sources); } $this->enqueue_static(); return fw_render_view($this->locate_path('/views/view.php'), compact('atts', 'content', 'tag', 'wrapper_atts')); }
/** * Get builder item width data * * Default widths are specified in the config, but some builder types can have custom widths * * Usage example: * <div class="<?php echo esc_attr(fw_ext_builder_get_item_width('builder-type', $item['width'] .'/frontend_class')) ?>" > * * @param string $builder_type Builder option type (some builders can have different item widths) * @param null|string $width_id Specify width id (accepts multikey) or leave empty to get all widths * @param null|mixed $default_value Return this value if specified key does not exist * @return array */ function fw_ext_builder_get_item_width($builder_type, $width_id = null, $default_value = null) { try { $cache_key = fw()->extensions->get('builder')->get_cache_key('item_widths/' . $builder_type); $widths = FW_Cache::get($cache_key); } catch (FW_Cache_Not_Found_Exception $e) { $widths = apply_filters('fw_builder_item_widths:' . $builder_type, fw()->extensions->get('builder')->get_config('default_item_widths')); FW_Cache::set($cache_key, $widths); } if (is_null($width_id)) { return $widths; } else { return fw_akg($width_id, $widths, $default_value); } }
public function get_config($key = null) { if (!$this->config) { $config_path = $this->path . '/config.php'; if (file_exists($config_path)) { $vars = fw_get_variables_from_file($config_path, array('cfg' => null)); $this->config = $vars['cfg']; } } if (!is_array($this->config)) { return null; } else { return $key === null ? $this->config : fw_akg($key, $this->config); } }
/** * @param string $option_name * @param string|null $specific_multi_key 'ab/c/def' * @param null|mixed $default_value If no option found in the database, this value will be returned * @param bool|null $get_original_value Original value from db, no changes and translations * @return mixed|null */ public static function get($option_name, $specific_multi_key = null, $default_value = null, $get_original_value = null) { if ($get_original_value === null) { $get_original_value = is_admin(); } $cache_key = self::$cache_key . '/' . $option_name; try { $values = FW_Cache::get($cache_key); } catch (FW_Cache_Not_Found_Exception $e) { $values = array(); $values['original'] = get_option($option_name, null); $values['prepared'] = fw_prepare_option_value($values['original']); FW_Cache::set($cache_key, $values); } return fw_akg(($get_original_value ? 'original' : 'prepared') . (empty($specific_multi_key) ? '' : '/' . $specific_multi_key), $values, $default_value); }
/** * {@inheritdoc} */ protected function _load($id, array $option, $value, array $params) { if ($post_id = $this->get_post_id($option, $params)) { $meta_id = $this->get_meta_id($id, $option, $params); $meta_value = get_post_meta($post_id, $meta_id, true); if ($meta_value === '' && is_array($value)) { return $value; } if (isset($option['fw-storage']['key'])) { return fw_akg($option['fw-storage']['key'], $meta_value, $value); } else { return $meta_value; } } else { return $value; } }
/** * @internal * {@inheritdoc} */ protected function _render($id, $option, $data) { $options_array = $this->prepare_option($id, $option); unset($option['attr']['name'], $option['attr']['value']); if ($option['show_borders']) { $option['attr']['class'] .= ' fw-option-type-multi-picker-with-borders'; } else { $option['attr']['class'] .= ' fw-option-type-multi-picker-without-borders'; } reset($option['picker']); $picker_key = key($option['picker']); $picker_type = $option['picker'][$picker_key]['type']; $picker = $option['picker'][$picker_key]; if (!is_string($picker_value = fw()->backend->option_type($picker_type)->get_value_from_input($picker, isset($data['value'][$picker_key]) ? $data['value'][$picker_key] : null))) { /** * Extract the string value that is used as array key */ switch ($picker_type) { case 'icon-v2': $picker_value = fw_akg('type', $picker_value, 'icon-font'); break; default: if (!is_string($picker_value = apply_filters('fw:option-type:multi-picker:string-value:' . $picker_type, $picker_value))) { trigger_error('[multi-picker] Cannot detect string value for picker type ' . $picker_type, E_USER_WARNING); $picker_value = '?'; } } } $skip_first = true; foreach ($options_array as $group_id => &$group) { if ($skip_first) { $skip_first = false; continue; // first is picker } if ($group_id === $id . '-' . $picker_value) { continue; // skip selected choice options } $options_array[$group_id]['attr']['data-options-template'] = fw()->backend->render_options($options_array[$group_id]['options'], $data['value'], array('id_prefix' => $data['id_prefix'] . $id . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . ']')); $options_array[$group_id]['options'] = array(); } return '<div ' . fw_attr_to_html($option['attr']) . '>' . fw()->backend->render_options($options_array, $data['value'], array('id_prefix' => $data['id_prefix'] . $id . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . ']')) . '</div>'; }
protected function _render($id, $option, $data) { $wrapper_attr = $option['attr']; $moment_format = $option['datetime-picker']['moment-format']; $wrapper_attr['data-min-date'] = fw_akg('datetime-picker/minDate', $option, false); $wrapper_attr['data-max-date'] = fw_akg('datetime-picker/maxDate', $option, false); $wrapper_attr['data-extra-formats'] = isset($option['datetime-picker']['extra-formats']) ? json_encode($option['datetime-picker']['extra-formats']) : ''; $wrapper_attr['data-datetime-attr'] = json_encode($option['datetime-picker']); unset($option['datetime-picker']['moment-format'], $option['datetime-picker']['extra-formats'], $option['attr']['class'], $wrapper_attr['name'], $wrapper_attr['id'], $wrapper_attr['value']); if (isset($option['datetime-picker']['value'])) { unset($option['datetime-picker']['value']); } $option['datetime-picker']['scrollInput'] = false; $option['datetime-picker']['lang'] = substr(get_locale(), 0, 2); $option['attr']['data-moment-format'] = $moment_format; echo '<div ' . fw_attr_to_html($wrapper_attr) . ' >'; echo fw()->backend->option_type('text')->render($id, $option, $data); echo '</div>'; }
/** * @param string $meta_type * @param int $object_id * @param string $multi_key 'abc' or 'ab/c/def' * @param null|mixed $default_value If no option found in the database, this value will be returned * @param bool|null $get_original_value REMOVED https://github.com/ThemeFuse/Unyson/issues/1676 * * @return mixed|null */ public static function get($meta_type, $object_id, $multi_key, $default_value = null, $get_original_value = null) { if (!is_null($get_original_value)) { _doing_it_wrong(__FUNCTION__, '$get_original_value parameter was removed', 'Unyson 2.5.8'); } if (empty($multi_key)) { trigger_error('Key not specified', E_USER_WARNING); return null; } $multi_key = explode('/', $multi_key); $key = array_shift($multi_key); $multi_key = implode('/', $multi_key); $value = get_metadata($meta_type, $object_id, $key, true); if (empty($multi_key) && $multi_key !== '0') { return $value; } else { return fw_akg($multi_key, $value, $default_value); } }
/** * @internal */ protected function _get_value_from_input($option, $input_value) { if (is_null($input_value)) { return $option['value']; } else { $value = fw_get_options_values_from_input($this->internal_options, $input_value); //remove time, if all_day selected $all_day = fw_akg('event_durability', $value); if ($all_day === 'yes') { foreach ($value['event_datetime'] as $key => &$row) { if (isset($row['event_date_range']['from'])) { $row['event_date_range']['from'] = date($this->only_date_format, strtotime($row['event_date_range']['from'])); } if (isset($row['event_date_range']['to'])) { $row['event_date_range']['to'] = date($this->only_date_format, strtotime($row['event_date_range']['to'])); } } } return $value; } }
/** * @param array $collected The found extensions {'extension_name' => array()} * @param array $extensions {'extension_name' => array()} * @param bool $check_all Check all extensions or only active extensions */ private function collect_extensions_that_requires(&$collected, $extensions, $check_all = false) { if (empty($extensions)) { return; } $found_extensions = array(); foreach ($this->get_installed_extensions() as $extension_name => $extension_data) { if (isset($collected[$extension_name])) { continue; } if (!$check_all) { if (!fw_ext($extension_name)) { continue; } } if (array_intersect_key($extensions, fw_akg('requirements/extensions', $extension_data['manifest'], array()))) { $found_extensions[$extension_name] = $collected[$extension_name] = array(); } } $this->collect_extensions_that_requires($collected, $found_extensions, $check_all); }
public static function REQUEST($multikey = null, $default_value = null) { return fw_stripslashes_deep_keys($multikey === null ? $_REQUEST : fw_akg($multikey, $_REQUEST, $default_value)); }
/** * Return config key value, or entire config array * Config array is merged from child configs * @param string|null $key Multi key format accepted: 'a/b/c' * @param mixed $default_value * @return mixed|null */ public final function get_config($key = null, $default_value = null) { $cache_key = self::$cache_key . '/config'; try { $config = FW_Cache::get($cache_key); } catch (FW_Cache_Not_Found_Exception $e) { $config = array('settings_form_ajax_submit' => true, 'settings_form_side_tabs' => false); if (file_exists(fw_get_template_customizations_directory('/theme/config.php'))) { $variables = fw_get_variables_from_file(fw_get_template_customizations_directory('/theme/config.php'), array('cfg' => null)); if (!empty($variables['cfg'])) { $config = array_merge($config, $variables['cfg']); unset($variables); } } if (is_child_theme() && file_exists(fw_get_stylesheet_customizations_directory('/theme/config.php'))) { $variables = fw_get_variables_from_file(fw_get_stylesheet_customizations_directory('/theme/config.php'), array('cfg' => null)); if (!empty($variables['cfg'])) { $config = array_merge($config, $variables['cfg']); unset($variables); } } unset($path); FW_Cache::set($cache_key, $config); } return $key === null ? $config : fw_akg($key, $config, $default_value); }
/** * Return config key value, or entire config array * Config array is merged from child configs * @param string|null $key Multi key format accepted: 'a/b/c' * @return mixed|null */ public final function get_config($key = null) { $cache_key = self::$cache_key . '/config'; try { $config = FW_Cache::get($cache_key); } catch (FW_Cache_Not_Found_Exception $e) { $config = array(); if (file_exists(FW_PT_CUSTOM_DIR . '/theme/config.php')) { $variables = fw_get_variables_from_file(FW_PT_CUSTOM_DIR . '/theme/config.php', array('cfg' => null)); if (!empty($variables['cfg'])) { $config = array_merge($config, $variables['cfg']); unset($variables); } } if (FW_CT && file_exists(FW_CT_CUSTOM_DIR . '/theme/config.php')) { $variables = fw_get_variables_from_file(FW_CT_CUSTOM_DIR . '/theme/config.php', array('cfg' => null)); if (!empty($variables['cfg'])) { $config = array_merge($config, $variables['cfg']); unset($variables); } } unset($path); FW_Cache::set($cache_key, $config); } return $key === null ? $config : fw_akg($key, $config); }
public function get_data_positions_options() { $sidebar_positions = $this->backend->config->get_sidebar_positions(); $choices = array(); foreach ($sidebar_positions as $key => $position) { $choices[$key] = array('label' => false, 'small' => $position['icon_url'], 'data' => array('colors' => fw_akg(_FW_Extension_Sidebars_Config::SIDEBARS_NR_KEY, $position))); } $data_positions_options = array('type' => 'image-picker', 'choices' => $choices, 'value' => '', 'attr' => array('class' => 'fw-ext-sidebars-positions')); return $data_positions_options; }
private function get_ics_content($post, $options, $row_id, $offset) { $all_day = fw_akg('all_day', $options, 'yes'); $date_template = 'Ymd\\T000000'; if ($all_day === 'no') { $date_template = 'Ymd\\THis\\Z'; } $start = date($date_template, $offset + strtotime(fw_akg('event_children/' . $row_id . '/event_date_range/from', $options, 'now'))); $end = date($date_template, $offset + strtotime(fw_akg('event_children/' . $row_id . '/event_date_range/to', $options, 'now'))); $location = fw_akg('event_location/location', $options, ''); return "BEGIN:VCALENDAR\n" . "VERSION:1.0\n" . "BEGIN:VEVENT\n" . "URL:" . get_permalink($post->ID) . "\n" . "DTSTART:" . $start . "\n" . "DTEND:" . $end . "\n" . "SUMMARY:" . $post->post_title . "\n" . "DESCRIPTION:For details, click here:" . get_permalink($post->ID) . "\n" . "LOCATION:" . $location . "\n" . "END:VEVENT\n" . "END:VCALENDAR"; }
/** * @param $keys * @param $keys_delimiter * @param $load_callback * @return mixed * @throws FW_Cache_Not_Found_Exception */ public static function get($keys, $load_callback = null, $keys_delimiter = '/') { $keys = (string) $keys; $keys_arr = explode($keys_delimiter, $keys); $key = $keys_arr; $key = array_shift($key); if ($key === '' || $key === null) { trigger_error('First key must not be empty', E_USER_ERROR); } $value = fw_akg($keys, self::$cache, self::$not_found_value, $keys_delimiter); self::free_memory(); // call it every time to take care about memory if ($value === self::$not_found_value) { $parameters = array('key' => $key, 'keys' => $keys, 'keys_arr' => $keys_arr); if (is_callable($load_callback)) { call_user_func_array($load_callback, array($parameters)); } else { do_action('fw_cache_load', $parameters); } unset($parameters); // try again to get value (maybe someone loaded it) $value = fw_akg($keys, self::$cache, self::$not_found_value, $keys_delimiter); if ($value === self::$not_found_value) { throw new FW_Cache_Not_Found_Exception('Cache key not found: ' . $keys); } } return $value; }
/** * Get avaible preset from DB by current page requirements */ private function get_preset_sidebars($data) { if ($this->config->is_enabled_select_option($data['type'], $data['sub_type'])) { $settings = $this->get_db(); if (!empty($data['id'])) { //get by ids preset if (isset($settings['settings'][$data['type']][$data['sub_type']]['saved_ids'])) { //check if id in saved_ids if (in_array($data['id'], $settings['settings'][$data['type']][$data['sub_type']]['saved_ids'])) { $by_ids_presets = $settings['settings'][$data['type']][$data['sub_type']]['by_ids']; usort($by_ids_presets, array($this, 'preset_timestamp_cmp')); foreach ($by_ids_presets as $preset_key => $preset) { if (in_array($data['id'], $preset['ids'])) { $this->current_page_preset = $preset; if (isset($this->current_page_preset['timestamp'])) { unset($this->current_page_preset['timestamp']); } return $this->current_page_preset; } } } } } $this->current_page_preset = fw_akg('settings/' . $data['type'] . '/' . $data['sub_type'] . '/common', $settings, false); if (isset($this->current_page_preset['timestamp'])) { unset($this->current_page_preset['timestamp']); } return $this->current_page_preset; } return false; }
if ($can_install) { $requirements[] = sprintf(__('You need to update the %s extension to %s: %s', 'fw'), $ext->manifest->get_name(), $req_ext_data['min_version'], fw_html_tag('a', array('href' => self_admin_url('update-core.php')), sprintf(__('Update %s', 'fw'), $ext->manifest->get_name()))); } else { $requirements[] = sprintf(__('The %s extension needs to be updated to %s', 'fw'), $ext->manifest->get_name(), $req_ext_data['min_version']); } } } if (!empty($req_ext_data['max_version'])) { if (!version_compare($req_ext_data['max_version'], $ext->manifest->get_version(), '>=')) { $requirements[] = sprintf(__('Maximum supported %s extension version is %s', 'fw'), $ext->manifest->get_name(), $req_ext_data['max_version']); } } } else { $ext_title = fw_id_to_title($req_ext); if (isset($lists['installed'][$req_ext])) { $ext_title = fw_akg('name', $lists['installed'][$req_ext]['manifest'], $ext_title); ob_start(); ?> <form action="<?php echo esc_attr($link); ?> &sub-page=activate&extension=<?php echo esc_attr($req_ext); ?> " method="post" style="display: inline;"> <?php wp_nonce_field($nonces['activate']['action'], $nonces['activate']['name']); ?> <?php echo sprintf(__('The %s extension is disabled', 'fw'), $ext_title); ?>
/** * Get a customizer framework option value from the database * * @param string|null $option_id Specific option id (accepts multikey). null - all options * @param null|mixed $default_value If no option found in the database, this value will be returned * // fixme: Maybe add this parameter? @ param null|bool $get_original_value Original value is that with no translations and other changes * * @return mixed|null */ function fw_get_db_customizer_option($option_id = null, $default_value = null) { // note: this contains only changed controls/options $all_db_values = get_theme_mod(FW_Option_Type::get_default_name_prefix(), array()); $cache_key = 'fw_default_options_values/customizer'; try { $all_default_values = FW_Cache::get($cache_key); } catch (FW_Cache_Not_Found_Exception $e) { // extract the default values from options array $all_default_values = fw_get_options_values_from_input(fw()->theme->get_customizer_options(), array()); FW_Cache::set($cache_key, $all_default_values); } if (is_null($option_id)) { return array_merge($all_default_values, $all_db_values); } else { $base_key = explode('/', $option_id); // note: option_id can be a multi-key 'a/b/c' $base_key = array_shift($base_key); $all_db_values = array_key_exists($base_key, $all_db_values) ? $all_db_values : $all_default_values; return fw_akg($option_id, $all_db_values, $default_value); } }
/** * Get a customizer framework option value from the database * * @param string|null $option_id Specific option id (accepts multikey). null - all options * @param null|mixed $default_value If no option found in the database, this value will be returned * // fixme: Maybe add this parameter? @ param null|bool $get_original_value Original value is that with no translations and other changes * * @return mixed|null */ function fw_get_db_customizer_option($option_id = null, $default_value = null) { // note: this contains only changed controls/options $db_values = get_theme_mod(FW_Option_Type::get_default_name_prefix(), null); if (!is_null($default_value) && is_null($option_id ? fw_akg($option_id, $db_values) : $db_values)) { /** * Default value was provided in case db value is empty. * * Do not extract default values from options files (below) * maybe this function was called from options files and it will cause infinite loop, * that's why the developer provided a default value to prevent that. */ return $default_value; } if (is_null($db_values)) { $db_values = array(); } if (is_null($option_id) || ($base_key = explode('/', $option_id)) && ($base_key = array_shift($base_key)) && !array_key_exists($base_key, $db_values)) { $cache_key = 'fw_default_options_values/customizer'; try { $default_values = FW_Cache::get($cache_key); } catch (FW_Cache_Not_Found_Exception $e) { // extract the default values from options array $default_values = fw_get_options_values_from_input(fw()->theme->get_customizer_options(), array()); FW_Cache::set($cache_key, $default_values); } $db_values = array_merge($default_values, $db_values); } return is_null($option_id) ? $db_values : fw_akg($option_id, $db_values, $default_value); }
/** * Return config key value, or entire config array * Config array is merged from child configs * @param string|null $key Multi key format accepted: 'a/b/c' * @return mixed|null */ public final function get_config($key = null) { $cache_key = $this->get_cache_key() . '/config'; try { $config = FW_Cache::get($cache_key); } catch (FW_Cache_Not_Found_Exception $e) { list($search_in_framework, $search_in_parent_theme, $search_in_child_theme) = $this->correct_search_in_locations(true, true, true); $rel_path = $this->get_rel_path() . '/config.php'; $config = array(); $paths = array(); if ($search_in_framework) { $paths[] = fw_get_framework_directory('/extensions' . $rel_path); } if ($search_in_parent_theme) { $paths[] = fw_get_template_customizations_directory('/extensions' . $rel_path); } if ($search_in_child_theme) { $paths[] = fw_get_stylesheet_customizations_directory('/extensions' . $rel_path); } foreach ($paths as $path) { if (file_exists($path)) { $variables = fw_get_variables_from_file($path, array('cfg' => null)); if (!empty($variables['cfg'])) { $config = array_merge($config, $variables['cfg']); unset($variables); } } } unset($path); FW_Cache::set($cache_key, $config); } return $key === null ? $config : fw_akg($key, $config); }
/** * Returns value of the form option * * @param string $id * @param null|string $multikey * * @return mixed|null */ public function get_option($id, $multikey = null) { $form = $this->get_db_data($this->get_name() . '-' . $id); if (empty($form)) { return null; } if (is_null($multikey)) { return $form; } return fw_akg($multikey, $form); }
public static function get($key, $default_value = null) { self::start_session(); return fw_akg($key, $_SESSION, $default_value); }