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


PHP _prime_post_caches函数代码示例

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


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

示例1: cache

 /**
  * Since we are filtering on 'bp_activity_prefetch_object_data', the activity meta is already cached,
  * So, we won't query for media ids instead loop and build the list
  * 
  * @param type $activities
  */
 public function cache($activities)
 {
     if (empty($activities)) {
         return;
     }
     $media_ids = array();
     $gallery_ids = array();
     foreach ($activities as $activity) {
         //check if the activity has attached gallery
         $gallery_id = mpp_activity_get_gallery_id($activity->id);
         if ($gallery_id) {
             $gallery_ids[] = $gallery_id;
         }
         //check for media ids
         $attached_media_ids = mpp_activity_get_attached_media_ids($activity->id);
         if (!empty($attached_media_ids)) {
             $media_ids = array_merge($media_ids, $attached_media_ids);
         }
         $associated_media_id = mpp_activity_get_media_id($activity->id);
         if (!empty($associated_media_id)) {
             $media_ids[] = $associated_media_id;
         }
     }
     $merged_ids = array_merge($media_ids, $gallery_ids);
     $merged_ids = array_unique($merged_ids);
     if (!empty($merged_ids)) {
         _prime_post_caches($merged_ids, true, true);
     }
     return $activities;
 }
开发者ID:enboig,项目名称:mediapress,代码行数:36,代码来源:class-mpp-activity-media-cache-helper.php

示例2: widget

 function widget($args, $instance)
 {
     if (!isset($args['widget_id'])) {
         $args['widget_id'] = $this->id;
     }
     $output = '';
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = !empty($instance['number']) ? absint($instance['number']) : 5;
     if (!$number) {
         $number = 5;
     }
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     $output .= $args['before_widget'];
     if ($title) {
         $output .= $args['before_title'] . $title . $args['after_title'];
     }
     $output .= '<ul id="recentcomments">';
     if (is_array($comments) && $comments) {
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             $title = get_the_title($comment->comment_post_ID);
             $output .= '<li class="recentcomments"><i class="fa fa-comments">&nbsp;</i> ';
             $output .= sprintf(_x('%1$s on %2$s', 'widgets'), '<span class="comment-author-link"><strong> ' . get_comment_author_link($comment) . '</strong></span>', '<br><a href="' . esc_url(get_comment_link($comment)) . '">' . $title . '</a>');
             $output .= '</li>';
         }
     }
     $output .= '</ul>';
     $output .= $args['after_widget'];
     echo $output;
 }
开发者ID:de190909,项目名称:WPTest,代码行数:32,代码来源:class-extend-recent-comments-widget.php

示例3: widget

 /**
  * Outputs the content for the current Recent Comments widget instance.
  *
  * @param array $args     Display arguments including 'before_title', 'after_title',
  *                        'before_widget', and 'after_widget'.
  * @param array $instance Settings for the current Recent Comments widget instance.
  */
 public function widget($args, $instance)
 {
     if (!isset($args['widget_id'])) {
         $args['widget_id'] = $this->id;
     }
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
     /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = !empty($instance['number']) ? absint($instance['number']) : 5;
     if (!$number) {
         $number = 5;
     }
     $show_date = isset($instance['show_date']) ? $instance['show_date'] : false;
     /**
      * Filter the arguments for the Recent Comments widget.
      *
      * @since 3.4.0
      *
      * @see WP_Comment_Query::query() for information on accepted arguments.
      *
      * @param array $comment_args An array of arguments used to retrieve the recent comments.
      */
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     if (is_array($comments) && $comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         $args['title'] = $title;
         $args['comments'] = $comments;
         $args['show_date'] = $show_date;
         get_template_part_hierarchical_fetch('partials/widgets/recent-comments', '', $args);
         wp_reset_postdata();
     }
 }
开发者ID:e-picas,项目名称:wp-basic-bootstrap,代码行数:41,代码来源:WP_Basic_Bootstrap_Widget_Recent_Comments.php

示例4: mpp_shortcode_show_gallery

function mpp_shortcode_show_gallery($atts = null, $content = '')
{
    $defaults = array('id' => false, 'in' => false, 'exclude' => false, 'slug' => false, 'per_page' => false, 'offset' => false, 'page' => isset($_REQUEST['mpage']) ? absint($_REQUEST['mpage']) : false, 'nopaging' => false, 'order' => 'DESC', 'orderby' => 'date', 'user_id' => false, 'include_users' => false, 'exclude_users' => false, 'user_name' => false, 'scope' => false, 'search_terms' => '', 'meta_key' => '', 'meta_value' => '', 'column' => 4, 'view' => '', 'show_pagination' => 1);
    $defaults = apply_filters('mpp_shortcode_show_gallery_defaults', $defaults);
    $atts = shortcode_atts($defaults, $atts);
    if (!$atts['id']) {
        return '';
    }
    $gallery_id = absint($atts['id']);
    global $wpdb;
    $attachments = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_type = %s ", $gallery_id, 'attachment'));
    array_push($attachments, $gallery_id);
    _prime_post_caches($attachments, true, true);
    $gallery = mpp_get_gallery($gallery_id);
    //if gallery does not exist, there is no proint in further proceeding
    if (!$gallery) {
        return '';
    }
    if (!$atts['meta_key']) {
        unset($atts['meta_key']);
        unset($atts['meta_value']);
    }
    $view = $atts['view'];
    unset($atts['id']);
    unset($atts['view']);
    $atts['gallery_id'] = $gallery_id;
    $shortcode_column = $atts['column'];
    mpp_shortcode_save_media_data('column', $shortcode_column);
    mpp_shortcode_save_media_data('shortcode_args', $atts);
    unset($atts['column']);
    $show_pagination = $atts['show_pagination'];
    unset($atts['show_pagination']);
    $atts = array_filter($atts);
    $atts = apply_filters('mpp_shortcode_show_gallery_query_args', $atts, $defaults);
    $query = new MPP_Media_Query($atts);
    mpp_shortcode_save_media_data('query', $query);
    $content = apply_filters('mpp_shortcode_mpp_show_gallery_content', '', $atts, $view);
    if (!$content) {
        $templates = array('shortcodes/grid.php');
        if ($view) {
            $type = $gallery->type;
            $preferred_templates = array("shortcodes/{$view}-{$type}.php", "shortcodes/{$view}.php");
            //audio-playlist, video-playlist
            $templates = array_merge($preferred_templates, $templates);
            //array_unshift( $templates, $preferred_template );
        }
        ob_start();
        $located = mpp_locate_template($templates, false);
        //load
        if ($located) {
            require $located;
        }
        $content = ob_get_clean();
    }
    mpp_shortcode_reset_media_data('column');
    mpp_shortcode_reset_media_data('query');
    mpp_shortcode_reset_media_data('shortcode_args');
    return $content;
}
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:59,代码来源:mpp-shortcode-gallery-list.php

示例5: widget

 function widget($args, $instance)
 {
     global $comments, $comment;
     $cache = array();
     if (!$this->is_preview()) {
         $cache = wp_cache_get('alizee_recent_comments', '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;
     }
     extract($args, EXTR_SKIP);
     $output = '';
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments', 'alizee');
     /** This filter is documented in wp-includes/default-widgets.php */
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = !empty($instance['number']) ? absint($instance['number']) : 5;
     if (!$number) {
         $number = 5;
     }
     $show_date = isset($instance['show_date']) ? $instance['show_date'] : false;
     /**
      * Filter the arguments for the Recent Comments widget.
      *
      * @since 3.4.0
      *
      * @see get_comments()
      *
      * @param array $comment_args An array of arguments used to retrieve the recent comments.
      */
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     $output .= $before_widget;
     if ($title) {
         $output .= $before_title . $title . $after_title;
     }
     $output .= '<ul class="list-group">';
     if ($comments) {
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             $output .= '<li class="list-group-item"><div class="recent-comment clearfix">' . get_avatar($comment, 60) . '<div class="recent-comment-meta"><span>' . sprintf(__('%1$s on %2$s', 'alizee'), get_comment_author_link(), '</span><a class="post-title" href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</div></li>';
         }
     }
     $output .= '</ul>';
     $output .= $after_widget;
     echo $output;
     if (!$this->is_preview()) {
         $cache[$args['widget_id']] = $output;
         wp_cache_set('alizee_recent_comments', $cache, 'widget');
     }
 }
开发者ID:huppuguru,项目名称:teemakasa,代码行数:57,代码来源:recent-comments.php

示例6: widget

 /**
  * Outputs the HTML for this widget.
  *
  * @param array $args     An array of standard parameters for widgets in this theme
  * @param array $instance An array of settings for this widget instance
  *
  * @return void Echoes it's output
  */
 public function widget($args, $instance)
 {
     global $comments, $comment;
     $cache = array();
     if (!$this->is_preview()) {
         $cache = wp_cache_get('widget_recent_comments', '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;
     }
     $output = '';
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments', 'bigboom');
     /** This filter is documented in wp-includes/default-widgets.php */
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = absint($instance['number']);
     if (!$number) {
         $number = 5;
     }
     /**
      * Filter the arguments for the Recent Comments widget.
      *
      * @since 3.4.0
      *
      * @see WP_Comment_Query::query() for information on accepted arguments.
      *
      * @param array $comment_args An array of arguments used to retrieve the recent comments.
      */
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     echo $args['before_widget'];
     if ($title) {
         echo $args['before_title'] . esc_html($title) . $args['after_title'];
     }
     echo '<ul id="recentcomments">';
     if ($comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             echo '<li class="recentcomments">';
             /* translators: comments widget: 1: comment author, 2: post link */
             echo sprintf(_x('Posted by: %1$s', 'widgets', 'bigboom'), '<span class="comment-author-link">' . get_comment_author_link() . '</span>');
             bigboom_content_limit($comment->comment_content, intval($instance['length']), '');
             echo '</li>';
         }
     }
     echo '</ul>';
     echo $args['after_widget'];
 }
开发者ID:Qualitair,项目名称:ecommerce,代码行数:63,代码来源:recent-comments.php

示例7: widget

 /**
  * 小工具的渲染方法,这里就是输出评论
  */
 function widget($args, $instance)
 {
     global $wpdb, $comments, $comment;
     $cache = wp_cache_get('f_comment', '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;
     }
     extract($args, EXTR_SKIP);
     $output = '';
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title'], $instance, $this->id_base);
     if (empty($instance['number']) || !($number = absint($instance['number']))) {
         $number = 5;
     }
     //获取评论,过滤掉管理员自己
     $comments = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE user_id !=1 and comment_approved = '1' and comment_type not in ('pingback','trackback') ORDER BY comment_date_gmt DESC LIMIT {$number}");
     $output .= $before_widget;
     if ($title) {
         $output .= $before_title . $title . $after_title;
     }
     $output .= '<div class="all-comments">';
     if ($comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             if ($comment->comment_author_email != $my_email) {
                 //头像
                 $avatar = get_avatar($comment, 36);
                 //作者名称
                 $author = get_comment_author();
                 //评论内容
                 $content = apply_filters('get_comment_text', $comment->comment_content);
                 $content = mb_strimwidth(strip_tags($content), 0, '65', '...', 'UTF-8');
                 $content = convert_smilies($content);
                 //评论的文章
                 $post = '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . $avatar . $author . '<span class="muted">' . timeago($comment->comment_date_gmt) . ':<br>' . $content . '</span></a>';
                 //这里就是输出的html,可以根据需要自行修改
                 $output .= $post;
             }
         }
     }
     $output .= '</div>';
     $output .= $after_widget;
     echo $output;
     $cache[$args['widget_id']] = $output;
     wp_cache_set('my_widget_recent_comments', $cache, 'widget');
 }
开发者ID:YocoZhang,项目名称:my-blog-site,代码行数:57,代码来源:wid-comment.php

示例8: widget

 function widget($args, $instance)
 {
     global $comments, $comment;
     $cache = wp_cache_get('widget_recent_comments', '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;
     }
     extract($args, EXTR_SKIP);
     $output = '';
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = !empty($instance['number']) ? absint($instance['number']) : 5;
     if (!$number) {
         $number = 5;
     }
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     $output .= $before_widget;
     if ($title) {
         $output .= $before_title . $title . $after_title;
     }
     $output .= '<ul id="recentcomments" class="bw-sidebar-posts">';
     if ($comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             if (Bw::get_option('enable_lazy_image')) {
                 $bw_image = "<img class='lazy' data-src='" . get_avatar_url($comment->user_id) . "' src='" . Bw::empty_img() . "' alt='' >";
             } else {
                 $bw_image = "<img src='" . get_avatar_url($comment->user_id) . "' alt='' >";
             }
             $output .= '<li class="recentcomments">';
             $output .= '<div class="thumb"><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . $bw_image . '</a></div>';
             $output .= '<div class="cont"><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_comment_author_link() . '</a>';
             $output .= '<p>' . Bw::truncate($comment->comment_content, 7) . '</p></div>';
             $output .= '</li>';
         }
     }
     $output .= '</ul>';
     $output .= $after_widget;
     echo $output;
     $cache[$args['widget_id']] = $output;
     wp_cache_set('widget_recent_comments', $cache, 'widget');
 }
开发者ID:damiansu,项目名称:wordpress-es,代码行数:51,代码来源:Bw_widgets_recent_comments.php

示例9: widget

 function widget($args, $instance)
 {
     global $comments, $comment;
     $cache = wp_cache_get('tm_recent_comments', '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;
     }
     $d = get_option('date_format');
     extract($args, EXTR_SKIP);
     $output = '';
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = !empty($instance['number']) ? absint($instance['number']) : 5;
     $number_char = !empty($instance['number_char']) ? absint($instance['number_char']) : 50;
     if (!$number) {
         $number = 5;
     }
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     $output .= $before_widget;
     if ($title) {
         $output .= $before_title . $title . $after_title;
     }
     $output .= '<ul id="tm_recentcomments">';
     if ($comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             $num_char = get_comment_text($comment->comment_ID);
             $len = strlen($num_char);
             if ($len > $number_char) {
                 $num_char = substr($num_char, 0, $number_char) . '...';
             }
             $output .= '<li class="tm_recentcomments"><a class="cm-avatar" href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_avatar($comment, 60, '', get_the_author()) . '</a>' . sprintf(_x('%1$s  %2$s', 'widgets'), '<div class="info_rc"><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . $num_char . '</a>', '<p><span>' . get_comment_author_link()) . '</span>' . get_comment_date($d, $comment->comment_ID) . '' . __(' at ', 'cactusthemes') . '' . get_comment_time() . '</p></div></li>';
         }
     }
     $output .= '</ul>';
     $output .= $after_widget;
     echo $output;
     $cache[$args['widget_id']] = $output;
     wp_cache_set('tm_recent_comments', $cache, 'widget');
 }
开发者ID:venamax,项目名称:trixandtrax-cl,代码行数:49,代码来源:widget-recent-comment.php

示例10: widget

 public function widget($args, $instance)
 {
     global $comments, $comment;
     $cache = array();
     if (!$this->is_preview()) {
         $cache = wp_cache_get('widget_custom_post_type_recent_comments', '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;
     }
     $output = '';
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments', 'custom-post-type-widgets') : $instance['title'], $instance, $this->id_base);
     $posttype = $instance['posttype'];
     if (empty($instance['number']) || !($number = absint($instance['number']))) {
         $number = 5;
     }
     $comments = get_comments(array('post_type' => $posttype, 'number' => $number, 'status' => 'approve', 'post_status' => 'publish'));
     $output .= $args['before_widget'];
     if ($title) {
         $output .= $args['before_title'] . $title . $args['after_title'];
     }
     $output .= '<ul>';
     if ($comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             $output .= '<li class="recentcomments">';
             /* translators: comments widget: 1: comment author, 2: post link */
             $output .= sprintf(_x('%1$s on %2$s', 'widgets'), '<span class="comment-author-link">' . get_comment_author_link() . '</span>', '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a>');
             $output .= '</li>';
         }
     }
     $output .= '</ul>';
     $output .= $args['after_widget'];
     echo $output;
     if (!$this->is_preview()) {
         $cache[$args['widget_id']] = $output;
         wp_cache_set('widget_custom_post_type_recent_comments', $cache, 'widget');
     }
 }
开发者ID:AryvartPhpTeam,项目名称:aryvartnew,代码行数:48,代码来源:widget-custom-post-type-recent-comments.php

示例11: update_post_thumbnail_cache

/**
 * Update cache for thumbnails in the current loop
 *
 * @since 3.2
 */
function update_post_thumbnail_cache()
{
    global $wp_query;
    if ($wp_query->thumbnails_cached) {
        return;
    }
    $thumb_ids = array();
    foreach ($wp_query->posts as $post) {
        if ($id = get_post_thumbnail_id($post->ID)) {
            $thumb_ids[] = $id;
        }
    }
    if (!empty($thumb_ids)) {
        _prime_post_caches($thumb_ids, false, true);
    }
    $wp_query->thumbnails_cached = true;
}
开发者ID:nuevomediagroup,项目名称:WordPress,代码行数:22,代码来源:post-thumbnail-template.php

示例12: widget

 function widget($args, $instance)
 {
     global $comments, $comment;
     $cache = wp_cache_get('widget_recent_comments_extended', '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;
     }
     extract($args, EXTR_SKIP);
     $output = '';
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments', THEME_NAME);
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = !empty($instance['number']) ? absint($instance['number']) : 5;
     if (!$number) {
         $number = 5;
     }
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     $output .= $before_widget;
     if ($title) {
         $output .= $before_title . $title . $after_title;
     }
     $output .= '<div class="offers"><ul class="list packed">';
     if ($comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             $output .= '<li class="offer">';
             $output .= '<div class="image"><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_post_thumbnail($comment->comment_post_ID, array(100, 100)) . '</a></div>';
             $output .= sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
         }
     }
     $output .= '</ul></div>';
     $output .= $after_widget;
     echo $output;
     $cache[$args['widget_id']] = $output;
     wp_cache_set('widget_recent_comments_extended', $cache, 'widget');
 }
开发者ID:pistonsky,项目名称:taivilla,代码行数:44,代码来源:custom-widgets.php

示例13: mpp_upgrade_legacy_1_0_b1_activity

function mpp_upgrade_legacy_1_0_b1_activity()
{
    if (get_option('mpp_upgraded_1_0_b1')) {
        return;
        //already upgraded
    }
    add_option('mpp_upgraded_1_0_b1', 1);
    if (!get_option('mpp-settings')) {
        return;
        //mediapress was not installed earlier
    }
    if (!function_exists('buddypress')) {
        return;
    }
    global $wpdb;
    $activity_table = bp_core_get_table_prefix() . 'bp_activity_meta';
    //rename _mpp_attached_media_ids key tp _mpp_attached_media_id
    $sql = "UPDATE {$activity_table} SET meta_key = '_mpp_attached_media_id' WHERE meta_key = '_mpp_attached_media_ids'";
    $wpdb->query($sql);
    //add context to all Media comments
    $update_query = "INSERT INTO {$activity_table} (activity_id, meta_key, meta_value) \n\t\t\tSELECT  activity_id, %s as meta_key, %s as meta_value FROM {$activity_table} where meta_key ='_mpp_galery_id'";
    //update the context? should we?
    $wpdb->query($wpdb->prepare($update_query, '_mpp_context', 'gallery'));
    //update type
    $wpdb->query($wpdb->prepare($update_query, '_mpp_activity_type', 'media_upload'));
    //for media comments
    //$entries = $wpdb->get_col( "SELECT activity_id, meta_value FROM {$activity_table} WHERE meta_key = '_mpp_media_id'" );
    $entries = $wpdb->get_results("SELECT activity_id, meta_value FROM {$activity_table} WHERE meta_key = '_mpp_media_id'");
    $media_ids = wp_list_pluck($entries, 'meta_value');
    //comments are there
    if (!empty($media_ids)) {
        _prime_post_caches($media_ids, false, false);
        //add parent gallery id for each of the media
        foreach ($entries as $entry) {
            $media = get_post($entry->meta_value);
            mpp_activity_update_gallery_id($entry->activity_id, $media->post_parent);
        }
        //update context to 'media'
        $update_query = "INSERT INTO {$activity_table} (activity_id, meta_key, meta_value) \n\t\t\tSELECT  activity_id, %s as meta_key, %s as meta_value FROM {$activity_table} WHERE meta_key ='_mpp_media_id'";
        $wpdb->query($wpdb->prepare($update_query, '_mpp_activity_type', 'media_comment'));
        $wpdb->query($wpdb->prepare($update_query, '_mpp_activity_type', 'media'));
    }
}
开发者ID:markc,项目名称:mediapress,代码行数:43,代码来源:mpp-admin-install.php

示例14: update_post_thumbnail_cache

/**
 * Update cache for thumbnails in the current loop
 *
 * @since 3.2.0
 *
 * @param object $wp_query Optional. A WP_Query instance. Defaults to the $wp_query global.
 */
function update_post_thumbnail_cache($wp_query = null)
{
    if (!$wp_query) {
        $wp_query = $GLOBALS['wp_query'];
    }
    if ($wp_query->thumbnails_cached) {
        return;
    }
    $thumb_ids = array();
    foreach ($wp_query->posts as $post) {
        if ($id = get_post_thumbnail_id($post->ID)) {
            $thumb_ids[] = $id;
        }
    }
    if (!empty($thumb_ids)) {
        _prime_post_caches($thumb_ids, false, true);
    }
    $wp_query->thumbnails_cached = true;
}
开发者ID:Didox,项目名称:beminfinito,代码行数:26,代码来源:post-thumbnail-template.php

示例15: widget

 function widget($args, $instance)
 {
     global $comments, $comment;
     $cache = wp_cache_get('widget_latest_comments_avatar', '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;
     }
     extract($args, EXTR_SKIP);
     $output = '';
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = !empty($instance['number']) ? absint($instance['number']) : 5;
     if (!$number) {
         $number = 5;
     }
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     $output .= $before_widget;
     if ($title) {
         $output .= $before_title . $title . $after_title;
     }
     $output .= '<ul class="cb-recent-comments-avatar">';
     if ($comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             $output .= '<li class="cb-comment-with-avatar"><div class="cb-avatar">' . get_avatar($comment, 60) . '</div><div class="cb-comment">' . get_comment_author_link() . ' <i class="icon-long-arrow-right"></i> <a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a></div></li>';
         }
     }
     $output .= '</ul>';
     $output .= $after_widget;
     echo $output;
     $cache[$args['widget_id']] = $output;
     wp_cache_set('widget_latest_comments_avatar', $cache, 'widget');
 }
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:42,代码来源:cb-recent-comments-avatar-widget.php


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