/** * Enqueue the plugin stylesheet(s). * * @author caseypicker * @since 3.9 * @return void */ public function enqueue_styles() { //Only enqueue wootickets styles on singular event page if (is_singular(Tribe__Tickets__Main::instance()->post_types())) { $stylesheet_url = $this->pluginUrl . 'src/resources/css/wootickets.css'; // Get minified CSS if it exists $stylesheet_url = Tribe__Template_Factory::getMinFile($stylesheet_url, true); // apply filters $stylesheet_url = apply_filters('tribe_wootickets_stylesheet_url', $stylesheet_url); wp_enqueue_style('TribeEventsWooTickets', $stylesheet_url, array(), apply_filters('tribe_events_wootickets_css_version', self::VERSION)); //Check for override stylesheet $user_stylesheet_url = Tribe__Tickets__Templates::locate_stylesheet('tribe-events/wootickets/wootickets.css'); $user_stylesheet_url = apply_filters('tribe_events_wootickets_stylesheet_url', $user_stylesheet_url); //If override stylesheet exists, then enqueue it if ($user_stylesheet_url) { wp_enqueue_style('tribe-events-wootickets-override-style', $user_stylesheet_url); } } }
/** * Handles the "send to email" action for the attendees list. */ public function send_attendee_mail_list() { $error = new WP_Error(); if (empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'email-attendees-list') || !$this->user_can('edit_posts', $_GET['event_id'])) { $error->add('nonce-fail', esc_html__('Cheatin Huh?', 'event-tickets'), array('type' => 'general')); return $error; } if (empty($_GET['event_id'])) { $error->add('no-event-id', esc_html__('Invalid Event ID', 'event-tickets'), array('type' => 'general')); return $error; } if (empty($_POST['email_to_address']) && (empty($_POST['email_to_user']) || 0 >= (int) $_POST['email_to_user'])) { $error->add('empty-fields', esc_html__('Empty user and email', 'event-tickets'), array('type' => 'general')); return $error; } if (!empty($_POST['email_to_address'])) { $type = 'email'; } else { $type = 'user'; } if ('email' === $type && !is_email($_POST['email_to_address'])) { $error->add('invalid-email', esc_html__('Invalid Email', 'event-tickets'), array('type' => $type)); return $error; } if ('user' === $type && !is_numeric($_POST['email_to_user'])) { $error->add('invalid-user', esc_html__('Invalid User ID', 'event-tickets'), array('type' => $type)); return $error; } /** * Now we know we have valid data */ if ('email' === $type) { // We already check this variable so, no harm here $email = $_POST['email_to_address']; } else { $user = get_user_by('id', $_POST['email_to_user']); if (!is_object($user)) { $error->add('invalid-user', esc_html__('Invalid User ID', 'event-tickets'), array('type' => $type)); return $error; } $email = $user->data->user_email; } $this->attendees_table = new Tribe__Tickets__Attendees_Table(); $items = $this->generate_filtered_attendees_list($_GET['event_id']); $event = get_post($_GET['event_id']); ob_start(); $attendee_tpl = Tribe__Tickets__Templates::get_template_hierarchy('tickets/attendees-email.php', array('disable_view_check' => true)); include $attendee_tpl; $content = ob_get_clean(); add_filter('wp_mail_content_type', array($this, 'set_contenttype')); if (!wp_mail($email, sprintf(esc_html__('Attendee List for: %s', 'event-tickets'), $event->post_title), $content)) { $error->add('email-error', esc_html__('Error when sending the email', 'event-tickets'), array('type' => 'general')); return $error; } return esc_html__('Email sent successfully!', 'event-tickets'); }
/** * Includes a template part, similar to the WP get template part, but looks * in the correct directories for Tribe Tickets templates * * @param string $slug The Base template name * @param null|string $name (optional) if set will try to include `{$slug}-{$name}.php` file * @param array $data (optional) array of vars to inject into the template part * @param boolean $echo (optional) Allows the user to print or return the template * * @uses Tribe__Tickets__Templates::get_template_hierarchy * * @return string|void It will depend if it's echoing or not **/ function tribe_tickets_get_template_part($slug, $name = null, array $data = null, $echo = true) { /** * Fires an Action before echoing the Template * * @param string $slug Slug for this template * @param string $name Template name * @param array $data The Data that will be used on this template */ do_action('tribe_tickets_pre_get_template_part', $slug, $name, $data); // Setup possible parts $templates = array(); if (isset($name)) { $templates[] = $slug . '-' . $name . '.php'; } $templates[] = $slug . '.php'; /** * Allow users to filter which templates can be included * * @param string $template The Template file, which is a relative path from the Folder we are dealing with * @param string $slug Slug for this template * @param string $name Template name * @param array $data The Data that will be used on this template */ $templates = apply_filters('tribe_tickets_get_template_part_templates', $templates, $slug, $name, $data); // Make any provided variables available in the template's symbol table if (is_array($data)) { extract($data); } // loop through templates, return first one found. foreach ($templates as $template) { $file = Tribe__Tickets__Templates::get_template_hierarchy($template, array('disable_view_check' => true)); /** * Allow users to filter which template will be included * * @param string $file Complete path to include the PHP File * @param string $template The Template file, which is a relative path from the Folder we are dealing with * @param string $slug Slug for this template * @param string $name Template name * @param array $data The Data that will be used on this template */ $file = apply_filters('tribe_tickets_get_template_part_path', $file, $template, $slug, $name, $data); /** * A more Specific Filter that will include the template name * * @param string $file Complete path to include the PHP File * @param string $slug Slug for this template * @param string $name Template name * @param array $data The Data that will be used on this template */ $file = apply_filters("tribe_tickets_get_template_part_path_{$template}", $file, $slug, $name, $data); if (!file_exists($file)) { continue; } ob_start(); /** * Fires an Action before including the template file * * @param string $template The Template file, which is a relative path from the Folder we are dealing with * @param string $file Complete path to include the PHP File * @param string $slug Slug for this template * @param string $name Template name * @param array $data The Data that will be used on this template */ do_action('tribe_tickets_before_get_template_part', $template, $file, $slug, $name, $data); include $file; /** * Fires an Action After including the template file * @param string $template The Template file, which is a relative path from the Folder we are dealing with * @param string $file Complete path to include the PHP File * @param string $slug Slug for this template * @param string $name Template name * @param array $data The Data that will be used on this template */ do_action('tribe_tickets_after_get_template_part', $template, $file, $slug, $name, $data); $html = ob_get_clean(); /** * Allow users to filter the final HTML * @param string $html The final HTML * @param string $template The Template file, which is a relative path from the Folder we are dealing with * @param string $file Complete path to include the PHP File * @param string $slug Slug for this template * @param string $name Template name * @param array $data The Data that will be used on this template */ $html = apply_filters('tribe_tickets_get_template_part_content', $html, $template, $file, $slug, $name, $data); if ($echo) { echo $html; } break; } /** * Files an Action after echoing/saving the html Template * * @param string $slug Slug for this template * @param string $name Template name * @param array $data The Data that will be used on this template */ do_action('tribe_tickets_post_get_template_part', $slug, $name, $data); if (!$echo) { // Return should come at the end return $html; } }
/** * Injects the Link to The front-end Tickets page to non Events * * @param string $content The content form the post * @return string $content */ public function inject_link_template_the_content($content) { // Prevents firing more then it needs too outside of the loop $in_the_loop = isset($GLOBALS['wp_query']->in_the_loop) && $GLOBALS['wp_query']->in_the_loop; $post_id = get_the_ID(); $user_id = get_current_user_id(); /** * @todo Remove this after we implement the Rewrites in Common */ $is_event_query = !empty($GLOBALS['wp_query']->tribe_is_event_query); // When it's not our query we don't care if (class_exists('Tribe__Events__Main') && $is_event_query || !$in_the_loop) { return $content; } // If we have this we are already on the tickets page $is_correct_page = get_query_var('tribe-edit-orders', false); if ($is_correct_page) { return $content; } if (!$this->has_rsvp_attendees($post_id, $user_id) && !$this->has_ticket_attendees($post_id, $user_id)) { return $content; } ob_start(); include Tribe__Tickets__Templates::get_template_hierarchy('tickets/orders-link.php'); $content .= ob_get_clean(); return $content; }
/** * Gets the user's attendance data and passes it to the relevant view. */ protected function generate_attendance_list() { $event_ids = $this->get_upcoming_attendances(); include Tribe__Tickets__Templates::get_template_hierarchy('shortcodes/my-attendance-list'); }