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


PHP update_postmeta_cache函数代码示例

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


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

示例1: wpi_get_post_meta

function wpi_get_post_meta($post_id, $key, $single = false)
{
    $post_id = (int) $post_id;
    $meta_cache = wp_cache_get($post_id, 'post_meta');
    if (!isset($meta_cache[$key])) {
        return false;
    }
    if (isset($meta_cache[$key])) {
        if ($single) {
            return maybe_unserialize($meta_cache[$key][0]);
        } else {
            return maybe_unserialize($meta_cache[$key]);
        }
    }
    if (!$meta_cache) {
        update_postmeta_cache($post_id);
        $meta_cache = wp_cache_get($post_id, 'post_meta');
    }
    if ($single) {
        if (isset($meta_cache[$key][0])) {
            return maybe_unserialize($meta_cache[$key][0]);
        } else {
            return '';
        }
    } else {
        return maybe_unserialize($meta_cache[$key]);
    }
}
开发者ID:Creativebq,项目名称:wp-istalker,代码行数:28,代码来源:query.php

示例2: pushpress_send_ping

 function pushpress_send_ping($callback, $post_id, $feed_type, $secret)
 {
     global $pushpress;
     // Need to make sure that the PuSHPress options are initialized
     $pushpress->init();
     do_action('pushpress_send_ping');
     $remote_opt = array('headers' => array('format' => $feed_type), 'sslverify' => FALSE, 'timeout' => $pushpress->http_timeout, 'user-agent' => $pushpress->http_user_agent);
     $post = get_post($post_id);
     do_enclose($post->post_content, $post_id);
     update_postmeta_cache(array($post_id));
     query_posts("p={$post_id}");
     ob_start();
     $feed_url = FALSE;
     if ($feed_type == 'rss2') {
         do_action('pushpress_send_ping_rss2');
         $feed_url = get_bloginfo('rss2_url');
         $remote_opt['headers']['Content-Type'] = 'application/rss+xml';
         $remote_opt['headers']['Content-Type'] .= '; charset=' . get_option('blog_charset');
         @load_template(ABSPATH . WPINC . '/feed-rss2.php');
     } elseif ($feed_type == 'atom') {
         do_action('pushpress_send_ping_atom');
         $feed_url = get_bloginfo('atom_url');
         $remote_opt['headers']['Content-Type'] = 'application/atom+xml';
         $remote_opt['headers']['Content-Type'] .= '; charset=' . get_option('blog_charset');
         @load_template(ABSPATH . WPINC . '/feed-atom.php');
     }
     $remote_opt['body'] = ob_get_contents();
     ob_end_clean();
     // Figure out the signatur header if we have a secret on
     // on file for this callback
     if (!empty($secret)) {
         $remote_opt['headers']['X-Hub-Signature'] = 'sha1=' . hash_hmac('sha1', $remote_opt['body'], $secret);
     }
     $response = wp_remote_post($callback, $remote_opt);
     // look for failures
     if (is_wp_error($result)) {
         do_action('pushpress_ping_wp_error');
         return FALSE;
     }
     if (isset($response->errors['http_request_failed'][0])) {
         do_action('pushpress_ping_http_failure');
         return FALSE;
     }
     $status_code = (int) $response['response']['code'];
     if ($status_code < 200 || $status_code > 299) {
         do_action('pushpress_ping_not_2xx_failure');
         $pushpress->unsubscribe_callback($feed_url, $callback);
         return FALSE;
     }
 }
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:50,代码来源:send-ping.php

示例3: setUp

 /**
  * Set it Up
  */
 public function setUp()
 {
     parent::setUp();
     $payment_id = Give_Helper_Payment::create_simple_payment();
     $this->_payment_key = give_get_payment_key($payment_id);
     $this->_payment_id = $payment_id;
     $this->_key = $this->_payment_key;
     $this->_transaction_id = 'FIR3SID3';
     give_set_payment_transaction_id($payment_id, $this->_transaction_id);
     give_insert_payment_note($payment_id, sprintf(esc_html__('PayPal Transaction ID: %s', 'give'), $this->_transaction_id));
     // Make sure we're working off a clean object caching in WP Core.
     // Prevents some payment_meta from not being present.
     clean_post_cache($payment_id);
     update_postmeta_cache(array($payment_id));
 }
开发者ID:wordimpress,项目名称:give,代码行数:18,代码来源:tests-payment-class.php

示例4: update_post_caches

/**
 * Call major cache updating functions for list of Post objects.
 *
 * @package WordPress
 * @subpackage Cache
 * @since 1.5.0
 *
 * @uses $wpdb
 * @uses update_post_cache()
 * @uses update_object_term_cache()
 * @uses update_postmeta_cache()
 *
 * @param array $posts Array of Post objects
 * @param string $post_type The post type of the posts in $posts. Default is 'post'.
 * @param bool $update_term_cache Whether to update the term cache. Default is true.
 * @param bool $update_meta_cache Whether to update the meta cache. Default is true.
 */
function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true)
{
    // No point in doing all this work if we didn't match any posts.
    if (!$posts) {
        return;
    }
    update_post_cache($posts);
    $post_ids = array();
    foreach ($posts as $post) {
        $post_ids[] = $post->ID;
    }
    if (empty($post_type)) {
        $post_type = 'post';
    }
    if (!is_array($post_type) && 'any' != $post_type && $update_term_cache) {
        update_object_term_cache($post_ids, $post_type);
    }
    if ($update_meta_cache) {
        update_postmeta_cache($post_ids);
    }
}
开发者ID:owaismeo,项目名称:wordpress-10,代码行数:38,代码来源:post.php

示例5: update_post_caches

/**
 * update_post_caches() - Call major cache updating functions for list of Post objects.
 *
 * @package WordPress
 * @subpackage Cache
 * @since 1.5
 *
 * @uses $wpdb
 * @uses update_post_cache()
 * @uses update_object_term_cache()
 * @uses update_postmeta_cache()
 *
 * @param array $posts Array of Post objects
 */
function update_post_caches(&$posts)
{
    // No point in doing all this work if we didn't match any posts.
    if (!$posts) {
        return;
    }
    update_post_cache($posts);
    $post_ids = array();
    for ($i = 0; $i < count($posts); $i++) {
        $post_ids[] = $posts[$i]->ID;
    }
    update_object_term_cache($post_ids, 'post');
    update_postmeta_cache($post_ids);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:28,代码来源:post.php

示例6: wpv_filter_extend_query_for_parametric_and_counters


//.........这里部分代码省略.........
    $view_settings_defaults = array('post_type' => 'any', 'orderby' => 'post-date', 'order' => 'DESC', 'paged' => '1', 'posts_per_page' => -1);
    extract($view_settings_defaults);
    $view_settings['view_id'] = $id;
    extract($view_settings, EXTR_OVERWRITE);
    $query = array('posts_per_page' => $posts_per_page, 'paged' => $paged, 'post_type' => $post_type, 'order' => $order, 'suppress_filters' => false, 'ignore_sticky_posts' => true);
    // Add special check for media (attachments) as their default status in not usually published
    if (sizeof($post_type) == 1 && $post_type[0] == 'attachment') {
        $query['post_status'] = 'any';
        // Note this can be overriden by adding a status filter.
    }
    $query = apply_filters('wpv_filter_query', $query, $view_settings, $id);
    // Now we have the $query as in the original one
    // We now need to overwrite the limit, offset, paged and pagination options
    // Also, we set it to just return the IDs
    $query['posts_per_page'] = -1;
    $query['ĺimit'] = -1;
    $query['paged'] = 1;
    $query['offset'] = 0;
    $query['fields'] = 'ids';
    if ($cache_exclude_queried_posts) {
        // do not query again already queried and cached posts
        $already = array();
        if (isset($post_query->posts) && !empty($post_query->posts)) {
            foreach ((array) $post_query->posts as $post_object) {
                $already[] = $post_object->ID;
            }
        }
        $WP_Views->returned_ids_for_parametric_search = $already;
        if (isset($query['pr_filter_post__in'])) {
            $query['post__in'] = $query['pr_filter_post__in'];
        } else {
            // If just for the missing ones, generate the post__not_in argument
            if (isset($query['post__not_in'])) {
                $query['post__not_in'] = array_merge((array) $query['post__not_in'], (array) $already);
            } else {
                $query['post__not_in'] = (array) $already;
            }
            // And adjust on the post__in argument
            if (isset($query['post__in'])) {
                $query['post__in'] = array_diff((array) $query['post__in'], (array) $query['post__not_in']);
                //unset( $query['post__in'] );
            }
        }
    }
    // Perform the query
    $aux_cache_query = new WP_Query($query);
    // In case we need to recreate our own cache object, we do not need to load there all the postmeta and taxonomy data, just for the elements involved in parametric search controls
    $filter_c_mode = isset($view_settings['filter_controls_mode']) && is_array($view_settings['filter_controls_mode']) ? $view_settings['filter_controls_mode'] : array();
    $filter_c_name = isset($view_settings['filter_controls_field_name']) && is_array($view_settings['filter_controls_field_name']) ? $view_settings['filter_controls_field_name'] : array();
    $f_taxes = array();
    $f_fields = array();
    foreach ($filter_c_mode as $f_index => $f_mode) {
        if (isset($filter_c_name[$f_index])) {
            switch ($f_mode) {
                case 'slug':
                    $f_taxes[] = $filter_c_name[$f_index];
                    break;
                case 'cf':
                    $f_fields[] = $filter_c_name[$f_index];
                    break;
                case 'rel':
                    if (function_exists('wpcf_pr_get_belongs')) {
                        $returned_post_types = $view_settings['post_type'];
                        $returned_post_type_parents = array();
                        if (empty($returned_post_types)) {
                            $returned_post_types = array('any');
                        }
                        foreach ($returned_post_types as $returned_post_type_slug) {
                            $parent_parents_array = wpcf_pr_get_belongs($returned_post_type_slug);
                            if ($parent_parents_array != false && is_array($parent_parents_array)) {
                                $returned_post_type_parents = array_merge($returned_post_type_parents, array_values(array_keys($parent_parents_array)));
                            }
                        }
                        foreach ($returned_post_type_parents as $parent_to_cache) {
                            $f_fields[] = '_wpcf_belongs_' . $parent_to_cache . '_id';
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }
    // If we are using the native caching, update the cache for the posts returned by the aux query
    if (is_array($aux_cache_query->posts) && !empty($aux_cache_query->posts)) {
        $WP_Views->returned_ids_for_parametric_search = array_merge($WP_Views->returned_ids_for_parametric_search, $aux_cache_query->posts);
        $WP_Views->returned_ids_for_parametric_search = array_unique($WP_Views->returned_ids_for_parametric_search);
        if ($cache_use_native) {
            // If we are using the native caching, update the cache for the posts returned by the aux query
            update_postmeta_cache($aux_cache_query->posts);
            update_object_term_cache($aux_cache_query->posts, $view_settings['post_type']);
        } else {
            // Else, we need to fake an $wp_object_cache->cache
            $f_data = array('cf' => $f_fields, 'tax' => $f_taxes);
            $cache_combined = wpv_custom_cache_metadata($aux_cache_query->posts, $f_data);
            $wp_object_cache->cache = $cache_combined;
        }
    }
    return $post_query;
}
开发者ID:supahseppe,项目名称:path-of-gaming,代码行数:101,代码来源:wpv-filter-query.php

示例7: get_post_custom

function get_post_custom($post_id = 0) {
	global $id, $post_meta_cache, $wpdb, $blog_id;

	if ( !$post_id )
		$post_id = (int) $id;

	$post_id = (int) $post_id;

	if ( !isset($post_meta_cache[$blog_id][$post_id]) )
		update_postmeta_cache($post_id);

	return $post_meta_cache[$blog_id][$post_id];
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:13,代码来源:post.php

示例8: pushpress_send_ping

 function pushpress_send_ping($callback, $post_id, $feed_type, $secret)
 {
     global $pushpress, $current_user;
     // Do all WP_Query calcs and send feeds as logged-out user.
     $old_user_id = $current_user->ID;
     wp_set_current_user(0);
     // Need to make sure that the PuSHPress options are initialized
     $pushpress->init();
     do_action('pushpress_send_ping');
     $remote_opt = array('headers' => array('format' => $feed_type), 'sslverify' => FALSE, 'timeout' => $pushpress->http_timeout, 'user-agent' => $pushpress->http_user_agent);
     $post = get_post($post_id);
     $post_status_obj = get_post_status_object($post->post_status);
     if (!$post_status_obj->public) {
         do_action('pushpress_nonpublic_post', $post_id);
         wp_set_current_user($old_user_id);
         return false;
     }
     do_enclose($post->post_content, $post_id);
     update_postmeta_cache(array($post_id));
     // make sure the channel title stays consistent
     // without this it would append the post title as well
     add_filter('wp_title', '__return_false', 999);
     query_posts("p={$post_id}");
     ob_start();
     $feed_url = FALSE;
     if ($feed_type == 'rss2') {
         do_action('pushpress_send_ping_rss2');
         $feed_url = get_bloginfo('rss2_url');
         $remote_opt['headers']['Content-Type'] = 'application/rss+xml';
         $remote_opt['headers']['Content-Type'] .= '; charset=' . get_option('blog_charset');
         @load_template(ABSPATH . WPINC . '/feed-rss2.php');
     } elseif ($feed_type == 'atom') {
         do_action('pushpress_send_ping_atom');
         $feed_url = get_bloginfo('atom_url');
         $remote_opt['headers']['Content-Type'] = 'application/atom+xml';
         $remote_opt['headers']['Content-Type'] .= '; charset=' . get_option('blog_charset');
         @load_template(ABSPATH . WPINC . '/feed-atom.php');
     }
     $remote_opt['body'] = ob_get_contents();
     ob_end_clean();
     // Figure out the signatur header if we have a secret on
     // on file for this callback
     if (!empty($secret)) {
         $remote_opt['headers']['X-Hub-Signature'] = 'sha1=' . hash_hmac('sha1', $remote_opt['body'], $secret);
     }
     $response = wp_remote_post($callback, $remote_opt);
     // look for failures
     if (is_wp_error($response)) {
         do_action('pushpress_ping_wp_error');
         wp_set_current_user($old_user_id);
         return FALSE;
     }
     if (isset($response->errors['http_request_failed'][0])) {
         do_action('pushpress_ping_http_failure');
         wp_set_current_user($old_user_id);
         return FALSE;
     }
     $status_code = (int) $response['response']['code'];
     if ($status_code < 200 || $status_code > 299) {
         do_action('pushpress_ping_not_2xx_failure');
         $pushpress->unsubscribe_callback($feed_url, $callback);
         wp_set_current_user($old_user_id);
         return FALSE;
     }
     wp_set_current_user($old_user_id);
 }
开发者ID:liangwei1988,项目名称:wordpress,代码行数:66,代码来源:send-ping.php

示例9: getEventCounts


//.........这里部分代码省略.........
     $args['fields'] = 'ids';
     // remove empty args and sort by key, this increases chance of a cache hit
     $args = array_filter($args, array(__CLASS__, 'filter_args'));
     ksort($args);
     $cache = new TribeEventsCache();
     $cache_key = 'daily_counts_and_ids_' . serialize($args);
     $found = $cache->get($cache_key, 'save_post');
     if ($found) {
         do_action('log', 'cache hit ' . __LINE__, 'tribe-events-cache', $args);
         return $found;
     }
     do_action('log', 'no cache hit ' . __LINE__, 'tribe-events-cache', $args);
     $cache_key = 'month_post_ids_' . serialize($args);
     $found = $cache->get($cache_key, 'save_post');
     if ($found && is_array($found)) {
         do_action('log', 'cache hit ' . __LINE__, 'tribe-events-cache', $args);
         $post_ids = $found;
     } else {
         do_action('log', 'no cache hit ' . __LINE__, 'tribe-events-cache', $args);
         $post_id_query = new WP_Query();
         $post_ids = $post_id_query->query($args);
         do_action('log', 'final args for month view post ids', 'tribe-events-query', $post_id_query->query_vars);
         do_action('log', 'Month view getEventCounts SQL', 'tribe-events-query', $post_id_query->request);
         $cache->set($cache_key, $post_ids, TribeEventsCache::NON_PERSISTENT, 'save_post');
     }
     do_action('log', 'Month view post ids found', 'tribe-events-query', $post_ids);
     $counts = array();
     $event_ids = array();
     if (!empty($post_ids)) {
         switch ($args['display_type']) {
             case 'daily':
             default:
                 global $wp_query;
                 $output_date_format = '%Y-%m-%d %H:%i:%s';
                 do_action('log', 'raw counts args', 'tribe-events-query', $args);
                 $raw_counts = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\t\t\tSELECT \ttribe_event_start.post_id as ID, \n\t\t\t\t\t\t\t\t\ttribe_event_start.meta_value as EventStartDate, \n\t\t\t\t\t\t\t\t\tDATE_FORMAT( tribe_event_end_date.meta_value, '%1\$s') as EventEndDate,\n\t\t\t\t\t\t\t\t\t{$wpdb->posts}.menu_order as menu_order\n\t\t\t\t\t\t\tFROM {$wpdb->postmeta} AS tribe_event_start\n\t\t\t\t\t\t\t\t\tLEFT JOIN {$wpdb->posts} ON (tribe_event_start.post_id = {$wpdb->posts}.ID)\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->postmeta} as tribe_event_end_date ON ( tribe_event_start.post_id = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = '_EventEndDate' )\n\t\t\t\t\t\t\tWHERE tribe_event_start.meta_key = '_EventStartDate'\n\t\t\t\t\t\t\tAND tribe_event_start.post_id IN ( %5\$s )\n\t\t\t\t\t\t\tAND ( (tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t\t\tOR (tribe_event_start.meta_value <= '%3\$s' AND tribe_event_end_date.meta_value >= '%3\$s')\n\t\t\t\t\t\t\t\tOR ( tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tORDER BY menu_order ASC, DATE(tribe_event_start.meta_value) ASC, TIME(tribe_event_start.meta_value) ASC;", $output_date_format, $output_date_format, $post_id_query->query_vars['start_date'], $post_id_query->query_vars['end_date'], implode(',', array_map('intval', $post_ids))));
                 do_action('log', 'raw counts query', 'tribe-events-query', $wpdb->last_query);
                 $start_date = new DateTime($post_id_query->query_vars['start_date']);
                 $end_date = new DateTime($post_id_query->query_vars['end_date']);
                 $days = TribeDateUtils::dateDiff($start_date->format('Y-m-d'), $end_date->format('Y-m-d'));
                 $term_id = isset($wp_query->query_vars[TribeEvents::TAXONOMY]) ? $wp_query->query_vars[TribeEvents::TAXONOMY] : null;
                 if (is_int($term_id)) {
                     $term = get_term_by('id', $term_id, TribeEvents::TAXONOMY);
                 } elseif (is_string($term_id)) {
                     $term = get_term_by('slug', $term_id, TribeEvents::TAXONOMY);
                 }
                 for ($i = 0, $date = $start_date; $i <= $days; $i++, $date->modify('+1 day')) {
                     $formatted_date = $date->format('Y-m-d');
                     $start_of_day = strtotime(tribe_event_beginning_of_day($formatted_date));
                     $end_of_day = strtotime(tribe_event_end_of_day($formatted_date)) + 1;
                     $count = 0;
                     $_day_event_ids = array();
                     foreach ($raw_counts as $record) {
                         $record_start = strtotime($record->EventStartDate);
                         $record_end = strtotime($record->EventEndDate);
                         /**
                          * conditions:
                          * event starts on this day (event start time is between start and end of day)
                          * event ends on this day (event end time is between start and end of day)
                          * event starts before start of day and ends after end of day (spans across this day)
                          * note:
                          * events that start exactly on the EOD cutoff will count on the following day
                          * events that end exactly on the EOD cutoff will count on the previous day
                          */
                         $event_starts_today = $record_start >= $start_of_day && $record_start < $end_of_day;
                         $event_ends_today = $record_end > $start_of_day && $record_end <= $end_of_day;
                         $event_spans_across_today = $record_start < $start_of_day && $record_end > $end_of_day;
                         if ($event_starts_today || $event_ends_today || $event_spans_across_today) {
                             if (isset($term->term_id)) {
                                 if (!has_term($term, TribeEvents::TAXONOMY, $record->ID)) {
                                     continue;
                                 }
                             }
                             if (count($_day_event_ids) < apply_filters('tribe_events_month_day_limit', tribe_get_option('monthEventAmount', '3'))) {
                                 $_day_event_ids[] = $record->ID;
                             }
                             $count++;
                         }
                     }
                     $event_ids[$formatted_date] = $_day_event_ids;
                     $counts[$formatted_date] = $count;
                 }
                 break;
         }
         // get a unique list of the event IDs that will be displayed, and update all their postmeta and term caches at once
         $final_event_ids = array();
         $final_event_ids = call_user_func_array('array_merge', $event_ids);
         $final_event_ids = array_unique($final_event_ids);
         do_action('log', 'updating term and postmeta caches for events', 'tribe-events-cache', $final_event_ids);
         update_object_term_cache($final_event_ids, TribeEvents::POSTTYPE);
         update_postmeta_cache($final_event_ids);
     }
     // return IDs per day and total counts per day
     $return = array('counts' => $counts, 'event_ids' => $event_ids);
     $cache = new TribeEventsCache();
     $cache_key = 'daily_counts_and_ids_' . serialize($args);
     $cache->set($cache_key, $return, TribeEventsCache::NON_PERSISTENT, 'save_post');
     do_action('log', 'final event counts result', 'tribe-events-query', $return);
     return $return;
 }
开发者ID:Vinnica,项目名称:theboxerboston.com,代码行数:101,代码来源:tribe-event-query.class.php

示例10: getEventCounts

 /**
  * Gets the event counts for individual days.
  *
  * @param array $args
  *
  * @return array The counts array.
  */
 public static function getEventCounts($args = array())
 {
     _deprecated_function(__METHOD__, '3.10.1');
     global $wpdb;
     $date = date('Y-m-d');
     $defaults = array('post_type' => Tribe__Events__Main::POSTTYPE, 'start_date' => tribe_beginning_of_day($date), 'end_date' => tribe_end_of_day($date), 'display_type' => 'daily', 'hide_upcoming_ids' => null);
     $args = wp_parse_args($args, $defaults);
     $args['posts_per_page'] = -1;
     $args['fields'] = 'ids';
     // remove empty args and sort by key, this increases chance of a cache hit
     $args = array_filter($args, array(__CLASS__, 'filter_args'));
     ksort($args);
     $cache = new Tribe__Cache();
     $cache_key = 'daily_counts_and_ids_' . serialize($args);
     $found = $cache->get($cache_key, 'save_post');
     if ($found) {
         return $found;
     }
     $cache_key = 'month_post_ids_' . serialize($args);
     $found = $cache->get($cache_key, 'save_post');
     if ($found && is_array($found)) {
         $post_ids = $found;
     } else {
         $post_id_query = new WP_Query();
         $post_ids = $post_id_query->query($args);
         $cache->set($cache_key, $post_ids, Tribe__Cache::NON_PERSISTENT, 'save_post');
     }
     $counts = array();
     $event_ids = array();
     if (!empty($post_ids)) {
         switch ($args['display_type']) {
             case 'daily':
             default:
                 global $wp_query;
                 $output_date_format = '%Y-%m-%d %H:%i:%s';
                 $raw_counts = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\t\t\tSELECT \ttribe_event_start.post_id as ID,\n\t\t\t\t\t\t\t\t\ttribe_event_start.meta_value as EventStartDate,\n\t\t\t\t\t\t\t\t\tDATE_FORMAT( tribe_event_end_date.meta_value, '%1\$s') as EventEndDate,\n\t\t\t\t\t\t\t\t\t{$wpdb->posts}.menu_order as menu_order\n\t\t\t\t\t\t\tFROM {$wpdb->postmeta} AS tribe_event_start\n\t\t\t\t\t\t\t\t\tLEFT JOIN {$wpdb->posts} ON (tribe_event_start.post_id = {$wpdb->posts}.ID)\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->postmeta} as tribe_event_end_date ON ( tribe_event_start.post_id = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = '_EventEndDate' )\n\t\t\t\t\t\t\tWHERE tribe_event_start.meta_key = '_EventStartDate'\n\t\t\t\t\t\t\tAND tribe_event_start.post_id IN ( %5\$s )\n\t\t\t\t\t\t\tAND ( (tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t\t\tOR (tribe_event_start.meta_value <= '%3\$s' AND tribe_event_end_date.meta_value >= '%3\$s')\n\t\t\t\t\t\t\t\tOR ( tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tORDER BY menu_order ASC, DATE(tribe_event_start.meta_value) ASC, TIME(tribe_event_start.meta_value) ASC;", $output_date_format, $output_date_format, $post_id_query->query_vars['start_date'], $post_id_query->query_vars['end_date'], implode(',', array_map('intval', $post_ids))));
                 $start_date = new DateTime($post_id_query->query_vars['start_date']);
                 $end_date = new DateTime($post_id_query->query_vars['end_date']);
                 $days = Tribe__Date_Utils::date_diff($start_date->format('Y-m-d'), $end_date->format('Y-m-d'));
                 $term_id = isset($wp_query->query_vars[Tribe__Events__Main::TAXONOMY]) ? $wp_query->query_vars[Tribe__Events__Main::TAXONOMY] : null;
                 $terms = array();
                 if (is_int($term_id)) {
                     $terms[0] = $term_id;
                 } elseif (is_string($term_id)) {
                     $term = get_term_by('slug', $term_id, Tribe__Events__Main::TAXONOMY);
                     if ($term) {
                         $terms[0] = $term->term_id;
                     }
                 }
                 if (!empty($terms) && is_tax(Tribe__Events__Main::TAXONOMY)) {
                     $terms = array_merge($terms, get_term_children($terms[0], Tribe__Events__Main::TAXONOMY));
                 }
                 for ($i = 0, $date = $start_date; $i <= $days; $i++, $date->modify('+1 day')) {
                     $formatted_date = $date->format('Y-m-d');
                     $count = 0;
                     $_day_event_ids = array();
                     foreach ($raw_counts as $record) {
                         $event = new stdClass();
                         $event->EventStartDate = $record->EventStartDate;
                         $event->EventEndDate = $record->EventEndDate;
                         $per_day_limit = apply_filters('tribe_events_month_day_limit', tribe_get_option('monthEventAmount', '3'));
                         if (tribe_event_is_on_date($formatted_date, $event)) {
                             if (!empty($terms) && !has_term($terms, Tribe__Events__Main::TAXONOMY, $record->ID)) {
                                 continue;
                             }
                             if (count($_day_event_ids) < $per_day_limit) {
                                 $_day_event_ids[] = $record->ID;
                             }
                             $count++;
                         }
                     }
                     $event_ids[$formatted_date] = $_day_event_ids;
                     $counts[$formatted_date] = $count;
                 }
                 break;
         }
         // get a unique list of the event IDs that will be displayed, and update all their postmeta and term caches at once
         $final_event_ids = call_user_func_array('array_merge', $event_ids);
         $final_event_ids = array_unique($final_event_ids);
         update_object_term_cache($final_event_ids, Tribe__Events__Main::POSTTYPE);
         update_postmeta_cache($final_event_ids);
     }
     // return IDs per day and total counts per day
     $return = array('counts' => $counts, 'event_ids' => $event_ids);
     $cache = new Tribe__Cache();
     $cache_key = 'daily_counts_and_ids_' . serialize($args);
     $cache->set($cache_key, $return, Tribe__Cache::NON_PERSISTENT, 'save_post');
     return $return;
 }
开发者ID:acutedeveloper,项目名称:havering-intranet-development,代码行数:96,代码来源:Query.php

示例11: aioseop_list_pages

function aioseop_list_pages($content)
{
    $matches = array();
    if (preg_match_all('/<li class="page_item page-item-(\\d+)/i', $content, $matches)) {
        update_postmeta_cache(array_values($matches[1]));
        unset($matches);
        $pattern = '/<li class="page_item page-item-(\\d+)([^\\"]*)"><a href=\\"([^\\"]+)" title="([^\\"]+)">([^<]+)<\\/a>/i';
        return preg_replace_callback($pattern, "aioseop_filter_callback", $content);
    }
    return $content;
}
开发者ID:hoonio,项目名称:wordpress,代码行数:11,代码来源:all_in_one_seo_pack.php

示例12: tdomf_upload_download_handler

function tdomf_upload_download_handler()
{
    global $current_user, $post_meta_cache, $blog_id;
    $post_ID = $_GET['tdomf_download'];
    $file_ID = $_GET['id'];
    $use_thumb = isset($_GET['thumb']);
    // Security check
    get_currentuserinfo();
    if (!current_user_can("publish_posts")) {
        $post = get_post($post_ID);
        if ($post->post_status != 'publish') {
            return;
        }
    }
    // For some reason, the post meta value cache does not include private
    // keys (those starting with _) so unset it and update it properly!
    //
    unset($post_meta_cache[$blog_id][$post_ID]);
    update_postmeta_cache($post_ID);
    if ($use_thumb) {
        $filepath = get_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_THUMB . $file_ID, true);
        // a previous version of TDOMF did not properly define
        // TDOMF_KEY_DOWNLOAD_THUMB so it used "TDOMF_KEY_DOWNLOAD_THUMB" as the
        // actually key, so double check here, just in case.
        if (!file_exists($filepath)) {
            tdomf_log_message("The key " . TDOMF_KEY_DOWNLOAD_THUMB . "{$file_ID} is not defined on {$post_ID}. Attempting to use " . 'TDOMF_KEY_DOWNLOAD_THUMB' . "{$file_ID}!", TDOMF_LOG_BAD);
            $filepath = get_post_meta($post_ID, 'TDOMF_KEY_DOWNLOAD_THUMB' . $file_ID, true);
        }
    } else {
        $filepath = get_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_PATH . $file_ID, true);
    }
    if (!empty($filepath)) {
        if (!$use_thumb) {
            $type = get_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_TYPE . $file_ID, true);
        }
        $name = get_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_NAME . $file_ID, true);
        // Check if file exists
        //
        if (file_exists($filepath)) {
            @ignore_user_abort();
            @set_time_limit(600);
            if (!empty($type)) {
                $mimetype = $type;
            } else {
                if (function_exists('mime_content_type')) {
                    // set mime-type
                    $mimetype = mime_content_type($filepath);
                } else {
                    // default
                    $mimetype = 'application/octet-stream';
                }
            }
            if (!$use_thumb) {
                // Other stuff we could track...
                //
                //$referer = $_SERVER['HTTP_REFERER'];
                //ip = $_SERVER['REMOTE_ADDR'];
                //$now = date('Y-m-d H:i:s');
                // Update count
                //
                // This includes partial downloads! If wanted only full downloads
                // we would track it afterwards
                //
                $count = intval(get_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_COUNT . $file_ID, true));
                $count++;
                update_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_COUNT . $file_ID, $count);
            }
            // Pass file
            $handle = fopen($filepath, "rb");
            // now let's get the file!
            #header("Pragma: "); // Leave blank for issues with IE
            #header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Content-Type: {$mimetype}");
            #header("Content-Disposition: attachment; filename=\"".basename($filepath)."\"");
            header("Content-Length: " . filesize($filepath));
            sleep(1);
            fpassthru($handle);
            return;
        } else {
            tdomf_log_message("File {$filepath} does not exist!", TDOMF_LOG_ERROR);
        }
    } else {
        if ($use_thumb) {
            tdomf_log_message("No thumb found on post with id {$post_ID}!", TDOMF_LOG_ERROR);
        } else {
            tdomf_log_message("No file found on post with id {$post_ID}!", TDOMF_LOG_ERROR);
        }
        tdomf_log_message("Post Meta Cache for {$post_ID} on {$blog_id} <pre>" . var_export($post_meta_cache[$blog_id][$post_ID], true) . "</pre>", TDOMF_LOG_BAD);
    }
    header("HTTP/1.0 404 Not Found");
    exit;
}
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:92,代码来源:tdomf-upload-functions.php

示例13: load_wp_data

 /**
  * self::load_multiple() must have been called before that because it loads
  * wp data from wp_ids found in $this->nodes_data.
  */
 public function load_wp_data($ids_wp = array(), $posts_already_loaded = array())
 {
     if (!empty($this->nodes_data)) {
         if (empty($ids_wp)) {
             $ids_wp = $this->get_wp_ids();
         }
         $posts = empty($posts_already_loaded) ? array() : $posts_already_loaded;
         $pages_found = array();
         if (empty($posts_already_loaded)) {
             /*
             //Old way to retrieve pages data, by separated requests (when coma separated post_status didn't seem
             //to work in get_pages() : 
             $posts = get_pages(array('include'=>array_values($ids_wp),'post_type'=>'page','post_status'=>'publish'));
             $posts_draft = get_pages(array('include'=>array_values($ids_wp),'post_type'=>'page','post_status'=>'draft'));
             $posts_pending = get_pages(array('include'=>array_values($ids_wp),'post_type'=>'page','post_status'=>'pending'));
             $posts_trash = get_pages(array('include'=>array_values($ids_wp),'post_type'=>'page','post_status'=>'trash'));
             $posts_private = get_pages(array('include'=>array_values($ids_wp),'post_type'=>'page','post_status'=>'private'));
             $posts_autodraft = get_pages(array('include'=>array_values($ids_wp),'post_type'=>'page','post_status'=>'auto-draft'));
             $posts = array_merge($posts,$posts_draft,$posts_pending,$posts_trash,$posts_private);
             */
             $allowed_post_status = ApmConfig::$allowed_post_status;
             //Note : we keep 'auto-draft' here to handle them in case there are some in $ids_wp,
             //which should not happen because 'auto-draft' are not retrieved at APM tree creation,
             //but can still happen if 'auto-draft' status is set outside the plugin.
             $allowed_post_status[] = 'auto-draft';
             $allowed_post_status = apply_filters('apm_allowed_post_status', $allowed_post_status, 'load_wp_data');
             $allowed_post_status = array_map("addslashes", $allowed_post_status);
             $posts = get_pages(array('include' => array_values($ids_wp), 'post_type' => 'page', 'post_status' => implode(',', $allowed_post_status)));
             /*
             				//If some problem occurs related to the use of the get_pages() function (for example if it is
             				//hooked by another plugin), keep in mind that we can do it by hand:
             				//To build the exact same query as in the native get_pages() function:
             				//Copied from the WP get_pages() function :
             				global $wpdb;
             				$inclusions = '';
             				$incpages = wp_parse_id_list(array_values($ids_wp));
             				if( !empty( $incpages ) ){
             					foreach( $incpages as $incpage ) {
             						if( empty($inclusions) ){
             							$inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage);
             						}else{
             							$inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage);
             						}
             					}
             				}
             				if( !empty($inclusions) ){
             					$inclusions .= ')';
             				}
             				
             				$sql = "SELECT * FROM $wpdb->posts   
             						WHERE post_type = 'page' AND post_status IN ('draft', 'publish', 'pending', 'trash', 'private', 'auto-draft')   
             							  $inclusions 
             						ORDER BY wp_posts.post_title ASC";
             				
             				//$posts = $wpdb->get_results($sql);
             				//_prime_post_caches($posts_ids);
             */
             //TODO : test performances issues when there is a lot of pages (>500) :
             //And commpare this to :
             //$posts = $wpdb->get_results($wpdb->prepare("SELECT * from $wpdb->posts WHERE post_type = 'page' AND ID IN ('". implode("','",$ids_wp) ."')"));
         }
         foreach ($posts as $k => $post) {
             $pages_found[$post->ID] = $post;
         }
         //Use this "apm_load_wp_data" hook to preload some data about WP pages before display :
         //Something like update_post_caches($pages_found,'page'); can be used in this hook to preload terms for example.
         //We don't do this update_post_caches() by default because we don't need pages terms info,
         //only meta data (see the following update_postmeta_cache).
         do_action('apm_load_wp_data', $pages_found);
         //Preload wp cached meta data, so they are not retrieved one by one in
         //the following loop of "load_data_from_wp_entity()" :
         update_postmeta_cache(array_keys($pages_found));
         foreach ($this->nodes_data as $apm_id => $node) {
             switch ($node->type) {
                 case 'root':
                     $this->nodes_data[$apm_id]->set(array('title' => 'Root'));
                     break;
                 case 'page':
                     $wp_id = $node->wp_id;
                     if (!empty($posts) && !empty($wp_id) && array_key_exists($wp_id, $pages_found)) {
                         $this->nodes_data[$apm_id]->load_data_from_wp_entity($pages_found[$wp_id]);
                     }
                     break;
             }
         }
     }
 }
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:91,代码来源:nodes_data.php

示例14: powerpress_get_post_meta

function powerpress_get_post_meta($post_id, $key)
{
    $pp_meta_cache = wp_cache_get($post_id, 'post_meta');
    if (!$pp_meta_cache) {
        update_postmeta_cache($post_id);
        $pp_meta_cache = wp_cache_get($post_id, 'post_meta');
    }
    $meta = false;
    if (isset($pp_meta_cache[$key])) {
        $meta = $pp_meta_cache[$key][0];
    }
    if (is_serialized($meta)) {
        if (false !== ($gm = @unserialize($meta))) {
            return $meta;
        }
    }
    return $meta;
}
开发者ID:briancfeeney,项目名称:portigal,代码行数:18,代码来源:powerpress.php

示例15: set_events_in_month

 /**
  * Get all the events in the month by directly querying the postmeta table
  * Also caches the postmeta and terms for the found events
  */
 protected function set_events_in_month()
 {
     global $wpdb;
     $grid_start_datetime = tribe_beginning_of_day($this->first_grid_date);
     $grid_end_datetime = tribe_end_of_day($this->final_grid_date);
     $cache = new Tribe__Cache();
     $cache_key = 'events_in_month' . $grid_start_datetime . '-' . $grid_end_datetime;
     // if we have a cached result, use that
     $cached_events = $cache->get($cache_key, 'save_post');
     if ($cached_events !== false) {
         $this->events_in_month = $cached_events;
         return;
     }
     $post_stati = array('publish');
     if (is_user_logged_in()) {
         $post_stati[] = 'private';
     }
     $post_stati = implode("','", $post_stati);
     $ignore_hidden_events_AND = $this->hidden_events_fragment();
     $events_request = $wpdb->prepare("SELECT tribe_event_start.post_id as ID,\n\t\t\t\t\t\ttribe_event_start.meta_value as EventStartDate,\n\t\t\t\t\t\ttribe_event_end_date.meta_value as EventEndDate\n\t\t\t\tFROM {$wpdb->postmeta} AS tribe_event_start\n\t\t\t\tLEFT JOIN {$wpdb->posts} ON tribe_event_start.post_id = {$wpdb->posts}.ID\n\t\t\t\tLEFT JOIN {$wpdb->postmeta} as tribe_event_end_date ON ( tribe_event_start.post_id = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = '_EventEndDate' )\n\t\t\t\tWHERE {$ignore_hidden_events_AND} tribe_event_start.meta_key = '_EventStartDate'\n\t\t\t\tAND ( (tribe_event_start.meta_value >= '%1\$s' AND  tribe_event_start.meta_value <= '%2\$s')\n\t\t\t\t\tOR (tribe_event_start.meta_value <= '%1\$s' AND tribe_event_end_date.meta_value >= '%1\$s')\n\t\t\t\t\tOR ( tribe_event_start.meta_value >= '%1\$s' AND  tribe_event_start.meta_value <= '%2\$s')\n\t\t\t\t)\n\t\t\t\tAND {$wpdb->posts}.post_status IN('{$post_stati}')\n\t\t\t\tORDER BY {$wpdb->posts}.menu_order ASC, DATE(tribe_event_start.meta_value) ASC, TIME(tribe_event_start.meta_value) ASC;\n\t\t\t\t", $grid_start_datetime, $grid_end_datetime);
     $this->events_in_month = $wpdb->get_results($events_request);
     // cache the postmeta and terms for all these posts in one go
     $event_ids_in_month = wp_list_pluck($this->events_in_month, 'ID');
     update_object_term_cache($event_ids_in_month, Tribe__Events__Main::POSTTYPE);
     update_postmeta_cache($event_ids_in_month);
     // cache the found events in the object cache
     $cache->set($cache_key, $this->events_in_month, 0, 'save_post');
 }
开发者ID:acutedeveloper,项目名称:havering-intranet-development,代码行数:32,代码来源:Month.php


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