本文整理汇总了PHP中FW_Cache::get方法的典型用法代码示例。如果您正苦于以下问题:PHP FW_Cache::get方法的具体用法?PHP FW_Cache::get怎么用?PHP FW_Cache::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FW_Cache
的用法示例。
在下文中一共展示了FW_Cache::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @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 Original value from db, no changes and translations
*
* @return mixed|null
*/
public static function get($meta_type, $object_id, $multi_key, $default_value = null, $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 . '/' . $meta_type . '/' . $object_id . '/' . $key;
try {
$values = FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$values = array();
$values['original'] = get_metadata($meta_type, $object_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'], $default_value);
}
}
示例2: get_fonts
/**
* Returns fonts
* @return array
*/
public function get_fonts()
{
$cache_key = 'fw_option_type/' . $this->get_type();
try {
return FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$fonts = array('standard' => apply_filters('fw_option_type_typography_v2_standard_fonts', array("Arial", "Verdana", "Trebuchet", "Georgia", "Times New Roman", "Tahoma", "Palatino", "Helvetica", "Calibri", "Myriad Pro", "Lucida", "Arial Black", "Gill Sans", "Geneva", "Impact", "Serif")), 'google' => json_decode(fw_get_google_fonts_v2(), true));
FW_Cache::set($cache_key, $fonts);
return $fonts;
}
}
示例3: get_updates
private function get_updates($force_check = false)
{
$cache_key = 'fw_ext_update/updates';
// use cache because this method may be called multiple times (to prevent useless requests to update servers)
try {
return FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$updates = array('framework' => $this->get_framework_update($force_check), 'theme' => $this->get_theme_update($force_check), 'extensions' => $this->get_extensions_with_updates($force_check));
FW_Cache::set($cache_key, $updates);
return $updates;
}
}
示例4: fw_ext_builder_get_item_width
/**
* 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);
}
}
示例5: get
/**
* @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);
}
示例6: get_predefined_templates
/**
* @param string $builder_type
* @return array|mixed
* @since 1.1.14
*/
protected function get_predefined_templates($builder_type)
{
$cache_id = 'fw_ext_builder/predefined_templates/' . $builder_type . '/' . $this->get_type();
try {
return FW_Cache::get($cache_id);
} catch (FW_Cache_Not_Found_Exception $e) {
$templates = array();
foreach (apply_filters('fw_ext_builder:predefined_templates:' . $builder_type . ':' . $this->get_type(), array()) as $id => $template) {
if (isset($template['title']) && is_string($template['title']) && isset($template['json']) && is_string($template['json']) && null !== json_decode($template['json'])) {
$templates[$id] = array('title' => $template['title'], 'json' => $template['json'], 'type' => 'predefined');
} else {
trigger_error('Invalid predefined template: ' . $id, E_USER_WARNING);
}
}
FW_Cache::set($cache_id, $templates);
return $templates;
}
}
开发者ID:reardestani,项目名称:Unyson-Builder-Extension,代码行数:23,代码来源:class-fw-ext-builder-templates-component.php
示例7: fw_ext_mega_menu_is_mm_item
/**
* Check if menu item is a MegaMenu item or is inside a MegaMenu item
* @param WP_Post $item
* @return bool
*/
function fw_ext_mega_menu_is_mm_item($item)
{
$cache_key = fw_ext('megamenu')->get_cache_key('/mm_item');
try {
$mm_items = FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$mm_items = array();
}
if (isset($mm_items[$item->ID])) {
return $mm_items[$item->ID];
}
$cursor_item = array('id' => $item->ID, 'parent' => $item->menu_item_parent);
do {
$is_mm_item = fw_ext_mega_menu_get_meta($cursor_item['id'], 'enabled');
} while (!$is_mm_item && intval($cursor_item['parent']) !== 0 && ($cursor_item = get_post($cursor_item['parent'])) && ($cursor_item = array('id' => $cursor_item->ID, 'parent' => get_post_meta($cursor_item->ID, '_menu_item_menu_item_parent', true))));
$mm_items[$item->ID] = (bool) $is_mm_item;
FW_Cache::set($cache_key, $mm_items);
return $mm_items[$item->ID];
}
示例8: get_base_dirs_map
/**
* @return array {base_dir_real_path => base_dir_wp_filesystem_path}
*/
public static function get_base_dirs_map()
{
/** @var WP_Filesystem_Base $wp_filesystem */
global $wp_filesystem;
if (!$wp_filesystem) {
trigger_error('Filesystem is not available', E_USER_ERROR);
}
try {
$cache_key = 'fw_wp_filesystem/base_dirs_map';
return FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$themes_dir = get_theme_root();
// Account for relative theme roots
if ('/themes' == $themes_dir || !is_dir($themes_dir)) {
$themes_dir = WP_CONTENT_DIR . $themes_dir;
}
$dirs = array(fw_fix_path(ABSPATH) => fw_fix_path($wp_filesystem->abspath()), fw_fix_path(WP_CONTENT_DIR) => fw_fix_path($wp_filesystem->wp_content_dir()), fw_fix_path(WP_PLUGIN_DIR) => fw_fix_path($wp_filesystem->wp_plugins_dir()), fw_fix_path($themes_dir) => fw_fix_path($wp_filesystem->wp_themes_dir()));
FW_Cache::set($cache_key, $dirs);
return $dirs;
}
}
示例9: get_post_type
private function get_post_type($post_id)
{
$post_id = $this->get_post_id($post_id);
try {
return FW_Cache::get($cache_key = $this->get_cache_key('type/' . $post_id));
} catch (FW_Cache_Not_Found_Exception $e) {
FW_Cache::set($cache_key, $post_type = get_post_type(($post_revision_id = wp_is_post_revision($post_id)) ? $post_revision_id : $post_id));
return $post_type;
}
}
示例10: get_installed_extensions
/**
* Scan all directories for extensions
*
* @param bool $reset_cache
*
* @return array
*/
private function get_installed_extensions($reset_cache = false)
{
$cache_key = $this->get_cache_key('installed_extensions');
if ($reset_cache) {
FW_Cache::del($cache_key);
}
try {
return FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$search_paths = array('framework' => fw_get_framework_directory('/extensions'), 'parent' => fw_get_template_customizations_directory('/extensions'));
if (is_child_theme()) {
$search_paths['child'] = fw_get_stylesheet_customizations_directory('/extensions');
}
$extensions = array();
foreach ($search_paths as $source => $path) {
$this->read_extensions($source, $path, $extensions);
}
FW_Cache::set($cache_key, $extensions);
return $extensions;
}
}
示例11: get_sets
private function get_sets()
{
$cache_key = 'fw_option_type_icon/sets';
try {
return FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$sets = apply_filters('fw_option_type_icon_sets', $this->get_default_sets());
// do not allow overwrite default sets
$sets = array_merge($sets, $this->get_default_sets());
FW_Cache::set($cache_key, $sets);
return $sets;
}
}
示例12: fw_get_google_fonts
/**
* @return Array with Google fonts
*/
function fw_get_google_fonts()
{
$cache_key = 'fw_google_fonts';
try {
return FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$g_fonts = json_decode(fw_get_google_fonts_v2(), true);
$old_fonts = (include dirname(__FILE__) . '/fw-google-fonts.json.php');
$fonts = array();
foreach ($g_fonts['items'] as $font) {
$fonts[$font['family']] = array('family' => $font['family'], 'variants' => $font['variants'], 'position' => isset($old_fonts[$font['family']]) ? $old_fonts[$font['family']]['position'] : 99999);
}
$fonts = apply_filters('fw_google_fonts', $fonts);
FW_Cache::set($cache_key, $fonts);
return $fonts;
}
}
示例13: get_settings_options
public final function get_settings_options()
{
try {
return FW_Cache::get($cache_key = $this->get_cache_key('/settings_options'));
} catch (FW_Cache_Not_Found_Exception $e) {
if (file_exists($path = $this->get_path('/settings-options.php'))) {
$variables = fw_get_variables_from_file($path, array('options' => array()));
} else {
$variables = array('options' => array());
}
FW_Cache::set($cache_key, $variables['options']);
return $variables['options'];
}
}
示例14: fw_get_db_customizer_option
/**
* 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);
}
}
示例15: get_config
/**
* 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);
}