/**
  * Static Singleton Factory Method
  *
  * @return Tribe__Events__Aggregator
  */
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 protected function create_post(array $record)
 {
     $post_status_setting = Tribe__Events__Aggregator__Settings::instance()->default_post_status('csv');
     $organizer = $this->build_organizer_array(false, $record);
     $id = Tribe__Events__API::createOrganizer($organizer, $post_status_setting);
     if ($this->is_aggregator && !empty($this->aggregator_record)) {
         $this->aggregator_record->meta['activity']->add('organizer', 'created', $id);
     }
     return $id;
 }
 private function build_venue_array($venue_id, array $record)
 {
     $show_map_setting = Tribe__Events__Aggregator__Settings::instance()->default_map('csv');
     $venue_address = trim($this->get_value_by_key($record, 'venue_address') . ' ' . $this->get_value_by_key($record, 'venue_address2'));
     $venue = array('Venue' => $this->get_value_by_key($record, 'venue_name'), 'Description' => $this->get_value_by_key($record, 'venue_description'), 'Address' => $venue_address, 'City' => $this->get_value_by_key($record, 'venue_city'), 'Country' => $this->get_value_by_key($record, 'venue_country'), 'Province' => $this->get_value_by_key($record, 'venue_state'), 'State' => $this->get_value_by_key($record, 'venue_state'), 'Zip' => $this->get_value_by_key($record, 'venue_zip'), 'Phone' => $this->get_value_by_key($record, 'venue_phone'), 'URL' => $this->get_value_by_key($record, 'venue_url'), 'ShowMap' => $venue_id ? get_post_meta($venue_id, '_VenueShowMap', true) : $show_map_setting, 'ShowMapLink' => $venue_id ? get_post_meta($venue_id, '_VenueShowMapLink', true) : $show_map_setting, 'FeaturedImage' => $this->get_featured_image($venue_id, $record));
     if (empty($venue['Country'])) {
         $venue['Country'] = 'United States';
     }
     $venue = apply_filters('tribe_events_importer_venue_array', $venue, $record, $venue_id, $this);
     return $venue;
 }
Beispiel #4
0
 public function init()
 {
     $plugin = Tribe__Events__Main::instance();
     $localize_data = array('name' => 'tribe_aggregator', 'data' => array('csv_column_mapping' => array('events' => get_option('tribe_events_import_column_mapping_events', array()), 'organizer' => get_option('tribe_events_import_column_mapping_organizers', array()), 'venue' => get_option('tribe_events_import_column_mapping_venues', array())), 'l10n' => array('all_day' => __('All Day', 'the-events-calendar'), 'am' => _x('AM', 'Meridian: am', 'the-events-calendar'), 'pm' => _x('PM', 'Meridian: pm', 'the-events-calendar'), 'preview_timeout' => __('The preview is taking longer than expected. Please try again in a moment.', 'the-events-calendar'), 'preview_fetch_error_prefix' => __('There was an error fetching the results from your import:', 'the-events-calendar'), 'import_all' => __('Import All (%d)', 'the-events-calendar'), 'import_all_no_number' => __('Import All', 'the-events-calendar'), 'import_checked' => __('Import Checked (%d)', 'the-events-calendar'), 'create_schedule' => __('Save Scheduled Import', 'the-events-calendar'), 'edit_save' => __('Save Changes', 'the-events-calendar'), 'events_required_for_manual_submit' => __('Your import must include at least one event', 'the-events-calendar'), 'no_results' => __('Your preview doesn\'t have any records to import.', 'the-events-calendar'), 'verify_schedule_delete' => __('Removing this scheduled import will stop automatic imports from the source. No events will be deleted.', 'the-events-calendar'), 'view_filters' => __('View Filters', 'the-events-calendar'), 'hide_filters' => __('Hide Filters', 'the-events-calendar'), 'preview_polling' => array(__('Please wait while your preview is fetched.', 'the-events-calendar'), __('Please continue to wait while your preview is generated.', 'the-events-calendar'), __('If all goes according to plan, you will have your preview in a few moments.', 'the-events-calendar'), __('Your preview is taking a bit longer than expected, but it <i>is</i> still being generated.', 'the-events-calendar')), 'debug' => defined('WP_DEBUG') && true === WP_DEBUG), 'default_settings' => Tribe__Events__Aggregator__Settings::instance()->get_all_default_settings()));
     /**
      * Filters the CSV column mapping output
      *
      * @param array $mapping Mapping data indexed by CSV import type
      */
     $localize_data['data']['csv_column_mapping'] = apply_filters('tribe_aggregator_csv_column_mapping', $localize_data['data']['csv_column_mapping']);
     // Load these on all the pages
     tribe_assets($plugin, array(array('tribe-ea-fields', 'aggregator-fields.js', array('jquery', 'tribe-datatables', 'underscore', 'tribe-bumpdown', 'tribe-dependency', 'tribe-events-select2', 'tribe-ea-facebook-login')), array('tribe-ea-page', 'aggregator-page.css', array('datatables-css'))), 'admin_enqueue_scripts', array('conditionals' => array(array($this, 'is_screen')), 'localize' => (object) $localize_data));
     tribe_asset($plugin, 'tribe-ea-facebook-login', 'aggregator-facebook-login.js', array('jquery', 'underscore', 'tribe-dependency'), 'admin_enqueue_scripts');
 }
Beispiel #5
0
 public function handle_import_finalize($data)
 {
     $this->messages = array('error' => array(), 'success' => array(), 'warning' => array());
     $record = Tribe__Events__Aggregator__Records::instance()->get_by_import_id($data['import_id']);
     if (is_wp_error($record)) {
         $this->messages['error'][] = $record->get_error_message();
         return $this->messages;
     }
     // Make sure we have a post status set no matter what
     if (empty($data['post_status'])) {
         $data['post_status'] = Tribe__Events__Aggregator__Settings::instance()->default_post_status($data['origin']);
     }
     // If the submitted category is null, that means the user intended to de-select the default
     // category if there is one, so setting it to null is ok here
     $record->update_meta('category', empty($data['category']) ? null : $data['category']);
     $record->update_meta('post_status', $data['post_status']);
     $record->update_meta('ids_to_import', empty($data['selected_rows']) ? 'all' : json_decode(stripslashes($data['selected_rows'])));
     // if we get here, we're good! Set the status to pending
     $record->set_status_as_pending();
     $record->finalize();
     if ('schedule' === $record->meta['type']) {
         $this->messages['success'][] = __('1 import was scheduled.', 'the-events-calendar');
         $create_schedule_result = $record->create_schedule_record();
         if (is_wp_error($create_schedule_result)) {
             $this->messages['error'][] = $create_schedule_result->get_error_message();
             tribe_notice('tribe-aggregator-import-failed', array($this, 'render_notice_import_failed'), 'type=error');
             $record->set_status_as_failed($create_schedule_result);
             return $create_schedule_result;
         }
     }
     $record->update_meta('interactive', true);
     if ('csv' === $data['origin']) {
         $result = $record->process_posts($data);
     } else {
         $result = $record->process_posts();
     }
     $this->messages = $this->get_result_messages($result);
     if (empty($this->messages['error']) || !empty($this->messages['success']) || !empty($this->messages['warning'])) {
         tribe_notice('tribe-aggregator-import-complete', array($this, 'render_notice_import_complete'), 'type=success');
     }
 }
 /**
  * A private method to prevent it to be created twice.
  * It will add the methods and setup any dependencies
  *
  * Note: This should load on `plugins_loaded@P10`
  */
 private function __construct()
 {
     /**
      * As previously seen by other major features some users would rather have it not active
      * @var bool
      */
     $should_load = (bool) apply_filters('tribe_aggregator_should_load', true);
     // You shall not Load!
     if (false === $should_load) {
         return;
     }
     // Loads the Required Classes and saves them as proprieties
     $this->meta_box = Tribe__Events__Aggregator__Meta_Box::instance();
     $this->migrate = Tribe__Events__Aggregator__Migrate::instance();
     $this->page = Tribe__Events__Aggregator__Page::instance();
     $this->service = Tribe__Events__Aggregator__Service::instance();
     $this->settings = Tribe__Events__Aggregator__Settings::instance();
     $this->records = Tribe__Events__Aggregator__Records::instance();
     $this->cron = Tribe__Events__Aggregator__Cron::instance();
     $this->queue_processor = new Tribe__Events__Aggregator__Record__Queue_Processor();
     $this->queue_realtime = new Tribe__Events__Aggregator__Record__Queue_Realtime(null, null, $this->queue_processor);
     $this->errors = Tribe__Events__Aggregator__Errors::instance();
     $this->pue_checker = new Tribe__PUE__Checker('http://tri.be/', 'event-aggregator', array('context' => 'service'));
     // Initializes the Classes related to the API
     $this->api();
     // Flags that the Aggregator has been fully loaded
     $this->is_loaded = true;
     // Register the Aggregator Endpoint
     add_action('tribe_events_pre_rewrite', array($this, 'action_endpoint_configuration'));
     // Intercept the Endpoint and trigger actions
     add_action('parse_request', array($this, 'action_endpoint_parse_request'));
     // Add endpoint query vars
     add_filter('query_vars', array($this, 'filter_endpoint_query_vars'));
     // Filter the "plugin name" for Event Aggregator
     add_filter('pue_get_plugin_name', array($this, 'filter_pue_plugin_name'), 10, 2);
     // To make sure that meaningful cache is purged when settings are changed
     add_action('updated_option', array($this, 'action_purge_transients'));
     // Remove aggregator records from ET
     add_filter('tribe_tickets_settings_post_types', array($this, 'filter_remove_record_post_type'));
     // Notify users about expiring Facebook Token if oauth is enabled
     add_action('plugins_loaded', array($this, 'setup_notices'), 11);
     // Let's prevent events-importer-ical from DESTROYING its saved recurring imports when it gets deactivated
     if (class_exists('Tribe__Events__Ical_Importer__Main')) {
         remove_action('deactivate_' . plugin_basename(Tribe__Events__Ical_Importer__Main::$plugin_path . 'the-events-calendar-ical-importer.php'), 'tribe_events_ical_deactivate');
     }
     add_action('admin_init', array($this, 'add_status_to_help'));
 }
Beispiel #7
0
	<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 
echo tribe_events_resource_url('images/aggregator/facebook.png');
 /**
  * Translates event JSON to the-events-calendar Event array format
  *
  * @param object $json Event data in Event Aggregator format
  *
  * @return array
  */
 public function translate_json_to_event($json)
 {
     if (empty($json->title) || empty($json->start_date) || empty($json->start_hour) || empty($json->start_minute) || empty($json->end_date) || empty($json->end_hour) || empty($json->end_minute)) {
         return tribe_error('core:aggregator:invalid-event-json');
     }
     $event = array();
     $event['post_type'] = Tribe__Events__Main::POSTTYPE;
     $event['post_status'] = Tribe__Events__Aggregator__Settings::instance()->default_post_status($json->origin);
     // translate json key/value pairs to event array key/value pairs
     foreach (get_object_vars($json) as $key => $value) {
         // venues and organizers are a bit more complex. We'll handle those later
         if ('venue' === $key || 'organizer' === $key) {
             continue;
         }
         if (isset($this->event_field_map[$key])) {
             $key = $this->event_field_map[$key];
         }
         $event[$key] = $value;
     }
     if (!empty($json->venue)) {
         $event['Venue'] = array();
         if (!is_array($json->venue)) {
             $json->venue = array($json->venue);
         }
         foreach ($json->venue as $venue) {
             $venue_data = array();
             if (empty($venue->venue)) {
                 continue;
             }
             foreach (get_object_vars($venue) as $key => $value) {
                 if (isset($this->venue_field_map[$key])) {
                     $key = $this->venue_field_map[$key];
                 }
                 $venue_data[$key] = $value;
             }
             $event['Venue'][] = $venue_data;
         }
     }
     if (!empty($json->organizer)) {
         $event['Organizer'] = array();
         if (!is_array($json->organizer)) {
             $json->organizer = array($json->organizer);
         }
         foreach ($json->organizer as $organizer) {
             $organizer_data = array();
             if (empty($organizer->organizer)) {
                 continue;
             }
             foreach (get_object_vars($organizer) as $key => $value) {
                 if (isset($this->organizer_field_map[$key])) {
                     $key = $this->organizer_field_map[$key];
                 }
                 $organizer_data[$key] = $value;
             }
             $event['Organizer'][] = $organizer_data;
         }
     }
     $show_map_setting = Tribe__Events__Aggregator__Settings::instance()->default_map($json->origin);
     $event['EventShowMap'] = $show_map_setting;
     $event['EventShowMapLink'] = $show_map_setting;
     return $event;
 }
<?php

$origin_slug = 'facebook';
$field = (object) array();
$field->label = __('Import Type:', 'the-events-calendar');
$field->placeholder = __('Select Import Type', 'the-events-calendar');
$field->help = __('One-time imports include all currently listed events, while scheduled imports automatically grab new events and updates from Facebook on a set schedule. Single events can be added via a one-time import.', 'the-events-calendar');
$field->source = 'facebook_import_type';
$frequency = (object) array();
$frequency->placeholder = __('Select Frequency', 'the-events-calendar');
$frequency->help = __('Select how often you would like events to be automatically imported.', 'the-events-calendar');
$frequency->source = 'facebook_import_frequency';
$cron = Tribe__Events__Aggregator__Cron::instance();
$frequencies = $cron->get_frequency();
$missing_facebook_credentials = !Tribe__Events__Aggregator__Settings::instance()->is_fb_credentials_valid();
$data_depends = '#tribe-ea-field-origin';
$data_condition = 'facebook';
if ($missing_facebook_credentials) {
    $data_depends = '#tribe-has-facebook-credentials';
    $data_condition = '1';
    ?>
	<tr class="tribe-dependent tribe-credential-row" data-depends="#tribe-ea-field-origin" data-condition="facebook">
		<td colspan="2" class="<?php 
    echo esc_attr($missing_facebook_credentials ? 'enter-credentials' : 'has-credentials');
    ?>
">
			<input type="hidden" name="has-credentials" id="tribe-has-facebook-credentials" value="0">
			<div class="tribe-message tribe-credentials-prompt">
				<p>
					<span class="dashicons dashicons-warning"></span>
					<?php 
 /**
  * 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;
 }
</legend>
		<div class="tribe-field-wrap">
			<p>
				<?php 
    if ($missing_fb_credentials) {
        esc_html_e('You need to connect to Facebook for Event Aggregator to work properly');
        $facebook_button_label = __('Connect to Facebook', 'the-events-calendar');
    } else {
        if ($passed > 0) {
            echo sprintf(__('Your Event Aggregator Facebook connection has expired %s.', 'the-events-calendar'), $time);
        } else {
            echo sprintf(__('Your Event Aggregator Facebook connection will expire %s.', 'the-events-calendar'), $time);
        }
        $facebook_button_label = __('Refresh your connection to Facebook', 'the-events-calendar');
        $facebook_disconnect_label = __('Disconnect', 'the-events-calendar');
        $facebook_disconnect_url = Tribe__Events__Aggregator__Settings::instance()->build_disconnect_facebook_url($current_url);
    }
    ?>
			</p>
			<a target="_blank" class="tribe-ea-facebook-button" href="<?php 
    echo esc_url(Tribe__Events__Aggregator__Record__Facebook::get_auth_url(array('back' => 'settings')));
    ?>
"><?php 
    esc_html_e($facebook_button_label);
    ?>
</a>
			<?php 
    if (!$missing_fb_credentials) {
        ?>
				<a href="<?php 
        echo esc_url($facebook_disconnect_url);
 private function build_event_array($event_id, array $record)
 {
     $start_date = strtotime($this->get_event_start_date($record));
     $end_date = strtotime($this->get_event_end_date($record));
     if (empty($this->is_aggregator)) {
         $post_status_setting = Tribe__Events__Importer__Options::get_default_post_status('csv');
     } elseif ($this->default_post_status) {
         $post_status_setting = $this->default_post_status;
     } else {
         $post_status_setting = Tribe__Events__Aggregator__Settings::instance()->default_post_status('csv');
     }
     $event = array('post_type' => Tribe__Events__Main::POSTTYPE, 'post_title' => $this->get_value_by_key($record, 'event_name'), 'post_status' => $post_status_setting, 'post_content' => $this->get_value_by_key($record, 'event_description'), 'comment_status' => $this->get_boolean_value_by_key($record, 'event_comment_status', 'open', 'closed'), 'ping_status' => $this->get_boolean_value_by_key($record, 'event_ping_status', 'open', 'closed'), 'post_excerpt' => $this->get_post_excerpt($event_id, $this->get_value_by_key($record, 'event_excerpt')), 'menu_order' => $this->get_boolean_value_by_key($record, 'event_sticky', '-1', '0'), 'EventStartDate' => date('Y-m-d', $start_date), 'EventStartHour' => date('h', $start_date), 'EventStartMinute' => date('i', $start_date), 'EventStartMeridian' => date('a', $start_date), 'EventEndDate' => date('Y-m-d', $end_date), 'EventEndHour' => date('h', $end_date), 'EventEndMinute' => date('i', $end_date), 'EventEndMeridian' => date('a', $end_date), 'EventShowMapLink' => $this->get_boolean_value_by_key($record, 'event_show_map_link', '1', ''), 'EventShowMap' => $this->get_boolean_value_by_key($record, 'event_show_map', '1', ''), 'EventCost' => $this->get_value_by_key($record, 'event_cost'), 'EventAllDay' => $this->get_boolean_value_by_key($record, 'event_all_day', 'yes'), 'EventHideFromUpcoming' => $this->get_boolean_value_by_key($record, 'event_hide', 'yes', ''), 'EventURL' => $this->get_value_by_key($record, 'event_website'), 'EventCurrencySymbol' => $this->get_value_by_key($record, 'event_currency_symbol'), 'EventCurrencyPosition' => $this->get_currency_position($record), 'FeaturedImage' => $this->get_featured_image($event_id, $record), 'EventTimezone' => $this->get_timezone($this->get_value_by_key($record, 'event_timezone')));
     if ($organizer_id = $this->find_matching_organizer_id($record)) {
         $event['organizer'] = is_array($organizer_id) ? $organizer_id : array('OrganizerID' => $organizer_id);
     }
     if ($venue_id = $this->find_matching_venue_id($record)) {
         $event['venue'] = array('VenueID' => $venue_id);
     }
     $cats = $this->get_value_by_key($record, 'event_category');
     if ($this->is_aggregator && !empty($this->default_category)) {
         $cats = $cats ? $cats . ',' . $this->default_category : $this->default_category;
     } elseif ($category_setting = Tribe__Events__Aggregator__Settings::instance()->default_category('csv')) {
         $cats = $cats ? $cats . ',' . $category_setting : $category_setting;
     }
     if ($this->is_aggregator) {
         if ($show_map_setting = Tribe__Events__Aggregator__Settings::instance()->default_map('csv')) {
             $event['EventShowMap'] = $show_map_setting;
             $event['EventShowMapLink'] = $show_map_setting;
         } else {
             if (isset($event['EventShowMap'])) {
                 unset($event['EventShowMap']);
             }
             if (isset($event['EventShowMapLink'])) {
                 unset($event['EventShowMapLink']);
             }
         }
     }
     if ($cats) {
         $event['tax_input'][Tribe__Events__Main::TAXONOMY] = $this->translate_terms_to_ids(explode(',', $cats));
     }
     if ($tags = $this->get_value_by_key($record, 'event_tags')) {
         $event['tax_input']['post_tag'] = $tags;
     }
     // don't create the _EventHideFromUpcoming meta key/value pair if it doesn't need to be created
     if (!$event['EventHideFromUpcoming']) {
         unset($event['EventHideFromUpcoming']);
     }
     if ($event['menu_order'] == '-1') {
         $event['EventShowInCalendar'] = 'yes';
     }
     $additional_fields = apply_filters('tribe_events_csv_import_event_additional_fields', array());
     if (!empty($additional_fields)) {
         foreach ($additional_fields as $key => $csv_column) {
             $event[$key] = $this->get_value_by_key($record, $key);
         }
     }
     return $event;
 }