Tribe__Events__Community__Event_Form::should_show_series_module()
Source
File: src/Tribe/Event_Form.php
public function should_show_series_module() {
if ( ! apply_filters( 'tec_community_events_use_series', false ) ) {
return false;
}
if ( ! class_exists( '\TEC\Events_Pro\Custom_Tables\V1\Series\Post_Type' ) ) {
return false;
}
$post_type = \TEC\Events_Pro\Custom_Tables\V1\Series\Post_Type::POSTTYPE;
// Otherwise let's check and ensure there are some posts for the user to select from:
// we'll apply the same logic as in Tribe__Events__Linked_Posts::saved_linked_post_dropdown()
// in terms of determining which post statuses are relevant
$pto = get_post_type_object( $post_type );
$statuses = current_user_can( $pto->cap->edit_others_posts )
? [ 'publish', 'draft', 'private', 'pending' ]
: [ 'publish' ];
$fetch_post = get_posts(
[
'post_type' => $post_type,
'fields' => 'ids',
'posts_per_page' => 1,
'post_status' => $statuses,
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
]
);
$posts_are_available = (bool) count( $fetch_post );
/**
* Dictates where the linked post module should be displayed or not.
*
* @since 4.10.0
*
* @param bool $should_show_module
* @param string $post_type
*/
return apply_filters( 'tribe_events_community_should_show_series_module',
$posts_are_available,
$post_type
);
}