tribe_tickets_is_enabled_post_context( null|int|WP_Post $post = null )
If we are in the front-end or back-end (e.g. currently editing or creating) context for a tickets-enabled post.
Contents
See also
Parameters
- $post
-
(null|int|WP_Post) (Optional) Post ID or object,
nullto get the ID of the global/current post object.Default value: null
Return
(bool) True if creating/editing (back-end) or viewing single or archive (front-end) of enabled post type.
Source
File: src/template-tags/tickets.php
function tribe_tickets_is_enabled_post_context( $post = null ) {
/** @var Tribe__Context $context */
$context = tribe( 'context' );
/** @var Tribe__Tickets__Main $main */
$main = tribe( 'tickets.main' );
$post_types = $main->post_types();
// Back-end
if ( $context->is_editing_post( $post_types ) ) {
return true;
}
// Front-end singular
$post = Tribe__Main::post_id_helper( $post );
if (
! empty( $post )
&& in_array( get_post_type( $post ), $post_types, true )
) {
return true;
}
// Front-end archive
if ( is_post_type_archive( $post_types ) ) {
return true;
}
/**
* Whether or not we are in tickets-enabled context, such as determining if we should load plugin assets.
*
* @since 4.11.1
*
* @param bool $result
* @param array $post_types The post types with tickets enabled.
* @param Tribe__Context $context
*
* @return bool
*/
return apply_filters( 'tribe_tickets_is_enabled_post_context', false, $post_types, $context );
}
Changelog
| Version | Description |
|---|---|
| 4.11.1 | Introduced. |