From f9de01e28fffc124cdc76c9a32ea0164accf7033 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 6 Jul 2020 16:43:12 +0300 Subject: A message is shown when a field value is invalid. --- wp-content/plugins/dx-cars/class.cpt.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'wp-content/plugins') diff --git a/wp-content/plugins/dx-cars/class.cpt.php b/wp-content/plugins/dx-cars/class.cpt.php index 9adb344..19c40fe 100644 --- a/wp-content/plugins/dx-cars/class.cpt.php +++ b/wp-content/plugins/dx-cars/class.cpt.php @@ -49,16 +49,15 @@ class Vehicles { // Cycle through the $events_meta array. // Note, in this example we just have one item, but this is helpful if you have multiple. foreach ( $events_meta as $key => $value ) { - // Don't store custom data twice if ( 'revision' === $post->post_type ) { return; } switch( $key ) { - case 'car-year': if( strcmp( "1769", $value ) > 0 || strcmp( "2020", $value ) < 0 ) return; break; - case 'car-millage': - case 'car-price': if( strcmp( "0", $value ) > 0 ) return; break; + case 'car-year': if( strcmp( "1769", $value ) > 0 || strcmp( get_the_date('Y'), $value ) < 0 ) wp_die('Invalid year.'); break; + case 'car-millage': if( strcmp( "0", $value ) > 0 ) wp_die('Invalid millage.'); break; + case 'car-price': if( strcmp( "0", $value ) > 0 ) wp_die('Invalid price.'); break; } if ( get_post_meta( $post_id, $key, false ) ) { -- cgit v1.3.1-26-gb76a