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


PHP get_approved_comments函数代码示例

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


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


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