protected function setup_where_clause() { /** @var wpdb $wpdb */ global $wpdb; $clauses = array(); $values = array_map('intval', $this->currentValue); $values = implode(',', $values); $eod_cutoff = tribe_get_option('multiDayCutoff', '00:00'); if ($eod_cutoff != '00:00') { $eod_time_difference = Tribe__Date_Utils::time_between('1/1/2014 00:00:00', "1/1/2014 {$eod_cutoff}:00"); $start_date = "DATE_SUB({$wpdb->postmeta}.meta_value, INTERVAL {$eod_time_difference} SECOND)"; $end_date = "DATE_SUB(tribe_event_end_date.meta_value, INTERVAL {$eod_time_difference} SECOND)"; } else { $start_date = "{$wpdb->postmeta}.meta_value"; $end_date = 'tribe_event_end_date.meta_value'; } $clauses[] = "(DAYOFWEEK({$start_date}) IN ({$values}))"; // is it on at least 7 days (first day is 0) $clauses[] = "(DATEDIFF({$end_date}, {$start_date}) >=6)"; // determine if the start of the nearest matching day is between the start and end dates $distance_to_day = array(); foreach ($this->currentValue as $day_of_week_index) { $day_of_week_index = (int) $day_of_week_index; $distance_to_day[] = "MOD( 7 + {$day_of_week_index} - DAYOFWEEK({$start_date}), 7 )"; } if (count($distance_to_day) > 1) { $distance_to_next_matching_day = 'LEAST(' . implode(',', $distance_to_day) . ')'; } else { $distance_to_next_matching_day = reset($distance_to_day); } $clauses[] = "(DATE(DATE_ADD({$start_date}, INTERVAL {$distance_to_next_matching_day} DAY)) < {$end_date})"; $this->whereClause = ' AND (' . implode(' OR ', $clauses) . ')'; }
public function render() { $aggregator = Tribe__Events__Aggregator::instance(); $event_id = get_the_ID(); $record = Tribe__Events__Aggregator__Records::instance()->get_by_event_id($event_id); $last_import = null; $source = null; $origin = null; if (is_wp_error($record)) { $last_import = get_post_meta($event_id, Tribe__Events__Aggregator__Event::$updated_key, true); $source = get_post_meta($event_id, Tribe__Events__Aggregator__Event::$source_key, true); $origin = get_post_meta($event_id, Tribe__Events__Aggregator__Event::$origin_key, true); } else { $last_import = $record->post->post_modified; $source_info = $record->get_source_info(); $source = $source_info['title']; $origin = $record->origin; } $origin = $aggregator->api('origins')->get_name($origin); $datepicker_format = Tribe__Date_Utils::datepicker_formats(tribe_get_option('datepickerFormat')); $last_import = $last_import ? tribe_format_date($last_import, true, $datepicker_format . ' h:i a') : null; $settings_link = Tribe__Settings::instance()->get_url(array('tab' => 'imports')); $import_setting = tribe_get_option('tribe_aggregator_default_update_authority', Tribe__Events__Aggregator__Settings::$default_update_authority); include Tribe__Events__Main::instance()->plugin_path . 'src/admin-views/aggregator/meta-box.php'; }
/** * Returns the closing tag of the disabled bar wrapper * * @return array The new body class array */ public function disabled_bar_after($after) { if (tribe_get_option('tribeDisableTribeBar', false) == true) { $after = '</div>'; echo $after; } }
function show_related_workshops() { if (tribe_get_option('hideRelatedWorkshops', false) == true) { return false; } return true; }
/** * Queues the import on the Aggregator service */ public function queue_import($args = array()) { $meetup_api_key = tribe_get_option('meetup_api_key'); $defaults = array('meetup_api_key' => $meetup_api_key); $args = wp_parse_args($args, $defaults); return parent::queue_import($args); }
public function __construct($data = array()) { parent::__construct($data); if (!isset($data['name'])) { $this->name = 'eventlist'; } if (!isset($data['posts'])) { $event_args = array(); // Get the active plugins. $active_plugins = get_option('active_plugins'); // We do some guessing here for Tzolkin if (in_array('tzolkin/tzolkin.php', $active_plugins)) { $event_args = ['post_type' => 'tz_events']; } // Some more guessing for The Events Calendar if (in_array('the-events-calendar/the-events-calendar.php', $active_plugins)) { $event_args = ['post_type' => \Tribe__Events__Main::POSTTYPE, 'orderby' => 'event_date', 'order' => 'ASC', 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'tribe_render_context' => 'default']; } $eventlist_event_args_filter = $this->name . '_event_args'; $event_args = apply_filters($eventlist_event_args_filter, $event_args); Atom::add_debug_entry('Filter', $eventlist_event_args_filter); $this->posts = new \WP_Query($event_args); } if (!isset($data['posts-structure'])) { $posts_structure = ['PostClass' => ['children' => ['image', 'text']], 'image' => ['parts' => ['PostThumbnail']], 'text' => ['parts' => ['EventBadge', 'PostTitleLink', 'EventDate', 'ForceExcerpt', 'PostLink' => 'Read More']]]; $postlist_posts_structure_filter = $this->name . '_posts_structure'; $this->posts_structure = apply_filters($postlist_posts_structure_filter, $posts_structure); Atom::add_debug_entry('Filter', $postlist_posts_structure_filter); } }
/** * Enqueue the appropriate CSS for the calendar/advanced list widgets, which share * the same basic appearance. */ public static function enqueue_calendar_widget_styles() { // CSS file $event_file = 'widget-calendar.css'; $event_file_option = 'widget-calendar-theme.css'; $stylesheet_option = tribe_get_option('stylesheetOption', 'tribe'); // Choose the appropriate stylesheet in light of the current styling options switch ($stylesheet_option) { case 'skeleton': case 'full': $event_file_option = "widget-calendar-{$stylesheet_option}.css"; break; } $style_url = tribe_events_pro_resource_url($event_file_option); $style_url = apply_filters('tribe_events_pro_widget_calendar_stylesheet_url', $style_url); $style_override_url = Tribe__Events__Templates::locate_stylesheet('tribe-events/pro/' . $event_file, $style_url); // Load up stylesheet from theme or plugin if ($style_url && 'tribe' === $stylesheet_option) { wp_enqueue_style('widget-calendar-pro-style', tribe_events_pro_resource_url('widget-calendar-full.css'), array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-calendar-pro-style', $style_url, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } else { wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-calendar-pro-style', $style_url, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } if ($style_override_url) { wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '--widget-calendar-pro-override-style', $style_override_url, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } }
/** * AJAX handler for the Map view */ public function ajax_response() { $tribe_paged = !empty($_POST['tribe_paged']) ? $_POST['tribe_paged'] : 1; Tribe__Events__Query::init(); $post_status = array('publish'); if (is_user_logged_in()) { $post_status[] = 'private'; } $defaults = array('post_type' => Tribe__Events__Main::POSTTYPE, 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'paged' => $tribe_paged, 'post_status' => $post_status, 'eventDisplay' => 'map', 'tribe_geoloc' => true); $view_state = 'map'; /* if past view */ if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') { $view_state = 'past'; $defaults['eventDisplay'] = 'past'; $defaults['order'] = 'DESC'; } if (isset($_POST['tribe_event_category'])) { $defaults[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category']; } if (isset($_POST[Tribe__Events__Main::TAXONOMY])) { $defaults[Tribe__Events__Main::TAXONOMY] = $_POST[Tribe__Events__Main::TAXONOMY]; } $query = Tribe__Events__Query::getEvents($defaults, true); $have_events = 0 < $query->found_posts; if ($have_events && Tribe__Events__Pro__Geo_Loc::instance()->is_geoloc_query()) { $lat = isset($_POST['tribe-bar-geoloc-lat']) ? $_POST['tribe-bar-geoloc-lat'] : 0; $lng = isset($_POST['tribe-bar-geoloc-lng']) ? $_POST['tribe-bar-geoloc-lng'] : 0; Tribe__Events__Pro__Geo_Loc::instance()->assign_distance_to_posts($query->posts, $lat, $lng); } elseif (!$have_events && isset($_POST['tribe-bar-geoloc'])) { Tribe__Notice::set_notice('event-search-no-results', sprintf(__('No results were found for events in or near <strong>"%s"</strong>.', 'tribe-events-calendar-pro'), esc_html($_POST['tribe-bar-geoloc']))); } elseif (!$have_events && isset($_POST['tribe_event_category'])) { Tribe__Notice::set_notice('events-not-found', sprintf(__('No matching events listed under %s. Please try viewing the full calendar for a complete list of events.', 'tribe-events-calendar-pro'), esc_html($_POST['tribe_event_category']))); } elseif (!$have_events) { Tribe__Notice::set_notice('event-search-no-results', __('There were no results found.', 'tribe-events-calendar-pro')); } $response = array('html' => '', 'markers' => array(), 'success' => true, 'tribe_paged' => $tribe_paged, 'max_pages' => $query->max_num_pages, 'total_count' => $query->found_posts, 'view' => $view_state); // @TODO: clean this up / refactor the following conditional if ($have_events) { global $wp_query, $post; $data = $query->posts; $post = $query->posts[0]; $wp_query = $query; Tribe__Events__Main::instance()->displaying = 'map'; ob_start(); tribe_get_view('pro/map/content'); $response['html'] .= ob_get_clean(); $response['markers'] = Tribe__Events__Pro__Geo_Loc::instance()->generate_markers($data); } else { global $wp_query; $wp_query = $query; Tribe__Events__Main::instance()->setDisplay(); ob_start(); tribe_get_view('pro/map/content'); $response['html'] .= ob_get_clean(); } $response = apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); exit; }
/** * Queues the import on the Aggregator service */ public function queue_import($args = array()) { $fb_token = tribe_get_option('fb_token'); $defaults = array('facebook_token' => $fb_token); $args = wp_parse_args($args, $defaults); return parent::queue_import($args); }
/** * Output a link for the mini calendar month previous nav, includes data attributes needed to update the month with ajax * * @return void **/ function tribe_events_the_mini_calendar_title() { $args = tribe_events_get_mini_calendar_args(); $date = strtotime($args['eventDate']); $date_format = tribe_get_option('monthAndYearFormat', 'M Y'); $title = tribe_event_format_date($date, false, $date_format); echo apply_filters('tribe_events_the_mini_calendar_title', $title); }
/** * Adds the browser key api key to the Google Maps JavaScript API url if set by the user. * * @param string $js_maps_api_url * * @return string */ public function filter_tribe_events_google_maps_api($js_maps_api_url) { $key = tribe_get_option($this->api_key_option_name); if (!empty($key)) { $js_maps_api_url = add_query_arg('key', $key, $js_maps_api_url); } return $js_maps_api_url; }
private function is_version_in_db_less_than($version) { $version_in_db = tribe_get_option('pro-schema-version', 0); if (version_compare($version, $version_in_db) > 0) { return TRUE; } return FALSE; }
public static function get_abbreviation() { $unit = tribe_get_option('geoloc_default_unit', 'miles'); if ($unit == 'miles') { return _x('mi', 'Abbreviation for the miles unit of measure', 'the-events-calendar'); } else { return _x('km', 'Abbreviation for the kilometers unit of measure', 'the-events-calendar'); } }
/** * constructor */ public function __construct() { $this->default_venue = (int) tribe_get_option('eventsDefaultVenueID', 0); $this->default_organizer = (int) tribe_get_option('eventsDefaultOrganizerID', 0); if (class_exists('TribeCommunityEvents')) { $community = TribeCommunityEvents::instance(); $this->default_community_venue = (int) $community->getOption('defaultCommunityVenueID', 0); $this->default_community_organizer = (int) $community->getOption('defaultCommunityOrganizerID', 0); } }
/** * Check to make sure that 'previous_ecp_versions' is saving correctly. * * @since 2.0.5 * @author Paul Hughes */ function test_previous_ecp_versions_saving() { $tribe_ecp = TribeEvents::instance(); $tribe_ecp->init(); $tribe_ecp->setOption('latest_ecp_version', '1.6.5'); $tribe_ecp->init(); $previous_ecp_versions = tribe_get_option('previous_ecp_versions'); $this->assertEquals('0', $previous_ecp_versions[0]); $this->assertEquals('1.6.5', $previous_ecp_versions[1]); $this->assertFalse(isset($previous_ecp_versions[2])); }
/** * Modify the database appropriately to reflect the current * recurring events status */ public function toggle_recurring_events() { $current_status = tribe_get_option('recurring_events_are_hidden', false); if ($current_status == 'hidden' && $this->recurring) { $this->restore_hidden_events(); tribe_update_option('recurring_events_are_hidden', 'exposed'); } elseif ($current_status == 'exposed' && !$this->recurring) { $this->hide_recurring_events(); tribe_update_option('recurring_events_are_hidden', 'hidden'); } elseif (!$current_status) { tribe_update_option('recurring_events_are_hidden', $this->recurring ? 'exposed' : 'hidden'); } }
/** * Set the notices used on month view * * @param array $args Set of $wp_query params for the month view, if none passed then will default to $wp_query * @since 3.0 */ public function __construct($args = null) { if ($args === null) { global $wp_query; $args = $wp_query->query; } self::$args = $args; self::$posts_per_page_limit = apply_filters('tribe_events_month_day_limit', tribe_get_option('monthEventAmount', '3')); if (!tribe_is_month()) { $this->asset_packages = array(); } parent::__construct(); }
/** * Google Map Embed Test * * Check if embed google map is enabled for this event (or venue ). * * @category Events * * @param int $postId Id of the post, if none specified, current post is used * * @return bool True if google map option is set to embed the map */ function tribe_embed_google_map($postId = null) { $output = false; $postId = Tribe__Events__Main::postIdHelper($postId); $post_type = get_post_type($postId); if (tribe_get_option('embedGoogleMaps', true)) { if ($post_type == Tribe__Events__Main::POSTTYPE) { $output = get_post_meta($postId, '_EventShowMap', 1) == 1; } elseif ($post_type == Tribe__Events__Main::VENUE_POST_TYPE) { $output = get_post_meta($postId, '_VenueShowMap', 1) !== 'false' ? 1 : 0; } } return apply_filters('tribe_embed_google_map', $output); }
function wpv_upcoming_events_title($title) { $upcoming = wpv_get_option('tribe-events-upcoming-title'); $past = wpv_get_option('tribe-events-past-title'); $month = wpv_get_option('tribe-events-month-title'); if (!empty($upcoming) && (tribe_is_upcoming() || function_exists('tribe_is_map') && tribe_is_map() || function_exists('tribe_is_photo') && tribe_is_photo())) { return $upcoming; } elseif (!empty($past) && tribe_is_past()) { return $past; } elseif (!empty($month) && tribe_is_month()) { return sprintf($month, date_i18n(tribe_get_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date()))); } return $title; }
/** * The main widget output function (called by the class's widget() function). * * @param array $args * @param array $instance * @param string $template_name The template name. * @param string $subfolder The subfolder where the template can be found. * @param string $namespace The namespace for the widget template stuff. * @param string $pluginPath The pluginpath so we can locate the template stuff. */ function widget_output($args, $instance, $template_name = 'list-widget', $subfolder = 'widgets', $namespace = '/', $pluginPath = '') { global $wp_query, $tribe_ecp, $post; extract($args, EXTR_SKIP); // The view expects all these $instance variables, which may not be set without pro $instance = wp_parse_args($instance, array('limit' => 5, 'title' => '')); extract($instance, EXTR_SKIP); // extracting $instance provides $title, $limit $title = apply_filters('widget_title', $title); if (!isset($category) || $category === '-1') { $category = 0; } if (tribe_get_option('viewOption') == 'upcoming') { $event_url = tribe_get_listview_link($category); } else { $event_url = tribe_get_gridview_link($category); } if (function_exists('tribe_get_events')) { $args = array('eventDisplay' => 'upcoming', 'posts_per_page' => $limit); if (!empty($category)) { $args['tax_query'] = array(array('taxonomy' => TribeEvents::TAXONOMY, 'terms' => $category, 'field' => 'ID', 'include_children' => false)); } $posts = tribe_get_events($args); } // if no posts, and the don't show if no posts checked, let's bail if (!$posts && $no_upcoming_events) { return; } /* Before widget (defined by themes). */ echo $before_widget; /* Title of widget (before and after defined by themes). */ echo $title ? $before_title . $title . $after_title : ''; if ($posts) { /* Display list of events. */ echo '<ol class="hfeed vcalendar">'; foreach ($posts as $post) { setup_postdata($post); include TribeEventsTemplates::getTemplateHierarchy('widgets/list-widget.php'); } echo "</ol><!-- .hfeed -->"; /* Display link to all events */ echo '<p class="tribe-events-widget-link"><a href="' . $event_url . '" rel="bookmark">' . __('View All Events', 'tribe-events-calendar') . '</a></p>'; } else { echo '<p>' . __('There are no upcoming events at this time.', 'tribe-events-calendar') . '</p>'; } /* After widget (defined by themes). */ echo $after_widget; wp_reset_query(); }
/** * Venue can be specified with one of "id" or "venue". Limit can be set using a * "count" attribute. */ protected function parse_args() { if (!empty($this->arguments['id'])) { $this->arguments['venue_ID'] = (int) $this->arguments['venue']; } elseif (!empty($this->arguments['venue'])) { $this->arguments['venue_ID'] = (int) $this->arguments['venue']; } elseif (!empty($this->arguments['slug'])) { $this->set_by_slug(); } if (!empty($this->arguments['limit'])) { $this->arguments['count'] = (int) $this->arguments['limit']; } else { $this->arguments['count'] = (int) tribe_get_option('postsPerPage', 10); } }
/** * Set the notices used on month view * * @param array $args Set of $wp_query params for the month view, if none passed then will default to $wp_query */ public function __construct($args = null) { if ($args === null) { global $wp_query; $args = $wp_query->query; } self::$args = $args; self::$posts_per_page_limit = apply_filters('tribe_events_month_day_limit', tribe_get_option('monthEventAmount', '3')); // don't enqueue scripts and js when we're not constructing month view, // they'll have to be enqueued separately if (!tribe_is_month()) { $this->asset_packages = array(); } parent::__construct(); }
/** * If appropriate, mould the query to obtain all events belonging to the parent * event of the sequence. Additionally may set up a filter to append a where clause * to obtain the parent post in the same query. */ protected function setup() { unset($this->query->query_vars['name']); unset($this->query->query_vars['tribe_events']); $this->get_parent_event(); if (empty($this->parent_event)) { $this->setup_for_404(); } else { $this->query->set('post_parent', $this->parent_event->ID); $this->query->set('post_status', 'publish'); $this->query->set('posts_per_page', tribe_get_option('postsPerPage', 10)); $this->query->is_singular = false; add_filter('posts_where', array($this, 'include_parent_event')); } }
public function handle() { // check if responsive should be killed if (apply_filters('tribe_events_kill_responsive', false)) { add_filter('tribe_events_mobile_breakpoint', '__return_zero'); } $stylesheets = array(); $mobile_break = tribe_get_mobile_breakpoint(); // Get the selected style option $style_option = tribe_get_option('stylesheetOption', 'tribe'); // from `some-style-option` // to `Tribe__Events__Asset__Events_Css_Some_Style_Option` $child_class_name = $this->get_child_class_name($style_option); /** * @var Tribe__Events__Asset__Abstract_Events_Css */ $child_class_instance = new $child_class_name(); // `$stylesheets` passed by reference $child_class_instance->handle($stylesheets, $mobile_break); // put override css at the end of the array $stylesheets['tribe-events-calendar-override-style'] = 'tribe-events/tribe-events.css'; // do the enqueues foreach ($stylesheets as $name => $css_file) { if ($name == 'tribe-events-calendar-override-style') { $user_stylesheet_url = Tribe__Events__Templates::locate_stylesheet('tribe-events/tribe-events.css'); if ($user_stylesheet_url) { wp_enqueue_style($name, $user_stylesheet_url); } } else { // get full URL $url = tribe_events_resource_url($css_file); // get the minified file $url = Tribe__Events__Template_Factory::getMinFile($url, true); // apply filters $url = apply_filters('tribe_events_stylesheet_url', $url, $name); // set the $media attribute if ($name == 'tribe-events-calendar-mobile-style' || $name == 'tribe-events-calendar-full-mobile-style') { $media = "only screen and (max-width: {$mobile_break}px)"; wp_enqueue_style($name, $url, array('tribe-events-calendar-style'), Tribe__Events__Main::VERSION, $media); } else { wp_register_style($name, $url, array(), Tribe__Events__Main::VERSION); wp_enqueue_style($name); } } } }
/** * Sort Events by Day * * Maps events to days of the month. * * @param array $results Array of events from tribe_get_events() * @param string $date * @return array Days of the month with events as values * @since 2.0 */ function tribe_sort_by_month($results, $date) { global $post; $cutoff_time = tribe_get_option('multiDayCutoff', '12:00'); if (preg_match('/(\\d{4})-(\\d{2})/', $date, $matches)) { $queryYear = $matches[1]; $queryMonth = $matches[2]; } else { return false; // second argument not a date we recognize } $monthView = array(); for ($i = 1; $i <= 31; $i++) { $monthView[$i] = array(); } foreach ($results as $event) { $post = $event; $started = false; list($startYear, $startMonth, $startDay) = explode('-', $event->EventStartDate); list($endYear, $endMonth, $endDay) = explode('-', $event->EventEndDate); list($startDay, $garbage) = explode(' ', $startDay); list($endDay, $garbage) = explode(' ', $endDay); for ($i = 1; $i <= 31; $i++) { $curDate = strtotime($queryYear . '-' . $queryMonth . '-' . $i); if ($i == $startDay && $startMonth == $queryMonth || strtotime($startYear . '-' . $startMonth) < strtotime($queryYear . '-' . $queryMonth)) { $started = true; } // if last day of multiday event if (!tribe_get_all_day() && tribe_is_multiday($event->ID) && date('Y-m-d', $curDate) == date('Y-m-d', strtotime($event->EventEndDate))) { $endTime = strtotime(date('Y-m-d', $curDate) . date('h:i A', strtotime($event->EventEndDate))); $cutoffTime = strtotime(date('Y-m-d', $curDate) . $cutoff_time . "AM"); // if end time is before cutoff, then don't show if ($endTime <= $cutoffTime) { $started = false; } } if ($started) { $monthView[$i][] = $event; } if ($i == $endDay && $endMonth == $queryMonth) { continue 2; } } } return $monthView; }
protected function get_values() { $distances = array(); $steps = apply_filters('geoloc-values-for-filters', $this->distances); $unit = tribe_get_option('geoloc_default_unit', 'miles'); switch ($unit) { case 'miles': $unit = __('Miles', 'tribe-events-calendar-pro'); break; case 'kms': $unit = __('Kilometers', 'tribe-events-calendar-pro'); break; } foreach ($steps as $value) { $distances[] = array('name' => sprintf(__('%d %s', 'tribe-events-calendar-pro'), $value, $unit), 'value' => $value); } return $distances; }
function widget_output($args, $instance, $template_name = 'events-list-load-widget-display') { global $wp_query, $tribe_ecp, $post; extract($args, EXTR_SKIP); extract($instance, EXTR_SKIP); // extracting $instance provides $title, $limit $title = apply_filters('widget_title', $title); if (!isset($category)) { $category = null; } if (tribe_get_option('viewOption') == 'upcoming') { $event_url = tribe_get_listview_link($category != -1 ? intval($category) : null); } else { $event_url = tribe_get_gridview_link($category != -1 ? intval($category) : null); } if (function_exists('tribe_get_events')) { $posts = tribe_get_events('eventDisplay=upcoming&posts_per_page=' . $limit . '&eventCat=' . $category); $template = TribeEventsTemplates::getTemplateHierarchy($template_name); } // if no posts, and the don't show if no posts checked, let's bail if (!$posts && $no_upcoming_events) { return; } /* Before widget (defined by themes). */ echo $before_widget; /* Title of widget (before and after defined by themes). */ echo $title ? $before_title . $title . $after_title : ''; if ($posts) { /* Display list of events. */ echo "<ul class='upcoming'>"; foreach ($posts as $post) { setup_postdata($post); include $template; } echo "</ul>"; /* Display link to all events */ echo '<div class="dig-in"><a href="' . $event_url . '">' . __('View All Events', 'tribe-events-calendar') . '</a></div>'; } else { _e('There are no upcoming events at this time.', 'tribe-events-calendar'); } /* After widget (defined by themes). */ echo $after_widget; wp_reset_query(); }
public function add_custom_field($label, $type = 'text', $default = '') { if (class_exists('Tribe__Events__Pro__Main')) { $custom_fields = tribe_get_option('custom-fields'); $field_exists = false; // Check in case the "new" custom field is already present foreach ($custom_fields as $field) { if ($field['label'] === $label) { $field_exists = true; } } // If it is not, add it if (false === $field_exists) { $index = count($custom_fields) + 1; $custom_fields[] = array('name' => "_ecp_custom_{$index}", 'label' => $label, 'type' => $type, 'values' => $default); tribe_update_option('custom-fields', $custom_fields); } } }
/** * @return array */ protected function fetch_posts_without_ticket_types() { $supported_types = array_map('esc_sql', (array) tribe_get_option('ticket-enabled-post-types', array())); if (empty($supported_types)) { $ids = array(); } /** @var \wpdb $wpdb */ global $wpdb; $post_types = "('" . implode("','", $supported_types) . "')"; $query = "SELECT DISTINCT(ID) FROM {$wpdb->posts}\n\t\t\t\tWHERE post_type IN {$post_types}"; $posts_with_tickets = $this->posts_with_ticket_types(); if (!empty($posts_with_tickets)) { $excluded = '(' . implode(',', $posts_with_tickets) . ')'; $query .= " AND ID NOT IN {$excluded}"; } $ids = $wpdb->get_col($query); $ids = is_array($ids) ? $ids : array(); return $ids; }
/** * If appropriate, mould the query to obtain all events belonging to the parent * event of the sequence. Additionally may set up a filter to append a where clause * to obtain the parent post in the same query. */ protected function setup() { unset($this->query->query_vars['name']); unset($this->query->query_vars['tribe_events']); $this->get_parent_event(); if (empty($this->parent_event)) { $this->setup_for_404(); } else { $this->query->set('post_parent', $this->parent_event->ID); $this->query->set('post_status', 'publish'); $this->query->set('posts_per_page', tribe_get_option('postsPerPage', 10)); // Configure what this page actually is $this->query->is_singular = false; $this->query->is_archive = true; $this->query->is_post_type_archive = true; add_filter('posts_where', array($this, 'include_parent_event')); add_action('wp', array($this, 'verify_all_page')); } }