Inventory_Presser_Plugin::modify_query_orderby( array $pieces )

Filter callback. Modifies a query’s ORDER BY clause to appropriately sort some meta values as numbers instead of strings while adding fields to the ORDER BY clause to account for all of the JOINs to the postmeta.


Parameters Parameters

$pieces

(array) (Required) All of a queries syntax organized into an array.


Top ↑

Return Return

(array) The changed array of database query fragments


Top ↑

Source Source

File: inventory-presser.php

					$replacement .= $direction;
					if ( $m < ( $meta_field_count - 1 ) ) {
						$replacement .= ', ';
					}
				}

				$pieces['orderby'] = $replacement;
			}
			return $pieces;
		}

		/**
		 * Action hook callback. Prevents vehicles from lingering in the Trash after
		 * they've been deleted if a plugin setting dictates such behavior.
		 *
		 * @param  int $post_id
		 * @return void
		 */
		public function maybe_force_delete( $post_id ) {
			// is the post a vehicle?
			if ( INVP::POST_TYPE !== get_post_type( $post_id ) ) {
				return;
			}

			$settings = INVP::settings();
			if ( ! $settings['skip_trash'] ) {
				return;
			}

			// force delete.
			wp_delete_post( $post_id, true );
		}

		/**
		 * Registers all meta fields our custom post type uses to define a vehicle
		 * and its attachments.
		 *
		 * @return void
		 */
		public function register_meta_fields() {
			// Add meta fields to our post type.
			foreach ( INVP::keys_and_types( true ) as $key_arr ) {

				if ( empty( $key_arr['name'] ) ) {
					continue;
				}
				$key = apply_filters( 'invp_prefix_meta_key', $key_arr['name'] );