Inventory_Presser_Options::callback_additional_listings_page()

callback_additional_listings_page


Description Description

Outputs controls to manage additional inventory listing pages.

Helps users create an additional inventory archive at example.com/[cash-deals] that contains vehicles that have a value for field [Down Payment].


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-dealership-options.php

	function callback_additional_listings_page()
	{
		?><p><?php

		echo $this->boolean_checkbox_setting_callback(
			'additional_listings_page',
			__( 'Create additional inventory archive(s)', 'inventory-presser' )
		);

			//output a table to hold the settings for additional sheets
			?></p>
		<div id="additional_listings_pages_settings">
			<table class="wp-list-table widefat striped additional_listings_pages">
				<thead>
					<tr>
						<th><?php _e( 'URL path', 'inventory-presser' ); ?></th>
						<th><?php _e( 'Field', 'inventory-presser' ); ?></th>
						<th><?php _e( 'Operator', 'inventory-presser' ); ?></th>
						<th><?php _e( 'Value', 'inventory-presser' ); ?></th>
						<th></th>
					</tr>
				</thead>
				<tbody><?php

				//output a row for each saved additional listing page + one blank
				$additional_listings = Inventory_Presser_Additional_Listings_Pages::additional_listings_pages_array();
				if( empty( $additional_listings ) )
				{
					$additional_listings = array( array() );
				}
				$keys = array(
					'url_path',
					'key',
					'operator',
					'value',
				);
				for( $a=0; $a<sizeof( $additional_listings ); $a++ )
				{
					foreach( $keys as $key )
					{
						if( ! isset( $additional_listings[$a][$key] ) )
						{
							$additional_listings[$a][$key] = '';
						}
					}

					?><tr id="row_<?php echo $a; ?>">
						<td><?php

						//url path
						printf(
							'%s/<input type="text" id="additional_listings_pages_slug_%s" name="%s[additional_listings_pages][%s][url_path]" value="%s" />',
							site_url(),
							$a,
							INVP::OPTION_NAME,
							$a,
							$additional_listings[$a]['url_path']
						);

						?></td>
						<td><?php

						//select list of vehicle fields
						echo $this->html_select_vehicle_keys( array(
							'id'   => 'additional_listings_pages_key_' . $a,
							'name' => INVP::OPTION_NAME . '[additional_listings_pages][' . $a . '][key]',
						), $additional_listings[$a]['key'] );

						?></td>
						<td><?php

						//select list of operators
						echo $this->html_select_operator( array(
							'id'    => 'additional_listings_pages_operator_' . $a,
							'name'  => INVP::OPTION_NAME . '[additional_listings_pages][' . $a . '][operator]',
							'class' => 'operator',
						), $additional_listings[$a]['operator'] );

						?></td>
						<td><?php

						//text box for comparison value
						printf(
							'<input type="text" id="additional_listings_pages_value_%s" name="%s[additional_listings_pages][%s][value]" value="%s" />',
							$a,
							INVP::OPTION_NAME,
							$a,
							$additional_listings[$a]['value']
						);

						?></td>
						<td>
							<a href="<?php echo site_url( $additional_listings[$a]['url_path'] ); ?>" class="button action" title="View this page"><span class="dashicons dashicons-welcome-view-site"></span></a><?php
							?><button class="button action delete-button" id="delete_<?php echo $a; ?>" title="Delete this page"><span class="dashicons dashicons-trash"></span></button>
						</td>
					</tr><?php

				}

				?></tbody>
			</table>
			<button class="button action" id="add_additional_listings_page">Add Additional Listings Page</button>
		</div><?php
	}