function converio_recent_posts($atts, $content = null) { if (isset($atts) && !empty($atts)) { array_walk($atts, 'converio_arrangement_shortcode_arr_value'); } extract(shortcode_atts(array('number_of_columns' => '4', 'number_of_posts' => '4', 'excerpt_words' => '40', 'strip_html' => 'yes', 'title' => '', 'category_name' => ''), $atts)); global $wpdb; $args = array('posts_per_page' => $number_of_posts, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'category_name' => $category_name, 'suppress_filters' => true); $posts_array = get_posts($args); $output = '<section class="columns postlist masonry postlist-blog">'; if (!empty($title)) { $output .= '<h3>' . $title . '</h3>'; } if (!empty($posts_array)) { foreach ($posts_array as $key_data => $val_data) { $comment = get_comment_count($val_data->ID); $output .= '<article class="col col' . $number_of_columns . ' item">'; if (has_post_thumbnail($val_data->ID)) { $output .= '<a href="' . get_permalink($val_data->ID) . '">' . get_the_post_thumbnail($val_data->ID, 'thumbnail-medium', $val_data->post_title) . '</a>'; } $output .= '<h2 class="post-headline"><a href="' . get_permalink($val_data->ID) . '">' . $val_data->post_title . '</a></h2>'; if (!has_post_thumbnail($val_data->ID)) { //show the excerp if there is no featured image if (!empty($val_data->post_excerpt)) { $output .= '<p>' . converio_cut_character_word($excerpt_words, $val_data->post_excerpt, $strip_html) . '</p>'; } elseif (!empty($val_data->post_content)) { $output .= '<p>' . converio_cut_character_word($excerpt_words, $val_data->post_content, $strip_html) . '</p>'; } } $output .= '</article>'; } } $output .= '</section>'; return $output; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $categories = empty($instance['categories']) ? $instance['categories'] : implode($instance['categories'], ','); $count = empty($instance['count']) ? 5 : $instance['count']; $limit = empty($instance['limit']) ? 100 : $instance['limit']; $show_thumbnails = $instance['show_thumbnails']; $show_excerpt = $instance['show_excerpt']; $all_post_formats = $instance['all_post_formats']; $thumb_width = empty($instance['thumb_width']) ? 50 : $instance['thumb_width']; $thumb_height = empty($instance['thumb_height']) ? 50 : $instance['thumb_height']; //remove aside and quote post formats from the list $postargs = $all_post_formats ? array('orderby' => 'comment_count', 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1) : array('orderby' => 'comment_count', 'tax_query' => array(array('operator' => 'NOT IN', 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-quote', 'post-format-aside'))), 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1); $post_query = new WP_Query($postargs); $rt_posts = '<div class="recent_posts clearfix"><ul>'; if ($post_query->have_posts()) { while ($post_query->have_posts()) { $post_query->the_post(); $post_title = get_the_title(); $link = get_permalink(); $date = get_the_time('d M Y'); $comment_count = get_comment_count($post_query->post->ID); $rt_gallery_images = get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_images", true) ? get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_images", true) : ""; $rt_gallery_image_titles = get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_titles", true) ? get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_titles", true) : ""; $rt_gallery_image_descs = get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_descs", true) ? get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_descs", true) : ""; $fist_featured_image = is_array($rt_gallery_images) ? find_image_org_path($rt_gallery_images[0]) : ""; $rt_posts .= '<li class="clearfix">'; if ($fist_featured_image && !$show_thumbnails) { $f_image = @vt_resize('', $fist_featured_image, $thumb_width, $thumb_height, true); if ($f_image["url"]) { $rt_posts .= '<img src="' . $f_image["url"] . '" alt="' . $title . '" class="recent-posts-thumb" />'; } } $rt_posts .= '<span class="date">' . $date . '</span>'; $rt_posts .= '<span class="title"><a href="' . $link . '">' . $post_title . '</a></span>'; $rt_posts .= $show_excerpt ? '' . wp_html_excerpt(get_the_excerpt(), $limit) . '...' : ""; if ($comment_count['approved'] > 0) { if ($comment_count['approved'] > 1) { $comments = $comment_count['approved'] . ' ' . __('Comments', 'rt_theme'); } else { $comments = __('1 Comment', 'rt_theme'); } $rt_posts .= ' <span class="comment_number date"><a href="' . get_comments_link() . '" title="' . $comments . '" class="comment_link">' . $comments . '</a></span>'; $rt_posts .= $show_excerpt ? '<div class="space margin-b10"></div>' : ""; } $rt_posts .= '</li>'; } } wp_reset_query(); $rt_posts .= '</ul></div>'; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo $rt_posts; echo $after_widget; }
function widget($args, $instance) { //defaults $instance = wp_parse_args($instance, array("title" => "", "categories" => "", "count" => "", "limit" => "", "show_thumbnails" => "", "show_excerpt" => "", "thumb_width" => "", "thumb_height" => "")); extract($args); $title = !empty($instance['title']) ? apply_filters('widget_title', $instance['title']) : ""; $categories = !empty($instance['categories']) ? implode($instance['categories'], ',') : ""; $count = !empty($instance['count']) ? $instance['count'] : 5; $limit = !empty($instance['limit']) ? $instance['limit'] : 100; $show_thumbnails = !empty($instance['show_thumbnails']) ? $instance['show_thumbnails'] : ""; $show_excerpt = !empty($instance['show_excerpt']) ? $instance['show_excerpt'] : ""; $thumb_width = !empty($instance['thumb_width']) ? $instance['thumb_width'] : 260; $thumb_height = !empty($instance['thumb_height']) ? $instance['thumb_height'] : 260; $comment = ""; //remove aside and quote post formats from the list $postargs = array('orderby' => 'comment_count', 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1); $post_query = new WP_Query($postargs); $rt_posts = ''; if ($post_query->have_posts()) { while ($post_query->have_posts()) { $post_query->the_post(); $post_title = get_the_title(); $link = get_permalink(); $date = get_the_time('d M Y'); $comment_count = get_comment_count($post_query->post->ID); $featured_image_id = get_post_thumbnail_id(); $get_the_excerpt = $show_excerpt ? '<p>' . wp_html_excerpt(get_the_excerpt(), $limit) . '...</p>' : ""; // Create thumbnail image $thumbnail_image_output = !empty($featured_image_id) ? get_resized_image_output(array("image_url" => "", "image_id" => $featured_image_id, "w" => $thumb_width, "h" => $thumb_height, "crop" => 1, "class" => "post-thumb")) : ""; if (empty($thumbnail_image_output) || !empty($show_thumbnails)) { $thumbnail_image_output = ""; } if ($comment_count['approved'] > 0) { if ($comment_count['approved'] > 1) { $comments = $comment_count['approved'] . ' ' . __('Comments', 'rt_theme'); } else { $comments = __('1 Comment', 'rt_theme'); } $comment = ' | <span class="comment_number"><span class="icon-comment-empty"></span><a href="' . get_comments_link() . '" title="' . $comments . '" class="comment_link">' . $comment_count['approved'] . '</a></span>'; } $rt_posts .= sprintf(' <div> %1$s <a class="title" href="%2$s" title="%3$s" rel="bookmark">%3$s</a> <span class="meta">%4$s %6$s</span> %5$s </div> ', $thumbnail_image_output, $link, $post_title, get_the_date(), $get_the_excerpt, $comment); } wp_reset_postdata(); } echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo $rt_posts; echo $after_widget; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); if (!empty($instance['title'])) { $title = $instance['title']; } else { $title = 'بىكەت ئۇچۇرى'; } $title = apply_filters('widget_title', $title, $instance, $this->id_base); $date = $instance['date']; echo $before_widget; echo $before_title . $title . $after_title; echo '<ul class="blog_info">'; if ($title) { } ?> <li>يازما سانى:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish; ?> </li> <li> بەت سانى:<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?> </li> <li>ئومۇمىي باھا:<?php $count_comments = get_comment_count(); echo $count_comments['approved']; ?> </li> <li>ئومۇمىي خەتكۈش:<?php echo $count_tags = wp_count_terms('post_tag'); ?> </li> <?php if (!empty($instance['date'])) { ?> <li>قۇرۇلغان ۋاقىت:<?php echo $date; ?> </li> <li>بىكەت يېشى:<?php echo floor((time() - strtotime("{$date}")) / 86400); ?> كۈن</li> <?php } ?> </ul> <?php echo $after_widget; }
public function test_get_comment_count_post_trashed() { self::factory()->comment->create(array('comment_approved' => 'post-trashed')); $count = get_comment_count(); $this->assertEquals(0, $count['approved']); $this->assertEquals(0, $count['awaiting_moderation']); $this->assertEquals(0, $count['spam']); $this->assertEquals(0, $count['trash']); $this->assertEquals(1, $count['post-trashed']); $this->assertEquals(0, $count['total_comments']); }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $categories = empty($instance['categories']) ? $instance['categories'] : implode($instance['categories'], ','); $count = empty($instance['count']) ? 5 : $instance['count']; $limit = empty($instance['limit']) ? 100 : $instance['limit']; $show_thumbnails = $instance['show_thumbnails']; $show_excerpt = $instance['show_excerpt']; $thumb_width = empty($instance['thumb_width']) ? 50 : $instance['thumb_width']; $thumb_height = empty($instance['thumb_height']) ? 50 : $instance['thumb_height']; $comment = ""; //remove aside and quote post formats from the list $postargs = array('orderby' => 'comment_count', 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1); $post_query = new WP_Query($postargs); $rt_posts = '<div class="recent_posts clearfix"><ul>'; if ($post_query->have_posts()) { while ($post_query->have_posts()) { $post_query->the_post(); $post_title = get_the_title(); $link = get_permalink(); $date = get_the_time('d M Y'); $comment_count = get_comment_count($post_query->post->ID); $featured_image_id = get_post_thumbnail_id(); // Create thumbnail image $thumbnail_image_output = !empty($featured_image_id) ? get_resized_image_output(array("image_url" => "", "image_id" => $featured_image_id, "w" => $thumb_width, "h" => $thumb_height, "crop" => 1, "class" => "recent-posts-thumb")) : ""; $rt_posts .= '<li class="clearfix">'; if ($thumbnail_image_output && !$show_thumbnails) { $rt_posts .= $thumbnail_image_output; } if ($comment_count['approved'] > 0) { if ($comment_count['approved'] > 1) { $comments = $comment_count['approved'] . ' ' . __('Comments', 'rt_theme'); } else { $comments = __('1 Comment', 'rt_theme'); } $comment = ' <span class="comment_number"><span class="icon-comment-empty"></span><a href="' . get_comments_link() . '" title="' . $comments . '" class="comment_link">' . $comment_count['approved'] . '</a></span>'; } $rt_posts .= '<span class="title"><a href="' . $link . '">' . $post_title . '</a></span>'; $rt_posts .= '<div class="widget-meta"><span class="date">' . $date . '</span> ' . $comment . '</div>'; $rt_posts .= $show_excerpt ? '' . wp_html_excerpt(get_the_excerpt(), $limit) . '...' . '<div class="space margin-b10"></div>' : ""; $rt_posts .= '</li>'; } } wp_reset_query(); $rt_posts .= '</ul></div>'; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo $rt_posts; echo $after_widget; }
/** * @return bool */ protected function is_flood() { if (get_comment_count($this->prompt_post->id()) < $this->trigger_count) { return false; } if ($this->prompt_post->get_flood_control_comment_id()) { return false; } $last_hour_comment_count = get_comments(array('count' => true, 'post_id' => $this->prompt_post->id(), 'status' => 'approve', 'date_query' => array(array('column' => 'comment_date', 'after' => '1 hour ago')))); if ($last_hour_comment_count <= $this->trigger_count) { return false; } return true; }
function cfgp_batch_import_blog($blog_id, $offset, $increment) { switch_to_blog($blog_id); // Get the shadow blog ID $cfgp_blog_id = cfgp_get_shadow_blog_id(); /* http://codex.wordpress.org/Template_Tags/query_posts#Offset_Parameter */ $args = array('offset' => $offset, 'showposts' => $increment); /* Grab posts */ query_posts($args); if (have_posts()) { global $post; // Setup a global variable for handling $posts = array(); $batch_status = 'running'; while (have_posts()) { /************ * POST WORK * ************/ /* Setup post data */ the_post(); /* Get the category names into array */ $categories = get_the_category($post->ID); /* Get the tag information */ $tags = get_the_tags($post->ID); /* Get all the post_meta for current post */ $all_post_meta = get_post_custom($post->ID); /* Check to see if we're inserting the post, or updating an existing */ $clone_post_id = cfgp_are_we_inserting($post->ID); /* Grab the Permalink of the post, so the shadow blog knows how to get back to the post */ $permalink = get_permalink($post->ID); /* Grab the comment count, so we can insert it into clone's post meta */ $comment_count = get_comment_count($post->ID); // Gather all of the info to be processed into one place $posts[$post->ID]['post'] = $post; $posts[$post->ID]['categories'] = $categories; $posts[$post->ID]['tags'] = $tags; $posts[$post->ID]['post_meta'] = $all_post_meta; $posts[$post->ID]['clone_post_id'] = $clone_post_id; $posts[$post->ID]['permalink'] = $permalink; $posts[$post->ID]['comment_count'] = $comment_count['approved']; } // Gather the clone ids into this array $clone_info = array(); $post = ''; switch_to_blog($cfgp_blog_id); foreach ($posts as $post) { $clone_post_id = $post['clone_post_id']; $the_post = $post['post']; $categories = $post['categories']; $tags = $post['tags']; $post_meta = $post['post_meta']; $permalink = $post['permalink']; $comment_number = $post['comment_count']; /************ * POST WORK * ************/ $old_post_id = $post['post']->ID; $clone_id = cfgp_do_the_post($the_post, $clone_post_id); /**************** * CATEGORY WORK * ****************/ if (is_array($categories)) { $cur_cat_names = array(); foreach ($categories as $cat) { $cur_cats_names[] = $cat->name; } $cat_results = cfgp_do_categories($clone_id, $cur_cats_names); } /*********** * TAG WORK * ***********/ if (is_array($tags)) { foreach ($tags as $tag) { $tag_names[] = $tag->name; } $tag_name_string = implode(', ', $tag_names); $tag_results = cfgp_do_tags($clone_id, $tag_name_string); } /***************** * POST META WORK * *****************/ $post_meta_results = apply_filters('cfgp_do_post_meta', array(), $clone_id, $blog_id, $post_meta, $permalink, $old_post_id); $clone_info[] = array('post_id' => $old_post_id, 'clone_id' => $clone_id); /********************* * COMMENT COUNT WORK * *********************/ $comment_update_results = cfgp_update_comment_count($clone_id, $comment_number, 0); /* Add the return values for this post */ $single_post_results[] = array('original_post' => $old_post_id, 'clone_id' => $clone_id, 'cat_results' => $cat_results, 'tag_results' => $tag_results, 'post_meta_results' => $post_meta_results, 'permalink' => $permalink, 'comment_count' => $comment_update_results); } restore_current_blog(); foreach ($clone_info as $clone) { /* Finally add post_meta to the original * post of the clone's post id */ update_post_meta($clone['post_id'], '_cfgp_clone_id', $clone['clone_id']); } } else { $batch_status = 'finished'; } $results = array('status' => $batch_status, 'blog' => $blog_id, 'posts' => $my_posts, 'result_details' => $single_post_results, 'next_offset' => $offset + $increment); restore_current_blog(); return $results; }
comments_number(__('No comment', 'takeaway'), __('One comment', 'takeaway'), __('Comments (%)', 'takeaway')); ?> </h5> <ul class="comments"> <li> <?php wp_list_comments('callback=takeaway_comments'); ?> </li> </ul> </div> <?php if (get_comment_count() > 1 && get_option('page_comments')) { ?> <div class="comments-nav-section clearfix"> <p class="fl"> <?php previous_comments_link(__('← Older Comments', 'adaptive-framework')); ?> </p> <p class="fl"> <?php next_comments_link(__('Newer Comments →', 'adaptive-framework')); ?> </p> </div> <!-- end comments-nav-section --> <?php }
function widget($args, $instance) { global $wpdb; extract($args); $title = $instance['title'] ? esc_attr($instance['title']) : ''; $date = $instance['date'] ? esc_attr($instance['date']) : ''; echo $before_widget; if ($title) { echo $before_title . '<i class="fa fa-sitemap"></i> ' . $title . $after_title; } ?> <ul class="list-group"> <li class="list-group-item">分类:<?php echo $count_categories = wp_count_terms('category'); ?> 个</li> <li class="list-group-item">运行:<?php echo floor((time() - strtotime($date)) / 86400); ?> 天</li> <li class="list-group-item">文章:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish; ?> 个</li> <li class="list-group-item">页面:<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?> 个</li> <li class="list-group-item">评论:<?php $count_comments = get_comment_count(); echo $count_comments['approved']; ?> 个</li> <li class="list-group-item">标签:<?php echo $count_tags = wp_count_terms('post_tag'); ?> 个</li> </ul> <?php echo $after_widget; }
public function match_trigger($trigger, $record) { $type = isset($trigger['type']) ? $trigger['type'] : null; $needle = isset($trigger['value']) ? $trigger['value'] : null; $operator = isset($trigger['operator']) ? $trigger['operator'] : null; $negative = isset($operator[0]) && '!' === $operator[0]; $haystack = null; // Post-specific triggers dirty work if (false !== strpos($trigger['type'], 'post_')) { $post = get_post($record['object_id']); if (empty($post)) { return false; } } switch ($type) { case 'search': $haystack = strtolower($record['summary']); $needle = strtolower($needle); break; case 'object_id': $haystack = $record['object_id']; break; case 'author': $haystack = $record['author']; break; case 'author_role': $user = get_userdata($record['author']); $haystack = is_object($user) && $user->exists() && $user->roles ? $user->roles[0] : false; break; case 'ip': $haystack = $record['ip']; break; case 'date': $haystack = get_date_from_gmt(date('Y-m-d H:i:s', strtotime($record['created'])), 'Ymd'); $needle = get_date_from_gmt(date('Y-m-d H:i:s', strtotime($needle)), 'Ymd'); break; case 'weekday': if (isset($needle[0]) && preg_match('#\\d+#', $needle[0], $weekday_match)) { $haystack = get_date_from_gmt(date('Y-m-d H:i:s', strtotime($record['created'])), 'w'); $needle = $weekday_match[0]; } break; case 'connector': $haystack = $record['connector']; break; case 'context': $haystack = $record['context']; break; case 'action': $haystack = $record['action']; break; /* Context-aware triggers */ /* Context-aware triggers */ case 'post': case 'user': case 'term': $haystack = $record['object_id']; break; case 'term_parent': $parent = get_term($record['meta']['term_parent'], $record['meta']['taxonomy']); if (empty($parent) || is_wp_error($parent)) { return false; } else { $haystack = $parent->term_taxonomy_id; } break; case 'tax': if (empty($record['meta']['taxonomy'])) { return false; } $haystack = $record['meta']['taxonomy']; break; case 'post_title': $haystack = $post->post_title; break; case 'post_slug': $haystack = $post->post_name; break; case 'post_content': $haystack = $post->post_content; break; case 'post_excerpt': $haystack = $post->post_excerpt; break; case 'post_status': $haystack = get_post_status($post->ID); break; case 'post_format': $haystack = get_post_format($post); break; case 'post_parent': $haystack = wp_get_post_parent_id($post->ID); break; case 'post_thumbnail': if (!function_exists('get_post_thumbnail_id')) { return false; } $haystack = get_post_thumbnail_id($post->ID) > 0; break; case 'post_comment_status': $haystack = $post->comment_status; break; case 'post_comment_count': $haystack = get_comment_count($post->ID); break; default: return false; break; } $match = false; switch ($operator) { case '=': case '!=': case '>=': case '<=': $needle = is_array($needle) ? $needle : explode(',', $needle); $match = (bool) array_intersect($needle, (array) $haystack); break; // string special comparison operators // string special comparison operators case 'contains': case '!contains': $match = false !== strpos($haystack, $needle); break; case 'starts': $match = 0 === strpos($haystack, $needle); break; case 'ends': $match = strlen($haystack) - strlen($needle) === strrpos($haystack, $needle); break; case 'regex': $match = preg_match($needle, $haystack) > 0; break; // date operators // date operators case '<': case '<=': $match = $match || $haystack < $needle; break; case '>': case '>=': $match = $match || $haystack > $needle; break; } $result = $match == !$negative; // Loose comparison needed return $result; }
function comments2wp($comments = '') { // General Housekeeping global $wpdb; $count = 0; $dccm2wpcm = array(); $postarr = get_option('dcposts2wpposts'); // Magic Mojo if (is_array($comments)) { echo '<p>' . __('Importing Comments...') . '<br /><br /></p>'; foreach ($comments as $comment) { $count++; extract($comment); // WordPressify Data $comment_ID = (int) ltrim($comment_id, '0'); $comment_post_ID = (int) $postarr[$post_id]; $comment_approved = "{$comment_pub}"; $name = $wpdb->escape(csc($comment_auteur)); $email = $wpdb->escape($comment_email); $web = "http://" . $wpdb->escape($comment_site); $message = $wpdb->escape(textconv($comment_content)); if ($cinfo = comment_exists($name, $comment_dt)) { // Update comments $ret_id = wp_update_comment(array('comment_ID' => $cinfo, 'comment_post_ID' => $comment_post_ID, 'comment_author' => $name, 'comment_author_email' => $email, 'comment_author_url' => $web, 'comment_author_IP' => $comment_ip, 'comment_date' => $comment_dt, 'comment_date_gmt' => $comment_dt, 'comment_content' => $message, 'comment_approved' => $comment_approved)); } else { // Insert comments $ret_id = wp_insert_comment(array('comment_post_ID' => $comment_post_ID, 'comment_author' => $name, 'comment_author_email' => $email, 'comment_author_url' => $web, 'comment_author_IP' => $comment_ip, 'comment_date' => $comment_dt, 'comment_date_gmt' => $comment_dt, 'comment_content' => $message, 'comment_approved' => $comment_approved)); } $dccm2wpcm[$comment_ID] = $ret_id; } // Store Comment ID translation for future use add_option('dccm2wpcm', $dccm2wpcm); // Associate newly formed categories with posts get_comment_count($ret_id); echo '<p>' . sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count) . '<br /><br /></p>'; return true; } echo __('No Comments to Import!'); return false; }
/** * Item meta for Posts stack */ function franz_stack_posts_meta() { $meta = array(); $meta['date'] = array('class' => 'date', 'meta' => '<a href="' . esc_url(get_permalink()) . '">' . get_the_time(get_option('date_format')) . '</a>'); $comment_count = get_comment_count(get_the_ID()); $comment_text = $comment_count['approved'] ? sprintf(_n('%d comment', '%d comments', $comment_count['approved'], 'franz-josef'), $comment_count['approved']) : __('Leave a reply', 'franz-josef'); $comments_link = $comment_count['approved'] ? get_comments_link() : str_replace('#comments', '#respond', get_comments_link()); $meta['comments'] = array('class' => 'comments-count', 'meta' => '<a href="' . $comments_link . '"><i class="fa fa-comment"></i> ' . $comment_text . '</a>'); $meta = apply_filters('franz_stack_posts_meta', $meta); if (!$meta) { return; } ?> <div class="item-meta clearfix"> <?php foreach ($meta as $item) { ?> <p class="<?php echo esc_attr($item['class']); ?> "><?php echo $item['meta']; ?> </p> <?php } ?> </div> <?php }
//促销信息 $smarty->assign('promotion_info', get_promotion_info()); /* 获得商品的信息 */ $goods = get_goods_info($goods_id); if ($goods === false) { /* 如果没有找到任何记录则跳回到首页 */ ecs_header("Location: ./\n"); exit; } else { if ($goods['brand_id'] > 0) { $goods['goods_brand_url'] = build_uri('brand', array('bid' => $goods['brand_id']), $goods['goods_brand']); } $shop_price = $goods['shop_price']; $linked_goods = get_linked_goods($goods_id); $goods['goods_style_name'] = add_style($goods['goods_name'], $goods['goods_name_style']); $goods['comment_count'] = get_comment_count($goods['goods_id']); /* 购买该商品可以得到多少钱的红包 */ if ($goods['bonus_type_id'] > 0) { $time = gmtime(); $sql = "SELECT type_money FROM " . $ecs->table('bonus_type') . " WHERE type_id = '{$goods['bonus_type_id']}' " . " AND send_type = '" . SEND_BY_GOODS . "' " . " AND send_start_date <= '{$time}'" . " AND send_end_date >= '{$time}'"; $goods['bonus_money'] = floatval($db->getOne($sql)); if ($goods['bonus_money'] > 0) { $goods['bonus_money'] = price_format($goods['bonus_money']); } } $goods['goods_desc'] = str_replace('src="/images/', 'src="' . $config['site_url'] . 'images/', $goods['goods_desc']); //修复产品详情的图片 by wang $smarty->assign('goods', $goods); $smarty->assign('goods_id', $goods['goods_id']); $smarty->assign('promote_end_time', $goods['gmt_end_time']); $smarty->assign('sales_count', get_goods_sales_count($goods['goods_id']));
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order) { $filter = isset($_REQUEST['filter']) ? intval($_REQUEST['filter']) : 0; $display = $GLOBALS['display']; $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 AND ({$children} OR " . get_extension_goods($children) . ')'; if ($filter == 1) { $where .= ' AND g.supplier_id=0 '; } elseif ($filter == 2) { $where .= ' AND g.supplier_id>0 '; } else { } if ($brand > 0) { /* 代码修改_start By www.68ecshop.com */ if (strstr($brand, '_')) { $brand_sql = str_replace("_", ",", $brand); $where .= "AND g.brand_id in ({$brand_sql}) "; } else { $where .= "AND g.brand_id={$brand} "; } /* 代码修改_end By www.68ecshop.com */ } if ($min > 0) { $where .= " AND g.shop_price >= {$min} "; } if ($max > 0) { $where .= " AND g.shop_price <= {$max} "; } if ($sort == goods_number) { $where .= " AND g.goods_number != 0 "; } /* 获得商品列表 */ $sort = $sort == 'shop_price' ? 'shop_p' : $sort; $sql = "SELECT g.goods_id, g.goods_name, g.goods_name_style, g.click_count, g.goods_number, g.market_price, " . " g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, " . " IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, " . " IF(g.promote_price != '' " . " AND g.promote_start_date < " . gmtime() . " AND g.promote_end_date > " . gmtime() . ", g.promote_price, shop_price) " . " AS shop_p, g.goods_type, " . " g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img " . " FROM " . $GLOBALS['ecs']->table('goods') . " AS g " . " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . " ON mp.goods_id = g.goods_id " . " AND mp.user_rank = '{$_SESSION['user_rank']}' " . " WHERE {$where} {$ext} " . " ORDER BY {$sort} {$order}"; if ($sort == 'salenum') { $sql = "SELECT IFNULL(o.num,0) AS salenum, g.goods_id, g.goods_name, g.click_count, g.goods_number, g.goods_name_style, " . " g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, " . " IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . " g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img " . " FROM " . $GLOBALS['ecs']->table('goods') . " AS g " . " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . " ON mp.goods_id = g.goods_id " . " AND mp.user_rank = '{$_SESSION['user_rank']}' " . " LEFT JOIN " . " (SELECT " . " SUM(og.`goods_number`) " . " AS num,og.goods_id " . " FROM " . " ecs_order_goods AS og, " . " ecs_order_info AS oi " . " WHERE oi.pay_status = 2 " . " AND oi.order_status >= 1 " . " AND oi.order_id = og.order_id " . " GROUP BY og.goods_id) " . " AS o " . " ON o.goods_id = g.goods_id " . " WHERE {$where} {$ext} " . " ORDER BY {$sort} {$order}"; } $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } /* 处理商品水印图片 */ $watermark_img = ''; if ($promote_price != 0) { $watermark_img = "watermark_promote_small"; } elseif ($row['is_new'] != 0) { $watermark_img = "watermark_new_small"; } elseif ($row['is_best'] != 0) { $watermark_img = "watermark_best_small"; } elseif ($row['is_hot'] != 0) { $watermark_img = 'watermark_hot_small'; } if ($watermark_img != '') { $arr[$row['goods_id']]['watermark_img'] = $watermark_img; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($display == 'grid') { $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $arr[$row['goods_id']]['goods_number'] = $row['goods_number']; $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['is_promote'] = $row['is_promote']; $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['is_hot'] = $row['is_hot']; $arr[$row['goods_id']]['is_best'] = $row['is_best']; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['comment_count'] = get_comment_count($row['goods_id']); $arr[$row['goods_id']]['count'] = selled_count($row['goods_id']); $arr[$row['goods_id']]['click_count'] = $row['click_count']; /* 检查是否已经存在于用户的收藏夹 */ $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('collect_goods') . " WHERE user_id='{$_SESSION['user_id']}' AND goods_id = " . $row['goods_id']; if ($GLOBALS['db']->GetOne($sql) > 0) { $arr[$row['goods_id']]['is_collet'] = 1; } else { $arr[$row['goods_id']]['is_collet'] = 0; } } return $arr; }
function dwqa_answer_columns_content($column_name, $post_ID) { $answer = get_post($post_ID); switch ($column_name) { case 'comment': $comment_count = get_comment_count($post_ID); echo '<a href="' . admin_url('edit-comments.php?p=' . $post_ID) . '" class="post-com-count"><span class="comment-count">' . $comment_count['approved'] . '</span></a>'; break; case 'info': //Build row actions $actions = array('edit' => sprintf('<a href="%s">%s</a>', get_edit_post_link($post_ID), __('Edit', 'edd-dw-membersip')), 'delete' => sprintf('<a href="%s">%s</a>', get_delete_post_link($post_ID), __('Delete', 'edd-dw-membersip')), 'view' => sprintf('<a href="%s">%s</a>', get_permalink($post_ID), __('View', 'edd-dw-membersip'))); printf('%s %s <a href="%s">%s %s</a> <br /> %s %s', __('Submitted', 'dwqa'), __('on', 'dwqa'), get_permalink(), date('M d Y', get_post_time('U', false, $answer)), time() - get_post_time('U', false, $answer) > 60 * 60 * 24 * 2 ? '' : ' at ' . human_time_diff(get_post_time('U', false, $answer)) . ' ago', substr(get_the_content(), 0, 140) . ' ...', dwqa_answer_row_actions($actions)); break; case 'dwqa-question': $question_id = get_post_meta($post_ID, '_question', true); $question = get_post($question_id); echo '<a href="' . get_permalink($question_id) . '" >' . $question->post_title . '</a><br>'; break; } }
</a></h3> <div class="article-meta"> <span><i class="glyphicon glyphicon-time"></i> <?php echo DATE('Y-m-d', strtotime($val->post_date)); ?> </span> <span><i class="glyphicon glyphicon-user"></i> <a href="<?php echo get_the_author_meta('url', $val->post_author); ?> "><?php echo get_the_author_meta('display_name', $val->post_author); ?> </a> </span> <span><i class="glyphicon glyphicon-comment"></i> <?php $_arr_comment = get_comment_count($val->ID); echo $_arr_comment['approved']; // echo_array(get_comment_count($val->ID)); ?> </span> </div> <?php if (has_post_thumbnail($val->ID)) { ?> <a href="<?php echo wp_get_shortlink($val->ID); ?> "> <div class="article-cover"><img class="img-rounded" src="<?php echo get_img_url($val->ID, array(360, 180));
/** * 获得品牌下的商品 * * @access private * @param integer $brand_id * @return array */ function brand_get_goods($brand_id, $cate, $size, $page, $sort, $order) { global $suppId; $cate_where = $cate > 0 ? 'AND ' . get_children($cate) : ''; /* 获得商品列表 */ /*$sql = 'SELECT g.goods_id, g.goods_name, g.click_count, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.supplier_id = '$suppId' AND g.brand_id = '$brand_id' $cate_where". "ORDER BY $sort $order";*/ $sql = 'SELECT g.goods_id, g.goods_name, g.click_count, g.goods_number, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '{$brand_id}' {$cate_where}" . "ORDER BY {$sort} {$order}"; /* 代码增加_start By www.68ecshop.com */ if ($sort == 'salenum') { $sql = 'SELECT SUM(o.goods_number) as salenum, g.goods_id, g.goods_name, g.click_count, g.goods_number, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "LEFT JOIN " . $GLOBALS['ecs']->table('order_goods') . " as o ON o.goods_id = g.goods_id " . " where g.brand_id = '{$brand_id}' {$ext} group by g.goods_id ORDER BY {$sort} {$order}"; } /* 代码增加_end By www.68ecshop.com */ $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($GLOBALS['display'] == 'grid') { $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['comment_count'] = get_comment_count($row['goods_id']); $arr[$row['goods_id']]['count'] = selled_count($row['goods_id']); $arr[$row['goods_id']]['click_count'] = $row['click_count']; $arr[$row['goods_id']]['goods_number'] = $row['goods_number']; /* 检查是否已经存在于用户的收藏夹 */ $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('collect_goods') . " WHERE user_id='{$_SESSION['user_id']}' AND goods_id = " . $row['goods_id']; if ($GLOBALS['db']->GetOne($sql) > 0) { $arr[$row['goods_id']]['is_collet'] = 1; } else { $arr[$row['goods_id']]['is_collet'] = 0; } } return $arr; }
public function getNumberOfAnswers() { $answers = get_comment_count($this->getId()); if ($answers && is_array($answers)) { return $answers['approved']; } return 0; }
* Project dashboard page */ cpm_get_header(__('Activity', 'cpm'), $project_id); ?> <h3 class="cpm-nav-title"> <?php _e('Project Activity', 'cpm'); if (cpm_user_can_access($project_id)) { cpm_project_actions($project_id); } ?> </h3> <ul class="cpm-activity dash"> <?php $count = get_comment_count($project_id); $activities = CPM_project::getInstance()->get_activity($project_id, array()); if ($activities) { echo cpm_activity_html($activities); } ?> </ul> <?php if ($count['approved'] > count($activities)) { ?> <a href="#" <?php cpm_data_attr(array('project_id' => $project_id, 'start' => count($activities) + 1, 'total' => $count['approved'])); ?> class="button cpm-load-more"><?php _e('Load More...', 'cpm');
public function comment_form() { if (empty($_POST['comment'])) { $this->result = ap_ajax_responce('comment_content_empty'); return; } if (!isset($_REQUEST['comment_ID'])) { // Do security check if (!ap_user_can_comment() || !isset($_POST['__nonce']) || !wp_verify_nonce($_POST['__nonce'], 'comment_' . (int) $_POST['comment_post_ID'])) { $this->result = ap_ajax_responce('no_permission'); return; } } else { if (!ap_user_can_edit_comment((int) $_REQUEST['comment_ID']) || !wp_verify_nonce($_REQUEST['__nonce'], 'comment_' . (int) $_REQUEST['comment_ID'])) { $this->result = ap_ajax_responce('no_permission'); return; } } $comment_post_ID = (int) $_POST['comment_post_ID']; $post = get_post($comment_post_ID); if (!$post || empty($post->post_status)) { return; } if (in_array($post->post_status, array('draft', 'pending', 'trash'))) { $this->result = ap_ajax_responce('draft_comment_not_allowed'); return; } if (isset($_POST['comment_ID'])) { $comment_id = (int) $_POST['comment_ID']; $updated = wp_update_comment(array('comment_ID' => $comment_id, 'comment_content' => trim($_POST['comment']))); if ($updated) { $comment = get_comment($comment_id); ob_start(); comment_text($comment_id); $html = ob_get_clean(); $this->result = ap_ajax_responce(array('action' => 'edit_comment', 'comment_ID' => $comment->comment_ID, 'comment_post_ID' => $comment->comment_post_ID, 'comment_content' => $comment->comment_content, 'html' => $html, 'message' => 'comment_edit_success')); } return; } else { $user = wp_get_current_user(); if ($user->exists()) { $user_ID = $user->ID; $comment_author = wp_slash($user->display_name); $comment_author_email = wp_slash($user->user_email); $comment_author_url = wp_slash($user->user_url); $comment_content = trim($_POST['comment']); $comment_type = 'anspress'; } else { $this->result = ap_ajax_responce('no_permission'); return; } $comment_parent = 0; if (isset($_POST['comment_ID'])) { $comment_parent = absint($_POST['comment_ID']); } $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); // Automatically approve parent comment. if (!empty($_POST['approve_parent'])) { $parent = get_comment($comment_parent); if ($parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID) { if (wp_set_comment_status($parent->comment_ID, 'approve')) { $comment_auto_approved = true; } } } $comment_id = wp_new_comment($commentdata); if ($comment_id > 0) { $comment = get_comment($comment_id); do_action('ap_after_new_comment', $comment); ob_start(); ap_comment($comment); $html = ob_get_clean(); $count = get_comment_count($comment->comment_post_ID); $this->result = ap_ajax_responce(array('action' => 'new_comment', 'status' => true, 'comment_ID' => $comment->comment_ID, 'comment_post_ID' => $comment->comment_post_ID, 'comment_content' => $comment->comment_content, 'html' => $html, 'message' => 'comment_success', 'view' => array('comments_count_' . $comment->comment_post_ID => '(' . $count['approved'] . ')', 'comment_count_label_' . $comment->comment_post_ID => sprintf(_n('One comment', '%d comments', $count['approved'], 'ap'), $count['approved'])))); } else { $this->result = ap_ajax_responce('something_wrong'); } } }
$arr[$row['goods_id']]['goods_name_www_68ecshop_com'] = preg_replace('/(?!<[^>]*)' . $temp_qq . '(?![^<]*>)/i', '<strong style="color:#cc0000;">' . $temp_qq . '</strong>', $arr[$row['goods_id']]['goods_name_www_68ecshop_com']); } /* 代码添加_END By www.68ecshop.com */ $arr[$row['goods_id']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $arr[$row['goods_id']]['evaluation'] = get_evaluation_sum($row['goods_id']); $arr[$row['goods_id']]['is_new'] = $row['is_new']; $arr[$row['goods_id']]['is_best'] = $row['is_best']; $arr[$row['goods_id']]['is_hot'] = $row['is_hot']; $arr[$row['goods_id']]['comment_count'] = get_comment_count($row['goods_id']); $arr[$row['goods_id']]['count'] = selled_count($row['goods_id']); $arr[$row['goods_id']]['click_count'] = $row['click_count']; $arr[$row['goods_id']]['goods_number'] = $row['goods_number']; /* 检查是否已经存在于用户的收藏夹 */ $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('collect_goods') . " WHERE user_id='{$_SESSION['user_id']}' AND goods_id = " . $row['goods_id']; if ($GLOBALS['db']->GetOne($sql) > 0) { $arr[$row['goods_id']]['is_collet'] = 1; } else { $arr[$row['goods_id']]['is_collet'] = 0; } } if ($display == 'grid') { if (count($arr) % 2 != 0) { $arr[] = array(); }
/** * Ajax action for deleting comment. * * @since 2.0.0 */ public function delete_comment() { $comment_id = (int) $_POST['comment_ID']; if (isset($_POST['comment_ID']) && ap_user_can_delete_comment($comment_id) && wp_verify_nonce($_POST['__nonce'], 'delete_comment')) { $comment = get_comment($comment_id); if (time() > get_comment_date('U', (int) $_POST['comment_ID']) + (int) ap_opt('disable_delete_after') && !is_super_admin()) { ap_send_json(ap_ajax_responce(array('message_type' => 'warning', 'message' => sprintf(__('This post was created %s, its locked hence you cannot delete it.', 'anspress-question-answer'), ap_human_time(get_comment_date('U', (int) $_POST['comment_ID'])))))); return; } do_action('ap_unpublish_comment', $comment); $delete = wp_delete_comment((int) $_POST['comment_ID'], true); if ($delete) { do_action('ap_after_deleting_comment', $comment); $count = get_comment_count($comment->comment_post_ID); $this->send(array('action' => 'delete_comment', 'comment_ID' => (int) $_POST['comment_ID'], 'message' => 'comment_delete_success', 'message' => 'comment_delete_success', 'view' => array('comments_count_' . $comment->comment_post_ID => '(' . $count['approved'] . ')', 'comment_count_label_' . $comment->comment_post_ID => sprintf(_n('One comment', '%d comments', $count['approved'], 'anspress-question-answer'), $count['approved'])))); } $this->something_wrong(); } $this->send('no_permission'); }
function wp_getCommentCount($args) { $this->escape($args); $blog_id = (int) $args[0]; $username = $args[1]; $password = $args[2]; $post_id = (int) $args[3]; if (!$this->login_pass_ok($username, $password)) { return new IXR_Error(403, __('Bad login/pass combination.')); } set_current_user(0, $username); if (!current_user_can('edit_posts')) { return new IXR_Error(403, __('You are not allowed access to details about comments.')); } do_action('xmlrpc_call', 'wp.getCommentCount'); return get_comment_count($post_id); }
/** * Use this function to cache the comment counting in the wp menu that can be slow on sites with lots of comments * use like this: * * @param $post_id * * @see wp_count_comments() * @return bool|false|mixed|string */ function wpcom_vip_cache_full_comment_counts($counts = false, $post_id = 0) { // We are only caching the global comment counts for now since those are often in the millions while the per page one is usually more reasonable. if (0 !== $post_id) { return $counts; } $cache_key = "vip-comments-{$post_id}"; $stats_object = wp_cache_get($cache_key); // retrieve comments in the same way wp_count_comments() does if (false === $stats_object) { $stats = get_comment_count($post_id); $stats['moderated'] = $stats['awaiting_moderation']; unset($stats['awaiting_moderation']); $stats_object = (object) $stats; wp_cache_set($cache_key, $stats_object, 'default', 30 * MINUTE_IN_SECONDS); } return $stats_object; }
function bp_checkins_live_get_new_comments() { if (empty($_POST['place_id'])) { $result['contents'] = 0; echo json_encode($result); return false; } $all_count = get_comment_count($_POST['place_id']); $comments = array(); $begin = $end = false; if (!empty($_POST['displayed_count'])) { $allready_displayed = $_POST['displayed_count']; $new = $all_count['approved'] - $allready_displayed; if ($new >= 1) { $comments = get_comments(array('post_id' => $_POST['place_id'], 'offset' => $new, 'number' => $new, 'order' => 'ASC')); } } else { if ($all_count['approved'] >= 1 && empty($_POST['displayed_count'])) { $comments = get_comments(array('post_id' => $_POST['place_id'])); } } if (count($comments) >= 1) { add_filter('comment_class', 'bp_checkins_add_live_comment_class'); $result = array(); if (empty($_POST['displayed_count'])) { $begin = '<div id="comments"><h3>' . __('<span>1</span> response(s)', 'bp-checkins') . '</h3><ol class="commentlist">'; $end = '</ol></div>'; $result['add_div'] = 1; } ob_start(); wp_list_comments(array('callback' => 'bp_checkins_list_comments', 'type' => 'comment', 'reverse_top_level' => 'ASC'), $comments); $result['contents'] = $begin . ob_get_contents() . $end; $result['comment_count'] = $all_count['approved']; ob_end_clean(); } else { $result['contents'] = 0; } echo json_encode($result); exit; }
• by <?php if (function_exists(coauthors_posts_links)) { coauthors_posts_links(); } else { the_author_posts_link(); } ?> • <?php if (in_category($featureddemo_id)) { fc_category_minusdemo(', '); } else { the_category(', '); } ?> • <?php $comment_count = get_comment_count($post->ID); if (comments_open() || $comment_count['approved'] > 0) { ?> <a href="<?php comments_link(); ?> "><?php comments_number('No comments yet', '1 comment', '% comments'); ?> </a> <?php } else { ?> Comments off <?php }
/** * Latest News Shortcode * @param array $atts * @param string $content * @return html $output */ function rt_latest_news($atts = array(), $content = null) { global $rt_post_values, $rt_blog_list_atts; //defaults $atts = shortcode_atts(array("id" => "", "image_width" => 250, "image_height" => 250, "list_orderby" => "date", "list_order" => "DESC", "max_item" => 10, "categories" => "", "excerpt_length" => 100, "style" => 1, "show_dates" => false), $atts); extract($atts); //id attr $id_attr = !empty($id) ? 'id="' . $id . '"' : ""; //create a post status array $post_status = is_user_logged_in() ? array('private', 'publish') : "publish"; //general query $args = array('post_status' => $post_status, 'post_type' => 'post', 'orderby' => $list_orderby, 'order' => $list_order, 'showposts' => $max_item); if (!empty($categories)) { $categories = is_array($categories) ? $categories : explode(",", rt_wpml_lang_object_ids($categories, "category")); $args = array_merge($args, array('tax_query' => array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => $categories, 'operator' => "IN")))); } $wp_query = new WP_Query($args); $output = ""; //get posts if ($wp_query->have_posts()) { //the loop while ($wp_query->have_posts()) { $wp_query->the_post(); $post_title = get_the_title(); $link = get_permalink(); $date = get_the_time('d M Y'); $comment_count = get_comment_count($wp_query->post->ID); $featured_image_id = get_post_thumbnail_id(); $get_the_excerpt = $excerpt_length > 0 ? '<p>' . wp_html_excerpt(get_the_excerpt(), $excerpt_length) . '...</p>' : ""; // Create thumbnail image $thumbnail_image_output = !empty($featured_image_id) ? get_resized_image_output(array("image_url" => "", "image_id" => $featured_image_id, "w" => $image_width, "h" => $image_height, "crop" => "true", "class" => "posts-image")) : ""; if (empty($thumbnail_image_output) || !empty($show_thumbnails)) { $thumbnail_image_output = ""; } if ($style == 1) { /** * Output Style 1 */ $output .= '<article>' . "\n"; $output .= sprintf(' <div class="date"> <span class="day">%1$s</span> <span class="year">%2$s %3$s</span> </div> ' . "\n", get_the_time("d"), get_the_time("M"), get_the_time("y")); $output .= sprintf(' <div class="text"> <h5 class="clean_heading"><a class="title" href="%1$s" title="%2$s" rel="bookmark">%2$s</a></h5> %3$s </div> ' . "\n", $link, $post_title, $get_the_excerpt); $output .= '</article>' . "\n"; } else { /** * Output Style 2 */ $output .= '<article>' . "\n"; $output .= !empty($thumbnail_image_output) ? sprintf(' <figure>%1$s</figure> ' . "\n", $thumbnail_image_output) : ""; $date = !empty($show_dates) ? '<span class="date">' . get_the_date() . '</span>' : ""; $output .= sprintf(' <div class="text"> %3$s <h5 class="clean_heading"><a class="title" href="%1$s" title="%2$s" rel="bookmark">%2$s</a></h5> %4$s </div> ' . "\n", $link, $post_title, $date, $get_the_excerpt); $output .= '</article>' . "\n"; } } //reset post data for the new query wp_reset_postdata(); } //create holder html $output = !empty($output) ? '<section class="latest_news clearfix style-' . $style . '">' . $output . '</section>' : ""; return $output; }
/** * Retrieve total comments for blog or single post. * * The properties of the returned object contain the 'moderated', 'approved', * and spam comments for either the entire blog or single post. Those properties * contain the amount of comments that match the status. The 'total_comments' * property contains the integer of total comments. * * The comment stats are cached and then retrieved, if they already exist in the * cache. * * @since 2.5.0 * * @param int $post_id Optional. Post ID. * @return object|array Comment stats. */ function wp_count_comments($post_id = 0) { $post_id = (int) $post_id; /** * Filter the comments count for a given post. * * @since 2.7.0 * * @param array $count An empty array. * @param int $post_id The post ID. */ $filtered = apply_filters('wp_count_comments', array(), $post_id); if (!empty($filtered)) { return $filtered; } $count = wp_cache_get("comments-{$post_id}", 'counts'); if (false !== $count) { return $count; } $stats = get_comment_count($post_id); $stats['moderated'] = $stats['awaiting_moderation']; unset($stats['awaiting_moderation']); $stats_object = (object) $stats; wp_cache_set("comments-{$post_id}", $stats_object, 'counts'); return $stats_object; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $categories = empty($instance['categories']) ? $instance['categories'] : implode($instance['categories'], ','); $count = empty($instance['count']) ? 5 : $instance['count']; $limit = empty($instance['limit']) ? 100 : $instance['limit']; $show_thumbnails = $instance['show_thumbnails']; $show_excerpt = $instance['show_excerpt']; $thumb_width = empty($instance['thumb_width']) ? 260 : $instance['thumb_width']; $thumb_height = empty($instance['thumb_height']) ? 260 : $instance['thumb_height']; //remove aside and quote post formats from the list $postargs = array('tax_query' => array(array('operator' => 'NOT IN', 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-quote', 'post-format-aside'))), 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1); $post_query = new WP_Query($postargs); $rt_posts = '<section class="latest-news-2 clearfix"><ul>'; if ($post_query->have_posts()) { while ($post_query->have_posts()) { $post_query->the_post(); $post_title = get_the_title(); $link = get_permalink(); $date = get_the_time('d M Y'); $comment_count = get_comment_count($post_query->post->ID); $featured_image_id = get_post_thumbnail_id(); $get_the_excerpt = $show_excerpt ? '<p>' . wp_html_excerpt(get_the_excerpt(), $limit) . '...</p>' : ""; // Create thumbnail image $thumbnail_image_output = !empty($featured_image_id) ? get_resized_image_output(array("image_url" => "", "image_id" => $featured_image_id, "w" => $thumb_width, "h" => $thumb_height, "crop" => 1, "class" => "-posts-thumb")) : ""; if (empty($thumbnail_image_output) || !empty($show_thumbnails)) { $thumbnail_image_output = ""; } if ($comment_count['approved'] > 0) { if ($comment_count['approved'] > 1) { $comments = $comment_count['approved'] . ' ' . __('Comments', 'rt_theme'); } else { $comments = __('1 Comment', 'rt_theme'); } $comment = ' <span class="comment_number"><span class="icon-comment-empty"></span><a href="' . get_comments_link() . '" title="' . $comments . '" class="comment_link">' . $comment_count['approved'] . '</a></span>'; } $rt_posts .= '<li class="clearfix">'; $rt_posts .= sprintf(' <section> <div class="date_box"> <span class="day">%1$s</span> <span class="year">%2$s %3$s</span> </div> </section> ', get_the_time("d"), get_the_time("M"), get_the_time("y")); $rt_posts .= sprintf(' <section> %1$s <a class="title" href="%2$s" title="%3$s" rel="bookmark">%3$s</a> %4$s </section> ', $thumbnail_image_output, $link, $post_title, $get_the_excerpt); $rt_posts .= '</li>'; } } wp_reset_query(); $rt_posts .= '</ul></section>'; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo $rt_posts; echo $after_widget; }