<?php if (!defined('ABSPATH')) { exit; } // Exit if accessed directly global $vehicle; ?> <div class="wpcm-content-block" id="wpcm-vehicle-data"> <h2><?php _e('Vehicle Details', 'wp-car-manager'); ?> </h2> <?php // get fields $fields = Never5\WPCarManager\Vehicle\Data::get_fields(); // split fields into 2 arrays $tables = array_chunk($fields, ceil(count($fields) / 2)); ?> <?php foreach ($tables as $table_fields) { ?> <table> <?php foreach ($table_fields as $data_key => $data_field) { ?> <?php wp_car_manager()->service('template_manager')->get_template_part('vehicle-data/data', $data_field['key'], array('key' => $data_field['key'])); ?> <?php
if (!defined('ABSPATH')) { exit; } // Exit if accessed directly ?> <div class="wpcm-content-block" id="wpcm-vehicle-data"> <h2><?php _e('Vehicle Details', 'wp-car-manager'); ?> </h2> <?php // get fields $fields = Never5\WPCarManager\Vehicle\Data::remove_empty_fields(array_map(function ($f) { return $f['key']; }, Never5\WPCarManager\Vehicle\Data::get_fields()), $vehicle); // make fields displayed on single vehicle filterable $fields = apply_filters('wpcm_single_vehicle_data_fields', $fields, $vehicle); // split fields into 2 arrays $tables = array_chunk($fields, ceil(count($fields) / 2)); ?> <?php foreach ($tables as $table_fields) { ?> <table> <?php foreach ($table_fields as $data_key => $data_field) { ?> <?php wp_car_manager()->service('template_manager')->get_template_part('vehicle-data/data', $data_field, array('key' => $data_field, 'vehicle' => $vehicle));
function wpcm_template_submit_car_form_fields_car_data($vehicle) { // get fields $fields = Never5\WPCarManager\Vehicle\Data::get_fields(); if (!empty($fields)) { ?> <h2><?php _e('Car Data', 'wp-car-manager'); ?> </h2> <?php foreach ($fields as $field) { ?> <fieldset class="wpcm-fieldset-<?php esc_attr_e($field['key']); ?> "> <label for="<?php esc_attr_e($field['key']); ?> "><?php echo $field['label'] . apply_filters('wpcm_submit_car_form_required_label', $field['required'] ? '' : ' <small>' . __('(optional)', 'wp-car-manager') . '</small>', $field); ?> </label> <div class="wpcm-field <?php echo $field['required'] ? 'wpcm-required-field' : ''; ?> "> <?php $value = ''; // check if there's a post set if (!empty($_POST['wpcm_submit_car'][$field['key']])) { $value = esc_attr(sanitize_text_field(stripslashes($_POST['wpcm_submit_car'][$field['key']]))); } // if we don't have a POST, take the vehicle data if (empty($value)) { // getter method for value $get_method = 'get_' . $field['key']; $value = $vehicle->{$get_method}(); if ('frdate' === $field['key'] && null !== $value) { $value = $value->format('Y-m-d'); } } wp_car_manager()->service('template_manager')->get_template_part('submit-car-form/form-fields/' . $field['type'], '', array('field' => $field, 'value' => $value, 'vehicle' => $vehicle)); ?> </div> </fieldset> <?php } } }
<?php if (!defined('ABSPATH')) { exit; } // Exit if accessed directly $summary_data = Never5\WPCarManager\Vehicle\Data::remove_empty_fields(wp_car_manager()->service('settings')->get_option('summary_data'), $vehicle); ?> <div class="wpcm-summary-data"> <table> <?php foreach ($summary_data as $data_key) { ?> <?php wp_car_manager()->service('template_manager')->get_template_part('vehicle-data/data', $data_key, array('key' => $data_key, 'vehicle' => $vehicle)); ?> <?php } ?> </table> </div>