示例#1
0
 public function get_invisible_comment_count($wc_new_comments, $wc_author_email = null, $visible_parent_comment_ids = array(), $wc_last_new_comment_id = 0, $wc_last_new_reply_id = 0)
 {
     $wc_new_comments_data = array();
     $wc_new_comments_count = 0;
     $wc_visible_parent_comment_ids = $visible_parent_comment_ids;
     $wc_visible_pcomment_ids = WC_Helper::wc_get_array($wc_visible_parent_comment_ids);
     $wc_new_comments_data['wc_new_comments_ids'] = array();
     $wc_new_comments_data['wc_new_replies_ids'] = array();
     $wc_new_comments_data['last_comment_id'] = 0;
     foreach ($wc_new_comments as $wc_new_comment) {
         $cid = $wc_new_comment['comment_id'];
         // new comment id
         $cpid = $wc_new_comment['comment_parent'];
         // new comment parent id
         $parent_comment = WC_Helper::get_comment_root_id($cid);
         $pid = $parent_comment->comment_ID;
         if (!in_array($pid, $wc_visible_pcomment_ids)) {
             $wc_new_comments_count++;
         } else {
             if ($wc_new_comments_data['last_comment_id'] < $cid && $cid != 0) {
                 $wc_new_comments_data['last_comment_id'] = $cid;
             }
         }
         if ($cpid) {
             $current_new_comment_parent = get_comment($cpid);
             $current_new_comment_author_email = $current_new_comment_parent->comment_author_email;
         } else {
             $current_new_comment_author_email = '';
         }
         if ($cid > $wc_last_new_comment_id && $wc_author_email != $current_new_comment_author_email || !$wc_author_email) {
             $wc_new_comments_data['wc_new_comments_ids'][] = $cid;
         }
         if ($cid > $wc_last_new_reply_id && $wc_author_email == $current_new_comment_author_email) {
             $wc_new_comments_data['wc_new_replies_ids'][] = $cid;
         }
     }
     $wc_new_comments_data['new_comments_count'] = $wc_new_comments_count;
     return $wc_new_comments_data;
 }