Esempio n. 1
0
 public function form($instance)
 {
     $defaults = array('title' => '', 'venue_ID' => null, 'count' => 3, 'hide_if_empty' => true);
     $venues = get_posts(array('post_type' => Tribe__Events__Main::VENUE_POST_TYPE, 'orderby' => 'title', 'nopaging' => true));
     $instance = wp_parse_args((array) $instance, $defaults);
     include Tribe__Events__Pro__Main::instance()->pluginPath . 'src/admin-views/widget-admin-venue.php';
 }
 /**
  * The asset loading function.
  *
  * @param string $name The name of the package reqested.
  * @param array  $deps An array of dependencies (this should be the registered name that is registered to the wp_enqueue functions).
  *
  * @return void
  */
 public static function asset_package($name, $deps = array())
 {
     $tec_pro = Tribe__Events__Pro__Main::instance();
     $prefix = 'tribe-events-pro';
     // setup plugin resources & 3rd party vendor urls
     $vendor_url = trailingslashit($tec_pro->pluginUrl) . 'vendor/';
     self::handle_asset_package_request($name, $deps, $vendor_url, $prefix, $tec_pro);
 }
 /**
  * The Queue_Realtime constructor method.
  *
  * @param Tribe__Events__Pro__Recurrence__Queue|null           $queue An optional Recurrence Queue instance.
  * @param Tribe__Events__Ajax__Operations|null                 $ajax_operations An optional Ajax Operations instance.
  * @param Tribe__Events__Pro__Recurrence__Queue_Processor|null $queue_processor An optional Queue_Processor instance.
  */
 public function __construct(Tribe__Events__Pro__Recurrence__Queue $queue = null, Tribe__Events__Ajax__Operations $ajax_operations = null, Tribe__Events__Pro__Recurrence__Queue_Processor $queue_processor = null)
 {
     add_action('admin_head-post.php', array($this, 'post_editor'));
     add_action('wp_ajax_tribe_events_pro_recurrence_realtime_update', array($this, 'ajax'));
     $this->queue = $queue;
     $this->ajax_operations = $ajax_operations ? $ajax_operations : new Tribe__Events__Ajax__Operations();
     $this->queue_processor = $queue_processor ? $queue_processor : Tribe__Events__Pro__Main::instance()->queue_processor;
 }
Esempio n. 4
0
 /**
  * Frontend Shortcode Handler
  *
  * @param array $atts array of attributes
  * @param string $content text within enclosing form of shortcode element
  * @param string $shortcodename the shortcode found, when == callback name
  * @return string $output returns the modified html string
  */
 function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
 {
     $atts = shortcode_atts(array('categories' => "", 'items' => "3", 'paginate' => "no"), $atts, $this->config['shortcode']);
     $output = "";
     $posts = $this->query_entries($atts);
     $entries = $posts->posts;
     if (class_exists('Tribe__Events__Pro__Main')) {
         $ecp = Tribe__Events__Pro__Main::instance();
         $ecp->disable_recurring_info_tooltip();
     }
     if (!empty($entries)) {
         global $post;
         $default_id = $post->ID;
         $output .= "<div class='av-upcoming-events " . $meta['el_class'] . "'>";
         foreach ($entries as $entry) {
             $class = "av-upcoming-event-entry";
             $image = get_the_post_thumbnail($entry->ID, 'square', array('class' => 'av-upcoming-event-image'));
             $class .= !empty($image) ? " av-upcoming-event-with-image" : " av-upcoming-event-without-image";
             $title = get_the_title($entry->ID);
             $link = get_permalink($entry->ID);
             $post->ID = $entry->ID;
             //temp set of the post id so that tribe fetches the correct price symbol
             $price = tribe_get_cost($entry->ID, true);
             $venue = tribe_get_venue($entry->ID);
             $post->ID = $default_id;
             $output .= "<a href='{$link}' class='{$class}'>";
             if ($image) {
                 $output .= $image;
             }
             $output .= "<span class='av-upcoming-event-data'>";
             $output .= "<h4 title='av-upcoming-event-title'>{$title}</h4>";
             $output .= "<span class='av-upcoming-event-meta'>";
             $output .= "<span class='av-upcoming-event-schedule'>" . tribe_events_event_schedule_details($entry) . "</span>";
             if ($price) {
                 $output .= "<span class='av-upcoming-event-cost'>{$price}</span>";
             }
             if ($price && $venue) {
                 $output .= " - ";
             }
             if ($venue) {
                 $output .= "<span class='av-upcoming-event-venue'>{$venue}</span>";
             }
             $output .= apply_filters('avf_upcoming_event_extra_data', "", $entry);
             $output .= "</span>";
             $output .= "</span>";
             $output .= "</a>";
         }
         if ($atts['paginate'] == "yes" && ($avia_pagination = avia_pagination($posts->max_num_pages, 'nav'))) {
             $output .= "<div class='pagination-wrap pagination-" . Tribe__Events__Main::POSTTYPE . "'>{$avia_pagination}</div>";
         }
         $output .= "</div>";
     }
     if (class_exists('Tribe__Events__Pro__Main')) {
         // Re-enable recurring event info
         $ecp->enable_recurring_info_tooltip();
     }
     return $output;
 }
 public function form($instance)
 {
     $defaults = array('title' => __('Events Calendar', 'tribe-events-calendar-pro'), 'layout' => 'tall', 'count' => 5, 'operand' => 'OR', 'filters' => null);
     $instance = wp_parse_args((array) $instance, $defaults);
     $taxonomies = get_object_taxonomies(Tribe__Events__Main::POSTTYPE, 'objects');
     $taxonomies = array_reverse($taxonomies);
     $ts = Tribe__Events__Pro__Main::instance();
     include $ts->pluginPath . 'src/admin-views/widget-calendar.php';
 }
 public function form($instance)
 {
     $defaults = array('title' => '', 'event_ID' => null, 'event_date' => null, 'show_seconds' => true, 'complete' => 'Hooray!');
     $instance = wp_parse_args((array) $instance, $defaults);
     $limit = apply_filters('tribe_events_pro_countdown_widget_limit', 250);
     $paged = apply_filters('tribe_events_pro_countdown_widget_paged', 1);
     $events = tribe_get_events(array('eventDisplay' => 'list', 'posts_per_page' => $limit, 'paged' => $paged));
     include Tribe__Events__Pro__Main::instance()->pluginPath . 'src/admin-views/widget-admin-countdown.php';
 }
Esempio n. 7
0
 /**
  * single_event_meta
  *
  * loads the custom field meta box on the event editor screen
  *
  * @return void
  */
 public static function single_event_meta()
 {
     $tribe_ecp = Tribe__Events__Main::instance();
     $customFields = tribe_get_option('custom-fields');
     $events_event_meta_template = Tribe__Events__Pro__Main::instance()->pluginPath . 'src/admin-views/event-meta.php';
     $events_event_meta_template = apply_filters('tribe_events_event_meta_template', $events_event_meta_template);
     if (!empty($events_event_meta_template)) {
         include $events_event_meta_template;
     }
 }
Esempio n. 8
0
 protected function setup()
 {
     Tribe__Events__Main::instance()->displaying = 'photo';
     $this->shortcode->set_current_page();
     $this->shortcode->prepare_default();
     Tribe__Events__Pro__Main::instance()->enqueue_pro_scripts();
     Tribe__Events__Pro__Template_Factory::asset_package('events-pro-css');
     Tribe__Events__Pro__Template_Factory::asset_package('ajax-photoview');
     $this->shortcode->set_template_object(new Tribe__Events__Pro__Templates__Photo($this->shortcode->get_query_args()));
 }
Esempio n. 9
0
 /**
  * Filters the Settings Fields to add the mobile fields
  *
  * @param  array  $settings An Array for The Events Calendar fields
  * @param  string $id       Which tab you are dealing field
  *
  * @return array
  */
 public function inject_mobile_fields($settings, $id)
 {
     // We don't care about other tabs
     if ('display' !== $id) {
         return $settings;
     }
     // Include the fields and replace with the return from the include
     $settings = (include Tribe__Events__Pro__Main::instance()->pluginPath . 'src/admin-views/tribe-options-mobile.php');
     return $settings;
 }
Esempio n. 10
0
 public function ajax()
 {
     $event_id = (int) $_POST['event'];
     // Nonce check
     if (!wp_verify_nonce($_POST['check'], 'generate_recurring_instances_' . $event_id . get_current_user_id())) {
         exit(json_encode(array('html' => __('Unable to continue processing recurring event data. Please reload this page to continue/try again.', 'tribe-events-pro'), 'progress' => false, 'continue' => false, 'complete' => false)));
     }
     // Load the queue
     $queue = new Tribe__Events__Pro__Recurrence__Queue($event_id);
     if (!$queue->is_empty()) {
         Tribe__Events__Pro__Main::instance()->queue_processor->process_batch($event_id);
     }
     $done = $queue->is_empty();
     $percentage = $queue->progress_percentage();
     exit(json_encode(array('html' => false, 'progress' => $percentage, 'progressText' => sprintf(__('%d%% complete', 'tribe-events-pro'), $percentage), 'continue' => !$done, 'complete' => $done)));
 }
Esempio n. 11
0
 public function form($instance)
 {
     $defaults = array('title' => '', 'type' => 'single-event', 'event' => null, 'show_seconds' => true, 'complete' => esc_attr__('Hooray!', 'tribe-events-calendar-pro'), 'event_ID' => null, 'event_date' => null);
     $instance = wp_parse_args((array) $instance, $defaults);
     if (empty($instance['event'])) {
         $instance['event'] = $instance['event_ID'];
     }
     $limit = apply_filters('tribe_events_pro_countdown_widget_limit', 250);
     $paged = apply_filters('tribe_events_pro_countdown_widget_paged', 1);
     $events = tribe_get_events(array('eventDisplay' => 'list', 'posts_per_page' => $limit, 'paged' => $paged));
     if (is_numeric($instance['event'])) {
         $event = get_post($instance['event']);
         if ($event instanceof WP_Post && !in_array($event->ID, wp_list_pluck($events, 'ID'))) {
             $event->EventStartDate = tribe_get_start_date($event->ID, false, Tribe__Date_Utils::DBDATETIMEFORMAT);
             $event->EventEndDate = tribe_get_end_date($event->ID, false, Tribe__Date_Utils::DBDATETIMEFORMAT);
             $events = array_merge(array($event), $events);
         }
     }
     include Tribe__Events__Pro__Main::instance()->pluginPath . 'src/admin-views/widget-admin-countdown.php';
 }
Esempio n. 12
0
 /**
  * This Week Widget - Ajax Change Week
  *
  *
  */
 public function ajax_change_this_week()
 {
     $response = array('success' => false, 'html' => '', 'view' => 'this-week');
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'this-week-ajax')) {
         wp_send_json_error();
     }
     if (isset($_POST['start_date']) && isset($_POST['count'])) {
         //Disable Tooltips
         $ecp = Tribe__Events__Pro__Main::instance();
         $tooltip_status = $ecp->recurring_info_tooltip_status();
         $ecp->disable_recurring_info_tooltip();
         $tax_query = isset($_POST['tax_query']) ? $_POST['tax_query'] : null;
         $_POST['start_date'] = trim($_POST['start_date']);
         if (false == strtotime($_POST['start_date'])) {
             wp_send_json_error();
         }
         //Array of Variables to use for Data Attributes and Query
         $this_week_query_vars['start_date'] = $_POST['start_date'];
         $this_week_query_vars['end_date'] = tribe_get_last_week_day($_POST['start_date']);
         $this_week_query_vars['count'] = $_POST['count'];
         $this_week_query_vars['layout'] = $_POST['layout'];
         $this_week_query_vars['tax_query'] = $tax_query;
         $this_week_query_vars['hide_weekends'] = $_POST['hide_weekends'];
         //Setup Variables for Template
         $this_week_template_vars = self::this_week_template_vars($this_week_query_vars);
         //Setup Attributes for Ajax
         $this_week_data_attrs = self::this_week_data_attr($this_week_query_vars);
         //Setups This Week Object for Each Day
         $week_days = self::this_week_query($this_week_query_vars);
         ob_start();
         include Tribe__Events__Templates::getTemplateHierarchy('pro/widgets/this-week-widget.php');
         $response['html'] = ob_get_clean();
         $response['success'] = true;
         // Re-enable recurring event info
         if ($tooltip_status) {
             $ecp->enable_recurring_info_tooltip();
         }
     }
     apply_filters('tribe_events_ajax_response', $response);
     wp_send_json($response);
 }
Esempio n. 13
0
 /**
  * Do the actual work of saving a recurring series of events
  *
  * @return bool
  */
 public function save_events()
 {
     $existing_instances = Tribe__Events__Pro__Recurrence__Children_Events::instance()->get_ids($this->event_id);
     $recurrences = Tribe__Events__Pro__Recurrence__Meta::get_recurrence_for_event($this->event_id);
     $to_create = array();
     $exclusions = array();
     $to_update = array();
     $to_delete = array();
     $possible_next_pending = array();
     $earliest_date = strtotime(Tribe__Events__Pro__Recurrence__Meta::$scheduler->get_earliest_date());
     $latest_date = strtotime(Tribe__Events__Pro__Recurrence__Meta::$scheduler->get_latest_date());
     foreach ($recurrences['rules'] as &$recurrence) {
         if (!$recurrence) {
             continue;
         }
         $recurrence->setMinDate($earliest_date);
         $recurrence->setMaxDate($latest_date);
         $to_create = array_merge($to_create, $recurrence->getDates());
         if ($recurrence->constrainedByMaxDate() !== false) {
             $possible_next_pending[] = $recurrence->constrainedByMaxDate();
         }
     }
     $to_create = tribe_array_unique($to_create);
     // find days we should exclude
     foreach ($recurrences['exclusions'] as &$recurrence) {
         if (!$recurrence) {
             continue;
         }
         $recurrence->setMinDate($earliest_date);
         $recurrence->setMaxDate($latest_date);
         $exclusions = array_merge($exclusions, $recurrence->getDates());
     }
     // make sure we don't create excluded dates
     $exclusions = tribe_array_unique($exclusions);
     $to_create = $this->exclusions->remove_exclusions($to_create, $exclusions);
     if ($possible_next_pending) {
         update_post_meta($this->event_id, '_EventNextPendingRecurrence', date(Tribe__Events__Pro__Date_Series_Rules__Rules_Interface::DATE_FORMAT, min($possible_next_pending)));
     }
     foreach ($existing_instances as $instance) {
         $start_date = strtotime(get_post_meta($instance, '_EventStartDate', true) . '+00:00');
         $end_date = strtotime(get_post_meta($instance, '_EventEndDate', true) . '+00:00');
         $duration = $end_date - $start_date;
         $existing_date_duration = array('timestamp' => $start_date, 'duration' => $duration);
         $found = array_search($existing_date_duration, $to_create);
         $should_be_excluded = in_array($existing_date_duration, $exclusions);
         if ($found === false || false !== $should_be_excluded) {
             $to_delete[$instance] = $existing_date_duration;
         } else {
             $to_update[$instance] = $to_create[$found];
             unset($to_create[$found]);
             // so we don't re-add it
         }
     }
     // Store the list of instances to create/update/delete etc for future processing
     $queue = new Tribe__Events__Pro__Recurrence__Queue($this->event_id);
     $queue->update($to_create, $to_update, $to_delete, $exclusions);
     // ...but don't wait around, process a small initial batch right away
     Tribe__Events__Pro__Main::instance()->queue_processor->process_batch($this->event_id);
     return true;
 }
Esempio n. 14
0
 /**
  * Do the actual work of saving a recurring series of events
  *
  * @param int $event_id The event that is being saved
  *
  * @return void
  */
 public static function saveEvents($event_id)
 {
     // don't use self::get_child_event_ids() due to caching that hasn't yet flushed
     $existing_instances = get_posts(array('post_parent' => $event_id, 'post_type' => Tribe__Events__Main::POSTTYPE, 'posts_per_page' => -1, 'fields' => 'ids', 'post_status' => get_post_stati(), 'meta_key' => '_EventStartDate', 'orderby' => 'meta_value', 'order' => 'ASC'));
     $recurrence = self::getRecurrenceForEvent($event_id);
     if ($recurrence) {
         $recurrence->setMinDate(strtotime(self::$scheduler->get_earliest_date()));
         $recurrence->setMaxDate(strtotime(self::$scheduler->get_latest_date()));
         $to_create = (array) $recurrence->getDates();
         $to_update = array();
         $to_delete = array();
         if ($recurrence->constrainedByMaxDate() !== false) {
             update_post_meta($event_id, '_EventNextPendingRecurrence', date(Tribe__Events__Pro__Date_Series_Rules__Rules_Interface::DATE_FORMAT, $recurrence->constrainedByMaxDate()));
         }
         foreach ($existing_instances as $instance) {
             $start_date = strtotime(get_post_meta($instance, '_EventStartDate', true) . '+00:00');
             $found = array_search($start_date, $to_create);
             if ($found === false) {
                 $to_delete[$instance] = $start_date;
             } else {
                 $to_update[$instance] = $to_create[$found];
                 unset($to_create[$found]);
                 // so we don't re-add it
             }
         }
         $exclusions = array_map('strtotime', self::get_excluded_dates($event_id));
         // Store the list of instances to create/update/delete etc for future processing
         $queue = new Tribe__Events__Pro__Recurrence__Queue($event_id);
         $queue->update($to_create, $to_update, $to_delete, $exclusions);
         // ...but don't wait around, process a small initial batch right away
         Tribe__Events__Pro__Main::instance()->queue_processor->process_batch($event_id);
     }
 }
Esempio n. 15
0
 /**
  *
  * returns the full markup for the AJAX Calendar
  *
  * @static
  *
  * @param array $args
  *                            -----> eventDate:   date    What month-year to print
  *                            count:       int     # of events in the list (doesn't affect the calendar).
  *                            tax_query:   array   For the events list (doesn't affect the calendar).
  *                            Same format as WP_Query tax_queries. See sample below.
  *
  *
  * tax_query sample:
  *
  *        array( 'relation' => 'AND',
  *               array( 'taxonomy' => 'tribe_events_cat',
  *                      'field'    => 'slug',
  *                      'terms'    => array( 'featured' ),
  *              array( 'taxonomy' => 'post_tag',
  *                     'field'    => 'id',
  *                     'terms'    => array( 103, 115, 206 ),
  *                     'operator' => 'NOT IN' ) ) );
  *
  *
  */
 public function do_calendar($args = array())
 {
     $this->args = $args;
     // Disable tooltips
     $ecp = Tribe__Events__Pro__Main::instance();
     $tooltip_status = $ecp->recurring_info_tooltip_status();
     $ecp->disable_recurring_info_tooltip();
     if (!isset($this->args['eventDate'])) {
         $this->args['eventDate'] = $this->get_month();
     }
     // don't show the list if they set it the widget option to show 0 events in the list
     if ($this->args['count'] == 0) {
         $this->show_list = false;
     }
     // enqueue the widget js
     self::styles_and_scripts();
     // widget setting for count is not 0
     if (!$this->show_list) {
         add_filter('tribe_events_template_widgets/mini-calendar/list.php', '__return_false');
     }
     tribe_get_template_part('pro/widgets/mini-calendar-widget');
     if ($tooltip_status) {
         $ecp->enable_recurring_info_tooltip();
     }
 }
Esempio n. 16
0
 /**
  * Returns json for javascript templating functions throughout the plugin.
  *
  * @category Events
  *
  * @param $event
  * @param $additional
  *
  * @return string
  */
 function tribe_events_template_data($event, array $additional = null)
 {
     $has_image = false;
     $image_src = '';
     $image_tool_src = '';
     $date_display = '';
     //Disable recurring event info in tooltip
     if (class_exists('Tribe__Events__Pro__Main')) {
         $ecp = Tribe__Events__Pro__Main::instance();
         $ecp->disable_recurring_info_tooltip();
         $date_display = strip_tags(tribe_events_event_schedule_details($event));
         // Re-enable recurring event info
         $ecp->enable_recurring_info_tooltip();
     } else {
         $date_display = strip_tags(tribe_events_event_schedule_details($event));
     }
     if (function_exists('has_post_thumbnail') && has_post_thumbnail($event->ID)) {
         $has_image = true;
         $image_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), 'medium');
         $image_src = $image_arr[0];
     }
     if ($has_image) {
         $image_tool_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), array(75, 75));
         $image_tool_src = $image_tool_arr[0];
     }
     if (has_excerpt($event->ID)) {
         $excerpt = $event->post_excerpt;
     } else {
         $excerpt = $event->post_content;
     }
     $excerpt = Tribe__Events__Main::instance()->truncate($excerpt, 30);
     $category_classes = tribe_events_event_classes($event->ID, false);
     $json = array('eventId' => $event->ID, 'title' => $event->post_title, 'permalink' => tribe_get_event_link($event->ID), 'imageSrc' => $image_src, 'dateDisplay' => $date_display, 'imageTooltipSrc' => $image_tool_src, 'excerpt' => $excerpt, 'categoryClasses' => $category_classes);
     /**
      * Template overrides (of month/tooltip.php) set up in 3.9.3 or earlier may still expect
      * these vars and will break without them, so they are being kept temporarily for
      * backwards compatibility purposes.
      *
      * @todo consider removing in 4.0
      */
     $json['startTime'] = tribe_get_start_date($event);
     $json['endTime'] = tribe_get_end_date($event);
     if ($additional) {
         $json = array_merge((array) $json, (array) $additional);
     }
     $json = apply_filters('tribe_events_template_data_array', $json, $event, $additional);
     $json = tribe_prepare_for_json_deep($json);
     return json_encode($json);
 }
 /**
  * Returns json for javascript templating functions throughout the plugin.
  *
  * @category Events
  *
  * @param $event
  * @param $additional
  *
  * @return string
  */
 function tribe_events_template_data($event = null, array $additional = null)
 {
     // Base JSON variable
     $json = array('i18n' => array());
     if (!is_null($event)) {
         $event = get_post($event);
         // Check if we are dealing with an Event
         if (is_object($event) && $event instanceof WP_Post && tribe_is_event($event->ID)) {
             $has_image = false;
             $image_src = '';
             $image_tool_src = '';
             $date_display = '';
             //Disable recurring event info in tooltip
             if (class_exists('Tribe__Events__Pro__Main')) {
                 $ecp = Tribe__Events__Pro__Main::instance();
                 $ecp->disable_recurring_info_tooltip();
                 $date_display = strip_tags(tribe_events_event_schedule_details($event));
                 // Re-enable recurring event info
                 $ecp->enable_recurring_info_tooltip();
             } else {
                 $date_display = strip_tags(tribe_events_event_schedule_details($event));
             }
             if (function_exists('has_post_thumbnail') && has_post_thumbnail($event->ID)) {
                 $has_image = true;
                 $image_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), 'medium');
                 $image_src = $image_arr[0];
             }
             if ($has_image) {
                 $image_tool_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), array(75, 75));
                 $image_tool_src = $image_tool_arr[0];
             }
             if (has_excerpt($event->ID)) {
                 $excerpt = $event->post_excerpt;
             } else {
                 $excerpt = $event->post_content;
             }
             $excerpt = Tribe__Events__Main::instance()->truncate($excerpt, 30);
             $category_classes = tribe_events_event_classes($event->ID, false);
             $json['eventId'] = $event->ID;
             $json['title'] = $event->post_title;
             $json['permalink'] = tribe_get_event_link($event->ID);
             $json['imageSrc'] = $image_src;
             $json['dateDisplay'] = $date_display;
             $json['imageTooltipSrc'] = $image_tool_src;
             $json['excerpt'] = $excerpt;
             $json['categoryClasses'] = $category_classes;
             /**
              * Template overrides (of month/tooltip.php) set up in 3.9.3 or earlier may still expect
              * these vars and will break without them, so they are being kept temporarily for
              * backwards compatibility purposes.
              *
              * @todo consider removing in 4.0
              */
             $json['startTime'] = tribe_get_start_date($event);
             $json['endTime'] = tribe_get_end_date($event);
         }
     }
     /**
      * Internationalization Strings
      */
     $json['i18n']['find_out_more'] = esc_attr__('Find out more »', 'tribe-events-calendar');
     $json['i18n']['for_date'] = esc_attr(sprintf(__('%s for', 'tribe-events-calendar'), tribe_get_event_label_plural()));
     if ($additional) {
         $json = array_merge((array) $json, (array) $additional);
     }
     $json = apply_filters('tribe_events_template_data_array', $json, $event, $additional);
     $json = tribe_prepare_for_json_deep($json);
     return json_encode($json);
 }
 public function form($instance)
 {
     $this->instance_defaults($instance);
     $taxonomies = get_object_taxonomies(Tribe__Events__Main::POSTTYPE, 'objects');
     $taxonomies = array_reverse($taxonomies);
     $instance = $this->instance;
     include Tribe__Events__Pro__Main::instance()->pluginPath . 'src/admin-views/widget-admin-advanced-list.php';
 }
					<input type="hidden" name="recurrence[exclusions][][occurrence-count-text]" data-field="occurrence-count-text" value="<?php 
esc_attr_e(_x('events', 'occurence count text', 'tribe-events-calendar-pro'));
?>
" />
					<span class="rec-error rec-days-error"><?php 
esc_html_e('Frequency of recurring event must be a number', 'tribe-events-calendar-pro');
?>
</span>
				</span>
				<div class="recurrence-rows">
					<?php 
$rule_type = 'exclusions';
include apply_filters('tribe_pro_recurrence_template_weeks', Tribe__Events__Pro__Main::instance()->pluginPath . '/src/admin-views/recurrence/weeks.php', $rule_type);
include apply_filters('tribe_pro_recurrence_template_months', Tribe__Events__Pro__Main::instance()->pluginPath . '/src/admin-views/recurrence/months.php', $rule_type);
include apply_filters('tribe_pro_recurrence_template_years', Tribe__Events__Pro__Main::instance()->pluginPath . '/src/admin-views/recurrence/years.php', $rule_type);
include apply_filters('tribe_pro_recurrence_template_time', Tribe__Events__Pro__Main::instance()->pluginPath . '/src/admin-views/recurrence/time.php', $rule_type);
?>
				</div>
			</div>
		</script>
		<button id="tribe-add-exclusion" class="button"><?php 
esc_html_e('Add Exclusion', 'tribe-events-calendar-pro');
?>
</button>
	</td>
</tr>
<tr class="recurrence-row tribe-recurrence-description">
	<td class="recurrence-description-header"><?php 
esc_html_e('Recurrence Description:', 'tribe-events-calendar-pro');
?>
</td>
Esempio n. 20
0
 /**
  * Render the shortcode
  * @param  array $args	 Shortcode paramters
  * @param  string $content Content between shortcode
  * @return string		  HTML output
  */
 function render($args, $content = '')
 {
     $defaults = shortcode_atts(array('class' => '', 'id' => '', 'cat_slug' => '', 'number_posts' => '4', 'columns' => '4', 'picture_size' => 'cover'), $args);
     extract($defaults);
     $html = '';
     $args = array('post_type' => 'tribe_events', 'posts_per_page' => $number_posts);
     if ($cat_slug) {
         $terms = explode(',', $cat_slug);
         $args['tax_query'] = array(array('taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => array_map('trim', $terms)));
     }
     switch ($columns) {
         case '1':
             $column_class = 'full-one';
             break;
         case '2':
             $column_class = 'one-half';
             break;
         case '3':
             $column_class = 'one-third';
             break;
         case '4':
             $column_class = 'one-fourth';
             break;
         case '5':
             $column_class = 'one-fifth';
             break;
         case '6':
             $column_class = 'one-sixth';
             break;
     }
     $events = new WP_Query($args);
     if ($events->have_posts()) {
         if ($id) {
             $id = ' id="' . $id . '"';
         }
         $html .= '<div class="fusion-events-shortcode ' . $class . '"' . $id . '>';
         $i = 1;
         $last = false;
         $columns = (int) $columns;
         while ($events->have_posts()) {
             $events->the_post();
             if ($i == $columns) {
                 $last = true;
             }
             if ($i > $columns) {
                 $i = 1;
                 $last = false;
             }
             if ($columns == 1) {
                 $last = true;
             }
             $html .= '<div class="fusion-' . $column_class . ' fusion-spacing-yes fusion-layout-column ' . ($last ? 'fusion-column-last' : '') . '">';
             $html .= '<div class="fusion-column-wrapper">';
             $thumb_id = get_post_thumbnail_id();
             $thumb_link = wp_get_attachment_image_src($thumb_id, 'full', true);
             $thumb_url = has_post_thumbnail(get_the_ID()) ? $thumb_link[0] : esc_url(trailingslashit(Tribe__Events__Pro__Main::instance()->pluginUrl) . 'src/resources/images/tribe-related-events-placeholder.png');
             $img_class = has_post_thumbnail(get_the_ID()) ? '' : 'fusion-events-placeholder';
             $thumb_img = '<img class="' . $img_class . '" src="' . $thumb_url . '" alt="' . esc_attr(get_the_title(get_the_ID())) . '" />';
             $thumb_bg = '<span class="tribe-events-event-image" style="background-image: url(' . $thumb_url . '); -webkit-background-size: cover; background-size: cover; background-position: center center;"></span>';
             $html .= '<div class="fusion-events-thumbnail hover-type-' . Avada()->settings->get('ec_hover_type') . '">';
             $html .= '<a href="' . get_the_permalink() . '" class="url" rel="bookmark">';
             if ($picture_size == 'auto') {
                 $html .= $thumb_img;
             } else {
                 $html .= $thumb_bg;
             }
             $html .= '</a>';
             $html .= '</div>';
             $html .= '<div class="fusion-events-meta">';
             $html .= '<h2><a href="' . get_the_permalink() . '" class="url" rel="bookmark">' . get_the_title() . '</a></h2>';
             $html .= '<h4>' . tribe_events_event_schedule_details() . '</h4>';
             $html .= '</div>';
             $html .= '</div>';
             $html .= '</div>';
             if ($last) {
                 $html .= '<div class="fusion-clearfix"></div>';
             }
             $i++;
         }
         $html .= '<div class="fusion-clearfix"></div>';
         $html .= '</div>';
     }
     return $html;
 }
Esempio n. 21
0
 /**
  * Tests if we have a sufficiently recent version of Events Calendar PRO in place and
  * if the additional field data in the database follows the currently expected pattern.
  *
  * @return bool
  */
 public static function additional_fields_ready()
 {
     $pro = Tribe__Events__Pro__Main::instance();
     // If the custom meta tools object is not available, the active version of PRO is too early
     if (!property_exists($pro, 'custom_meta_tools')) {
         self::$unsupported = self::UNSUPPORTED_EARLY_PRO;
         return false;
     }
     // If updates are required for additional fields we cannot support them until the updates are made
     if ($pro->custom_meta_tools->are_updates_needed()) {
         self::$unsupported = self::UNSUPPORTED_UPDATE_NEEDED;
         return false;
     }
     // Otherwise, things should be good!
     return true;
 }
Esempio n. 22
0
 /**
  * Do the actual work of saving a recurring series of events
  *
  * @param int $event_id The event that is being saved
  *
  * @return void
  */
 public static function saveEvents($event_id)
 {
     // don't use self::get_child_event_ids() due to caching that hasn't yet flushed
     $existing_instances = get_posts(array('post_parent' => $event_id, 'post_type' => Tribe__Events__Main::POSTTYPE, 'posts_per_page' => -1, 'fields' => 'ids', 'post_status' => get_post_stati(), 'meta_key' => '_EventStartDate', 'orderby' => 'meta_value', 'order' => 'ASC'));
     $recurrences = self::get_recurrence_for_event($event_id);
     $to_create = array();
     $exclusions = array();
     $to_update = array();
     $to_delete = array();
     $possible_next_pending = array();
     $earliest_date = strtotime(self::$scheduler->get_earliest_date());
     $latest_date = strtotime(self::$scheduler->get_latest_date());
     foreach ($recurrences['rules'] as &$recurrence) {
         if (!$recurrence) {
             continue;
         }
         $recurrence->setMinDate($earliest_date);
         $recurrence->setMaxDate($latest_date);
         $to_create = array_merge($to_create, $recurrence->getDates());
         if ($recurrence->constrainedByMaxDate() !== false) {
             $possible_next_pending[] = $recurrence->constrainedByMaxDate();
         }
     }
     $to_create = self::array_unique($to_create);
     // find days we should exclude
     foreach ($recurrences['exclusions'] as &$recurrence) {
         if (!$recurrence) {
             continue;
         }
         $recurrence->setMinDate($earliest_date);
         $recurrence->setMaxDate($latest_date);
         $exclusions = array_merge($exclusions, $recurrence->getDates());
     }
     // make sure we don't create excluded dates
     $exclusions = self::array_unique($exclusions);
     $to_create = self::remove_exclusions($to_create, $exclusions);
     if ($possible_next_pending) {
         update_post_meta($event_id, '_EventNextPendingRecurrence', date(Tribe__Events__Pro__Date_Series_Rules__Rules_Interface::DATE_FORMAT, min($possible_next_pending)));
     }
     foreach ($existing_instances as $instance) {
         $start_date = strtotime(get_post_meta($instance, '_EventStartDate', true) . '+00:00');
         $end_date = strtotime(get_post_meta($instance, '_EventEndDate', true) . '+00:00');
         $duration = $end_date - $start_date;
         $existing_date_duration = array('timestamp' => $start_date, 'duration' => $duration);
         $found = array_search($existing_date_duration, $to_create);
         $should_be_excluded = in_array($existing_date_duration, $exclusions);
         if ($found === false || false !== $should_be_excluded) {
             $to_delete[$instance] = $existing_date_duration;
         } else {
             $to_update[$instance] = $to_create[$found];
             unset($to_create[$found]);
             // so we don't re-add it
         }
     }
     // Store the list of instances to create/update/delete etc for future processing
     $queue = new Tribe__Events__Pro__Recurrence__Queue($event_id);
     $queue->update($to_create, $to_update, $to_delete, $exclusions);
     // ...but don't wait around, process a small initial batch right away
     Tribe__Events__Pro__Main::instance()->queue_processor->process_batch($event_id);
 }
Esempio n. 23
0
 /**
  * Get the date for the day navigation link.
  *
  * @category Events
  * @param string $date_description
  *
  * @return string
  * @throws OverflowException
  */
 function tribe_get_the_day_link_date($date_description)
 {
     if (is_null($date_description)) {
         return Tribe__Events__Pro__Main::instance()->todaySlug;
     }
     if ($date_description == 'previous day') {
         return tribe_get_previous_day_date(get_query_var('start_date'));
     }
     if ($date_description == 'next day') {
         return tribe_get_next_day_date(get_query_var('start_date'));
     }
     return date('Y-m-d', strtotime($date_description));
 }
Esempio n. 24
0
 function tribe_events_pro_resource_url($resource, $echo = false)
 {
     $extension = pathinfo($resource, PATHINFO_EXTENSION);
     $resources_path = 'src/resources/';
     switch ($extension) {
         case 'css':
             $resource_path = $resources_path . 'css/';
             break;
         case 'js':
             $resource_path = $resources_path . 'js/';
             break;
         case 'scss':
             $resource_path = $resources_path . 'scss/';
             break;
         default:
             $resource_path = $resources_path;
             break;
     }
     $path = $resource_path . $resource;
     $url = apply_filters('tribe_events_pro_resource_url', trailingslashit(Tribe__Events__Pro__Main::instance()->pluginUrl) . $path, $resource);
     if ($echo) {
         echo $url;
     }
     return $url;
 }
Esempio n. 25
0
function tribe_events_pro_deactivation($network_deactivating)
{
    require_once dirname(__FILE__) . '/src/Tribe/Main.php';
    Tribe__Events__Pro__Main::deactivate($network_deactivating);
}
$posts = tribe_get_related_posts();
if (is_array($posts) && !empty($posts)) {
    ?>

<div class="related-posts single-related-posts">
	<?php 
    echo Avada()->template->title_template(sprintf(__('Related %s', 'tribe-events-calendar-pro'), tribe_get_event_label_plural()), '3');
    ?>

	<ul class="tribe-related-events tribe-clearfix hfeed vcalendar">
		<?php 
    foreach ($posts as $post) {
        ?>
		<li>
			<?php 
        $thumb = has_post_thumbnail($post->ID) ? get_the_post_thumbnail($post->ID, 'large') : '<img src="' . esc_url(trailingslashit(Tribe__Events__Pro__Main::instance()->pluginUrl) . 'src/resources/images/tribe-related-events-placeholder.png') . '" alt="' . esc_attr(get_the_title($post->ID)) . '" />';
        ?>
			<div class="tribe-related-events-thumbnail hover-type-<?php 
        echo Avada()->settings->get('ec_hover_type');
        ?>
">
				<a href="<?php 
        echo esc_url(tribe_get_event_link($post));
        ?>
" class="url" rel="bookmark"><?php 
        echo $thumb;
        ?>
</a>
			</div>
			<div class="tribe-related-event-info">
				<h3 class="tribe-related-events-title summary"><a href="<?php 
 /**
  * Displays the events recurrence form on the event editor screen
  *
  * @param integer $post_id ID of the current event
  *
  * @return void
  */
 public static function loadRecurrenceData($post_id)
 {
     $post = get_post($post_id);
     if (!empty($post->post_parent)) {
         return;
         // don't show recurrence fields for instances of a recurring event
     }
     $recurrence = array();
     if ($post_id) {
         $recurrence = self::getRecurrenceMeta($post_id);
     }
     self::enqueue_recurrence_data($post_id);
     $premium = Tribe__Events__Pro__Main::instance();
     include Tribe__Events__Pro__Main::instance()->pluginPath . 'src/admin-views/event-recurrence.php';
 }
Esempio n. 28
0
 /**
  * Adds Pro domain to the list of domains to use to translate strings.
  *
  * @param array $domains
  *
  * @return array
  */
 public function filter_tribe_events_rewrite_i18n_domains(array $domains)
 {
     $domains['tribe-events-calendar-pro'] = Tribe__Events__Pro__Main::instance()->pluginDir . 'lang/';
     return $domains;
 }
Esempio n. 29
0
 /**
  * The singleton function.
  *
  * @return Tribe__Events__Pro__Main The instance.
  */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
Esempio n. 30
0
    add_action('tribe_events_after_the_event_title', 'avia_events_open_outer_wrap', 10);
    function avia_events_open_outer_wrap()
    {
        echo "<div class='av-tribe-events-outer-content-wrap'>";
    }
}
if (!function_exists('avia_events_open_inner_wrap')) {
    add_action('tribe_events_after_the_meta', 'avia_events_open_inner_wrap', 10);
    function avia_events_open_inner_wrap()
    {
        echo "<div class='av-tribe-events-inner-content-wrap'>";
    }
}
if (!function_exists('avia_events_close_div')) {
    /*call 3 times, once for wrappper, outer and inner wrap*/
    add_action('tribe_events_after_the_content', 'avia_events_close_div', 1000);
    add_action('tribe_events_after_the_content', 'avia_events_close_div', 1001);
    add_action('tribe_events_after_the_content', 'avia_events_close_div', 1003);
    function avia_events_close_div()
    {
        echo "</div>";
    }
}
/*PRO PLUGIN*/
if (!class_exists('Tribe__Events__Pro__Main')) {
    return false;
}
/*move related events*/
$tec = Tribe__Events__Pro__Main::instance();
remove_action('tribe_events_single_event_after_the_meta', array($tec, 'register_related_events_view'));
add_action('tribe_events_single_event_after_the_content', array($tec, 'register_related_events_view'));