Inventory_Presser_Customize_Dashboard::meta_box_html_vehicle( WP_Post $post, mixed $meta_box )

meta_box_html_vehicle


Description Description

Creates a meta box to help the user manage the bulk of the meta fields that define a vehicle.


Top ↑

Parameters Parameters

$post

(WP_Post) (Required)

$meta_box

(mixed) (Required)


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-customize-admin-dashboard.php

	function meta_box_html_vehicle( $post, $meta_box )
	{
		//HTML output for vehicle data meta box
		$custom = get_post_custom( $post->ID );

		$body_style = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'body_style' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'body_style' )][0] : '' );
		$color = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'color' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'color' )][0] : '' );
		$engine = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'engine' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'engine' )][0] : '' );
		$interior_color = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'interior_color' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'interior_color' )][0] : '' );
		$make = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'make' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'make' )][0] : '' );
		$model = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'model' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'model' )][0] : '' );
		$odometer = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'odometer' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'odometer' )][0] : '' );
		$stock_number = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'stock_number' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'stock_number' )][0] : '' );
		$trim = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'trim' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'trim' )][0] : '' );
		$VIN = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'vin' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'vin' )][0] : '' );
		$year = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'year' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'year' )][0] : '' );
		$youtube = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'youtube' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'youtube' )][0] : '' );

		//boat items
		$beam = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'beam' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'beam' )][0] : '' );
		$length = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'length' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'length' )][0] : '' );
		$hull_material = ( isset( $custom[apply_filters( 'invp_prefix_meta_key', 'hull_material' )] ) ? $custom[apply_filters( 'invp_prefix_meta_key', 'hull_material' )][0] : '' );

		printf(
			'<table class="form-table"><tbody>'

		//VIN
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td>%s</td>'

		//Stock number
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td>'

		//Year
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><select name="%s"><option></option>',

			apply_filters( 'invp_prefix_meta_key', 'vin' ),
			__( 'VIN', 'inventory-presser' ),
			apply_filters( 'invp_edit_control_vin', sprintf(
				'<input type="text" name="%s" maxlength="17" value="%s">',
				apply_filters( 'invp_prefix_meta_key', 'vin' ),
				$VIN
			) ),

			apply_filters( 'invp_prefix_meta_key', 'stock_number' ),
			__( 'Stock number', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'stock_number' ),
			$stock_number,

			apply_filters( 'invp_prefix_meta_key', 'year' ),
			__( 'Year', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'year' )
		);

		for( $y=date('Y')+2; $y>=1920; $y-- )
		{
			printf(
				'<option%s>%s</option>',
				selected( $y, $year, false ),
				$y
			);
		}

		printf(
			'</select></td></tr>'

		//Make
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td></tr>'

		//Model
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td></tr>'

		//Trim level
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td></tr>'

		//Engine
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td></tr>'

		//Body style
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" id="%s" value="%s">'

			. '<select name="%s_hidden" id="%s_hidden">',

			apply_filters( 'invp_prefix_meta_key', 'make' ),
			__( 'Make', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'make' ),
			$make,

			apply_filters( 'invp_prefix_meta_key', 'model' ),
			__( 'Model', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'model' ),
			$model,

			apply_filters( 'invp_prefix_meta_key', 'trim' ),
			__( 'Trim', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'trim' ),
			$trim,

			apply_filters( 'invp_prefix_meta_key', 'engine' ),
			__( 'Engine', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'engine' ),
			$engine,

			apply_filters( 'invp_prefix_meta_key', 'body_style' ),
			__( 'Body style', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'body_style' ),
			apply_filters( 'invp_prefix_meta_key', 'body_style' ),
			$body_style,
			apply_filters( 'invp_prefix_meta_key', 'body_style' ),
			apply_filters( 'invp_prefix_meta_key', 'body_style' )
		);

		$boat_styles = apply_filters( 'invp_default_boat_styles', array(
			'Bass boat',
			'Bow Rider',
			'Cabin Cruiser',
			'Center Console',
			'Cuddy Cabin',
			'Deck boat',
			'Performance',
			'Pontoon',
		) );
		foreach( $boat_styles as $s )
		{
			printf(
				'<option%s>%s</option>',
				selected( $s, $body_style ),
				$s
			);
		}

		printf( '</select></td></tr>'

		//Color
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td></tr>'

		//Interior color
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td></tr>'

		//Odometer
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s">'
			. ' <span class="invp_odometer_units">%s</span></td></tr>'

		//YouTube
			. '<tr><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td></tr>'

		//Beam (boats)
			. '<tr class="boat-postmeta"><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td></tr>'

		//Length (boats)
			. '<tr class="boat-postmeta"><th scope="row"><label for="%s">%s</label></th>'
			. '<td><input type="text" name="%s" value="%s"></td></tr>'

		//Hull material
			. '<tr class="boat-postmeta"><th scope="row"><label for="%s">%s</label></th>'
			. '<td><select name="%s"><option></option>',

			apply_filters( 'invp_prefix_meta_key', 'color' ),
			__( 'Color', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'color' ),
			$color,

			apply_filters( 'invp_prefix_meta_key', 'interior_color' ),
			__( 'Interior color', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'interior_color' ),
			$interior_color,

			apply_filters( 'invp_prefix_meta_key', 'odometer' ),
			__( 'Odometer', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'odometer' ),
			$odometer,
			apply_filters( 'invp_odometer_word', 'miles' ),

			apply_filters( 'invp_prefix_meta_key', 'youtube' ),
			__( 'YouTube video ID', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'youtube' ),
			$youtube,

			apply_filters( 'invp_prefix_meta_key', 'beam' ),
			__( 'Beam', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'beam' ),
			$beam,

			apply_filters( 'invp_prefix_meta_key', 'length' ),
			__( 'Length', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'length' ),
			$length,

			apply_filters( 'invp_prefix_meta_key', 'hull_material' ),
			__( 'Hull material', 'inventory-presser' ),
			apply_filters( 'invp_prefix_meta_key', 'hull_material' )
		);

		$hull_materials = apply_filters( 'invp_default_hull_materials', array(
			'Aluminum',
			'Carbon Fiber',
			'Composite',
			'Ferro-Cement',
			'Fiberglass',
			'Hypalon',
			'Other',
			'PVC',
			'Steel',
			'Wood',
		) );
		foreach( $hull_materials as $m )
		{
			printf(
				'<option%s>%s</option>',
				selected( $m, $hull_material, false ),
				$m
			);
		}
		echo '</select></tbody></table>';
	}