PHP Class WC_Comments

Handle comments (reviews and order notes)
Author: WooThemes
Exibir arquivo Open project: woocommerce/woocommerce Class Usage Examples

Public Methods

Method Description
add_avatar_for_review_comment_type ( array $comment_types ) : array Make sure WP displays avatars for comments with the review type.
add_comment_purchase_verification ( integer $comment_id ) : boolean Determine if a review is from a verified owner at submission.
add_comment_rating ( integer $comment_id ) Rating field for comments.
check_comment_rating ( array $comment_data ) : array Validate the comment ratings.
clear_transients ( integer $post_id ) Ensure product average rating and review count is kept up to date.
comment_moderation_recipients ( array $emails, integer $comment_id ) : array Modify recipient of review email.
delete_comments_count_cache ( ) : void Delete comments count cache whenever there is new comment or the status of a comment changes. Cache will be regenerated next time WC_Comments::wp_count_comments() is called.
exclude_order_comments ( array $clauses ) : array Exclude order comments from queries and RSS.
exclude_order_comments_from_feed_join ( string $join ) : string Exclude order comments from queries and RSS.
exclude_order_comments_from_feed_where ( string $where ) : string Exclude order comments from queries and RSS.
exclude_webhook_comments ( array $clauses ) : array Exclude webhook comments from queries and RSS.
exclude_webhook_comments_from_feed_join ( string $join ) : string Exclude webhook comments from queries and RSS.
exclude_webhook_comments_from_feed_where ( string $where ) : string Exclude webhook comments from queries and RSS.
get_average_rating_for_product ( WC_Product &$product ) : float Get product rating for a product. Please note this is not cached.
get_rating_counts_for_product ( WC_Product &$product ) : array Get product rating count for a product. Please note this is not cached.
get_review_count_for_product ( WC_Product &$product ) : integer Get product review count for a product (not replies). Please note this is not cached.
init ( ) Hook in methods.
wp_count_comments ( object $stats, integer $post_id ) : object Remove order notes and webhook delivery logs from wp_count_comments().

Method Details

add_avatar_for_review_comment_type() public static method

Make sure WP displays avatars for comments with the review type.
Since: 2.3
public static add_avatar_for_review_comment_type ( array $comment_types ) : array
$comment_types array
return array

add_comment_purchase_verification() public static method

Determine if a review is from a verified owner at submission.
public static add_comment_purchase_verification ( integer $comment_id ) : boolean
$comment_id integer
return boolean

add_comment_rating() public static method

Rating field for comments.
public static add_comment_rating ( integer $comment_id )
$comment_id integer

check_comment_rating() public static method

Validate the comment ratings.
public static check_comment_rating ( array $comment_data ) : array
$comment_data array
return array

clear_transients() public static method

Ensure product average rating and review count is kept up to date.
public static clear_transients ( integer $post_id )
$post_id integer

comment_moderation_recipients() public static method

Modify recipient of review email.
public static comment_moderation_recipients ( array $emails, integer $comment_id ) : array
$emails array
$comment_id integer
return array

delete_comments_count_cache() public static method

Delete comments count cache whenever there is new comment or the status of a comment changes. Cache will be regenerated next time WC_Comments::wp_count_comments() is called.
public static delete_comments_count_cache ( ) : void
return void

exclude_order_comments() public static method

This code should exclude shop_order comments from queries. Some queries (like the recent comments widget on the dashboard) are hardcoded. and are not filtered, however, the code current_user_can( 'read_post', $comment->comment_post_ID ) should keep them safe since only admin and. shop managers can view orders anyway. The frontend view order pages get around this filter by using remove_filter('comments_clauses', array( 'WC_Comments' ,'exclude_order_comments'), 10, 1 );
public static exclude_order_comments ( array $clauses ) : array
$clauses array
return array

exclude_order_comments_from_feed_join() public static method

Exclude order comments from queries and RSS.
public static exclude_order_comments_from_feed_join ( string $join ) : string
$join string
return string

exclude_order_comments_from_feed_where() public static method

Exclude order comments from queries and RSS.
public static exclude_order_comments_from_feed_where ( string $where ) : string
$where string
return string

exclude_webhook_comments() public static method

Exclude webhook comments from queries and RSS.
Since: 2.2
public static exclude_webhook_comments ( array $clauses ) : array
$clauses array
return array

exclude_webhook_comments_from_feed_join() public static method

Exclude webhook comments from queries and RSS.
Since: 2.2
public static exclude_webhook_comments_from_feed_join ( string $join ) : string
$join string
return string

exclude_webhook_comments_from_feed_where() public static method

Exclude webhook comments from queries and RSS.
Since: 2.1
public static exclude_webhook_comments_from_feed_where ( string $where ) : string
$where string
return string

get_average_rating_for_product() public static method

Get product rating for a product. Please note this is not cached.
Since: 2.7.0
public static get_average_rating_for_product ( WC_Product &$product ) : float
$product WC_Product
return float

get_rating_counts_for_product() public static method

Get product rating count for a product. Please note this is not cached.
Since: 2.7.0
public static get_rating_counts_for_product ( WC_Product &$product ) : array
$product WC_Product
return array of integers

get_review_count_for_product() public static method

Get product review count for a product (not replies). Please note this is not cached.
Since: 2.7.0
public static get_review_count_for_product ( WC_Product &$product ) : integer
$product WC_Product
return integer

init() public static method

Hook in methods.
public static init ( )

wp_count_comments() public static method

Remove order notes and webhook delivery logs from wp_count_comments().
Since: 2.2
public static wp_count_comments ( object $stats, integer $post_id ) : object
$stats object Comment stats.
$post_id integer Post ID.
return object