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


PHP get_comment_count函数代码示例

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


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

示例1: converio_recent_posts

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;
}
开发者ID:javalidigital,项目名称:tecnigrav,代码行数:35,代码来源:recent_posts.php

示例2: widget

 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;
 }
开发者ID:patrickouc,项目名称:wordpress2,代码行数:58,代码来源:popular_posts.php

示例3: 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;
        }
开发者ID:ryan-konkolewski,项目名称:rt-theme-19-extentions-multisite,代码行数:58,代码来源:popular_posts.php

示例4: 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;
    }
开发者ID:MenZil-Team,项目名称:gulzar,代码行数:56,代码来源:blog_info.php

示例5: test_get_comment_count_post_trashed

 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']);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:11,代码来源:getCommentCount.php

示例6: widget

 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;
 }
开发者ID:nikolaev-k,项目名称:alwadi,代码行数:53,代码来源:popular_posts.php

示例7: is_flood

 /**
  * @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;
 }
开发者ID:postmatic,项目名称:beta-dist,代码行数:17,代码来源:comment-flood-controller.php

示例8: cfgp_batch_import_blog

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);
//.........这里部分代码省略.........
开发者ID:bigdawggi,项目名称:wp-cf-global-posts,代码行数:101,代码来源:cf-global-posts.php

示例9: comments_number

    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(__('&larr; Older Comments', 'adaptive-framework'));
        ?>
</p>
            <p class="fl"> <?php 
        next_comments_link(__('Newer Comments &rarr;', 'adaptive-framework'));
        ?>
</p>
        </div> <!-- end comments-nav-section -->

    <?php 
    }
开发者ID:ankitparsanaa,项目名称:foodapp,代码行数:31,代码来源:comments.php

示例10: widget

    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;
    }
开发者ID:carpliyz,项目名称:9IPHP,代码行数:44,代码来源:widgets.php

示例11: match_trigger


//.........这里部分代码省略.........
         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;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:101,代码来源:class-wp-stream-notifications-matcher.php

示例12: comments2wp

 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;
 }
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:40,代码来源:dotclear.php

示例13: franz_stack_posts_meta

/**
 * 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 
}
开发者ID:samuel657677,项目名称:flipbook,代码行数:33,代码来源:stacks.php

示例14: get_promotion_info

 //促销信息
 $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']));
开发者ID:YangZeSummer,项目名称:NanJingSecond-Hand,代码行数:31,代码来源:goods2.php

示例15: category_get_goods

/**
 * 获得分类下的商品
 *
 * @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;
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:99,代码来源:category.php


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