diff --git a/includes/class-wc-comments.php b/includes/class-wc-comments.php index 3ecab01113c..f43e17b302b 100644 --- a/includes/class-wc-comments.php +++ b/includes/class-wc-comments.php @@ -182,23 +182,16 @@ class WC_Comments { /** * Validate the comment ratings. + * * @param array $comment_data * @return array */ public static function check_comment_rating( $comment_data ) { // If posting a comment (not trackback etc) and not logged in - if ( - ! is_admin() - && 'product' === get_post_type( $_POST['comment_post_ID'] ) - && empty( $_POST['rating'] ) - && '' === $comment_data['comment_type'] - && 'yes' === get_option( 'woocommerce_enable_review_rating' ) - && 'yes' === get_option( 'woocommerce_review_rating_required' ) - ) { + if ( ! is_admin() && isset( $_POST['comment_post_ID'], $_POST['rating'], $comment_data['comment_type'] ) && 'product' === get_post_type( $_POST['comment_post_ID'] ) && empty( $_POST['rating'] ) && '' === $comment_data['comment_type'] && 'yes' === get_option( 'woocommerce_enable_review_rating' ) && 'yes' === get_option( 'woocommerce_review_rating_required' ) ) { wp_die( __( 'Please rate the product.', 'woocommerce' ) ); exit; } - return $comment_data; }