• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_cache_set函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_cache_set函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_set函数的具体用法?PHP wp_cache_set怎么用?PHP wp_cache_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_cache_set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: widget

 function widget($args, $instance)
 {
     $cache = wp_cache_get('widget_nice_opening_hours', 'widget');
     if (!is_array($cache)) {
         $cache = array();
     }
     if (!isset($args['widget_id'])) {
         $args['widget_id'] = $this->id;
     }
     if (isset($cache[$args['widget_id']])) {
         echo $cache[$args['widget_id']];
         return;
     }
     ob_start();
     $settings = array_fill_keys($this->settings, '');
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args($instance, $settings);
     extract($instance, EXTR_SKIP);
     echo $before_widget;
     if ($title != '') {
         echo $before_title . apply_filters('widget_title', $title, $instance, $this->id_base) . $after_title;
     }
     // get times and do the magic!
     echo nice_opening_hours();
     echo $after_widget;
     $cache[$args['widget_id']] = ob_get_flush();
     wp_cache_set('widget_nice_opening_hours', $cache, 'widget');
 }
开发者ID:scottbrabazon,项目名称:scottbrabazon.com,代码行数:28,代码来源:widget-opening-hours.php


示例2: get_terms_in_found_set

 function get_terms_in_found_set()
 {
     if (isset($this->terms_in_found_set)) {
         return $this->terms_in_found_set;
     }
     $matching_post_ids = $this->facets->get_matching_post_ids();
     // if there aren't any matching post ids, we don't need to query
     if (!$matching_post_ids) {
         return array();
     }
     //end if
     $cache_key = md5(serialize($matching_post_ids));
     if (!($this->terms_in_found_set = wp_cache_get($cache_key, 'scrib-facet-post-author'))) {
         global $wpdb;
         $terms = $wpdb->get_results('SELECT post_author , COUNT(*) AS hits FROM ' . $wpdb->posts . ' WHERE ID IN (' . implode(',', $matching_post_ids) . ') GROUP BY post_author LIMIT 1000 /* generated in Facet_Post_Author::get_terms_in_found_set() */');
         $this->terms_in_found_set = array();
         foreach ($terms as $term) {
             $userdata = get_userdata($term->post_author);
             if (empty($userdata->display_name)) {
                 continue;
             }
             $this->terms_in_found_set[] = (object) array('facet' => $this->name, 'slug' => $userdata->user_nicename, 'name' => $userdata->display_name, 'description' => $userdata->user_description, 'term_id' => $term->post_author, 'count' => $term->hits);
         }
         wp_cache_set($cache_key, $this->terms_in_found_set, 'scrib-facet-post-author', $this->ttl);
     }
     return $this->terms_in_found_set;
 }
开发者ID:nrporter,项目名称:scriblio,代码行数:27,代码来源:class-facet-post-author.php


示例3: cached_result

function cached_result($cache_key, $cache_group, $fn = null)
{
    if (is_null($fn)) {
        $fn = $cache_group;
        $cache_group = '';
        $namespaced = [];
    }
    if ($cache_group) {
        $namespaced = wp_cache_get($cache_group, 'cache_namespaces');
        if ($namespaced === false) {
            wp_cache_set($cache_group, $namespaced = [], CACHE_NAMESPACES);
        }
    }
    if (!is_preview() && in_array($cache_key, $namespaced) && ($result = wp_cache_get($cache_key, $cache_group))) {
        return $result;
    }
    $result = call_user_func($fn);
    if (!is_preview()) {
        wp_cache_set($cache_key, $result, $cache_group);
        if ($cache_group) {
            wp_cache_set($cache_group, $namespaced + [$cache_key], CACHE_NAMESPACES);
        }
    }
    return $result;
}
开发者ID:edygar,项目名称:wp-extensions,代码行数:25,代码来源:cache.php


示例4: ap_opt

/**
 * To retrive AnsPress option 		
 * @param  string $key   Name of option to retrive,
 *                       Keep it blank to get all options of AnsPress
 * @param  string $value Enter value to update existing option
 * @return string         
 * @since 0.1
 */
function ap_opt($key = false, $value = null)
{
    $settings = wp_cache_get('ap_opt', 'options');
    if ($settings === false) {
        $settings = get_option('anspress_opt');
        if (!$settings) {
            $settings = array();
        }
        $settings = $settings + ap_default_options();
        wp_cache_set('ap_opt', $settings, 'options');
    }
    if (!is_null($value)) {
        $settings[$key] = $value;
        update_option('anspress_opt', $settings);
        // clear cache if option updated
        wp_cache_delete('ap_opt', 'options');
        return;
    }
    if (false === $key) {
        return $settings;
    }
    if (isset($settings[$key])) {
        return $settings[$key];
    } else {
        return NULL;
    }
    return false;
}
开发者ID:BRoz,项目名称:anspress,代码行数:36,代码来源:options.php


示例5: widget

 function widget($args, $instance)
 {
     $cache = wp_cache_get($this->className, 'widget');
     if (!is_array($cache)) {
         $cache = array();
     }
     if (!isset($args['widget_id'])) {
         $args['widget_id'] = null;
     }
     if (isset($cache[$args['widget_id']])) {
         echo $cache[$args['widget_id']];
         return;
     }
     ob_start();
     extract($args, EXTR_SKIP);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     echo $before_widget;
     if ($title) {
         echo $before_title, $title, $after_title;
     }
     if (isset($instance['list'])) {
         echo ciGetPracticeAreasTitlesList($instance['maxPracticeAreas']);
     } else {
         echo ciGetPracticeAreasHTML($instance['maxPracticeAreas'], 0, $instance['maxCharLength']);
     }
     echo $after_widget;
     $cache[$args['widget_id']] = ob_get_flush();
     wp_cache_set($this->className, $cache, 'widget');
 }
开发者ID:s3cur3,项目名称:ci-plugins,代码行数:29,代码来源:createWidget.php


示例6: get_galleries

function get_galleries($ids = array())
{
    $galleries = wp_cache_get('galleries', THEME_NAME);
    if (!$galleries) {
        $options = array('post_type' => 'property_gallery', 'post_status' => 'publish', 'post__in' => $ids, 'posts_per_page' => PHP_INT_MAX);
        $galleries = get_posts($options);
        foreach ($galleries as &$gallery) {
            $_content = $gallery->post_content;
            $gallery_images_ids = array();
            $featured_image = null;
            preg_match('/\\[gallery ids="(.*?)"\\]/', $_content, $matches);
            $gallery->images = array();
            $gallery->featured_image = null;
            if (!empty($matches[1])) {
                $gallery_images_ids = explode(',', $matches[1]);
                $featured_image = wp_get_attachment_image_src($gallery_images_ids[0], 'properties-gallery-normal');
                $_gallery = array();
                foreach ($gallery_images_ids as $id) {
                    $image = wp_get_attachment_image_src($id, 'properties-gallery-normal');
                    $_gallery[] = $image;
                }
                $gallery->images = $_gallery;
                $gallery->featured_image = $featured_image;
            }
        }
        // Save galleries if there is a permanent cache installed
        wp_cache_set('galleries', $galleries, THEME_NAME);
    }
    return $galleries;
}
开发者ID:pistonsky,项目名称:taivilla,代码行数:30,代码来源:template-gallery.php


示例7: acf_get_value

function acf_get_value($post_id, $field)
{
    // try cache
    $found = false;
    $cache = wp_cache_get("load_value/post_id={$post_id}/name={$field['name']}", 'acf', false, $found);
    if ($found) {
        return $cache;
    }
    // load value
    $value = acf_get_metadata($post_id, $field['name']);
    // if value was duplicated, it may now be a serialized string!
    $value = maybe_unserialize($value);
    // no value? try default_value
    if ($value === null && isset($field['default_value'])) {
        $value = $field['default_value'];
    }
    // filter for 3rd party customization
    $value = apply_filters("acf/load_value", $value, $post_id, $field);
    $value = apply_filters("acf/load_value/type={$field['type']}", $value, $post_id, $field);
    $value = apply_filters("acf/load_value/name={$field['name']}", $value, $post_id, $field);
    $value = apply_filters("acf/load_value/key={$field['key']}", $value, $post_id, $field);
    //update cache
    wp_cache_set("load_value/post_id={$post_id}/name={$field['name']}", $value, 'acf');
    // return
    return $value;
}
开发者ID:johannes-klaushofer,项目名称:modolab,代码行数:26,代码来源:api-value.php


示例8: testGetPostNavFromCache

 function testGetPostNavFromCache()
 {
     wp_cache_set('navigation-1', array('test' => 2), 'comicpress');
     $post_2 = (object) array('ID' => 2);
     wp_insert_post((array) $post_2);
     $this->assertEquals(array('test' => $post_2), $this->nav->get_post_nav((object) array('ID' => 1)));
 }
开发者ID:johnbintz,项目名称:comicpress-core,代码行数:7,代码来源:ComicPressNavigationTest.php


示例9: hsinsider_get_lead_art

function hsinsider_get_lead_art($post = null)
{
    if (empty($post)) {
        global $post;
    }
    if (has_post_thumbnail()) {
        $featured_id = get_post_thumbnail_id($post->ID);
        $the_query = wp_cache_get($featured_id . '_attachment');
        if ($the_query == false) {
            /**
             * Query for the Featured Image Caption
             */
            $args = array('p' => $featured_id, 'post_type' => 'attachment');
            $the_query = new WP_Query($args);
            // Set the cache to expire the data after 300 seconds
            wp_cache_set($featured_id . '_attachment', $the_query, '', 300);
        }
        if ($the_query->have_posts()) {
            while ($the_query->have_posts()) {
                $the_query->the_post();
                $featured_caption = get_the_excerpt();
            }
        }
        wp_reset_postdata();
        $featured_url = wp_get_attachment_url($featured_id);
        $featured_html = '<figure><img src="' . esc_url($featured_url) . '" class="attachment-post-thumbnail size-post-thumbnail wp-post-image img-responsive"/><figcaption class="wp-caption-text">' . esc_html($featured_caption) . '</figcaption></figure>';
        echo $featured_html;
    }
}
开发者ID:jperezlatimes,项目名称:hsinsider,代码行数:29,代码来源:template-tags.php


示例10: widget

 public function widget($args, $instance)
 {
     $cache = wp_cache_get('widget_willow_recent_posts', 'widget');
     if (!is_array($cache)) {
         $cache = array();
     }
     if (!isset($args['widget_id'])) {
         $args['widget_id'] = $this->id;
     }
     if (isset($cache[$args['widget_id']])) {
         echo $cache[$args['widget_id']];
         return;
     }
     $title = apply_filters('widget_title', $instance['title']);
     if (empty($instance['number']) || !($number = absint($instance['number']))) {
         $number = 5;
     }
     $show_date = isset($instance['show_date']) ? $instance['show_date'] : false;
     global $wp_query;
     $temp = $wp_query;
     $wp_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1));
     ob_start();
     echo $args['before_widget'];
     echo !empty($title) ? $args['before_title'] . $title . $args['after_title'] : '';
     include locate_template('loop-widget-posts.php');
     echo $args['after_widget'];
     $cache[$args['widget_id']] = ob_get_flush();
     $wp_query = $temp;
     wp_reset_postdata();
     wp_cache_set('widget_willow_recent_posts', $cache, 'widget');
 }
开发者ID:cntlscrut,项目名称:bicyclepeddler2,代码行数:31,代码来源:class-widget-willow-recent-posts.php


示例11: wpjam_get_post_thumbnail_uri

function wpjam_get_post_thumbnail_uri($post = null)
{
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $post_id = $post->ID;
    $post_thumbnail_uri = wp_cache_get($post_id, 'post_thumbnail_uri');
    if ($post_thumbnail_uri === false) {
        if (has_post_thumbnail($post_id)) {
            $post_thumbnail_uri = wp_get_attachment_url(get_post_meta($post_id, '_thumbnail_id', true));
        } elseif ($post_thumbnail_uri = apply_filters('wpjam_pre_post_thumbnail_uri', false, $post)) {
            // do nothing
        } elseif ($first_img = get_post_first_image(do_shortcode($post->post_content))) {
            $pre = apply_filters('pre_qiniu_remote', false, $first_img);
            $img_type = strtolower(pathinfo($first_img, PATHINFO_EXTENSION));
            if ($pre == false && wpjam_qiniutek_get_setting('remote') && get_option('permalink_structure') && strpos($first_img, LOCAL_HOST) === false && strpos($first_img, CDN_HOST) === false) {
                $img_type = $img_type == 'png' ? $img_type : 'jpg';
                $first_img = CDN_HOST . '/qiniu/' . $post_id . '/image/' . md5($first_img) . '.' . $img_type;
            }
            $post_thumbnail_uri = $first_img;
        } elseif ($post_thumbnail_uri = apply_filters('wpjam_post_thumbnail_uri', false, $post)) {
            //do nothing
        } else {
            $post_thumbnail_uri = wpjam_get_default_thumbnail_uri();
        }
        wp_cache_set($post_id, $post_thumbnail_uri, 'post_thumbnail_uri', 6000);
    }
    return $post_thumbnail_uri;
}
开发者ID:yszar,项目名称:linuxwp,代码行数:30,代码来源:wpjam-thumbnail.php


示例12: ap_find_mentioned_users

function ap_find_mentioned_users($content)
{
    global $wpdb;
    // Find all mentions in content.
    preg_match_all('/(?:[\\s.]|^)@(\\w+)/', $content, $matches);
    if (is_array($matches) && count($matches) > 0 && !empty($matches[0])) {
        $user_logins = array();
        // Remove duplicates.
        $unique_logins = array_unique($matches[0]);
        foreach ($unique_logins as $user_login) {
            $user_logins[] = sanitize_title_for_query(sanitize_user(wp_unslash($user_login), true));
        }
        if (count($user_logins) == 0) {
            return false;
        }
        $user_logins_s = "'" . implode("','", $user_logins) . "'";
        $key = md5($user_logins_s);
        $cache = wp_cache_get($key, 'ap_user_ids');
        if (false !== $cache) {
            return $cache;
        }
        $query = $wpdb->prepare("SELECT id, user_login FROM {$wpdb->users} WHERE user_login IN ({$user_logins_s})");
        $result = $wpdb->get_results($query);
        wp_cache_set($key, $result, 'ap_user_ids');
        return $result;
    }
    return false;
}
开发者ID:Byrlyne,项目名称:anspress,代码行数:28,代码来源:mention.php


示例13: get_tags_from_current_posts

 /**
  * Get tags from current post views
  *
  * @return boolean
  */
 public static function get_tags_from_current_posts()
 {
     if (is_array(self::$posts) && count(self::$posts) > 0) {
         // Generate SQL from post id
         $postlist = implode("', '", self::$posts);
         // Generate key cache
         $key = md5(maybe_serialize($postlist));
         $results = array();
         // Get cache if exist
         $cache = wp_cache_get('generate_keywords', 'simpletags');
         if ($cache === false) {
             foreach (self::$posts as $object_id) {
                 // Get terms
                 $terms = get_object_term_cache($object_id, 'post_tag');
                 if (false === $terms) {
                     $terms = wp_get_object_terms($object_id, 'post_tag');
                 }
                 if ($terms != false) {
                     $results = array_merge($results, $terms);
                 }
             }
             $cache[$key] = $results;
             wp_cache_set('generate_keywords', $cache, 'simpletags');
         } else {
             if (isset($cache[$key])) {
                 return $cache[$key];
             }
         }
         return $results;
     }
     return array();
 }
开发者ID:EasterAndJay,项目名称:tamichelew.com,代码行数:37,代码来源:class.client.autolinks.php


示例14: update_translation_batch

 public static function update_translation_batch($batch_name = false, $tp_id = false)
 {
     global $wpdb;
     $batch_name = $batch_name ? $batch_name : ((bool) $tp_id === false || $tp_id === 'local' ? self::get_generic_batch_name() : TranslationProxy_Basket::get_basket_name());
     if (!$batch_name) {
         return null;
     }
     $cache_key = md5($batch_name);
     $cache_group = 'update_translation_batch';
     $cache_found = false;
     $batch_id = wp_cache_get($cache_key, $cache_group, false, $cache_found);
     if ($cache_found && $batch_id) {
         return $batch_id;
     }
     $batch_id_sql = "SELECT id FROM {$wpdb->prefix}icl_translation_batches WHERE batch_name=%s";
     $batch_id_prepared = $wpdb->prepare($batch_id_sql, array($batch_name));
     $batch_id = $wpdb->get_var($batch_id_prepared);
     if (!$batch_id) {
         $data = array('batch_name' => $batch_name, 'last_update' => date('Y-m-d H:i:s'));
         if ($tp_id) {
             if ($tp_id === 'local') {
                 $tp_id = 0;
             }
             $data['tp_id'] = $tp_id;
         }
         $wpdb->insert($wpdb->prefix . 'icl_translation_batches', $data);
         $batch_id = $wpdb->insert_id;
         wp_cache_set($cache_key, $batch_id, $cache_group);
     }
     return $batch_id;
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:31,代码来源:translationproxy-batch.class.php


示例15: refresh

 /**
  * Reads the options from options table
  *
  * @since  1.0.0
  */
 public function refresh()
 {
     $option_key = $this->option_key();
     $settings = MS_Factory::get_option($option_key);
     MS_Factory::populate_model($this, $settings);
     wp_cache_set($option_key, $this, 'MS_Model_Option');
 }
开发者ID:EdoMagen,项目名称:project-s-v2,代码行数:12,代码来源:class-ms-model-option.php


示例16: onp_updates_324_set_site_transient

function onp_updates_324_set_site_transient($transient, $value, $expiration = 0, $actions = false)
{
    global $_wp_using_ext_object_cache;
    if ($actions) {
        $value = apply_filters('pre_set_site_transient_' . $transient, $value);
    }
    if ($_wp_using_ext_object_cache) {
        $result = wp_cache_set($transient, $value, 'site-transient', $expiration);
    } else {
        $transient_timeout = '_site_transient_timeout_' . $transient;
        $transient = '_site_transient_' . $transient;
        if (false === get_site_option($transient)) {
            if ($expiration) {
                add_site_option($transient_timeout, time() + $expiration);
            }
            $result = add_site_option($transient, $value);
        } else {
            if ($expiration) {
                update_site_option($transient_timeout, time() + $expiration);
            }
            delete_site_option($transient);
            $result = update_site_option($transient, $value);
        }
    }
    if ($result && $actions) {
        do_action('set_site_transient_' . $transient);
        do_action('setted_site_transient', $transient);
    }
    return $result;
}
开发者ID:vihoangson,项目名称:vihoangson.vus.vn,代码行数:30,代码来源:transient.functions.php


示例17: get_gateway_data

 public function get_gateway_data()
 {
     if (!($this->gateway_data = wp_cache_get($this->log_id, 'wpsc_checkout_form_gateway_data'))) {
         $map = array('firstname' => 'first_name', 'lastname' => 'last_name', 'address' => 'street', 'city' => 'city', 'state' => 'state', 'country' => 'country', 'postcode' => 'zip', 'phone' => 'phone');
         foreach (array('shipping', 'billing') as $type) {
             $data_key = "{$type}_address";
             $this->gateway_data[$data_key] = array();
             foreach ($map as $key => $new_key) {
                 $key = $type . $key;
                 if (isset($this->data[$key])) {
                     $value = $this->data[$key];
                     if ($new_key == 'state' && is_numeric($value)) {
                         $value = wpsc_get_state_by_id($value, 'code');
                     }
                     $this->gateway_data[$data_key][$new_key] = $value;
                 }
             }
             $name = isset($this->gateway_data[$data_key]['first_name']) ? $this->gateway_data[$data_key]['first_name'] . ' ' : '';
             $name .= isset($this->gateway_data[$data_key]['last_name']) ? $this->gateway_data[$data_key]['last_name'] : '';
             $this->gateway_data[$data_key]['name'] = trim($name);
         }
         wp_cache_set($this->log_id, $this->gateway_data, 'wpsc_checkout_form_gateway_data');
     }
     return apply_filters('wpsc_checkout_form_gateway_data', $this->gateway_data, $this->log_id);
 }
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:25,代码来源:checkout-form-data.class.php


示例18: get_comment_changes

 function get_comment_changes()
 {
     global $spec_comment_log, $current_user;
     $user_roles = $current_user->roles;
     $role = array_shift($user_roles);
     $action_id = 0;
     if (isset($_POST['action_id'])) {
         $action_id = absint($_POST['action_id']);
     }
     $time = '';
     if (isset($_POST['time'])) {
         $time = $_POST['time'];
     }
     $post_id = $_POST['post_id'];
     // Get the details from cache
     $cachekey = 'icit_spec_discus_' . $post_id . '_' . $action_id . '_' . $role;
     $encoded_json = wp_cache_get($cachekey, 'spec_discussion');
     if (empty($encoded_json)) {
         $encoded_json = $this->grab_changedcomments_json($spec_comment_log, $post_id, $time, $action_id);
         // The details weren't in cache lets add it now.
         wp_cache_set($cachekey, $encoded_json, 'spec_discussion', 20);
     }
     echo $encoded_json;
     die;
 }
开发者ID:gagelafleur,项目名称:thebluemuse,代码行数:25,代码来源:spec-ajax.php


示例19: bp_members_prefetch_member_type

/**
 * Pre-fetch member type data when initializing a Members loop.
 *
 * @since BuddyPress (2.2.0)
 *
 * @param BP_User_Query $bp_user_query BP_User_Query object.
 */
function bp_members_prefetch_member_type( BP_User_Query $bp_user_query ) {
	$uncached_member_ids = bp_get_non_cached_ids( $bp_user_query->user_ids, 'bp_member_type' );

	$member_types = bp_get_object_terms( $uncached_member_ids, 'bp_member_type', array(
		'fields' => 'all_with_object_id',
	) );

	// Rekey by user ID.
	$keyed_member_types = array();
	foreach ( $member_types as $member_type ) {
		if ( ! isset( $keyed_member_types[ $member_type->object_id ] ) ) {
			$keyed_member_types[ $member_type->object_id ] = array();
		}

		$keyed_member_types[ $member_type->object_id ][] = $member_type->name;
	}

	$cached_member_ids = array();
	foreach ( $keyed_member_types as $user_id => $user_member_types ) {
		wp_cache_set( $user_id, $user_member_types, 'bp_member_type' );
		$cached_member_ids[] = $user_id;
	}

	// Cache an empty value for users with no type.
	foreach ( array_diff( $uncached_member_ids, $cached_member_ids ) as $no_type_id ) {
		wp_cache_set( $no_type_id, '', 'bp_member_type' );
	}
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:35,代码来源:bp-members-cache.php


示例20: getMonthly

 /**
  * Return monthly
  *
  * @link
  *       https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/general-template.php#L1335
  * @return string
  */
 public static function getMonthly($limit = self::LIMIT)
 {
     global $wpdb, $wp_locale;
     $last_changed = wp_cache_get('last_changed', 'posts');
     if (!$last_changed) {
         $last_changed = microtime();
         wp_cache_set('last_changed', $last_changed, 'posts');
     }
     $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as total\n\t\t\tFROM {$wpdb->posts}\n\t\t\tWHERE post_type = 'post' AND post_status = 'publish'\n\t\t\tGROUP BY YEAR(post_date), MONTH(post_date)\n\t\t\tORDER BY post_date DESC ";
     if ($limit) {
         $query .= " LIMIT {$limit}";
     }
     $key = md5($query);
     $key = "wp_get_archives:{$key}:{$last_changed}";
     if (!($results = wp_cache_get($key, 'posts'))) {
         $results = $wpdb->get_results($query);
         wp_cache_set($key, $results, 'posts');
     }
     $archives = [];
     foreach ($results as $result) {
         $url = get_month_link($result->year, $result->month);
         /* translators: 1: month name, 2: 4-digit year */
         $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
         $archives[] = new Archive($text, $url, $result->total);
     }
     return $archives;
 }
开发者ID:chemaclass,项目名称:knob-base,代码行数:34,代码来源:Archive.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_cache_switch_to_blog函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_cache_reset函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap