Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/publish offers #104

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions wp-content/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Silence is golden.
40 changes: 40 additions & 0 deletions wp-content/plugins/dx-vehicles/vehicles-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ function init() {
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() {
Expand Down Expand Up @@ -121,4 +123,42 @@ function vehicle_info_save_meta( $post_id, $post ) {
}
}
}

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 );
}
}
}
2 changes: 2 additions & 0 deletions wp-content/plugins/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Silence is golden.
180 changes: 180 additions & 0 deletions wp-content/themes/carmag/assets/dist/css/master.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions wp-content/themes/carmag/assets/dist/css/master.css.map

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions wp-content/themes/carmag/assets/dist/css/master.min.css

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions wp-content/themes/carmag/assets/dist/css/master.min.css.map

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion wp-content/themes/carmag/assets/dist/scripts/bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion wp-content/themes/carmag/assets/src/sass/master.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// and in the darkness bind them.
// The order of files include is important. Dont change it.


// All general settings and utils
@import "base/settings";
@import "base/mixins";
Expand Down Expand Up @@ -50,6 +49,7 @@
@import "pages/404";
@import "pages/single";
@import "pages/search";
@import "pages/publish_offer";
@import "pages/faq";
@import "pages/single-vehicle";
@import "pages/login-register";
Loading