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.
On This Page
Parameters Parameters
- $post_ID
-
(int) (Required) Post ID.
- $post
-
(WP_Post) (Required) Post object.
- $update
-
(bool) (Required) Whether this is an existing post being updated.
Source Source
File: inventory-presser.php
public function mark_vehicles_for_sale_during_insertion( $post_ID, $post, $update ) {
if ( $update ) {
// Abort, we only want to affect insertions.
return;
}
// 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.
return;
}
// No, create a relationship with "For Sale".
wp_set_object_terms( $post_ID, 'for-sale', 'availability' );
}
Expand full source codeCollapse full source codeView on Github