ost, $update ); } /** * Filters the object returned by the `tribe_get_event` function to add to it properties related to event status. * * @since 5.11.0 * * @param WP_Post $post The events post object to be modified. * * @return \WP_Post The original event object decorated with properties related to event status. */ public function filter_tribe_get_event( $post ) { if ( ! $post instanceof WP_Post ) { // We should only act on event posts, else bail. return $post; } return $this->container->make( Models\Event::class )->add_properties( $post ); } /** * Add, to the Context, the locations used by the plugin. * * @since 5.11.0 * * @param array $context_locations The current Context locations. * * @return array The updated Context locations. */ public function filter_context_locations( array $context_locations ) { $context_locations['events_status_data'] = [ 'read' => [ Context::REQUEST_VAR => [ Classic_Editor::$id ], ], ]; return $context_locations; } /** * Add the event statuses to select for an event. * * @since 5.11.0 * * @param array $statuses The event status options for an event. * @param string $current_status The current event status for the event or empty string if none. * * @return array The event status options for an event. */ public function filter_event_statuses( $statuses, $current_status ) { return $this->container->make( Status_Labels::class )->filter_event_statuses( $statuses, $current_status ); } /** * Add the status classes for the views v2 elements * * @since 5.11.0 * * @param array $classes Space-separated string or array of class names to add to the class list. * @param int|WP_Post $post Post ID or post object. * * @return array An array of post classes with the status added. */ public function filter_add_post_class( $classes, $class, $post ) { $new_classes = $this->container->make( Template_Modifications::class )->get_post_classes( $post ); return array_merge( $classes, $new_classes ); } /** * Modifiers to the JSON LD object we use. * * @since 5.11.0 * * @param object $data The JSON-LD object. * @param array $args The arguments used to get data. * @param WP_Post $post The post object. * * @return object JSON LD object after modifications. */ public function filter_json_ld_modifiers( $data, $args, $post ) { return $this->container->make( JSON_LD::class )->modify_event( $data, $args, $post ); } /** * Adds the templates for event status. * * @since 5.11.0 */ protected function add_templates() { // "Classic" Event Single. add_filter( 'tribe_the_notices', [ $this, 'filter_include_single_status_reason' ], 15, 2 ); $label_templates = [ // List View. 'events/v2/list/event/title:after_container_open', // Month View. 'events/v2/month/calendar-body/day/calendar-events/calendar-event/title:after_container_open', 'events/v2/month/calendar-body/day/calendar-events/calendar-event/tooltip/title:after_container_open', 'events/v2/month/mobile-events/mobile-day/mobile-event/title:after_container_open', 'events/v2/month/calendar-body/day/multiday-events/multiday-event/bar/title:after_container_open', 'events/v2/month/calendar-body/day/multiday-events/multiday-event/hidden/link/title:after_container_open', // Day View. 'events/v2/day/event/title:after_container_open', // Latest Past Events View. 'events/v2/latest-past/event/title:after_container_open', // List Widget. 'events/v2/widgets/widget-events-list/event/title:after_container_open', ]; /** * Filters the list of template where the event status label is added. * * @since 5.11.0 * * @param array $label_templates The array of template names for each view to add the status label. */ $label_templates = apply_filters( 'tec_event_status_templates', $label_templates ); foreach ( $label_templates as $template ) { if ( ! is_string( $template ) ) { continue; } add_filter( 'tribe_template_entry_point:' . $template, [ $this, 'filter_insert_status_label' ], 15, 3 ); } } /** * Include the status reason for the single pages. * * @since 5.11.0 * * @param string $notices_html Previously set HTML. * @param array $notices Array of notices added previously. * * @return string Before event html with the status reason. */ public function filter_include_single_status_reason( $notices_html, $notices ) { return $this->container->make( Template_Modifications::class )->add_single_status_reason( $notices_html, $notices ); } /** * Inserts Status Label. * * @since 5.11.0 * * @param string $hook_name For which template include this entry point belongs. * @param string $entry_point_name Which entry point specifically we are triggering. * @param Template $template Current instance of the Template. */ public function filter_insert_status_label( $hook_name, $entry_point_name, $template ) { return $this->container->make( Template_Modifications::class )->insert_status_label( $hook_name, $entry_point_name, $template ); } /** * Handles the compatibility with the "The Events Calendar Extension: Events Control" plugin. * * @since 5.12.1 */ public function handle_events_control_extension() { if ( ! class_exists( Events_Control_Main::class ) ) { return; } $this->container->register( Compatibility\Events_Control_Extension\Service_Provider::class ); } /** * Handles the compatibility with the Filter Bar plugin. * * @since 5.12.1 */ public function handle_filter_bar() { if ( ! tribe( Detect::class )::is_active() ) { return; } $this->container->register( Compatibility\Filter_Bar\Service_Provider::class ); } }