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));
     $event = array('post_type' => Tribe__Events__Main::POSTTYPE, 'post_title' => $this->get_value_by_key($record, 'event_name'), 'post_status' => Tribe__Events__Importer__Options::get_default_post_status('csv'), '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);
     }
     if ($cats = $this->get_value_by_key($record, 'event_category')) {
         $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;
 }
Exemplo n.º 2
0
 * Hook to this filter to print More fields on the Importer Settings page
 */
$fields = apply_filters('tribe_import_general_settings', array());
foreach ($fields as $key => $field_args) {
    if (strpos($key, 'imported_post_status') === false) {
        $value = Tribe__Settings_Manager::get_option($key, null);
    } else {
        /**
         * Regular Expression to match "suboption_name" given "option_name[suboption_name]"
         */
        if (preg_match('/\\[([^\\]]+)\\]/i', $key, $match)) {
            $type = end($match);
        } else {
            $type = 'csv';
        }
        $value = Tribe__Events__Importer__Options::get_default_post_status($type);
    }
    new Tribe__Field($key, $field_args, $value);
}
wp_nonce_field('tribe-import-general-settings', 'tribe-import-general-settings');
?>
		<div class="tribe-settings-form-wrap">
			<p>
				<input type="submit" name="tribe-events-importexport-general-settings-submit" class="button-primary" value="<?php 
esc_attr_e('Save Settings', 'the-events-calendar');
?>
"/>
			</p>
		</div>
	</form>
</div>
 private function build_event_array(array $record)
 {
     $start_date = strtotime($this->get_event_start_date($record));
     $end_date = strtotime($this->get_event_end_date($record));
     $event = array('post_type' => Tribe__Events__Main::POSTTYPE, 'post_title' => $this->get_value_by_key($record, 'event_name'), 'post_status' => Tribe__Events__Importer__Options::get_default_post_status('csv'), 'post_content' => $this->get_value_by_key($record, 'event_description'), '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'), 'EventShowMap' => $this->get_boolean_value_by_key($record, 'event_show_map'), 'EventCost' => $this->get_value_by_key($record, 'event_cost'), 'EventAllDay' => $this->get_boolean_value_by_key($record, 'event_all_day', 'yes'), 'EventHideFromUpcoming' => $this->get_value_by_key($record, 'event_hide'), 'EventURL' => $this->get_value_by_key($record, 'event_website'), 'EventCurrencySymbol' => $this->get_value_by_key($record, 'event_currency_symbol'), 'EventCurrencyPosition' => $this->get_value_by_key($record, 'event_currency_position'));
     if ($organizer_id = $this->find_matching_organizer_id($record)) {
         $event['Organizer'] = array('OrganizerID' => $organizer_id);
     }
     if ($venue_id = $this->find_matching_venue_id($record)) {
         $event['Venue'] = array('VenueID' => $venue_id);
     }
     if ($cats = $this->get_value_by_key($record, 'event_category')) {
         $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;
     }
     $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;
 }