When ratings are required for reviews, ensure validation is performed if the rating element is removed from DOM.

Closes #7371
This commit is contained in:
Mike Jolley 2015-02-11 23:06:18 +00:00
parent bce209c21d
commit 1f9b9c0ae0
2 changed files with 3 additions and 2 deletions

View File

@ -180,7 +180,7 @@ class WC_Comments {
*/
public static function check_comment_rating( $comment_data ) {
// If posting a comment (not trackback etc) and not logged in
if ( isset( $_POST['rating'] ) && empty( $_POST['rating'] ) && '' === $comment_data['comment_type'] && 'yes' === get_option( 'woocommerce_review_rating_required' ) ) {
if ( 'product' === get_post_type( $_POST['comment_post_ID'] ) && empty( $_POST['rating'] ) && '' === $comment_data['comment_type'] && 'yes' === get_option( 'woocommerce_review_rating_required' ) ) {
wp_die( __( 'Please rate the product.', 'woocommerce' ) );
exit;
}
@ -193,7 +193,7 @@ class WC_Comments {
* @param int $comment_id
*/
public static function add_comment_rating( $comment_id ) {
if ( isset( $_POST['rating'] ) ) {
if ( isset( $_POST['rating'] ) && 'product' === get_post_type( $_POST['comment_post_ID'] ) ) {
if ( ! $_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0 ) {
return;
}

View File

@ -141,6 +141,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Fix - Item meta removal query in order class.
* Fix - Pass correct shipping cost to PayPal.
* Fix - Flat rate extra costs when costs are an array.
* Fix - When ratings are required for reviews, ensure validation is performed if the rating element is removed from DOM.
= 2.3.1 - 11/02/2015 =
* Fix - When the geolocation database cannot download, ensure the correct method is used to log the error.