本文整理汇总了PHP中EM_Event::get_categories方法的典型用法代码示例。如果您正苦于以下问题:PHP EM_Event::get_categories方法的具体用法?PHP EM_Event::get_categories怎么用?PHP EM_Event::get_categories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EM_Event
的用法示例。
在下文中一共展示了EM_Event::get_categories方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importEventsCSV
//.........这里部分代码省略.........
if (!$location) {
// must create a new location object
$location = new EM_Location();
$location->location_name = empty($data['location_name']) ? self::fudgeLocationName($data) : $data['location_name'];
$location->location_address = empty($data['location_address']) ? $data['location_name'] : $data['location_address'];
$location->location_town = $data['location_town'];
$location->location_state = $data['location_state'];
$location->location_postcode = $data['location_postcode'];
$location->location_country = $data['location_country'];
$location->location_region = $data['location_region'];
$location->location_latitude = $data['location_latitude'];
$location->location_longitude = $data['location_longitude'];
self::maybeSetCoordinates($location);
$location->save();
}
}
// try to find existing event with matching unique ID first, so can update it
$event = false;
if ($data['uid']) {
add_filter('em_events_get_default_search', array(__CLASS__, 'filterEventArgs'), 10, 2);
add_filter('em_events_build_sql_conditions', array(__CLASS__, 'filterEventSQL'), 10, 2);
$event = EM_Events::get(array('em_impexp_uid' => $data['uid']));
$event = count($event) > 0 ? $event[0] : false;
remove_filter('em_events_get_default_search', array(__CLASS__, 'filterEventArgs'), 10, 2);
remove_filter('em_events_build_sql_conditions', array(__CLASS__, 'filterEventSQL'), 10, 2);
}
if (!$event) {
// must create a new event
$event = new EM_Event();
}
$event->location_id = $location ? $location->location_id : 0;
$event->event_attributes['em_impexp_uid'] = $data['uid'];
$event->event_attributes['em_impexp_url'] = $data['url'];
$event->event_name = $data['summary'];
$event->post_content = $data['post_content'];
$event->post_excerpt = $data['post_excerpt'];
if (preg_match('@^\\d\\d/\\d\\d/\\d\\d\\d\\d$@', $data['dtstart'])) {
$data['dtstart'] .= ' 00:00:00';
$event->start = date_create_from_format('d/m/Y H:i:s', $data['dtstart'])->getTimestamp();
$event->event_start_date = date('Y-m-d', $event->start);
$event->event_start_time = date('H:i:s', $event->start);
}
if (preg_match('@^\\d\\d/\\d\\d/\\d\\d\\d\\d$@', $data['dtend'])) {
$data['dtend'] .= ' 00:00:00';
$event->end = date_create_from_format('d/m/Y H:i:s', $data['dtend'])->getTimestamp();
$event->event_end_date = date('Y-m-d', $event->end);
$event->event_end_time = date('H:i:s', $event->end);
} else {
$event->end = $event->start;
$event->event_end_date = $event->event_start_date;
$event->event_end_time = $event->event_start_time;
}
$event->event_date_modified = current_time('mysql');
$event->event_all_day = $event->event_start_time === '00:00:00' && $event->event_end_time === '00:00:00' ? 1 : 0;
foreach ($attrs as $attrName => $value) {
$event->event_attributes[$attrName] = $value;
}
// TODO: recurring events
switch ($data['freq']) {
case 'DAILY':
break;
case 'WEEKLY':
//~ $event->freq = $data['freq'];
//~ $event->byday = $data['byday'];
//~ $event->interval = $data['interval'];
//~ $event->until = $data['until'];
break;
case 'MONTHLY':
break;
}
if ($event) {
$event->save();
$event->save_meta();
if ($data['categories']) {
$categories = explode(',', $data['categories']);
$eventcats = $event->get_categories();
foreach ($categories as $category) {
$category = trim($category);
if (isset($eventCategories[$category])) {
$cat = $eventCategories[$category];
} else {
$cat = wp_insert_term($category, 'event-categories');
if (is_array($cat)) {
$cat = new EM_Category($cat['term_id']);
$eventCategories[$category] = $cat;
}
}
if ($cat) {
$eventcats->categories[$cat->id] = $cat;
}
}
$eventcats->save();
}
}
$records++;
}
}
$wpdb->query('commit');
$this->plugin->showMessage($records === 1 ? '1 events loaded' : "{$records} events loaded");
}