WC_Comments::add_comment_rating( int $comment_id )
Rating field for comments.
Description Description
Parameters Parameters
- $comment_id
-
(Required) Comment ID.
Source Source
File: includes/class-wc-comments.php
public static function add_comment_rating( $comment_id ) { if ( isset( $_POST['rating'], $_POST['comment_post_ID'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) ) { // WPCS: input var ok, CSRF ok. if ( ! $_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok, CSRF ok, sanitization ok. return; } add_comment_meta( $comment_id, 'rating', intval( $_POST['rating'] ), true ); // WPCS: input var ok, CSRF ok. $post_id = isset( $_POST['comment_post_ID'] ) ? absint( $_POST['comment_post_ID'] ) : 0; // WPCS: input var ok, CSRF ok. if ( $post_id ) { self::clear_transients( $post_id ); } } }