コード例 #1
0
 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';
 }
コード例 #2
0
 /**
  * Checks to fix all the required datepicker dates to the correct format
  *
  * @param  array $recurrence  The Recurrence meta rules
  * @return array              Recurrence Meta after maybe fixing the data
  */
 public static function maybe_fix_datepicker_output($recurrence, $post_id)
 {
     if (empty($recurrence['exclusions'])) {
         return $recurrence;
     }
     // Fetch the datepicker current format
     $datepicker_format = Tribe__Date_Utils::datepicker_formats(tribe_get_option('datepickerFormat'));
     foreach ($recurrence['exclusions'] as &$exclusion) {
         // Only do something if the exclusion is custom+date
         if (empty($exclusion['custom']) || 'Date' !== $exclusion['custom']['type']) {
             continue;
         }
         // Actually do the conversion of output
         $exclusion['custom']['date']['date'] = date($datepicker_format, strtotime($exclusion['custom']['date']['date']));
     }
     return $recurrence;
 }
コード例 #3
0
 protected function set_end_date_time()
 {
     $this->vars['endMinuteOptions'] = Tribe__View_Helpers::getMinuteOptions($this->vars['_EventEndDate']);
     $this->vars['endHourOptions'] = Tribe__View_Helpers::getHourOptions($this->vars['_EventAllDay'] == 'yes' ? null : $this->vars['_EventEndDate']);
     $this->vars['endMeridianOptions'] = Tribe__View_Helpers::getMeridianOptions($this->vars['_EventEndDate']);
     $datepicker_format = Tribe__Date_Utils::datepicker_formats(tribe_get_option('datepickerFormat'));
     if ($this->vars['_EventEndDate']) {
         $end = Tribe__Date_Utils::date_only($this->vars['_EventEndDate'], false, $datepicker_format);
     }
     // If we don't have a valid end date, assume today's date
     $this->vars['EventEndDate'] = isset($end) && $end ? $end : date($datepicker_format);
 }
コード例 #4
0
ファイル: API.php プロジェクト: partisan-collective/partisan
 /**
  * given a set of meta data, prepare date data if it exists
  *
  * @param $data array Associative array of event meta data
  *
  * @return array
  */
 protected static function prepare_event_date_meta($event_id, $data)
 {
     $date_provided = false;
     if (isset($data['EventAllDay'])) {
         if (Tribe__Date_Utils::is_all_day($data['EventAllDay'])) {
             $data['EventAllDay'] = 'yes';
         } else {
             $data['EventAllDay'] = 'no';
         }
     }
     $datepicker_format = Tribe__Date_Utils::datepicker_formats(tribe_get_option('datepickerFormat'));
     if (isset($data['EventStartDate'])) {
         $data['EventStartDate'] = Tribe__Date_Utils::datetime_from_format($datepicker_format, $data['EventStartDate']);
     }
     if (isset($data['EventEndDate'])) {
         $data['EventEndDate'] = Tribe__Date_Utils::datetime_from_format($datepicker_format, $data['EventEndDate']);
     }
     if (isset($data['EventAllDay']) && 'yes' === $data['EventAllDay']) {
         $date_provided = true;
         $data['EventStartDate'] = tribe_beginning_of_day($data['EventStartDate']);
         $data['EventEndDate'] = tribe_end_of_day($data['EventEndDate']);
     } elseif (isset($data['EventStartDate']) && isset($data['EventEndDate'])) {
         $date_provided = true;
         delete_post_meta($event_id, '_EventAllDay');
         $start_date_string = "{$data['EventStartDate']} {$data['EventStartHour']}:{$data['EventStartMinute']}:00";
         $end_date_string = "{$data['EventEndDate']} {$data['EventEndHour']}:{$data['EventEndMinute']}:00";
         if (isset($data['EventStartMeridian'])) {
             $start_date_string .= " {$data['EventStartMeridian']}";
         }
         if (isset($data['EventEndMeridian'])) {
             $end_date_string .= " {$data['EventEndMeridian']}";
         }
         $data['EventStartDate'] = date(Tribe__Date_Utils::DBDATETIMEFORMAT, strtotime($start_date_string));
         $data['EventEndDate'] = date(Tribe__Date_Utils::DBDATETIMEFORMAT, strtotime($end_date_string));
     }
     if (!$date_provided) {
         $data['EventStartDate'] = get_post_meta($event_id, '_EventStartDate', true);
         $data['EventEndDate'] = get_post_meta($event_id, '_EventEndDate', true);
         return $data;
     }
     // If a specific timezone was not specified, default to the sitewide timezone
     if (!isset($data['EventTimezone'])) {
         $data['EventTimezone'] = Tribe__Events__Timezones::wp_timezone_string();
     }
     // Additionally store datetimes in UTC
     if (empty($data['EventStartDateUTC'])) {
         $data['EventStartDateUTC'] = Tribe__Events__Timezones::to_utc($data['EventStartDate'], $data['EventTimezone']);
     }
     if (empty($data['EventEndDateUTC'])) {
         $data['EventEndDateUTC'] = Tribe__Events__Timezones::to_utc($data['EventEndDate'], $data['EventTimezone']);
     }
     if (empty($data['EventTimezoneAbbr'])) {
         $data['EventTimezoneAbbr'] = Tribe__Events__Timezones::abbr($data['EventStartDate'], $data['EventTimezone']);
     }
     // sanity check that start date < end date
     $start_timestamp = strtotime($data['EventStartDate']);
     $end_timestamp = strtotime($data['EventEndDate']);
     if ($start_timestamp > $end_timestamp) {
         $data['EventEndDate'] = $data['EventStartDate'];
     }
     $data['EventDuration'] = strtotime($data['EventEndDate']) - $start_timestamp;
     return $data;
 }
コード例 #5
0
 public function datepicker_formats($translate = null)
 {
     return Tribe__Date_Utils::datepicker_formats($translate);
 }