Changeset 1084838
- Timestamp:
- 02/08/2015 08:12:59 AM (11 years ago)
- Location:
- autostock
- Files:
-
- 11 added
- 5 edited
-
assets/Thumbs.db (added)
-
assets/screenshot-1.png (added)
-
assets/screenshot-2.png (added)
-
assets/screenshot-3.png (added)
-
assets/screenshot-4.png (added)
-
assets/screenshot-5.png (added)
-
assets/screenshot-6.png (added)
-
assets/screenshot-7.png (added)
-
assets/screenshot-8.png (added)
-
trunk/autostock.php (modified) (2 diffs)
-
trunk/css/autostock_admin.css (modified) (1 diff)
-
trunk/includes/Car_Post_Type.php (modified) (11 diffs)
-
trunk/includes/admin_settings.php (modified) (6 diffs)
-
trunk/js (added)
-
trunk/js/autostock.js (added)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
autostock/trunk/autostock.php
r1071530 r1084838 4 4 * Plugin URI: http://kevinphillips.co.nz 5 5 * Description: Car dealer stock management plugin for WordPress. 6 * Version: 1.0. 26 * Version: 1.0.3 7 7 * Author: Kevin Phillips 8 8 * Author URI: http://kevinphillips.co.nz … … 72 72 } 73 73 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __NAMESPACE__ . '\add_action_links' ); 74 -
autostock/trunk/css/autostock_admin.css
r1071530 r1084838 9 9 } 10 10 } 11 -
autostock/trunk/includes/Car_Post_Type.php
r1071530 r1084838 27 27 add_filter( 'enter_title_here', array( $this, 'change_title_input' ) ); 28 28 add_action( 'edit_form_after_title', array( $this, 'reorder_meta_box' ) ); 29 add_action( 'admin_head', array( $this, 'remove_media_button' ) );30 29 add_filter( 'gettext', array( $this, 'change_text' ) ); 31 30 add_action( 'save_post', array( $this, 'vehicle_details_save_meta_box' ) ); … … 70 69 'menu_icon' => 'dashicons-backup', 71 70 'hierarchical' => false, 72 'supports' => array( 'title', 'author', 'excerpt', 'editor' ),71 'supports' => array( 'title', 'author', 'excerpt', 'editor', 'thumbnail' ), 73 72 'register_meta_box_cb' => array( $this, 'register_meta_box' ), 74 73 'has_archive' => true, … … 131 130 ); 132 131 $args = array( 133 'hierarchical' => false,132 'hierarchical' => true, 134 133 'labels' => $labels, 135 134 'show_ui' => true, … … 141 140 register_taxonomy( 142 141 'car_features', 142 'cars', 143 $args 144 ); 145 146 // Car Types 147 $labels = array( 148 'name' => _x( 'Car Types', 'taxonomy general name', AUTO ), 149 'singular' => _x( 'Car Type', 'taxonomy singular name', AUTO ), 150 'search_items' => __( 'Search Car Type ', AUTO ), 151 'all_items' => __( 'All Car Types', AUTO ), 152 'parent_item' => __( 'Parent Car Type', AUTO ), 153 'parent_item_colon' => __( 'Parent Car Type', AUTO ), 154 'edit_item' => __( 'Edit Car Type', AUTO ), 155 'update_item' => __( 'Update Car Type', AUTO ), 156 'add_new_item' => __( 'Add New Car Type', AUTO ), 157 'new_item_name' => __( 'New Car Type', AUTO ), 158 'menu_name' => __( 'Car Types', AUTO ), 159 'popular_items' => __( 'Popular Car Types', AUTO ), 160 'not_found' => __( 'Car type not found', AUTO ) 161 ); 162 $args = array( 163 'hierarchical' => false, 164 'labels' => $labels, 165 'show_ui' => true, 166 'show_admin_column' => false, 167 'query_var' => true, 168 'rewrite' => array( 'slug', 'car_types' ), 169 'show_cloud' => true, 170 ); 171 register_taxonomy( 172 'car_types', 143 173 'cars', 144 174 $args … … 163 193 ); 164 194 165 166 195 } 167 196 168 197 public function replace_features_meta_box() { 169 198 // Remove the default meta box for the features categories 170 remove_meta_box( ' tagsdiv-car_features', 'cars', 'side');199 remove_meta_box( 'car_featuresdiv', 'cars', 'side' ); 171 200 add_meta_box( 172 201 'car_features_taxonomy', 173 __( 'Car Features', AUTO ),174 array( $this, 'car_features_render_box_callback' ),202 __( 'Car Features', AUTO ), 203 array( $this, 'car_features_render_box_callback' ), 175 204 'cars', 176 205 'car_meta_box_position', 177 206 'core' 178 207 ); 208 209 // Remove the default meta box for car types 210 remove_meta_box( 'tagsdiv-car_types', 'cars', 'side' ); 179 211 } 180 212 … … 185 217 186 218 global $post, $wp_meta_boxes; 219 187 220 do_meta_boxes( get_current_screen(), 'car_meta_box_position', $post ); 188 221 … … 229 262 $value = get_post_meta( $post->ID, '_vehicle_details', true ); 230 263 231 echo '<p>' . __( 'Enter a unique stock number for this vehicle', AUTO ) . '</p>'; 264 echo '<p>'; 265 echo '<label for="stock_sold"><strong>' . __( 'Sold', AUTO ) . '</strong></label><br>'; 266 $checked = isset( $value['stock_sold'] ) && $value['stock_sold'] == 1 ? 'checked' : ''; 267 echo '<input type="checkbox" name="stock_sold" id="stock_sold" value="1" ' . $checked . '>'; 268 echo '<i>' . __( 'Never delete stock as it is really bad for SEO, mark it as sold', AUTO ) . '</i>'; 269 echo '</p>'; 270 271 echo '<p>'; 272 echo '<label for="featured_stock"><strong>' . __( 'Featured', AUTO ) . '</strong></label><br>'; 273 $checked = isset( $value['featured_stock'] ) && $value['featured_stock'] == 1 ? 'checked' : ''; 274 echo '<input type="checkbox" name="featured_stock" id="featured_stock" value="1" ' . $checked . '>'; 275 echo '<i>' . __( 'Display as featured item, useful for templates, galleries and sliders', AUTO ) . '</i>'; 276 echo '</p>'; 277 278 echo '<p>'; 279 echo '<label for="stock_no"><strong>' . __( 'Stock No.', AUTO ) . '</strong></label><br>'; 232 280 $stock_no = isset( $value['stock_no'] ) ? esc_attr( $value['stock_no'] ) : ''; 233 281 echo '<input type="text" id="stock_no" name="stock_no" value="' . $stock_no . '">'; 234 235 echo '<p>' . __( 'You can optionally add a sub title here' ) . '</p>'; 282 echo '<br><i>' . __( 'Enter a unique stock number for this vehicle', AUTO ) . '</i>'; 283 echo '</p>'; 284 285 echo '<p>'; 286 echo '<label for="sub_title"><strong>' . __( 'Sub Title' ) . '</strong></label><br>'; 236 287 $sub_title = isset( $value['sub_title'] ) ? esc_attr( $value['sub_title'] ) : ''; 237 288 echo '<input type="text" id="sub_title" name="sub_title" value="' . $sub_title . '">'; 238 239 echo '<p>' . __( 'Enter the VIN for this vehicle', AUTO ) . '</p>'; 289 echo '<br><i>' . __( 'You can optionally add a sub title here' ) . '</i>'; 290 echo '</p>'; 291 292 echo '<p>'; 293 echo '<label for="vin"><strong>' . __( 'VIN', AUTO ) . '</strong></label><br>'; 240 294 $vin = isset( $value['vin'] ) ? esc_attr( $value['vin'] ) : ''; 241 295 echo '<input type="text" id="vin" name="vin" value="' . $vin . '">'; 242 243 echo '<p>' . __( 'Enter the chassis number for this vehicle', AUTO ) . '</p>'; 296 echo '<br><i>' . __( 'VIN (Vehicle Identification Number), Required by some countries', AUTO ) . '</i>'; 297 echo '</p>'; 298 299 echo '<p>'; 300 echo '<label for="chassis"><strong>' . __( 'Chassis Number', AUTO ) . '</strong></label><br>'; 244 301 $chassis = isset( $value['chassis'] ) ? esc_attr( $value['chassis'] ) : ''; 245 302 echo '<input type="text" id="chassis" name="chassis" value="' . $chassis . '">'; 246 247 // lets use the oop way 303 echo '<br><i>' . __( 'Chassis number for this vehicle', AUTO ) . '</i>'; 304 echo '</p>'; 305 306 echo '<p>'; 307 echo '<label for="rego"><strong>' . __( 'Plate', AUTO ) . '</strong></label><br>'; 308 $rego = isset( $value['rego'] ) ? esc_attr( $value['rego'] ) : ''; 309 echo '<input type="text" name="rego" id="rego" value="' . esc_attr( $rego ) . '" >'; 310 echo '<br><i>' . __( 'Registration Number Plate', AUTO ) . '</i>'; 311 echo '</p>'; 248 312 249 313 // check to see if we have latest year … … 259 323 } 260 324 261 echo '<p>' . __( 'Select vehicle year', AUTO ) . '</p>'; 325 echo '<p>'; 326 echo '<label for="year"><strong>' . __( 'Year', AUTO ) . '</strong></label><br>'; 262 327 echo '<select name="vehicle_year" id="vehicle_year">'; 263 /** @noinspection PhpExpressionResultUnusedInspection */264 328 for ( $latest_year; $latest_year >= $earliest_year; $latest_year -- ) { 265 329 echo '<option value="' . $latest_year . '" ' . selected( $value['vehicle_year'], $latest_year ) . '>' . $latest_year . '</option>'; 266 330 } 267 331 echo '</select>'; 332 echo '<br><i>' . __( 'Select vehicle year', AUTO ) . '</i>'; 333 echo '</p>'; 268 334 269 335 $odometer_type = isset( $this->options['odometer'][0] ) ? esc_attr( $this->options['odometer'][0] ) : 'kilometres'; 270 336 271 echo '<p>' . __( ucfirst( $odometer_type ), AUTO ) . __( ' (use only digits)', AUTO ) . '</p>'; 337 echo '<p>'; 338 echo '<label for="odometer"><strong>' . __( ucfirst( $odometer_type ), AUTO ) . '</strong></label><br>'; 272 339 $odometer = isset( $value['odometer'] ) ? esc_attr( $value['odometer'] ) : ''; 273 340 echo '<input type="text" name="odometer" id="odometer" value="' . $odometer . '" >'; 274 341 echo '<br><i>' . __( ' (use only digits)', AUTO ) . '</i>'; 342 echo '</p>'; 343 344 echo '<p>'; 345 echo '<label for="car_types"><strong>' . __( 'Vehicle Type', AUTO ) . '</strong></label><br>'; 346 echo '<input type="hidden" name="tax_input[car_types][]" value="0">'; 347 $selected_array = wp_get_post_terms( $post->ID, 'car_types' ); 348 349 if ( empty( $selected_array ) ) { 350 $selected = ''; 351 } else { 352 // We know this can only be one so let's just drill down the array 353 $selected = $selected_array[0]->term_id; 354 } 355 356 $args = array( 357 'show_option_none' => 'Please select', 358 'taxonomy' => 'car_types', 359 'hide_empty' => 0, 360 'name' => 'car_types', 361 'id' => 'car_types', 362 'selected' => $selected 363 ); 364 wp_dropdown_categories( $args ); 365 echo '</p>'; 366 367 echo '<p>'; 368 echo '<label for="engine"><strong>' . __( 'Engine', AUTO ) . '</strong></label><br>'; 369 $engine = isset( $value['engine'] ) ? esc_attr( $value['engine'] ) : ''; 370 echo '<input type="text" name="engine" id="engine" value="' . esc_attr( $engine ) . '" >'; 371 echo '<br><i>' . __( 'Engine', AUTO ) . '</i>'; 372 echo '</p>'; 373 374 echo '<p>'; 375 echo '<label for="drive"><strong>' . __( 'Drive', AUTO ) . '</strong></label><br>'; 376 $drive = isset( $value['drive'] ) ? esc_attr( $value['drive'] ) : ''; 377 echo '<input type="text" name="drive" id="engine" value="' . esc_attr( $drive ) . '" >'; 378 echo '<br><i>' . __( 'Drive', AUTO ) . '</i>'; 379 echo '</p>'; 380 381 echo '<p>'; 382 echo '<label for="transmission"><strong>' . __( 'Transmission', AUTO ) . '</strong></label><br>'; 383 $transmission = isset( $value['transmission'] ) ? esc_attr( $value['transmission'] ) : ''; 384 echo '<input type="text" name="transmission" id="transmission" value="' . esc_attr( $transmission ) . '" >'; 385 echo '<br><i>' . __( 'Transmission', AUTO ) . '</i>'; 386 echo '</p>'; 387 388 echo '<p>'; 389 echo '<label for="fuel"><strong>' . __( 'Fuel', AUTO ) . '</strong></label><br>'; 390 $fuel = isset( $value['fuel'] ) ? esc_attr( $value['fuel'] ) : ''; 391 echo '<input type="text" name="fuel" id="fuel" value="' . esc_attr( $fuel ) . '" >'; 392 echo '<br><i>' . __( 'Fuel Type, ie petrol, diesel', AUTO ) . '</i>'; 393 echo '</p>'; 394 395 echo '<p>'; 396 echo '<label for="seats"><strong>' . __( 'Seats', AUTO ) . '</strong></label><br>'; 397 $seats = isset( $value['seats'] ) ? esc_attr( $value['seats'] ) : ''; 398 echo '<input type="text" name="seats" id="seats" value="' . esc_attr( $seats ) . '" >'; 399 echo '<br><i>' . __( 'Number of seats (digital only)', AUTO ) . '</i>'; 400 echo '</p>'; 401 402 echo '<p>'; 403 echo '<label for="condition"><strong>' . __( 'Condition', AUTO ) . '</strong></label><br>'; 404 $condition = isset( $value['condition'] ) ? esc_attr( $value['condition'] ) : ''; 405 echo '<input type="text" name="condition" id="condition" value="' . esc_attr( $condition ) . '" >'; 406 echo '<br><i>' . __( 'Overall condition', AUTO ) . '</i>'; 407 echo '</p>'; 408 409 echo '<p>'; 410 echo '<label for="exterior"><strong>' . __( 'Exterior', AUTO ) . '</strong></label><br>'; 411 $exterior = isset( $value['exterior'] ) ? esc_attr( $value['exterior'] ) : ''; 412 echo '<input type="text" name="exterior" id="exterior" value="' . esc_attr( $exterior ) . '" >'; 413 echo '<br><i>' . __( 'Exterior', AUTO ) . '</i>'; 414 echo '</p>'; 415 416 echo '<p>'; 417 echo '<label for="interior"><strong>' . __( 'Interior', AUTO ) . '</strong></label><br>'; 418 $exterior = isset( $value['interior'] ) ? esc_attr( $value['interior'] ) : ''; 419 echo '<input type="text" name="interior" id="interior" value="' . esc_attr( $exterior ) . '" >'; 420 echo '<br><i>' . __( 'Exterior', AUTO ) . '</i>'; 421 echo '</p>'; 422 423 echo '<p>'; 424 echo '<label for="price"><strong>' . __( 'Price', AUTO ) . '</strong></label><br>'; 425 $price = isset( $value['price'] ) ? esc_attr( $value['price'] ) : ''; 426 echo '<input type="text" name="price" id="price" value="' . esc_attr( $price ) . '" >'; 427 echo '<br><i>' . __( 'Price (Digits only)', AUTO ) . '</i>'; 428 echo '</p>'; 429 430 echo '<p>'; 431 echo '<label for="sale"><strong>' . __( 'Sale Price', AUTO ) . '</strong></label><br>'; 432 $sale = isset( $value['sale'] ) ? esc_attr( $value['sale'] ) : ''; 433 echo '<input type="text" name="sale" id="sale" value="' . esc_attr( $sale ) . '" >'; 434 echo '<br><i>' . __( 'Sale Price (Digits only)', AUTO ) . '</i>'; 435 echo '</p>'; 275 436 } 276 437 277 438 public function car_features_render_box_callback( $post ) { 278 439 $taxonomy = 'car_features'; 279 $tax = get_taxonomy( $taxonomy );440 $tax = get_taxonomy( $taxonomy ); 280 441 $selected = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); 281 442 ?> 282 443 283 <div id="taxonomy-<?php echo $taxonomy;?>" class="categorydiv"> 284 <input type="hidden" name="tax_input[<?php echo $taxonomy;?>][]" value="0"> 285 286 <ul id="<?php echo $taxonomy;?>checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> 287 <?php 288 wp_terms_checklist( $post->ID, array( 289 'taxonomy' => $taxonomy, 290 'selected_cats' => $selected, 291 'checked_ontop' => false 292 ) ); 293 ?> 444 <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv"> 445 <input type="hidden" name="tax_input[<?php echo $taxonomy; ?>][]" value="0"> 446 <ul id="<?php echo $taxonomy; ?>checklist" data-wp-lists="lists:<?php echo $taxonomy; ?> class=" 447 categorychecklist form-no-clear 448 "> 449 <?php 450 wp_terms_checklist( $post->ID, array( 451 'taxonomy' => $taxonomy, 452 'selected_cats' => $selected, 453 'checked_ontop' => false, 454 ) ); 455 ?> 294 456 </ul> 295 457 296 458 </div> 297 <?php459 <?php 298 460 299 461 } … … 305 467 */ 306 468 public function vehicle_details_save_meta_box( $post_id ) { 469 307 470 308 471 // Check nonce is set … … 332 495 $data = array(); 333 496 334 $data['stock_no'] = sanitize_text_field( $_POST['stock_no'] ); 335 $data['sub_title'] = sanitize_text_field( $_POST['sub_title'] ); 336 $data['vin'] = sanitize_text_field( $_POST['vin'] ); 337 338 $data['chassis'] = sanitize_text_field( $_POST['chassis'] ); 339 $data['vehicle_year'] = sanitize_text_field( $_POST['vehicle_year'] ); 340 $data['odometer'] = preg_replace( '/\D/', '', $_POST['odometer'] ); 497 $data['stock_no'] = isset( $_POST['stock_no'] ) ? sanitize_text_field( $_POST['stock_no'] ) : ''; 498 $data['sub_title'] = isset( $_POST['sub_title'] ) ? sanitize_text_field( $_POST['sub_title'] ): ''; 499 $data['vin'] = isset( $_POST['vin'] ) ? sanitize_text_field( $_POST['vin'] ) : ''; 500 501 $data['chassis'] = isset( $_POST['chassis'] ) ? sanitize_text_field( $_POST['chassis'] ) : ''; 502 $data['vehicle_year'] = isset( $_POST['vehicle_year'] ) ? sanitize_text_field( $_POST['vehicle_year'] ) : ''; 503 $data['odometer'] = isset( $_POST['odometer'] ) ? preg_replace( '/\D/', '', $_POST['odometer'] ) : ''; 504 $data['stock_sold'] = isset( $_POST['stock_sold'] ) ? (int) $_POST['stock_sold'] : 0; 505 $data['featured_stock'] = isset( $_POST['featured_stock'] ) ? (int) $_POST['featured_stock'] : 0; 506 $data['rego'] = isset( $_POST['rego'] ) ? sanitize_text_field( ( $_POST['rego'] ) ) : ''; 507 $data['plate'] = isset( $_POST['plate'] ) ? sanitize_text_field( $_POST['plate'] ) : ''; 508 $data['engine'] = isset( $_POST['engine'] ) ? sanitize_text_field( $_POST['engine'] ) : ''; 509 $data['drive'] = isset( $_POST['drive'] ) ? sanitize_text_field( $_POST['drive'] ) : ''; 510 $data['transmission'] = isset( $_POST['transmission'] ) ? sanitize_text_field( $_POST['transmission'] ) : ''; 511 $data['fuel'] = isset( $_POST['fuel'] ) ? sanitize_text_field( $_POST['fuel'] ) : ''; 512 $data['seats'] = isset( $_POST['seats'] ) ? preg_replace( '/\D/', '', $_POST['seats'] ) : ''; 513 $data['condition'] = isset( $_POST['condition'] ) ? sanitize_text_field( $_POST['condition'] ) : ''; 514 $data['exterior'] = isset( $_POST['exterior'] ) ? sanitize_text_field( $_POST['exterior'] ) : ''; 515 $data['interior'] = isset( $_POST['interior'] ) ? sanitize_text_field( $_POST['interior'] ) : ''; 516 $data['price'] = isset( $_POST['price'] ) ? preg_replace( '/\D/', '', $_POST['price'] ) : ''; 517 $data['sale'] = isset( $_POST['sale'] ) ? preg_replace( '/\D/', '', $_POST['sale'] ) : ''; 341 518 342 519 // if the data array is not empty then save the meta data array. 343 520 if ( ! empty( $data ) ) { 344 521 update_post_meta( $post_id, '_vehicle_details', $data ); 522 } 523 524 if ( isset( $_POST['car_types'] ) ) { 525 wp_set_post_terms( $post_id, array( (int) $_POST['car_types'] ), 'car_types', false ); 345 526 } 346 527 … … 364 545 } 365 546 366 /**367 * Function to remove add media button on the editor368 */369 public function remove_media_button() {370 global $post;371 372 if ( isset( $post ) && 'cars' == $post->post_type ) {373 remove_action( 'media_buttons', 'media_buttons' );374 }375 }376 377 547 public function enqueue_admin_scripts() { 378 wp_register_style( 'autostock_admin_css', plugins_url( 'css/autostock_admin.css', dirname( __FILE__ ) ) );379 380 wp_enqueue_style( 'autostock_admin_css' );548 wp_register_style( 'autostock_admin_css', plugins_url( 'css/autostock_admin.css', dirname( __FILE__ ) ) ); 549 wp_enqueue_script( 'autostockjs', plugin_dir_url( dirname( __FILE__ ) ) . '/js/autostock.js' ); 550 wp_enqueue_style( 'autostock_admin_css' ); 381 551 } 382 552 -
autostock/trunk/includes/admin_settings.php
r1071530 r1084838 127 127 'Add Default Features', 128 128 array( $this, 'add_default_car_features_callback' ), 129 'car_features_setting', 130 'car_features_settings_section' 131 ); 132 133 add_settings_field( 134 'add_default_car_types', 135 'Add Default Car Types', 136 array( $this, 'add_default_car_types_callback' ), 129 137 'car_features_setting', 130 138 'car_features_settings_section' … … 271 279 */ 272 280 public function add_default_car_features_callback() { 273 274 $checked = isset( $this->car_features_options['add_default_features'] ); 275 echo '<input type="checkbox" name="add_default_features" value="1"' . checked( $checked, 1, false ) .'>'; 276 echo '<label>' . __( 'Select to install default vehicle features', AUTO) . '</label>'; 277 278 279 } 281 282 echo '<pre>'; 283 print_r($this->car_features_options); 284 echo '</pre>'; 285 if ( isset( $this->car_features_options['add_default_features'] ) && $this->car_features_options['add_default_features'] == 1 ) { 286 echo '<input type="hidden" name="add_default_features" value="1">'; 287 echo '<label>' . __( 'Default vehicle features have already been saved', AUTO ) . '</label>'; 288 echo '<input type="hidden" name="default_features_installed" value="1">'; 289 } else { 290 echo '<input type="checkbox" name="add_default_features" value="1">'; 291 echo '<label>' . __( 'Select to install default vehicle features', AUTO ) . '</label>'; 292 echo '<input type="hidden" name="default_features_installed" value="0">'; 293 } 294 295 296 } 297 298 public function add_default_car_types_callback() { 299 300 if ( isset( $this->car_features_options['add_default_car_types'] ) && $this->car_features_options['add_default_car_types'] == 1 ) { 301 echo '<input type="hidden" name="add_default_car_types" value="1">'; 302 echo '<label>' . __( 'Default car types have already been installed', AUTO) . '</label>'; 303 echo '<input type="hidden" name="default_car_types_installed" value="1">'; 304 } else { 305 echo '<input type="checkbox" name="add_default_car_types" value="1">'; 306 echo '<label>' . __( 'Select to install default car types', AUTO) . '</label>'; 307 echo '<input type="hidden" name="default_car_types_installed" value="0">'; 308 } 309 310 } 311 280 312 281 313 /** … … 292 324 $input['add_default_features'] = 1; 293 325 294 if ( isset($this->car_features_options['add_default_features']) ) { 295 // do nothing as it has already been loaded 296 } else { 326 if ( $_POST['default_features_installed'] == 0 ){ 297 327 // We now need to load the file with the default values 298 328 $features = $this->array_default_features(); … … 302 332 303 333 } 334 335 add_settings_error( 'vehicle_details', 'add_default_features', __( 'Features list has been updated to include defaults.', AUTO ), 'updated'); 304 336 } 305 add_settings_error( 'vehicle_details', 'add_default_features', __( 'Features list has been updated to include defaults.', AUTO ), 'updated'); 306 307 } 337 338 } 339 340 if ( isset ( $_POST['add_default_car_types'] ) && 1 == $_POST['add_default_car_types'] ) { 341 342 $input['add_default_car_types'] = 1; 343 344 if ( $_POST['default_car_types_install'] == 0 ) { 345 // We should now install the default car types 346 $car_types = $this->array_default_car_types(); 347 foreach ( $car_types as $car_type ) { 348 wp_insert_term( $car_type[0], $car_type[1], $car_type[2] ); 349 } 350 add_settings_error( 'vehicle_details', 'add_default_car_types', __( 'Car type list has been updated to include defaults.', AUTO ), 'updated'); 351 } 352 353 } 354 308 355 309 356 return $input; … … 317 364 settings_errors('vehicle_details'); 318 365 } 366 319 367 320 368 /** … … 401 449 } 402 450 451 private function array_default_car_types() { 452 $car_types = array( 453 array( 'Classic', 'car_types', array( 'slug' => 'classic' ) ), 454 array( 'Coach', 'car_types', array( 'slug' => 'coach' ) ), 455 array( 'Convertible', 'car_types', array( 'slug' => 'convertible' ) ), 456 array( 'Coupe', 'car_types', array( 'slug' => 'coupe' ) ), 457 array( 'Hatchback', 'car_types', array( 'slug' => 'hatchback' ) ), 458 array( 'RV-SUV', 'car_types', array( 'slug' => 'rv-suv' ) ), 459 array( 'Sedan', 'car_types', array( 'slug' => 'sedan' ) ), 460 array( 'Station Wagon', 'car_types', array( 'slug' => 'station-wagon' ) ), 461 array( 'Ute', 'car_types', array( 'slug' => 'ute' ) ), 462 array( 'Van', 'car_types', array( 'slug' => 'van' ) ), 463 ); 464 465 return $car_types; 466 467 } 403 468 } 404 469 new Admin_Settings(); -
autostock/trunk/readme.txt
r1071530 r1084838 5 5 Requires at least: 4.1 6 6 Tested up to: 4.1 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl.html … … 19 19 hosting server must be running minimum of PHP 5.3.6 as the code includes namespaces. 20 20 21 This plugin is still under development but the stable version is safe to use on a production site. 21 You should be able to use this plugin as a custom post type for vehicle sales. (See the screenshots) 22 22 23 Next upgrade will include gallery for vehicle images. 23 I have decided not to incorporate any image gallery as we have access to hundreds, if not thousands through the WordPress Repository. 24 I am using the built in WordPress Gallery to manage images for each vehicle and a simple plugin to add a light box plugin (Lightbox Galleries EWSEL). 25 26 If you feel this plugin is useful and you would like me to continue developing it please consider a small donation :-) 27 28 Please contact me if you have any request or features that would be useful. 24 29 25 30 ***** NOTICE ****** … … 43 48 == Frequently Asked Questions == 44 49 45 = How long until new features are added=50 = Where is the image upload function = 46 51 47 I h ope to be adding new features on a regular basis, most weeks48 52 I have not added any custom image or gallery function as we have so many, hundreds if not thousands to choose from it would seem wrong to limit this plugin by a single imaage/gallery option. 53 With my demo site I amd using the built in WordPress gallery and I've added the Lightbox Galleries EWSEL plugin to give me a simple light box. 49 54 50 55 == Screenshots == 51 56 57 1. Setup vehicle options, vehicle year range and kilometres vs Miles. 58 2. Vehicle makes, features and types are categories ( so we can use them for indexing), here you can load some defaults. 59 3. Add new car just like any other post/page. Enter in the vehicle details which can be displayed via your theme. 60 4. Select vehicle features, which are categories so you can add/edit them like any other category. 61 5. In the body add vehicle description and images. You can optionally use one of the many hundreds of plugins to create a gallery or use the built in WordPress gallery library. 62 6. Some countries require you to display fuel economy information (I have copied the New Zealand badge from the government website). 63 7. Add vehicle make, model and badge, here I have used three levels as I intended to use these later in my indexing. 64 8. Manage your categories just like any other. 52 65 53 66 == Changelog == 67 68 1.0.3 Added Vehicle Details and Features category to post type 69 1.0.2 Added custom car features to car post types as taxonomy with checkboxes. 54 70 1.0.1 Added settings options and taxonomy for makes and models 55 1.0.2 Added custom car features to car post types as taxonomy with checkboxes. 71 56 72 == Upgrade Notice ==
Note: See TracChangeset
for help on using the changeset viewer.