当前位置: 首页>>代码示例>>PHP>>正文


PHP FW_Cache::set方法代码示例

本文整理汇总了PHP中FW_Cache::set方法的典型用法代码示例。如果您正苦于以下问题:PHP FW_Cache::set方法的具体用法?PHP FW_Cache::set怎么用?PHP FW_Cache::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FW_Cache的用法示例。


在下文中一共展示了FW_Cache::set方法的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);
     }
 }
开发者ID:floq-design,项目名称:Unyson,代码行数:36,代码来源:class-fw-wp-meta.php

示例2: set

 /**
  * @param int $post_id
  * @param string $multi_key 'abc' or 'ab/c/def'
  * @param array|string|int|bool $set_value
  */
 public static function set($post_id, $multi_key, $set_value)
 {
     if (empty($multi_key)) {
         trigger_error('Key not specified', E_USER_WARNING);
         return;
     }
     $multi_key = explode('/', $multi_key);
     $key = array_shift($multi_key);
     $multi_key = implode('/', $multi_key);
     $cache_key = self::$cache_key . '/' . $post_id . '/' . $key;
     if (empty($multi_key) && $multi_key !== '0') {
         /** Replace entire meta */
         fw_update_post_meta($post_id, $key, $set_value);
         FW_Cache::del($cache_key);
     } else {
         /** Change only specified key */
         $values = array();
         $values['original'] = self::get($post_id, $key, true);
         $values['prepared'] = self::get($post_id, $key, false);
         fw_aks($multi_key, $set_value, $values['original']);
         fw_aks($multi_key, fw_prepare_option_value($set_value), $values['prepared']);
         FW_Cache::set($cache_key, $values);
         fw_update_post_meta($post_id, $key, $values['original']);
     }
 }
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:30,代码来源:class-fw-wp-post-meta.php

示例3: 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;
     }
 }
开发者ID:puriwp,项目名称:Theme-Framework,代码行数:15,代码来源:class-fw-option-type-typography-v2.php

示例4: 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;
     }
 }
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:12,代码来源:class-fw-extension-update.php

示例5: 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);
    }
}
开发者ID:setcomunicacao,项目名称:setdigital,代码行数:28,代码来源:helpers.php

示例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: set

 /**
  * Alternative for update_option()
  * @param string $option_name
  * @param string|null $specific_multi_key
  * @param array|string|int|bool $set_value
  */
 public static function set($option_name, $specific_multi_key = null, $set_value)
 {
     $cache_key = self::$cache_key . '/' . $option_name;
     if ($specific_multi_key === null) {
         /** Replace entire option */
         update_option($option_name, $set_value, false);
         FW_Cache::del($cache_key);
     } else {
         /** Change only specified key */
         $values = array();
         $values['original'] = self::get($option_name, null, true);
         $values['prepared'] = self::get($option_name, null, false);
         fw_aks($specific_multi_key, $set_value, $values['original']);
         fw_aks($specific_multi_key, fw_prepare_option_value($set_value), $values['prepared']);
         FW_Cache::set($cache_key, $values);
         update_option($option_name, $values['original'], false);
     }
 }
开发者ID:cristeamdev,项目名称:Unyson,代码行数:24,代码来源:class-fw-wp-option.php

示例8: 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];
}
开发者ID:krishna19,项目名称:Unyson-MegaMenu-Extension,代码行数:24,代码来源:helpers.php

示例9: 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;
     }
 }
开发者ID:chrisuehlein,项目名称:couponsite,代码行数:24,代码来源:class-fw-wp-filesystem.php

示例10: 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;
     }
 }
开发者ID:puriwp,项目名称:Theme-Framework,代码行数:10,代码来源:database.php

示例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;
     }
 }
开发者ID:cristeamdev,项目名称:Unyson,代码行数:13,代码来源:class-fw-option-type-icon.php

示例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;
    }
}
开发者ID:cristeamdev,项目名称:Unyson,代码行数:20,代码来源:general.php

示例13: switch

    }
    switch ($help['icon']) {
        case 'info':
            $help['class'] = 'dashicons dashicons-info';
            break;
        case 'video':
            $help['class'] = 'dashicons dashicons-video-alt3';
            break;
        default:
            $help['class'] = 'dashicons dashicons-smiley';
    }
}
try {
    $responsive_classes = FW_Cache::get($cache_key = 'fw:backend-option-view:responsive-classes');
} catch (FW_Cache_Not_Found_Exception $e) {
    FW_Cache::set($cache_key, $responsive_classes = apply_filters('fw:backend-option-view:design-default:responsive-classes', array('label' => 'fw-col-xs-12 fw-col-sm-3 fw-col-lg-2', 'input' => 'fw-col-xs-12 fw-col-sm-9 fw-col-lg-10')));
}
$classes = array('option' => array('fw-backend-option', 'fw-backend-option-design-default', 'fw-backend-option-type-' . $option['type'], 'fw-row'), 'label' => array('fw-backend-option-label', 'responsive' => $responsive_classes['label']), 'input' => array('fw-backend-option-input', 'fw-backend-option-input-type-' . $option['type'], 'responsive' => $responsive_classes['input']), 'desc' => array('fw-backend-option-desc', 'responsive' => 'fw-col-xs-12 fw-col-sm-offset-3 fw-col-sm-9 fw-col-lg-offset-2 fw-col-lg-10'));
if ($help) {
    $classes['option'][] = 'with-help';
}
if ($option['label'] === false) {
    $classes['label']['hidden'] = 'fw-hidden';
    unset($classes['label']['responsive']);
    $classes['input']['responsive'] = 'fw-col-xs-12';
    $classes['desc']['responsive'] = 'fw-col-xs-12';
}
$width_type = fw()->backend->option_type($option['type'])->_get_backend_width_type();
if (!in_array($width_type, array('auto', 'fixed', 'full'))) {
    $width_type = 'auto';
}
开发者ID:cristeamdev,项目名称:Unyson,代码行数:31,代码来源:backend-option-design-default.php

示例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);
    }
}
开发者ID:alireza--noori,项目名称:initial-portfolio-website-test-,代码行数:31,代码来源:database.php

示例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);
 }
开发者ID:rawcreative,项目名称:Unyson,代码行数:33,代码来源:theme.php


注:本文中的FW_Cache::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。