Inventory_Presser_Order_By_Widget::get_post_meta_keys_and_labels( array $instance )

get_post_meta_keys_and_labels


Description

Produces an associative array where the post meta keys are the keys and the values are human-readable labels.


Parameters

$instance

(array) (Required) The widget options


Return

(array)


Source

File: includes/widget/class-widget-order-by.php

	function get_post_meta_keys_and_labels( $instance ) {
		/**
		 * Example output
		 *
		 *    array(
		 *        '{meta-prefix}odometer' => 'Odometer',
		 *        '{meta-prefix}price'    => 'Price',
		 *    )
		 */
		$arr = array();
		foreach ( INVP::keys() as $key ) {
			$key = apply_filters( 'invp_prefix_meta_key', $key );
			// if we have a saved label, use that. otherwise, create a label
			$arr[ $key ] = ( isset( $instance[ 'label-' . $key ] ) ? $instance[ 'label-' . $key ] : $this->prettify_meta_key( $key ) );
		}
		/**
		 * Some fields do not make sense to order by, such as interior color & VIN
		 */
		$ignored_keys = array(
			apply_filters( 'invp_prefix_meta_key', 'body_style' ),
			apply_filters( 'invp_prefix_meta_key', 'car_id' ),
			apply_filters( 'invp_prefix_meta_key', 'color' ),
			apply_filters( 'invp_prefix_meta_key', 'dealer_id' ),
			apply_filters( 'invp_prefix_meta_key', 'edmunds_style_id' ),
			apply_filters( 'invp_prefix_meta_key', 'engine' ),
			apply_filters( 'invp_prefix_meta_key', 'featured' ),
			apply_filters( 'invp_prefix_meta_key', 'interior_color' ),
			apply_filters( 'invp_prefix_meta_key', 'leads_id' ),
			apply_filters( 'invp_prefix_meta_key', 'options_array' ),
			apply_filters( 'invp_prefix_meta_key', 'prices' ),
			apply_filters( 'invp_prefix_meta_key', 'trim' ),
			apply_filters( 'invp_prefix_meta_key', 'vin' ),
		);
		foreach ( apply_filters( 'invp_sort_by_widget_ignored_fields', $ignored_keys ) as $ignored_key ) {
			unset( $arr[ $ignored_key ] );
		}
		return $arr;
	}