Inventory_Presser_Plugin::mark_vehicles_for_sale_during_insertion( int $post_ID, WP_Post $post, bool $update )

Fires once a vehicle post has been saved.

Parameters Parameters


(int) (Required) Post ID.


(WP_Post) (Required) Post object.


(bool) (Required) Whether this is an existing post being updated.

Top ↑

Source Source

File: inventory-presser.php

	function mark_vehicles_for_sale_during_insertion( $post_ID, $post, $update )
		if( $update )
			//Abort, we only want to affect insertions

		//Does the vehicle already have a term in the Availabilities taxonomy?
		$terms = wp_get_object_terms( $post_ID, 'availability' );
		if( ! empty( $terms ) && is_array( $terms ) )
			//Yes, abort

		//No, create a relationship with "For Sale"
		wp_set_object_terms( $post_ID, 'for-sale', 'availability' );