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

PHP get_approved_comments函数代码示例

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

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



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

示例1: test_get_approved_comments_with_post_id_0_should_return_empty_array

 /**
  * @ticket 30412
  */
 public function test_get_approved_comments_with_post_id_0_should_return_empty_array()
 {
     $p = $this->factory->post->create();
     $ca1 = $this->factory->comment->create(array('comment_post_ID' => $p, 'comment_approved' => '1'));
     $found = get_approved_comments(0);
     $this->assertSame(array(), $found);
 }
开发者ID:plis197715,项目名称:wordpress-develop,代码行数:10,代码来源:comment.php


示例2: digressit_add_comment_change_notice

/**
 * 
 */
function digressit_add_comment_change_notice()
{
    $comments = get_approved_comments($_GET['post']);
    if (count($comments)) {
        add_action('admin_notices', 'digressit_change_content_warning');
    }
}
开发者ID:angelmoratilla,项目名称:digressit,代码行数:10,代码来源:admin-functions.php


示例3: filterCommentsNumber

function filterCommentsNumber($count)
{
    global $id;
    if (empty($id)) {
        return $count;
    }
    $comments = get_approved_comments((int) $id);
    $comments = array_filter($comments, "stripTrackback");
    return sizeof($comments);
}
开发者ID:alx,项目名称:barceloneta,代码行数:10,代码来源:functions.php


示例4: k2_comment_count

/**
 * Updates comment count to only include comments
 *
 * @since 1.0
 * @global int $id The current post id
 *
 * @param int $count Current number of comments/pings of current post
 *
 * @return int The number of comments only
 */
function k2_comment_count($count)
{
    global $id;
    if ($count == 0) {
        return $count;
    }
    $comments = get_approved_comments($id);
    $comments = array_filter($comments, 'k2_strip_trackback');
    return count($comments);
}
开发者ID:r15ch13,项目名称:unwakeable,代码行数:20,代码来源:comments.php


示例5: comment_count

 /**
  * Don't count reactions when determining
  * the number of comments on a post.
  */
 public function comment_count($count)
 {
     global $id;
     $comment_count = 0;
     $comments = get_approved_comments($id);
     foreach ($comments as $comment) {
         if ('emoji-reaction' !== $comment->comment_type) {
             $comment_count++;
         }
     }
     return $comment_count;
 }
开发者ID:justinshreve,项目名称:emoji-reactions,代码行数:16,代码来源:prevent-reactions-in-comments.php


示例6: wiziapp_getCommentsCount

function wiziapp_getCommentsCount($post_id)
{
    $comments = get_approved_comments($post_id);
    /**
     * @todo check for failures
     */
    $status = TRUE;
    $message = '';
    $header = array('action' => 'commentsCount', 'status' => $status, 'code' => $status ? 200 : 4004, 'message' => $message);
    echo json_encode(array('header' => $header, 'count' => count($comments)));
    exit;
}
开发者ID:sajidsan,项目名称:sajidsan.github.io,代码行数:12,代码来源:util_webservices.php


示例7: vp_filter_comments_count

/**
 * Comments count without pingback/trackback.
 *
 * @since 0.0.1
 *
 * @param int $count The filter need this.
 * @return int The comments number.
 */
function vp_filter_comments_count($count)
{
    global $id;
    $comments = get_approved_comments($id);
    $comment_count = 0;
    foreach ($comments as $comment) {
        if ($comment->comment_type == "") {
            $comment_count++;
        }
    }
    return $comment_count;
}
开发者ID:nacheal,项目名称:V2Press,代码行数:20,代码来源:custom-comment.php


示例8: get_items

 /**
  * Get all reviews from a product.
  *
  * @param WP_REST_Request $request
  * @return array
  */
 public function get_items($request)
 {
     $product = get_post((int) $request['product_id']);
     if (empty($product->post_type) || 'product' !== $product->post_type) {
         return new WP_Error('woocommerce_rest_product_invalid_id', __('Invalid product id.', 'woocommerce'), array('status' => 404));
     }
     $reviews = get_approved_comments($product->ID);
     $data = array();
     foreach ($reviews as $review_data) {
         $review = $this->prepare_item_for_response($review_data, $request);
         $review = $this->prepare_response_for_collection($review);
         $data[] = $review;
     }
     return rest_ensure_response($data);
 }
开发者ID:unfulvio,项目名称:woocommerce,代码行数:21,代码来源:class-wc-rest-product-reviews-controller.php


示例9: __construct

 /**
  * Builds an email without specific recipient info that can be used as a template for all recipients.
  *
  * The set_recipient method can be called to fill in recipient-specific fields.
  *
  * @since 2.0.0
  *
  * @param Prompt_Post_Rendering_Context $context      Rendering context for the target post
  * @param array                         $args         {
  * @type bool                           $excerpt_only Override the excerpt only checkbox in the delivery metabox.
  *                                                    }
  */
 public function __construct(Prompt_Post_Rendering_Context $context, $args = array())
 {
     $this->context = $context;
     $context->setup();
     $prompt_author = $context->get_author();
     $prompt_post = $context->get_post();
     $is_api_delivery = Prompt_Enum_Email_Transports::API == Prompt_Core::$options->get('email_transport');
     $will_strip_content = (!$is_api_delivery and $context->has_fancy_content());
     $subject = html_entity_decode($prompt_post->get_wp_post()->post_title, ENT_QUOTES);
     list($footnote_html, $footnote_text) = $this->footnote_content();
     if ('draft' == $prompt_post->get_wp_post()->post_status) {
         /* translators: %s is a post title */
         $subject = sprintf(__('PREVIEW of %s', 'Postmatic'), $subject);
         $footnote_html = $footnote_text = '';
     }
     $excerpt_only = Prompt_Admin_Delivery_Metabox::excerpt_only($prompt_post->id());
     if (isset($args['excerpt_only'])) {
         $excerpt_only = $args['excerpt_only'];
     }
     $this->comments = get_approved_comments($prompt_post->id());
     $template_data = array('prompt_author' => $prompt_author, 'prompt_post' => $prompt_post, 'featured_image_src' => $context->get_the_featured_image_src(), 'excerpt_only' => $excerpt_only, 'the_text_content' => $context->get_the_text_content(), 'subject' => $subject, 'alternate_versions_menu' => $context->alternate_versions_menu(), 'is_api_delivery' => $is_api_delivery, 'will_strip_content' => $will_strip_content, 'comments' => $this->comments);
     /**
      * Filter new post email template data.
      *
      * @param array      $template_data      {
      * @type Prompt_User $prompt_author
      * @type Prompt_Post $prompt_post
      * @type array       $featured_image_src url, width, height
      * @type bool        $excerpt_only       whether to include only the post excerpt
      * @type string      $the_text_content
      * @type string      $subject
      * @type bool        $is_api_delivery
      * @type bool        $will_strip_content
      *                                       }
      */
     $template_data = apply_filters('prompt/post_email/template_data', $template_data);
     $html_template = new Prompt_Template("new-post-email.php");
     $text_template = new Prompt_Text_Template("new-post-email-text.php");
     $batch_message_template = array('subject' => $subject, 'from_name' => '{{{from_name}}}', 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::POST, 'reply_to' => '{{{reply_to}}}', 'footnote_html' => $footnote_html, 'footnote_text' => $footnote_text);
     $this->replyable = (comments_open($prompt_post->id()) and !$excerpt_only);
     if (!$this->replyable) {
         $batch_message_template['from_address'] = $prompt_author->get_wp_user()->user_email;
     }
     $default_values = array('from_name' => $this->to_utf8(get_option('blogname')));
     $context->reset();
     parent::__construct($batch_message_template, array(), $default_values);
 }
开发者ID:postmatic,项目名称:beta-dist,代码行数:59,代码来源:post-email-batch.php


示例10: dsq_can_replace

function dsq_can_replace()
{
    global $id, $post;
    $replace = get_option('disqus_replace');
    if ('draft' == $post->post_status) {
        return false;
    }
    if (!get_option('disqus_forum_url')) {
        return false;
    } else {
        if ('all' == $replace) {
            return true;
        }
    }
    if (!isset($post->comment_count)) {
        $num_comments = 0;
    } else {
        if ('empty' == $replace) {
            // Only get count of comments, not including pings.
            // If there are comments, make sure there are comments (that are not track/pingbacks)
            if ($post->comment_count > 0) {
                // Yuck, this causes a DB query for each post.  This can be
                // replaced with a lighter query, but this is still not optimal.
                $comments = get_approved_comments($post->ID);
                foreach ($comments as $comment) {
                    if ($comment->comment_type != 'trackback' && $comment->comment_type != 'pingback') {
                        $num_comments++;
                    }
                }
            } else {
                $num_comments = 0;
            }
        } else {
            $num_comments = $post->comment_count;
        }
    }
    return 'empty' == $replace && 0 == $num_comments || 'closed' == $replace && 'closed' == $post->comment_status;
}
开发者ID:simpsonjulian,项目名称:puppet-wordpress,代码行数:38,代码来源:disqus.php


示例11: hs_count_only_comments

 function hs_count_only_comments($post_id)
 {
     $count = 0;
     $comment_array = get_approved_comments($post_id);
     foreach ($comment_array as $comment) {
         if ($comment->comment_type == '') {
             $count++;
         }
     }
     return $count;
 }
开发者ID:venturepact,项目名称:blog,代码行数:11,代码来源:hs-tracking.php


示例12: wiziapp_buildPostCommentSubCommentsPage

/**
* TODO: Add paging support here
* 
*/
function wiziapp_buildPostCommentSubCommentsPage($post_id, $p_comment_id)
{
    //    $numberOfPosts = appcom_getAppCommentsListLimit();
    $screen_conf = $GLOBALS['WiziappScreens']->getScreenLayout('comments', 'sub_list');
    $page = array();
    $comments = get_approved_comments($post_id);
    // First add the parent comment to the list
    $parentCommentSection = array('section' => array('title' => '', 'id' => 'parent_comment', 'items' => array()));
    $subCommentsSection = array('section' => array('title' => '', 'id' => 'subComments', 'items' => array()));
    $comment = get_comment($p_comment_id);
    wiziapp_appendComponentByLayout($parentCommentSection['section']['items'], $screen_conf['header'], $comment);
    foreach ($comments as $comment) {
        // Only add top level comments unless told otherwise
        if ($comment->comment_parent == $p_comment_id) {
            wiziapp_appendComponentByLayout($subCommentsSection['section']['items'], $screen_conf['items'], $comment);
        }
    }
    //$post = get_post($post_id);
    //$title = str_replace('&', '&', $post->post_title);
    $title = __("Comments", 'title');
    $screen = wiziapp_prepareSectionScreen(array($parentCommentSection, $subCommentsSection), $title, "List");
    echo json_encode($screen);
}
开发者ID:sajidsan,项目名称:sajidsan.github.io,代码行数:27,代码来源:screens.php


示例13: extract_xml

 function extract_xml($siteId, $offset = 0)
 {
     $maxqueries = 50;
     $maxlength = 500000;
     $index = $offset;
     $next_chunk = false;
     $total_queries = 0;
     do {
         $total_queries++;
         if ($total_queries > $maxqueries) {
             $next_chunk = true;
             break;
         }
         $args = array('post_type' => 'any', 'numberposts' => 20, 'offset' => $index);
         $myposts = new WP_Query($args);
         if (!isset($articles)) {
             $articles = '';
         }
         $inner_idx = 0;
         if ($myposts->have_posts()) {
             while ($myposts->have_posts()) {
                 $myposts->the_post();
                 if ($parent_id = wp_is_post_revision(get_the_ID())) {
                     $post_id = $parent_id;
                 } else {
                     $post_id = get_the_ID();
                 }
                 $newArticle = '<article id="' . $post_id . '"><title>' . $this->comment_data_filter(get_the_title()) . '</title><source>' . get_permalink(get_the_ID()) . '</source>';
                 if (get_post_time('c', true) != null && !strstr(get_post_time('c', true), '0000-00-00')) {
                     $newArticle .= '<created>' . preg_replace('/\\s/', 'T', get_post_time('c', true)) . 'Z</created>';
                 }
                 $comment_array = get_approved_comments(get_the_ID());
                 $comment_array = array_filter($comment_array, array('LFAPPS_Comments_Import_Impl', 'skip_trackback_filter'));
                 foreach ($comment_array as $comment) {
                     $comment_content = $this->comment_data_filter($comment->comment_content);
                     if ($comment_content == "") {
                         continue;
                         #don't sync blank
                     }
                     $commentParent = $comment->comment_parent ? " parent-id=\"{$comment->comment_parent}\"" : '';
                     $commentXML = "<comment id=\"{$comment->comment_ID}\"{$commentParent}>";
                     $commentXML .= '<author format="html">' . $this->comment_data_filter($comment->comment_author) . '</author>';
                     $commentXML .= '<author-email format="html">' . $this->comment_data_filter($comment->comment_author_email) . '</author-email>';
                     $commentXML .= '<author-url format="html">' . $this->comment_data_filter($comment->comment_author_url) . '</author-url>';
                     $commentXML .= '<body format="wphtml">' . $comment_content . '</body>';
                     $use_date = $comment->comment_date_gmt;
                     if ($use_date == '0000-00-00 00:00:00Z') {
                         $use_date = $comment->comment_date;
                     }
                     if ($use_date != null && !strstr($use_date, '0000-00-00')) {
                         $commentXML .= '<created>' . preg_replace('/\\s/', 'T', $use_date) . 'Z</created>';
                     } else {
                         // We need to supply a datetime so the XML parser does not fail
                         $now = new DateTime();
                         $commentXML .= '<created>' . $now->format('Y-m-d\\TH:i:s\\Z') . '</created>';
                     }
                     $commentXML .= '</comment>';
                     $newArticle .= $commentXML;
                 }
                 $newArticle .= '</article>';
                 if (strlen($newArticle) + strlen($articles) > $maxlength && strlen($articles)) {
                     $next_chunk = true;
                     break;
                 } else {
                     $inner_idx += 1;
                     $articles .= $newArticle;
                 }
                 unset($newArticle);
             }
         }
     } while ($myposts->found_posts != 0 && !$next_chunk && ($index = $index + 10));
     if (strlen($articles) == 0) {
         return 'no-data';
     } else {
         return 'to-offset:' . ($inner_idx + $index) . "\n" . $this->wrap_xml($articles);
     }
 }
开发者ID:GiantRobX,项目名称:wordpress-vip-plugins,代码行数:77,代码来源:LFAPPS_Comments_Import_Impl.php


示例14: wp_geshi_filter_and_replace_code_snippets

function wp_geshi_filter_and_replace_code_snippets()
{
    global $wp_query;
    global $wp_geshi_comments;
    // Iterate over all posts in this query.
    foreach ($wp_query->posts as $post) {
        // Extract code snippets from the content. Replace them.
        $post->post_content = wp_geshi_filter_replace_code($post->post_content);
        // Iterate over all approved comments belonging to this post.
        // Store comments with uuid (code replacement) in `$wp_geshi_comments`.
        $comments = get_approved_comments($post->ID);
        foreach ($comments as $comment) {
            $wp_geshi_comments[$comment->comment_ID] = wp_geshi_filter_replace_code($comment->comment_content);
        }
    }
}
开发者ID:Air-Craft,项目名称:air-craft-www,代码行数:16,代码来源:wp-geshi-highlight.php


示例15: filter_comments_number

 public static function filter_comments_number($count)
 {
     global $id;
     if (empty($id)) {
         return $count;
     }
     $comments = get_approved_comments((int) $id);
     $comments = array_filter($comments, array("AECUtility", 'filter_strip_trackbacks'));
     return sizeof($comments);
 }
开发者ID:EfncoPlugins,项目名称:ajax-edit-comments,代码行数:10,代码来源:class.filters.php


示例16: mystique_comment_count

function mystique_comment_count($comment_types = 'comments', $post_id = false)
{
    global $id;
    $post_id = (int) $post_id;
    if (!$post_id) {
        $post_id = $id;
    }
    $comments = get_approved_comments($post_id);
    $num_pings = 0;
    $num_comments = 0;
    foreach ($comments as $comment) {
        if (get_comment_type() != "comment") {
            $num_pings++;
        } else {
            $num_comments++;
        }
    }
    return $comment_types == 'comments' ? $num_comments : $num_pings;
}
开发者ID:nottombrown,项目名称:vlab,代码行数:19,代码来源:core.php


示例17: get_approved_comments

 /**
  * LazyestCommentor::get_approved_comments()
  * Adds filevar varaiable to comments
  * 
  * @since 1.1.0
  * @return array all comments on gallery 
  */
 function get_approved_comments()
 {
     global $lg_gallery, $wpdb;
     $page_id = (int) $lg_gallery->get_option('gallery_id');
     $comments = get_approved_comments($page_id);
     $files = $wpdb->get_results("SELECT * FROM {$lg_gallery->table}");
     $results = $wpdb->get_results("SELECT comment_id, meta_value FROM  {$wpdb->commentmeta} WHERE meta_key = 'lazyest';");
     foreach ($comments as $comment) {
         $img_id = 0;
         foreach ($results as $result) {
             if ($comment->comment_ID == $result->comment_id) {
                 $img_id = $result->meta_value;
                 break;
             }
         }
         if (0 == $img_id) {
             $comment->filevar = '';
         } else {
             foreach ($files as $file) {
                 if ($file->img_ID == $img_id) {
                     $comment->filevar = $file->file;
                     break;
                 }
             }
         }
     }
     return $comments;
 }
开发者ID:slavam,项目名称:adult-childhood,代码行数:35,代码来源:comments.php


示例18: show_comments

        echo show_comments($c, true);
        ?>
        <?php 
    }
    ?>
      </ul>
    </div>
    <div class="comment-input">
      <?php 
    get_template_part('shared/comment_form');
    ?>
    </div>
  <?php 
} else {
    ?>
    <span class="article__section--text">
      <i class="material-icons">comment</i>
      <?php 
    echo count(get_approved_comments(get_the_ID()));
    ?>
    </span>
    <div class="comment-input">
      <?php 
    get_template_part('shared/comment_form');
    ?>
    </div>
  <?php 
}
?>
</div>
开发者ID:vsanna,项目名称:blog,代码行数:30,代码来源:comments.php


示例19: pingback_trackback_count

/**
 * Retrieve the amount of Pingback/Trackbacks a post has.
 *
 * @param int $count The Comment Count
 * @param int $post_id The Post ID
 * @return int The number of Pingback/Trackbacks a post has
 *
 * @since rtPanel 2.0
 */
function pingback_trackback_count($count, $post_id)
{
    $comments = get_approved_comments($post_id);
    $pingtrack_count = 0;
    foreach ($comments as $comment) {
        if ($comment->comment_type != '') {
            $pingtrack_count++;
        }
    }
    return $pingtrack_count;
}
开发者ID:Phillydevs,项目名称:rtpanel,代码行数:20,代码来源:rtp-comments.php


示例20: test_bp_blogs_comment_sync_activity_comment_for_custom_post_type

 /**
  * @group bp_blogs_comment_sync_activity_comment
  * @group post_type_comment_activities
  */
 public function test_bp_blogs_comment_sync_activity_comment_for_custom_post_type()
 {
     if (is_multisite()) {
         $b = $this->factory->blog->create();
         switch_to_blog($b);
         add_filter('comment_flood_filter', '__return_false');
     } else {
         $b = get_current_blog_id();
     }
     $u = $this->factory->user->create();
     $userdata = get_userdata($u);
     $labels = array('name' => 'bars', 'singular_name' => 'bar');
     register_post_type('foo', array('labels' => $labels, 'public' => true, 'supports' => array('comments')));
     add_post_type_support('foo', 'buddypress-activity');
     bp_activity_set_post_type_tracking_args('foo', array('comment_action_id' => 'new_foo_comment'));
     add_filter('bp_disable_blogforum_comments', '__return_false');
     $p = $this->factory->post->create(array('post_author' => $u, 'post_type' => 'foo'));
     $a1 = bp_activity_get_activity_id(array('type' => 'new_foo', 'filter' => array('item_id' => $b, 'secondary_item_id' => $p)));
     $c = wp_new_comment(array('comment_post_ID' => $p, 'comment_author' => $userdata->user_nicename, 'comment_author_url' => 'http://buddypress.org', 'comment_author_email' => $userdata->user_email, 'comment_content' => 'this is a foo comment', 'comment_type' => '', 'comment_parent' => 0, 'user_id' => $u));
     $a2 = bp_activity_new_comment(array('content' => 'this should generate a new foo comment', 'user_id' => $u, 'activity_id' => $a1));
     $activity_args = array('type' => 'activity_comment', 'display_comments' => 'stream', 'meta_query' => array(array('key' => 'bp_blogs_foo_comment_id', 'compare' => 'exists')));
     $a = bp_activity_get($activity_args);
     $aids = wp_list_pluck($a['activities'], 'id');
     $cids = wp_list_pluck(get_approved_comments($p), 'comment_ID');
     foreach ($aids as $aid) {
         $this->assertTrue(in_array(bp_activity_get_meta($aid, 'bp_blogs_foo_comment_id'), $cids), 'The comment ID should be in the activity meta');
     }
     foreach ($cids as $cid) {
         $this->assertTrue(in_array(get_comment_meta($cid, 'bp_activity_comment_id', true), $aids), 'The activity ID should be in the comment meta');
     }
     _unregister_post_type('foo');
     if (is_multisite()) {
         restore_current_blog();
         remove_filter('comment_flood_filter', '__return_false');
     }
     remove_filter('bp_disable_blogforum_comments', '__return_false');
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:41,代码来源:functions.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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