added checking for invalid ratings while saving

This commit is contained in:
Mohammed Saimon 2018-04-09 18:13:13 +06:00
parent 6d973b98b6
commit eccd74b71d
2 changed files with 5 additions and 1 deletions

View File

@ -65,7 +65,7 @@ class WC_Admin_Meta_Boxes {
add_action( 'woocommerce_process_shop_coupon_meta', 'WC_Meta_Box_Coupon_Data::save', 10, 2 );
// Save Rating Meta Boxes.
add_filter( 'wp_update_comment_data', 'WC_Meta_Box_Product_Reviews::save', 1, 2 );
add_filter( 'wp_update_comment_data', 'WC_Meta_Box_Product_Reviews::save', 1 );
// Error handling (for showing errors from meta boxes on next page load).
add_action( 'admin_notices', array( $this, 'output_errors' ) );

View File

@ -50,6 +50,10 @@ class WC_Meta_Box_Product_Reviews {
return $data;
}
if ( $_POST['rating'] > 5 || $_POST['rating'] < 0 ) {
return $data;
}
$comment_id = $data['comment_ID'];
// Update meta