diff options
| Commit | 3ffe6583e345496a03fb4785d1469772c8e3081d (patch) | |
|---|---|---|
| Author | 2020-07-15 14:03:38 +0300 | |
| Committer | 2020-07-15 14:03:38 +0300 | |
| Files | 3bac78e096e258304b30a51fee7f1c759e7c82c0 /wp-content/plugins | |
| tues-interns-2020-feature/publish-offers.tar tues-interns-2020-feature/publish-offers.tar.gz tues-interns-2020-feature/publish-offers.zip | ||
| Parent | d631407b79d7507f6c9829268b7ecf24ccb3fc21 (diff) | |
issues with post from custom template feature/publish-offers
1 files changed, 40 insertions, 0 deletions
| -rwxr-xr-x | wp-content/plugins/dx-vehicles/vehicles-class.php | 40 |
diff --git a/wp-content/plugins/dx-vehicles/vehicles-class.php b/wp-content/plugins/dx-vehicles/vehicles-class.php index 3a0b127..7f6b100 100755 --- a/wp-content/plugins/dx-vehicles/vehicles-class.php +++ b/wp-content/plugins/dx-vehicles/vehicles-class.php @@ -4,6 +4,8 @@ class Vehicles { add_action( 'init', array( $this, 'cpt_create' ) ); add_action( 'add_meta_boxes', array( $this, 'register_meta_boxes' ) ); add_action( 'save_post', array( $this, 'vehicle_info_save_meta' ), 1, 2 ); + add_action( 'admin_post_process_offer', array( $this, 'process_offer_data' )); + } public function labels() { @@ -121,4 +123,42 @@ class Vehicles { } } } + + function process_offer_data () { + $post_data = array( + 'vehicle-year' => $_POST['vehicle-year'], + 'vehicle-millage' => $_POST['vehicle-millage'], + 'vehicle-horsepower' => $_POST['vehicle-horsepower'], + // 'vehicle-range' => sanitize_text_field( isset( $_POST['vehicle-range'] ) ? $_POST['vehicle-range'] : null ), + 'vehicle-price' => $_POST['vehicle-price'], + 'vehicle-images' => $_FILES['vehicle-images'], + ); + + // 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 ) { + if ( $value == null ) { + continue; + } + + switch ( $key ) { + case 'vehicle-year': + if( strcmp( "1769", $value ) > 0 || strcmp( "2020", $value ) < 0 ) wp_die( 'Invalid year' ); + break; + case 'vehicle-millage': + if( strcmp( "0", $value ) > 0 ) wp_die( 'Invalid millage.' ); + break; + case 'vehicle-horsepower': + if( strcmp( "0", $value ) > 0 ) wp_die( 'Invalid horsepower.' ); + break; + case 'vehicle-range': + if( strcmp( "0", $value ) > 0 ) wp_die( 'Invalid range.' ); + break; + case 'vehicle-price': + if( strcmp( "0", $value ) > 0 ) wp_die( 'Invalid price.' ); + break; + } + $post_id = wp_insert_post( $post_data ); + } + } } |
