Tribe__Tickets__Tickets_Handler::save_order( int $post, $tickets = null )
Save the the drag-n-drop ticket order
Contents
Parameters
- $post
-
(int) (Required)
Source
File: src/Tribe/Tickets_Handler.php
public function save_order( $post, $tickets = null ) {
// We're calling this during post save, so the save nonce has already been checked.
// don't do anything on autosave, auto-draft, or massupdates
if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
return false;
}
if ( ! $post instanceof WP_Post ) {
$post = get_post( $post );
}
// Bail on Invalid post
if ( ! $post instanceof WP_Post ) {
return false;
}
// If we didn't get any Ticket data we fetch from the $_POST
if ( is_null( $tickets ) ) {
$tickets = tribe_get_request_var( array( 'tribe-tickets', 'list' ), null );
}
if ( empty( $tickets ) ) {
return false;
}
foreach ( $tickets as $id => $ticket ) {
if ( ! isset( $ticket['order'] ) ) {
continue;
}
$args = array(
'ID' => absint( $id ),
'menu_order' => (int) $ticket['order'],
);
$updated[] = wp_update_post( $args );
}
// Verify if any failed
return ! in_array( 0, $updated );
}
Changelog
| Version | Description |
|---|---|
| 4.6 | Introduced. |