示例#1
0
 /**
  * Create a clean way of fetching API variables
  *
  * @return stdClass|WP_Error
  */
 public function api()
 {
     // Make it an Object
     $api = (object) $this->api;
     if (defined('EVENT_AGGREGATOR_API_BASE_URL')) {
         $api->domain = EVENT_AGGREGATOR_API_BASE_URL;
     }
     // Since we don't need to fetch this key elsewhere
     $api->key = get_option('pue_install_key_event_aggregator');
     /**
      * Creates a clean way to filter and redirect to another API domain/path
      * @var stdClass
      */
     $api = (object) apply_filters('tribe_aggregator_api', $api);
     // The user doesn't have a license key
     if (empty($api->key)) {
         return tribe_error('core:aggregator:invalid-service-key');
     }
     $aggregator = Tribe__Events__Aggregator::instance();
     $plugin_name = $aggregator->filter_pue_plugin_name('', 'event-aggregator');
     $pue_notices = Tribe__Main::instance()->pue_notices();
     $has_notice = $pue_notices->has_notice($plugin_name);
     // The user doesn't have a valid license key
     if (empty($api->key) || $has_notice) {
         return tribe_error('core:aggregator:invalid-service-key');
     }
     return $api;
 }
 /**
  * Static Singleton Factory Method
  *
  * @return Tribe__Events__Aggregator
  */
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 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';
 }
    public function render_update_message()
    {
        if (!Tribe__Events__Aggregator__Page::instance()->is_screen()) {
            return;
        }
        $processor = Tribe__Events__Aggregator::instance()->queue_processor;
        if (!($this->record_id = $processor->next_waiting_record(true))) {
            return false;
        }
        $this->queue = $this->queue ? $this->queue : new Tribe__Events__Aggregator__Record__Queue($this->record_id);
        if ($this->queue->is_empty()) {
            return false;
        }
        $this->update_loop_vars();
        ob_start();
        $percent = $this->sanitize_progress($this->queue->progress_percentage());
        $spinner = '<img src="' . get_admin_url(null, '/images/spinner.gif') . '">';
        ?>
		<div class="tribe-message">
			<p>
				<?php 
        esc_html_e('Your import is currently in progress. Don\'t worry, you can safely navigate away&ndash;the import will continue in the background.', 'the-events-calendar');
        ?>
			</p>
		</div>
		<ul class="tracker">
			<li class="tracked-item track-created"><strong><?php 
        esc_html_e('Created:', 'the-events-calendar');
        ?>
</strong> <span class="value"></span></li>
			<li class="tracked-item track-updated"><strong><?php 
        esc_html_e('Updated:', 'the-events-calendar');
        ?>
</strong> <span class="value"></span></li>
			<li class="tracked-item track-skipped"><strong><?php 
        esc_html_e('Skipped:', 'the-events-calendar');
        ?>
</strong> <span class="value"></span></li>
		</ul>
		<div class="progress-container">
			<div class="progress" title="<?php 
        echo esc_html(sprintf(__('%d%% complete', 'the-events-calendar'), $percent));
        ?>
">
				<div class="bar"></div>
			</div>
			<img src="<?php 
        echo esc_url(get_admin_url(null, '/images/spinner.gif'));
        ?>
">
		</div>
		<?php 
        $html = ob_get_clean();
        return Tribe__Admin__Notices::instance()->render('aggregator-update-msg', $html);
    }
示例#5
0
 /**
  * Returns whether oauth for a given origin is enabled
  *
  * @param string $origin Origin
  *
  * @return boolean
  */
 public function is_oauth_enabled($origin)
 {
     if (!Tribe__Events__Aggregator::instance()->is_service_active()) {
         return false;
     }
     $cached_oauth_settings = get_transient("{$this->cache_group}_origin_oauth");
     if ($cached_oauth_settings && isset($cached_oauth_settings->{$origin})) {
         return (bool) $cached_oauth_settings->{$origin};
     }
     $service_origins = $this->fetch_origin_data();
     if (!isset($service_origins->oauth->{$origin})) {
         return false;
     }
     return (bool) $service_origins->oauth->{$origin};
 }
示例#6
0
 /**
  * Checks if there are existing settings from the Old iCal or Facebook Plugins
  * and displays a notice with a button to migrated those using AJAX
  *
  * @return string
  */
 public function notice()
 {
     if (!Tribe__Events__Aggregator__Page::instance()->is_screen()) {
         return false;
     }
     if (($this->is_facebook_migrated() || !$this->has_facebook_setting()) && ($this->is_ical_migrated() || !$this->has_ical_setting())) {
         return false;
     }
     $aggregator = Tribe__Events__Aggregator::instance();
     $html = '<p>' . esc_html__('Thanks for activating Event Aggregator! It looks like you have some settings and imports configured on our legacy importer plugins. To complete your transition, we need to transfer those options to our new system.', 'the-events-calendar');
     if (!$this->is_facebook_migrated() && $this->has_facebook_setting()) {
         $html .= '<p style="display:inline-block;">' . get_submit_button(esc_html__('Migrate Facebook Events settings', 'the-events-calendar'), 'secondary', 'tribe-migrate-facebook-settings', false) . '<span class="spinner"></span></p>';
     }
     if (!$this->is_ical_migrated() && $this->has_ical_setting()) {
         $html .= '<p style="display:inline-block;">' . get_submit_button(esc_html__('Migrate iCal Importer settings', 'the-events-calendar'), 'secondary', 'tribe-migrate-ical-settings', false) . '<span class="spinner"></span></p>';
     }
     return Tribe__Admin__Notices::instance()->render('tribe-aggregator-migrate-legacy-settings', $html);
 }
			<td>
				<?php 
if ('edit' === $aggregator_action) {
    ?>
					<input
						type="hidden"
						name="aggregator[origin]"
						id="tribe-ea-field-origin"
						class="tribe-ea-field"
						value="<?php 
    echo esc_attr($record->meta['origin']);
    ?>
"
					>
					<strong class="tribe-ea-field-readonly"><?php 
    esc_html_e(Tribe__Events__Aggregator::instance()->api('origins')->get_name($record->meta['origin']));
    ?>
</strong>
				<?php 
} else {
    ?>
					<select
						name="aggregator[origin]"
						id="tribe-ea-field-origin"
						class="tribe-ea-field tribe-ea-dropdown tribe-ea-size-large"
						placeholder="<?php 
    echo esc_attr($field->placeholder);
    ?>
"
						data-hide-search
						data-prevent-clear
示例#8
0
<table class="event-aggregator-status">
	<thead>
		<tr class="table-heading">
			<th colspan="4"><?php 
esc_html_e('Third Party Accounts', 'the-events-calendar');
?>
</th>
		</tr>
	</thead>
	<tbody>
		<?php 
// Facebook status section
$indicator = 'good';
$notes = '&nbsp;';
$text = 'Connected';
if (Tribe__Events__Aggregator::instance()->api('origins')->is_oauth_enabled('facebook')) {
    if (!Tribe__Events__Aggregator__Settings::instance()->is_fb_credentials_valid()) {
        $indicator = 'warning';
        $text = __('You have not connected Event Aggregator to Facebook', 'the-events-calendar');
        $facebook_auth_url = Tribe__Events__Aggregator__Record__Facebook::get_auth_url(array('back' => 'settings'));
        $notes = '<a href="' . esc_url($facebook_auth_url) . '">' . esc_html_x('Connect to Facebook', 'link for connecting facebook', 'the-events-calendar') . '</a>';
    }
} else {
    $indicator = 'warning';
    $text = __('Limited connectivity with Facebook', 'the-events-calendar');
    $notes = esc_html__('The service has disabled oAuth. Some types of events may not import.', 'the-events-calendar');
}
?>
		<tr>
			<td class="label">
				<img src="<?php 
    /**
     * Renders the "Missing Aggregator License" notice
     *
     * @return string
     */
    public function maybe_display_aggregator_missing_license_key_message()
    {
        if (Tribe__Events__Aggregator::instance()->is_service_active()) {
            return;
        }
        ob_start();
        ?>
		<div class="notice inline notice-info tribe-notice-tribe-missing-aggregator-license" data-ref="tribe-missing-aggregator-license">
			<p>
				<strong>
					<?php 
        esc_html_e('All scheduled imports are currently suspended, and no events will be imported.', 'the-events-calendar');
        ?>
				</strong>
			</p>
			<p>
				<?php 
        printf(esc_html__('To continue using scheduled imports, please enter a valid Event Aggregator license key under %1$sEvents > Settings > Licenses%2$s.', 'the-events-calendar'), '<a href="' . esc_url(admin_url(Tribe__Settings::$parent_page . '&page=tribe-common&tab=licenses')) . '">', '</a>');
        ?>
			</p>
			<p>
				<a href="<?php 
        echo esc_url(admin_url(Tribe__Settings::$parent_page . '&page=tribe-common&tab=licenses'));
        ?>
" class="tribe-license-link tribe-button tribe-button-primary"><?php 
        esc_html_e('Enter Event Aggregator License', 'the-events-calendar');
        ?>
</a>
			</p>
		</div>
		<?php 
        return ob_get_clean();
    }
示例#10
0
 public function is_fb_credentials_valid($time = null)
 {
     // if the service hasn't enabled oauth for facebook, always assume it is valid
     if (!Tribe__Events__Aggregator::instance()->api('origins')->is_oauth_enabled('facebook')) {
         return true;
     }
     if (!$this->has_fb_credentials()) {
         return false;
     }
     $credentials = $this->get_fb_credentials();
     // Allow passing comparing time
     if (is_null($time)) {
         $time = time();
     }
     return $credentials->expires > $time;
 }
示例#11
0
 /**
  * Inserts events, venues, and organizers for the Import Record
  *
  * @param array $data Dummy data var to allow children to optionally react to passed in data
  *
  * @return array|WP_Error
  */
 public function insert_posts($items = array())
 {
     add_filter('tribe-post-origin', array(Tribe__Events__Aggregator__Records::instance(), 'filter_post_origin'), 10);
     // Creates an Activity to log what Happened
     $activity = new Tribe__Events__Aggregator__Record__Activity();
     $args = array('post_status' => $this->meta['post_status']);
     $unique_field = $this->get_unique_field();
     $existing_ids = $this->get_existing_ids_from_import_data($items);
     //cache
     $possible_parents = array();
     $found_organizers = array();
     $found_venues = array();
     //if we have no non recurring events the message may be different
     $non_recurring = false;
     $show_map_setting = Tribe__Events__Aggregator__Settings::instance()->default_map($this->meta['origin']);
     $update_authority_setting = Tribe__Events__Aggregator__Settings::instance()->default_update_authority($this->meta['origin']);
     $unique_inserted = array();
     foreach ($items as $item) {
         $event = Tribe__Events__Aggregator__Event::translate_service_data($item);
         // set the event ID if it can be set
         if ($unique_field && isset($event[$unique_field['target']]) && isset($existing_ids[$event[$unique_field['target']]])) {
             $event['ID'] = $existing_ids[$event[$unique_field['target']]]->post_id;
         }
         // only set the post status if there isn't an ID
         if (empty($event['ID'])) {
             $event['post_status'] = $args['post_status'];
         }
         /**
          * Should events that have previously been imported be overwritten?
          *
          * By default this is turned off (since it would reset the post status, description
          * and any other fields that have subsequently been edited) but it can be enabled
          * by returning true on this filter.
          *
          * @var bool $overwrite
          * @var int  $event_id
          */
         if (!empty($event['ID']) && 'retain' === $update_authority_setting) {
             // Log this Event was Skipped
             $activity->add('event', 'skipped', $event['ID']);
             continue;
         }
         if ($show_map_setting) {
             $event['EventShowMap'] = $show_map_setting;
             $event['EventShowMapLink'] = $show_map_setting;
         }
         if (empty($event['recurrence'])) {
             $non_recurring = true;
         }
         // set the parent
         if (!empty($event['ID']) && ($id = wp_get_post_parent_id($event['ID']))) {
             $event['post_parent'] = $id;
         } elseif (!empty($event['parent_uid']) && ($k = array_search($event['parent_uid'], $possible_parents))) {
             $event['post_parent'] = $k;
         }
         //if we should create a venue or use existing
         if (!empty($event['Venue']['Venue'])) {
             $v_id = array_search($event['Venue']['Venue'], $found_venues);
             if (false !== $v_id) {
                 $event['EventVenueID'] = $v_id;
             } elseif ($venue = get_page_by_title($event['Venue']['Venue'], 'OBJECT', Tribe__Events__Main::VENUE_POST_TYPE)) {
                 $found_venues[$venue->ID] = $event['Venue']['Venue'];
                 $event['EventVenueID'] = $venue->ID;
             } else {
                 $event['Venue']['ShowMap'] = $show_map_setting;
                 $event['Venue']['ShowMapLink'] = $show_map_setting;
                 $event['EventVenueID'] = Tribe__Events__Venue::instance()->create($event['Venue'], $this->meta['post_status']);
                 // Log this Venue was created
                 $activity->add('venue', 'created', $event['EventVenueID']);
             }
             // Remove the Venue to avoid duplicates
             unset($event['Venue']);
         }
         //if we should create an organizer or use existing
         if (!empty($event['Organizer']['Organizer'])) {
             $o_id = array_search($event['Organizer']['Organizer'], $found_organizers);
             if (false !== $o_id) {
                 $event['EventOrganizerID'] = $o_id;
             } elseif ($organizer = get_page_by_title($event['Organizer']['Organizer'], 'OBJECT', Tribe__Events__Main::ORGANIZER_POST_TYPE)) {
                 $found_organizers[$organizer->ID] = $event['Organizer']['Organizer'];
                 $event['EventOrganizerID'] = $organizer->ID;
             } else {
                 $event['EventOrganizerID'] = Tribe__Events__Organizer::instance()->create($event['Organizer'], $this->meta['post_status']);
                 // Log this Organizer was created
                 $activity->add('organizer', 'created', $event['EventOrganizerID']);
             }
             // Remove the Organizer to avoid duplicates
             unset($event['Organizer']);
         }
         $event['post_type'] = Tribe__Events__Main::POSTTYPE;
         /**
          * Filters the event data before any sort of saving of the event
          *
          * @param array $event Event data to save
          * @param Tribe__Events__Aggregator__Record__Abstract Importer record
          */
         $event = apply_filters('tribe_aggregator_before_save_event', $event, $this);
         if (!empty($event['ID'])) {
             if ('preserve_changes' === $update_authority_setting) {
                 $event = Tribe__Events__Aggregator__Event::preserve_changed_fields($event);
             }
             add_filter('tribe_aggregator_track_modified_fields', '__return_false');
             /**
              * Filters the event data before updating event
              *
              * @param array $event Event data to save
              * @param Tribe__Events__Aggregator__Record__Abstract Importer record
              */
             $event = apply_filters('tribe_aggregator_before_update_event', $event, $this);
             $event['ID'] = tribe_update_event($event['ID'], $event);
             // since the Event API only supports the _setting_ of these meta fields, we need to manually
             // delete them rather than relying on Tribe__Events__API::saveEventMeta()
             if (isset($event['EventShowMap']) && (empty($event['EventShowMap']) || 'no' === $event['EventShowMap'])) {
                 delete_post_meta($event['ID'], '_EventShowMap');
             }
             if (isset($event['EventShowMapLink']) && (empty($event['EventShowMapLink']) || 'no' === $event['EventShowMapLink'])) {
                 delete_post_meta($event['ID'], '_EventShowMapLink');
             }
             remove_filter('tribe_aggregator_track_modified_fields', '__return_false');
             // Log that this event was updated
             $activity->add('event', 'updated', $event['ID']);
         } else {
             /**
              * Filters the event data before inserting event
              *
              * @param array $event Event data to save
              * @param Tribe__Events__Aggregator__Record__Abstract Importer record
              */
             $event = apply_filters('tribe_aggregator_before_insert_event', $event, $this);
             $event['ID'] = tribe_create_event($event);
             // Log this event was created
             $activity->add('event', 'created', $event['ID']);
         }
         Tribe__Events__Aggregator__Records::instance()->add_record_to_event($event['ID'], $this->id, $this->origin);
         //add post parent possibility
         if (empty($event['parent_uid'])) {
             $possible_parents[$event['ID']] = $event[$unique_field['target']];
         }
         if (!empty($event[$unique_field['target']])) {
             update_post_meta($event['ID'], "_{$unique_field['target']}", $event[$unique_field['target']]);
         }
         //Save the meta data in case of updating to pro later on
         if (!empty($event['EventRecurrenceRRULE'])) {
             update_post_meta($event['ID'], '_EventRecurrenceRRULE', $event['EventRecurrenceRRULE']);
         }
         $terms = array();
         if (!empty($event['categories'])) {
             foreach ($event['categories'] as $cat) {
                 if (!($term = term_exists($cat, Tribe__Events__Main::TAXONOMY))) {
                     $term = wp_insert_term($cat, Tribe__Events__Main::TAXONOMY);
                     if (!is_wp_error($term)) {
                         $terms[] = (int) $term['term_id'];
                         // Track that we created a Term
                         $activity->add('cat', 'created', $term['term_id']);
                     }
                 } else {
                     $terms[] = (int) $term['term_id'];
                 }
             }
         }
         // if we are setting all events to a category specified in saved import
         if (!empty($this->meta['category'])) {
             $terms[] = (int) $this->meta['category'];
         }
         wp_set_object_terms($event['ID'], $terms, Tribe__Events__Main::TAXONOMY, false);
         // If we have a Image Field from Service
         if (!empty($event['image'])) {
             // Attempt to grab the event image
             $image_import = Tribe__Events__Aggregator::instance()->api('image')->get($event['image']->id);
             /**
              * Filters the returned event image url
              *
              * @param array|bool $image       Attachment information
              * @param array      $event       Event array
              */
             $image = apply_filters('tribe_aggregator_event_image', $image_import, $event);
             // If there was a problem bail out
             if (false === $image) {
                 continue;
             }
             // Verify for more Complex Errors
             if (is_wp_error($image)) {
                 continue;
             }
             if (isset($image->status) && 'created' === $image->status) {
                 // Set as featured image
                 $featured_status = set_post_thumbnail($event['ID'], $image->post_id);
                 if ($featured_status) {
                     // Log this attachment was created
                     $activity->add('attachment', 'created', $image->post_id);
                 }
             }
         }
     }
     remove_filter('tribe-post-origin', array(Tribe__Events__Aggregator__Records::instance(), 'filter_post_origin'), 10);
     return $activity;
 }
示例#12
0
$origin_show_map_options = array('' => $use_global_settings_phrase) + $show_map_options;
$change_authority = array('import-defaults-update_authority' => array('type' => 'html', 'html' => '<h3 id="tribe-import-update-authority">' . esc_html__('Event Update Authority', 'the-events-calendar') . '</h3>'), 'info-update_authority' => array('type' => 'html', 'html' => '<p>' . esc_html__('You can make changes to imported events via The Events Calendar and see those changes reflected on your site’s calendar. The owner of the original event source (e.g. the iCalendar feed or Facebook group) might also make changes to their event. If you choose to re-import an altered event (manually or via a scheduled import), any changes made at the source or on your calendar will need to be addressed.', 'the-events-calendar') . '</p>'), 'tribe_aggregator_default_update_authority' => array('type' => 'radio', 'label' => esc_html__('Event Update Authority', 'the-events-calendar'), 'validation_type' => 'options', 'default' => Tribe__Events__Aggregator__Settings::$default_update_authority, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => array('overwrite' => __('Overwrite my event with any changes from the original source.', 'the-events-calendar'), 'retain' => __('Do not re-import events. Changes made locally will be preserved.', 'the-events-calendar'), 'preserve_changes' => __('Preserve the most recent change in each event field, whether that change occurred on my site or at the original source.', 'the-events-calendar'))));
$csv = array('csv-defaults' => array('type' => 'html', 'html' => '<h3 id="tribe-import-csv-settings">' . esc_html__('CSV Import Settings', 'the-events-calendar') . '</h3>'), 'tribe_aggregator_default_csv_post_status' => array('type' => 'dropdown', 'label' => esc_html__('Default Status', 'the-events-calendar'), 'tooltip' => esc_html__('The default post status for events imported via CSV', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_post_statuses), 'tribe_aggregator_default_csv_category' => array('type' => 'dropdown', 'label' => esc_html__('Default Event Category', 'the-events-calendar'), 'tooltip' => esc_html__('The default event category for events imported via CSV', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_categories));
$global = $ical = $ics = $facebook = $gcal = $meetup = array();
// if there's an Event Aggregator license key, add the Global settings, Facebook, iCal, and Meetup fields
if (Tribe__Events__Aggregator::is_service_active()) {
    $global = array('import-defaults' => array('type' => 'html', 'html' => '<h3 id="tribe-import-global-settings">' . esc_html__('Global Import Settings', 'the-events-calendar') . '</h3>'), 'tribe_aggregator_default_post_status' => array('type' => 'dropdown', 'label' => esc_html__('Default Status', 'the-events-calendar'), 'tooltip' => esc_html__('The default post status for events', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => 'publish', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $post_statuses), 'tribe_aggregator_default_category' => array('type' => 'dropdown', 'label' => esc_html__('Default Event Category', 'the-events-calendar'), 'tooltip' => esc_html__('The default event category for events', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $categories), 'tribe_aggregator_default_show_map' => array('type' => 'dropdown', 'label' => esc_html__('Show Google Map', 'the-events-calendar'), 'tooltip' => esc_html__('Show Google Map by default on imported event and venues', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => 'no', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $show_map_options));
    $ical = array('ical-defaults' => array('type' => 'html', 'html' => '<h3 id="tribe-import-ical-settings">' . esc_html__('iCalendar Import Settings', 'the-events-calendar') . '</h3>'), 'tribe_aggregator_default_ical_post_status' => array('type' => 'dropdown', 'label' => esc_html__('Default Status', 'the-events-calendar'), 'tooltip' => esc_html__('The default post status for events imported via iCalendar', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_post_statuses), 'tribe_aggregator_default_ical_category' => array('type' => 'dropdown', 'label' => esc_html__('Default Event Category', 'the-events-calendar'), 'tooltip' => esc_html__('The default event category for events imported via iCalendar', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_categories), 'tribe_aggregator_default_ical_show_map' => array('type' => 'dropdown', 'label' => esc_html__('Show Google Map', 'the-events-calendar'), 'tooltip' => esc_html__('Show Google Map by default on imported event and venues', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => 'no', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_show_map_options));
    $ics = array('ics-defaults' => array('type' => 'html', 'html' => '<h3 id="tribe-import-ics-settings">' . esc_html__('ICS File Import Settings', 'the-events-calendar') . '</h3>'), 'tribe_aggregator_default_ics_post_status' => array('type' => 'dropdown', 'label' => esc_html__('Default Status', 'the-events-calendar'), 'tooltip' => esc_html__('The default post status for events imported via .ics files', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_post_statuses), 'tribe_aggregator_default_ics_category' => array('type' => 'dropdown', 'label' => esc_html__('Default Event Category', 'the-events-calendar'), 'tooltip' => esc_html__('The default event category for events imported via .ics files', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_categories), 'tribe_aggregator_default_ics_show_map' => array('type' => 'dropdown', 'label' => esc_html__('Show Google Map', 'the-events-calendar'), 'tooltip' => esc_html__('Show Google Map by default on imported event and venues', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => 'no', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_show_map_options));
    $facebook = array('facebook-defaults' => array('type' => 'html', 'html' => '<h3 id="tribe-import-facebook-settings">' . esc_html__('Facebook Import Settings', 'the-events-calendar') . '</h3>'), 'tribe_aggregator_default_facebook_post_status' => array('type' => 'dropdown', 'label' => esc_html__('Default Status', 'the-events-calendar'), 'tooltip' => esc_html__('The default post status for events imported via Facebook', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_post_statuses), 'tribe_aggregator_default_facebook_category' => array('type' => 'dropdown', 'label' => esc_html__('Default Event Category', 'the-events-calendar'), 'tooltip' => esc_html__('The default event category for events imported via Facebook', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_categories), 'tribe_aggregator_default_facebook_show_map' => array('type' => 'dropdown', 'label' => esc_html__('Show Google Map', 'the-events-calendar'), 'tooltip' => esc_html__('Show Google Map by default on imported event and venues', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => 'no', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_show_map_options));
    $gcal = array('gcal-defaults' => array('type' => 'html', 'html' => '<h3 id="tribe-import-google-settings">' . esc_html__('Google Calendar Import Settings', 'the-events-calendar') . '</h3>'), 'tribe_aggregator_default_gcal_post_status' => array('type' => 'dropdown', 'label' => esc_html__('Default Status', 'the-events-calendar'), 'tooltip' => esc_html__('The default post status for events imported via Google Calendar', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_post_statuses), 'tribe_aggregator_default_gcal_category' => array('type' => 'dropdown', 'label' => esc_html__('Default Event Category', 'the-events-calendar'), 'tooltip' => esc_html__('The default event category for events imported via Google Calendar', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_categories), 'tribe_aggregator_default_gcal_show_map' => array('type' => 'dropdown', 'label' => esc_html__('Show Google Map', 'the-events-calendar'), 'tooltip' => esc_html__('Show Google Map by default on imported event and venues', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => 'no', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_show_map_options));
    $meetup = array('meetup-defaults' => array('type' => 'html', 'html' => '<h3 id="tribe-import-meetup-settings">' . esc_html__('Meetup Import Settings', 'the-events-calendar') . '</h3>'), 'meetup-defaults-info' => array('type' => 'html', 'html' => '<p>' . sprintf(esc_html__('To import Meetup events, please be sure to add your Meetup API key on %1$sEvents > Settings > APIs%2$s', 'the-events-calendar'), '<a href="' . admin_url(Tribe__Settings::$parent_page . '&page=tribe-common&tab=addons') . '">', '</a>') . '</p>'), 'tribe_aggregator_default_meetup_post_status' => array('type' => 'dropdown', 'label' => esc_html__('Default Status', 'the-events-calendar'), 'tooltip' => esc_html__('The default post status for events imported via Meetup', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_post_statuses), 'tribe_aggregator_default_meetup_category' => array('type' => 'dropdown', 'label' => esc_html__('Default Event Category', 'the-events-calendar'), 'tooltip' => esc_html__('The default event category for events imported via Meetup', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => '', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_categories), 'tribe_aggregator_default_meetup_show_map' => array('type' => 'dropdown', 'label' => esc_html__('Show Google Map', 'the-events-calendar'), 'tooltip' => esc_html__('Show Google Map by default on imported event and venues', 'the-events-calendar'), 'size' => 'medium', 'validation_type' => 'options', 'default' => 'no', 'can_be_empty' => true, 'parent_option' => Tribe__Events__Main::OPTIONNAME, 'options' => $origin_show_map_options));
}
$internal = array_merge($change_authority, $global, $csv, $ical, $ics, $facebook, $gcal, $meetup);
$internal = apply_filters('tribe_aggregator_fields', $internal);
if (Tribe__Events__Aggregator::instance()->is_service_active()) {
    ob_start();
    ?>
	<p>
		<?php 
    printf(esc_html__('Use the options below to configure your imports. Global Import Settings apply to all imports, but you can also override the global settings by adjusting the origin-specific options. Check your Event Aggregator Service Status on the %1$s.', 'the-events-calendar'), '<a href="' . Tribe__Settings::instance()->get_url(array('page' => 'tribe-help')) . '#tribe-tribe-aggregator-status">' . esc_html__('Help page', 'the-events-calendar') . '</a>');
    ?>
	</p>
	<div>
		<a href="#tribe-import-update-authority"><?php 
    esc_html_e('Update Authority', 'the-events-calendar');
    ?>
</a> |
		<a href="#tribe-import-global-settings"><?php 
    esc_html_e('Global', 'the-events-calendar');
    ?>
示例#13
0
 /**
  * Checks if any record data needs to be fetched from the service, this will run on the Cron every 15m
  *
  * @since  4.3
  * @return void
  */
 public function verify_fetching_from_service()
 {
     // if the service isn't active, don't do anything
     if (!Tribe__Events__Aggregator::instance()->is_service_active()) {
         return;
     }
     $records = Tribe__Events__Aggregator__Records::instance();
     $query = $records->query(array('post_status' => Tribe__Events__Aggregator__Records::$status->pending, 'posts_per_page' => -1, 'order' => 'ASC', 'meta_query' => array(array('key' => '_tribe_aggregator_origin', 'value' => 'csv', 'compare' => '!='))));
     if (!$query->have_posts()) {
         $this->log('debug', 'No Records Pending, skipped Fetching from service');
         return;
     }
     foreach ($query->posts as $post) {
         $record = $records->get_by_post_id($post);
         // Just double Check for CSV
         if ('csv' === $record->origin) {
             $this->log('debug', sprintf('Record (%d) skipped, has CSV origin', $record->id));
             continue;
         }
         // Open a Queue to try to process the posts
         $queue = $record->process_posts();
         if (!is_wp_error($queue)) {
             /** @var Tribe__Events__Aggregator__Record__Queue $queue */
             $this->log('debug', sprintf('Record (%d) has processed queue ', $queue->record->id));
             $activity = $queue->activity()->get();
             foreach ($activity as $key => $actions) {
                 foreach ($actions as $action => $ids) {
                     if (empty($ids)) {
                         continue;
                     }
                     $this->log('debug', sprintf("\t" . '%s — %s: %s', $key, $action, implode(', ', $ids)));
                 }
             }
         } else {
             $this->log('debug', sprintf('Record (%d) — %s', $record->id, $queue->get_error_message()));
         }
     }
 }
示例#14
0
 /**
  * Get's all products from the API
  *
  * @return array|WP_Error
  */
 private function get_all_products()
 {
     $products = array((object) array('title' => __('Event Aggregator', 'tribe-common'), 'link' => 'https://theeventscalendar.com/product/event-aggregator/?utm_campaign=in-app&utm_source=addonspage&utm_medium=event-aggregator&utm_content=appstoreembedded-1', 'description' => __('Importing events from multiple sources has never been easier! Event Aggregator helps you curate and manage event import feeds from Facebook, Meetup, Google Calendar, iCalendar, CSV, and ICS. Schedule automatic imports or manually import events when you’re ready. Event Aggregator provides a convenient dashboard to manage bulk imports, filters, one-way sync, import history, and more.', 'tribe-common'), 'image' => 'images/app-shop-ical.jpg', 'is_installed' => Tribe__Events__Aggregator::is_service_active()), (object) array('title' => __('Events Calendar PRO', 'tribe-common'), 'link' => 'https://theeventscalendar.com/product/wordpress-events-calendar-pro/?utm_campaign=in-app&utm_source=addonspage&utm_medium=wordpress-events-calendar-pro&utm_content=appstoreembedded-1', 'description' => sprintf(__('The Events Calendar PRO is a paid Add-On to our open source WordPress plugin %1$sThe Events Calendar%2$s. PRO offers a whole host of calendar features including recurring events, custom event attributes, saved venues and organizers, venue pages, advanced event admin and lots more.', 'tribe-common'), '<a href="http://m.tri.be/18vc">', '</a>'), 'image' => 'images/app-shop-pro.jpg', 'is_installed' => class_exists('Tribe__Events__Pro__Main')), (object) array('title' => __('Event Tickets Plus', 'tribe-common'), 'link' => 'https://theeventscalendar.com/product/wordpress-event-tickets-plus/?utm_campaign=in-app&utm_source=addonspage&utm_medium=wordpress-event-tickets-plus&utm_content=appstoreembedded-1', 'description' => sprintf(__('Event Tickets Plus allows you to sell tickets to your events using WooCommerce, Shopp, WP eCommerce, or Easy Digital Downloads. Use it on your posts and pages, or add %1$sThe Events Calendar%2$s and sell tickets from your events listings.', 'tribe-common'), '<a href="http://m.tri.be/18vc">', '</a>'), 'image' => 'images/app-shop-tickets-plus.jpg', 'is_installed' => class_exists('Tribe__Tickets_Plus__Main')), (object) array('title' => __('Filter Bar', 'tribe-common'), 'link' => 'https://theeventscalendar.com/product/wordpress-events-filterbar/?utm_campaign=in-app&utm_source=addonspage&utm_medium=wordpress-events-filterbar&utm_content=appstoreembedded-1', 'description' => __('It is awesome that your calendar is <em>THE PLACE</em> to get hooked up with prime choice ways to spend time. You have more events than Jabba the Hutt has rolls. Too bad visitors are hiring a personal assistant to go through all the choices. Ever wish you could just filter the calendar to only show events in walking distance, on a weekend, that are free? BOOM. Now you can. Introducing… the Filter Bar.', 'tribe-common'), 'image' => 'images/app-shop-filter-bar.jpg', 'is_installed' => class_exists('Tribe__Events__Filterbar__View')), (object) array('title' => __('Community Events', 'tribe-common'), 'link' => 'https://theeventscalendar.com/product/wordpress-community-events/?utm_campaign=in-app&utm_source=addonspage&utm_medium=wordpress-community-events&utm_content=appstoreembedded-1', 'description' => __('Enable users to submit events to your calendar with Community Events. You can require user accounts or allow visitors to submit without an account. Want to make sure that nothing fishy is going on? Just turn on moderation. Decide if users can edit and manage their own events, or simply submit. Plus, no scary form setup! Just activate, configure the options & off you go.', 'tribe-common'), 'image' => 'images/app-shop-community.jpg', 'is_installed' => class_exists('Tribe__Events__Community__Main')), (object) array('title' => __('Community Tickets', 'tribe-common'), 'link' => 'https://theeventscalendar.com/product/community-tickets/?utm_campaign=in-app&utm_source=addonspage&utm_medium=community-tickets&utm_content=appstoreembedded-1', 'description' => __('Enable Community Events organizers to offer tickets to their events. You can set flexible payment and fee options. They can even check-in attendees to their events! All of this managed from the front-end of your site without ever needing to grant access to your admin', 'tribe-common'), 'requires' => _x('Event Tickets Plus and Community Events', 'Names of required plugins for Community Tickets', 'tribe-common'), 'image' => 'images/app-shop-community-tickets.jpg', 'is_installed' => class_exists('Tribe__Events__Community__Tickets__Main')), (object) array('title' => __('Eventbrite Tickets', 'tribe-common'), 'link' => 'https://theeventscalendar.com/product/wordpress-eventbrite-tickets/?utm_campaign=in-app&utm_source=addonspage&utm_medium=wordpress-eventbrite-tickets&utm_content=appstoreembedded-1', 'description' => sprintf(__('The Eventbrite Tickets add-on allows you to create & sell tickets through The Events Calendar using the power of %1$sEventbrite%2$s. Whether you’re creating your ticket on the WordPress dashboard or importing the details of an already-existing event from %1$sEventbrite.com%2$s, this add-on brings the power of the Eventbrite API to your calendar.', 'tribe-common'), '<a href="http://www.eventbrite.com/r/etp">', '</a>'), 'image' => 'images/app-shop-eventbrite.jpg', 'is_installed' => class_exists('Tribe__Events__Tickets__Eventbrite__Main')));
     return $products;
 }
示例#15
0
    /**
     * Renders the "Missing Aggregator License" notice
     *
     * @return string
     */
    public function maybe_display_aggregator_upsell()
    {
        if (defined('TRIBE_HIDE_UPSELL')) {
            return;
        }
        if (Tribe__Events__Aggregator::instance()->is_service_active()) {
            return;
        }
        ob_start();
        ?>
		<div class="notice inline notice-info tribe-dependent tribe-notice-tribe-missing-aggregator-license" data-ref="tribe-missing-aggregator-license" data-depends="#tribe-ea-field-origin" data-condition-empty>

			<div class="upsell-banner">
				<img src="<?php 
        echo esc_url(tribe_events_resource_url('images/aggregator/upsell-banner.png'));
        ?>
">
			</div>

			<h3><?php 
        esc_html_e('Import Using Event Aggregator', 'the-events-calendar');
        ?>
</h3>

			<p><?php 
        esc_html_e('With Event Aggregator, you can import events from Facebook, iCalendar, Google, and Meetup.com in a jiffy.', 'the-events-calendar');
        ?>
</p>

			<a href="http://m.tri.be/196y" class="tribe-license-link tribe-button tribe-button-primary" target="_blank">
				<?php 
        esc_html_e('Buy It Now', 'the-events-calendar');
        ?>
				<span class="screen-reader-text">
					<?php 
        esc_html_e('opens in a new window', 'the-events-calendar');
        ?>
				</span>
			</a>

			<a href="http://m.tri.be/196z" class="tribe-license-link tribe-button tribe-button-secondary" target="_blank">
				<?php 
        esc_html_e('Learn More', 'the-events-calendar');
        ?>
				<span class="screen-reader-text">
					<?php 
        esc_html_e('opens in a new window', 'the-events-calendar');
        ?>
				</span>
			</a>
		</div>
		<?php 
        return ob_get_clean();
    }
示例#16
0
 public function column_source($post)
 {
     $record = Tribe__Events__Aggregator__Records::instance()->get_by_post_id($post);
     if ('scheduled' !== $this->tab->get_slug()) {
         $html[] = $this->get_status_icon($record);
     }
     $source_info = $record->get_source_info();
     $source_info['title'] = $source_info['title'];
     if ($record->is_schedule && Tribe__Events__Aggregator::instance()->is_service_active()) {
         $html[] = '<p><b><a href="' . get_edit_post_link($post->ID) . '">' . esc_html($source_info['title']) . '</a></b></p>';
     } else {
         $html[] = '<p><b>' . esc_html($source_info['title']) . '</b></p>';
     }
     $html[] = '<p>' . esc_html_x('via ', 'record via origin', 'the-events-calendar') . '<strong>' . $source_info['via'] . '</strong></p>';
     if (!empty($record->meta['keywords']) || !empty($record->meta['start']) || !empty($record->meta['location']) || !empty($record->meta['radius'])) {
         $html[] = '<div class="tribe-view-filters-container">';
         $html[] = '<a href="" class="tribe-view-filters">' . esc_html__('View Filters', 'the-events-calendar') . '</a>';
         $html[] = '<dl class="tribe-filters">';
         if (!empty($record->meta['keywords'])) {
             $html[] = '<dt>' . __('Keywords:', 'the-events-calendar') . '</dt><dd>' . esc_html($record->meta['keywords']) . '</dd>';
         }
         if (!empty($record->meta['start'])) {
             $html[] = '<dt>' . __('Start:', 'the-events-calendar') . '</dt><dd>' . esc_html($record->meta['start']) . '</dd>';
         }
         if (!empty($record->meta['location'])) {
             $html[] = '<dt>' . __('Location:', 'the-events-calendar') . '</dt><dd>' . esc_html($record->meta['location']) . '</dd>';
         }
         if (!empty($record->meta['radius'])) {
             $html[] = '<dt>' . __('Radius:', 'the-events-calendar') . '</dt><dd>' . esc_html($record->meta['radius']) . '</dd>';
         }
         $html[] = '</dl></div>';
     }
     return $this->render($html);
 }
示例#17
0
    public function notice_legacy_plugins()
    {
        if (!Tribe__Admin__Helpers::instance()->is_screen()) {
            return false;
        }
        $aggregator = Tribe__Events__Aggregator::instance();
        if (!$aggregator->is_service_active()) {
            return false;
        }
        $ical_active = $aggregator->is_legacy_ical_active();
        $facebook_active = $aggregator->is_legacy_facebook_active();
        if (!$ical_active && !$facebook_active) {
            return false;
        }
        $active = array();
        if ($facebook_active) {
            $active[] = '<b>' . esc_html__('Facebook Events', 'the-events-calendar') . '</b>';
        }
        if ($ical_active) {
            $active[] = '<b>' . esc_html__('iCal Importer', 'the-events-calendar') . '</b>';
        }
        ob_start();
        ?>
		<p>
			<?php 
        printf(esc_html(_n('It looks like you are using our legacy plugin, %1$s, along with our new Event Aggregator service. Event Aggregator includes all the features of the legacy plugin plus enhanced functionality. For best results, please deactivate %1$s.', 'It looks like you are using our legacy plugins, %1$s and %2$s, along with our new Event Aggregator service. Event Aggregator includes all the features of the legacy plugins plus enhanced functionality. For best results, please deactivate %1$s and %2$s.', count($active), 'the-events-calendar')), $active[0], isset($active[1]) ? $active[1] : '');
        ?>
		</p>
		<p>
			<a href="<?php 
        echo esc_url(admin_url('plugins.php?plugin_status=active'));
        ?>
"><?php 
        esc_html_e('Manage Active Plugins', 'the-events-calendar');
        ?>
</a>
		</p>
		<?php 
        $html = ob_get_clean();
        return Tribe__Admin__Notices::instance()->render('tribe-aggregator-legacy-import-plugins-active', $html);
    }