Tribe__Tickets__Data_API::detect_by_id( null $post = null )
Detect what is available in the custom post type by the id passed to it
Contents
Parameters
- $post
-
(null) (Optional) id or post object.
Default value: null
Return
(array|bool) An array of available information about the object and the tribe_tickets_tickets class to use
Source
File: src/Tribe/Data_API.php
public function detect_by_id( $post = null ) {
// only the rsvp order key is non numeric
if ( is_object( $post ) && ! empty( $post->ID ) ) {
$cpt = get_post_type( $post->ID );
$post = (int) $post->ID;
} elseif ( ! is_numeric( $post ) ) {
$post = esc_attr( $post );
$cpt = $this->check_rsvp_order_key_exists( $post );
} else {
$post = absint( $post );
$cpt = get_post_type( $post );
}
// if no custom post type
if ( ! $cpt ) {
return false;
}
$cpt_arr = array();
$cpt_arr['post_type'] = $cpt;
foreach ( $this->ticket_types as $type => $cpts ) {
if ( in_array( $cpt, $cpts ) ) {
$cpt_arr[] = $type;
}
}
foreach ( $this->ticket_class as $classes => $cpts ) {
if ( in_array( $cpt, $cpts ) ) {
$cpt_arr['class'] = $classes;
}
}
return $cpt_arr;
}