本文整理汇总了PHP中em_get_event函数的典型用法代码示例。如果您正苦于以下问题:PHP em_get_event函数的具体用法?PHP em_get_event怎么用?PHP em_get_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了em_get_event函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_form
/**
* @param EM_Booking $EM_Booking
*/
function get_form($EM_Event = false, $custom_form_id = false)
{
//special lookup for multiple bookings
if (is_object($custom_form_id) && get_class($custom_form_id) == 'EM_Multiple_Booking') {
$custom_form_id = get_option('dbem_multiple_bookings_form');
}
//make sure we don't need to get another form rather than the one already stored in this object
$reload = is_numeric($EM_Event) && $EM_Event != self::$event_id || !empty($EM_Event->event_id) && $EM_Event->event_id != self::$event_id || empty($EM_Event) && $custom_form_id && $custom_form_id != self::$form_id;
//get the right form
if (empty(self::$form) || $reload) {
global $wpdb;
if (is_numeric($EM_Event)) {
$EM_Event = em_get_event($EM_Event);
}
$custom_form_id = !empty($EM_Event->post_id) ? get_post_meta($EM_Event->post_id, '_custom_booking_form', true) : $custom_form_id;
$form_id = !empty($custom_form_id) && is_numeric($custom_form_id) ? $custom_form_id : get_option('em_booking_form_fields');
$sql = $wpdb->prepare("SELECT meta_id, meta_value FROM " . EM_META_TABLE . " WHERE meta_key = 'booking-form' AND meta_id=%d", $form_id);
$form_data_row = $wpdb->get_row($sql, ARRAY_A);
if (empty($form_data_row)) {
$form_data = self::$form_template;
self::$form_name = __('Default', 'em-pro');
} else {
$form_data = unserialize($form_data_row['meta_value']);
self::$form_id = $form_data_row['meta_id'];
self::$form_name = $form_data['name'];
}
self::$event_id = !empty($EM_Event) ? $EM_Event->event_id : false;
self::$form = new EM_Form($form_data['form'], 'em_bookings_form');
self::$form->form_required_error = get_option('em_booking_form_error_required');
}
return self::$form;
}
开发者ID:shieldsdesignstudio,项目名称:trilogic,代码行数:35,代码来源:bookings-form.php
示例2: redirection
/**
* will redirect old links to new link structures.
*/
public static function redirection()
{
global $wpdb, $wp_query;
if (is_object($wp_query) && $wp_query->get('em_redirect')) {
//is this a querystring url?
if ($wp_query->get('event_slug')) {
$event = $wpdb->get_row('SELECT event_id, post_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='" . $wp_query->get('event_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
if (!empty($event)) {
$EM_Event = em_get_event($event['event_id']);
$url = get_permalink($EM_Event->post_id);
}
} elseif ($wp_query->get('location_slug')) {
$location = $wpdb->get_row('SELECT location_id, post_id FROM ' . EM_LOCATIONS_TABLE . " WHERE location_slug='" . $wp_query->get('location_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
if (!empty($location)) {
$EM_Location = em_get_location($location['location_id']);
$url = get_permalink($EM_Location->post_id);
}
} elseif ($wp_query->get('category_slug')) {
$url = get_term_link($wp_query->get('category_slug'), EM_TAXONOMY_CATEGORY);
}
if (!empty($url)) {
wp_redirect($url, 301);
exit;
}
}
}
开发者ID:pcco,项目名称:portal-redesign,代码行数:29,代码来源:em-permalinks.php
示例3: em_get_event_shortcode
/**
* Shows a list of events according to given specifications. Accepts any event query attribute.
* @param array $atts
* @return string
*/
function em_get_event_shortcode($atts, $format = '')
{
global $EM_Event, $post;
$the_event = is_object($EM_Event) ? clone $EM_Event : null;
//save global temporarily
$atts = (array) $atts;
$atts['format'] = $format != '' || empty($atts['format']) ? $format : $atts['format'];
$atts['format'] = html_entity_decode($atts['format']);
//shorcode doesn't accept html
if (!empty($atts['event']) && is_numeric($atts['event'])) {
$EM_Event = em_get_event($atts['event']);
$return = !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
} elseif (!empty($atts['post_id']) && is_numeric($atts['post_id'])) {
$EM_Event = em_get_event($atts['post_id'], 'post_id');
$return = !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
}
//no specific event or post id supplied, check globals
if (!empty($EM_Event)) {
$return = !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
} elseif ($post->post_type == EM_POST_TYPE_EVENT) {
$EM_Event = em_get_event($post->ID, 'post_id');
$return = !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
}
$EM_Event = is_object($the_event) ? $the_event : $EM_Event;
//reset global
return $return;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:32,代码来源:em-shortcode.php
示例4: em_bp_events_format_activity_action_events
/**
* Not yet used fully - formats event-related actions
* @param string $action
* @param object $activity
* @return string
*/
function em_bp_events_format_activity_action_events($action, $activity)
{
return '';
$member_link = bp_core_get_userlink($activity->user_id);
$EM_Event = em_get_event($activity->item_id);
$action = sprintf(__('%s added the event %s', 'dbem'), $member_link, $EM_Event->output('#_EVENTLINK'));
return apply_filters('bp_events_format_activity_action_events', $action, $activity);
}
开发者ID:sajjadalisiddiqui,项目名称:cms,代码行数:14,代码来源:bp-em-activity.php
示例5: em_ml_admin_original_event_link
public static function em_ml_admin_original_event_link($link)
{
global $EM_Event;
if (empty($EM_Event->event_id) && !empty($_REQUEST['trid'])) {
$post_id = SitePress::get_original_element_id_by_trid($_REQUEST['trid']);
$original_event_link = em_get_event($post_id, 'post_id')->get_edit_url();
}
return $link;
}
开发者ID:sajjadalisiddiqui,项目名称:cms,代码行数:9,代码来源:em-wpml-admin.php
示例6: the_category
function the_category($thelist, $separator = '', $parents = '')
{
global $post, $wp_rewrite;
if ($post->post_type == EM_POST_TYPE_EVENT) {
$EM_Event = em_get_event($post);
$categories = $EM_Event->get_categories();
if (empty($categories)) {
return '';
}
/* Copied from get_the_category_list function, with a few minor edits to make urls work, and removing parent stuff (for now) */
$rel = is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ? 'rel="category tag"' : 'rel="category"';
$thelist = '';
if ('' == $separator) {
$thelist .= '<ul class="post-categories">';
foreach ($categories as $category) {
$thelist .= "\n\t<li>";
switch (strtolower($parents)) {
case 'multiple':
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '" ' . $rel . '>' . $category->name . '</a></li>';
break;
case 'single':
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '" ' . $rel . '>';
$thelist .= $category->name . '</a></li>';
break;
case '':
default:
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '" ' . $rel . '>' . $category->name . '</a></li>';
}
}
$thelist .= '</ul>';
} else {
$i = 0;
foreach ($categories as $category) {
if (0 < $i) {
$thelist .= $separator;
}
switch (strtolower($parents)) {
case 'multiple':
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '" ' . $rel . '>' . $category->name . '</a>';
break;
case 'single':
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '" ' . $rel . '>';
$thelist .= "{$category->name}</a>";
break;
case '':
default:
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '" ' . $rel . '>' . $category->name . '</a>';
}
++$i;
}
}
/* End copying */
}
return $thelist;
}
开发者ID:rajankz,项目名称:webspace,代码行数:55,代码来源:em-event-post.php
示例7: em_get_event_shortcode
/**
* Shows a list of events according to given specifications. Accepts any event query attribute.
* @param array $atts
* @return string
*/
function em_get_event_shortcode($atts, $format = '')
{
$atts = (array) $atts;
$atts['format'] = $format != '' || empty($atts['format']) ? $format : $atts['format'];
$atts['format'] = html_entity_decode($atts['format']);
//shorcode doesn't accept html
if (!empty($atts['event']) && is_numeric($atts['event'])) {
$EM_Event = em_get_event($atts['event']);
return !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
} elseif (!empty($atts['post_id']) && is_numeric($atts['post_id'])) {
$EM_Event = em_get_event($atts['post_id'], 'post_id');
return !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
}
}
开发者ID:rajankz,项目名称:webspace,代码行数:19,代码来源:em-shortcode.php
示例8: em_ical_event
function em_ical_event()
{
global $wpdb;
//add endpoints to events
if (get_query_var(EM_POST_TYPE_EVENT) && get_query_var('ical')) {
$event_id = $wpdb->get_var('SELECT event_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='" . get_query_var(EM_POST_TYPE_EVENT) . "' AND event_status=1 LIMIT 1");
if (!empty($event_id)) {
global $EM_Event;
$EM_Event = em_get_event($event_id);
ob_start();
em_locate_template('templates/ical-event.php', true);
echo preg_replace("/([^\r])\n/", "\$1\r\n", ob_get_clean());
exit;
}
}
}
开发者ID:rajankz,项目名称:webspace,代码行数:16,代码来源:em-ical.php
示例9: em_ical_event
/**
* Generates an ics file for a single event
*/
function em_ical_event()
{
global $wpdb, $wp_query;
//add endpoints to events
if (!empty($wp_query) && $wp_query->get(EM_POST_TYPE_EVENT) && $wp_query->get('ical')) {
$event_id = $wpdb->get_var('SELECT event_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='" . $wp_query->get(EM_POST_TYPE_EVENT) . "' AND event_status=1 LIMIT 1");
if (!empty($event_id)) {
global $EM_Event;
$EM_Event = em_get_event($event_id);
//send headers
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename="' . $EM_Event->event_slug . '.ics"');
em_locate_template('templates/ical.php', true);
exit;
}
}
}
开发者ID:batruji,项目名称:metareading,代码行数:20,代码来源:em-ical.php
示例10: remove_booking
function remove_booking($event_id)
{
if (!empty($this->bookings[$event_id])) {
$EM_Event = em_get_event($event_id);
//remove ticket booking records belonging to this event
foreach ($EM_Event->get_tickets() as $EM_Ticket) {
/* @var $EM_Ticket EM_Ticket */
if (!empty($this->get_tickets_bookings()->tickets_bookings[$EM_Ticket->ticket_id])) {
unset($this->get_tickets_bookings()->tickets_bookings[$EM_Ticket->ticket_id]);
}
}
//remove event from bookings array
unset($this->bookings[$_REQUEST['event_id']]);
//refresh price and spaces
$this->calculate_price();
$this->get_spaces(true);
return true;
}
return false;
}
开发者ID:shieldsdesignstudio,项目名称:trilogic,代码行数:20,代码来源:multiple-booking.php
示例11: em_get_event_shortcode
/**
* Shows a list of events according to given specifications. Accepts any event query attribute.
* @param array $atts
* @return string
*/
function em_get_event_shortcode($atts, $format = '')
{
$atts = (array) $atts;
$atts['format'] = $format != '' || empty($atts['format']) ? $format : $atts['format'];
$atts['format'] = html_entity_decode($atts['format']);
//shorcode doesn't accept html
if (!empty($atts['event']) && is_numeric($atts['event'])) {
$EM_Event = em_get_event($atts['event']);
return !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
} elseif (!empty($atts['post_id']) && is_numeric($atts['post_id'])) {
$EM_Event = em_get_event($atts['post_id'], 'post_id');
return !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
}
//no specific event or post id supplied, check globals
global $EM_Event, $post;
if (!empty($EM_Event)) {
return !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
} elseif ($post->post_type == EM_POST_TYPE_EVENT) {
$EM_Event = em_get_event($post->ID, 'post_id');
return !empty($atts['format']) ? $EM_Event->output($atts['format']) : $EM_Event->output_single();
}
}
开发者ID:hscale,项目名称:webento,代码行数:27,代码来源:em-shortcode.php
示例12: columns_output
function columns_output($column)
{
global $post, $EM_Event;
if ($post->post_type == 'event-recurring') {
$post = $EM_Event = em_get_event($post);
/* @var $post EM_Event */
switch ($column) {
case 'event-id':
echo $EM_Event->event_id;
break;
case 'location':
//get meta value to see if post has location, otherwise
$EM_Location = $EM_Event->get_location();
if (!empty($EM_Location->location_id)) {
echo "<strong>" . $EM_Location->location_name . "</strong><br/>" . $EM_Location->location_address . " - " . $EM_Location->location_town;
} else {
echo __('None', 'dbem');
}
break;
case 'date-time':
echo $EM_Event->get_recurrence_description();
break;
}
}
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:25,代码来源:em-event-posts-admin.php
示例13: get
/**
* Returns an array of EM_Events that match the given specs in the argument, or returns a list of future evetnts in future
* (see EM_Events::get_default_search() ) for explanation of possible search array values. You can also supply a numeric array
* containing the ids of the events you'd like to obtain
*
* @param array $args
* @return EM_Event array()
*/
public static function get($args = array(), $count = false)
{
global $wpdb;
$events_table = EM_EVENTS_TABLE;
$locations_table = EM_LOCATIONS_TABLE;
//Quick version, we can accept an array of IDs, which is easy to retrieve
if (self::array_is_numeric($args)) {
//Array of numbers, assume they are event IDs to retreive
//We can just get all the events here and return them
$sql = "\r\n\t\t\t\tSELECT * FROM {$events_table}\r\n\t\t\t\tLEFT JOIN {$locations_table} ON {$locations_table}.location_id={$events_table}.location_id\r\n\t\t\t\tWHERE event_id=" . implode(" OR event_id=", $args) . "\r\n\t\t\t";
$results = $wpdb->get_results(apply_filters('em_events_get_sql', $sql), ARRAY_A);
$events = array();
foreach ($results as $result) {
$events[$result['event_id']] = new EM_Event($result);
}
return $events;
//We return all the events matched as an EM_Event array.
}
//We assume it's either an empty array or array of search arguments to merge with defaults
$args = self::get_default_search($args);
$limit = $args['limit'] && is_numeric($args['limit']) ? "LIMIT {$args['limit']}" : '';
$offset = $limit != "" && is_numeric($args['offset']) ? "OFFSET {$args['offset']}" : '';
$groupby_sql = '';
//Get the default conditions
$conditions = self::build_sql_conditions($args);
//Put it all together
$where = count($conditions) > 0 ? " WHERE " . implode(" AND ", $conditions) : '';
//Get ordering instructions
$EM_Event = new EM_Event();
$EM_Location = new EM_Location();
$orderby = self::build_sql_orderby($args, array_keys(array_merge($EM_Event->fields, $EM_Location->fields)), get_option('dbem_events_default_order'));
//Now, build orderby sql
$orderby_sql = count($orderby) > 0 ? 'ORDER BY ' . implode(', ', $orderby) : '';
//Create the SQL statement and execute
if (!$count && $args['array']) {
$selectors_array = array();
foreach (array_keys($EM_Event->fields) as $field_selector) {
$selectors_array[] = $events_table . '.' . $field_selector;
}
$selectors = implode(',', $selectors_array);
} elseif (EM_MS_GLOBAL) {
$selectors = $events_table . '.post_id, ' . $events_table . '.blog_id';
$groupby_sql[] = $events_table . '.post_id, ' . $events_table . '.blog_id';
} else {
$selectors = $events_table . '.post_id';
$groupby_sql[] = $events_table . '.post_id';
//prevent duplicates showing in lists
}
if ($count) {
$selectors = 'SQL_CALC_FOUND_ROWS *';
$limit = 'LIMIT 1';
$offset = 'OFFSET 0';
}
//add group_by if needed
$groupby_sql = !empty($groupby_sql) && is_array($groupby_sql) ? 'GROUP BY ' . implode(',', $groupby_sql) : '';
$sql = apply_filters('em_events_get_sql', "\r\n\t\t\tSELECT {$selectors} FROM {$events_table}\r\n\t\t\tLEFT JOIN {$locations_table} ON {$locations_table}.location_id={$events_table}.location_id\r\n\t\t\t{$where}\r\n\t\t\t{$groupby_sql} {$orderby_sql}\r\n\t\t\t{$limit} {$offset}\r\n\t\t", $args);
//If we're only counting results, return the number of results
if ($count) {
$wpdb->query($sql);
return apply_filters('em_events_get_count', $wpdb->get_var('SELECT FOUND_ROWS()'), $args);
}
$results = $wpdb->get_results($sql, ARRAY_A);
//If we want results directly in an array, why not have a shortcut here?
if ($args['array'] == true) {
return apply_filters('em_events_get_array', $results, $args);
}
//Make returned results EM_Event objects
$results = is_array($results) ? $results : array();
$events = array();
if (EM_MS_GLOBAL) {
foreach ($results as $event) {
$events[] = em_get_event($event['post_id'], $event['blog_id']);
}
} else {
foreach ($results as $event) {
$events[] = em_get_event($event['post_id'], 'post_id');
}
}
return apply_filters('em_events_get', $events, $args);
}
开发者ID:mpaskew,项目名称:isc-dev,代码行数:88,代码来源:em-events.php
示例14: meta_boxes
public static function meta_boxes()
{
global $EM_Event, $post;
//no need to proceed if we're not dealing with a recurring event
if ($post->post_type != 'event-recurring') {
return;
}
//since this is the first point when the admin area loads event stuff, we load our EM_Event here
if (empty($EM_Event) && !empty($post)) {
$EM_Event = em_get_event($post->ID, 'post_id');
}
add_meta_box('em-event-recurring', __('Recurrences', 'events-manager'), array('EM_Event_Recurring_Post_Admin', 'meta_box_recurrence'), 'event-recurring', 'normal', 'high');
//add_meta_box('em-event-meta', 'Event Meta (debugging only)', array('EM_Event_Post_Admin','meta_box_metadump'),'event-recurring', 'normal','high');
add_meta_box('em-event-where', __('Where', 'events-manager'), array('EM_Event_Post_Admin', 'meta_box_location'), 'event-recurring', 'normal', 'high');
if (get_option('dbem_rsvp_enabled') && $EM_Event->can_manage('manage_bookings', 'manage_others_bookings')) {
add_meta_box('em-event-bookings', __('Bookings/Registration', 'events-manager'), array('EM_Event_Post_Admin', 'meta_box_bookings'), 'event-recurring', 'normal', 'high');
}
if (get_option('dbem_attributes_enabled')) {
add_meta_box('em-event-attributes', __('Attributes', 'events-manager'), array('EM_Event_Post_Admin', 'meta_box_attributes'), 'event-recurring', 'normal', 'default');
}
if (EM_MS_GLOBAL && !is_main_site() && get_option('dbem_categories_enabled')) {
add_meta_box('em-event-categories', __('Site Categories', 'events-manager'), array('EM_Event_Post_Admin', 'meta_box_ms_categories'), 'event-recurring', 'side', 'low');
}
if (defined('WP_DEBUG') && WP_DEBUG && defined('WP_DEBUG_DISPLAY') && WP_DEBUG_DISPLAY) {
add_meta_box('em-event-meta', 'Event Meta (debugging only)', array('EM_Event_Post_Admin', 'meta_box_metadump'), 'event-recurring', 'normal', 'high');
}
}
开发者ID:mjrobison,项目名称:FirstCareCPR,代码行数:27,代码来源:em-event-post-admin.php
示例15: get_event
/**
* Gets the event for this object, or a blank event if none exists
* @return EM_Event
*/
function get_event()
{
if (is_numeric($this->event_id)) {
return em_get_event($this->event_id);
} else {
return new EM_Event();
}
}
开发者ID:mpaskew,项目名称:isc-dev,代码行数:12,代码来源:em-categories.php
示例16: get_event
/**
* Smart event locator, saves a database read if possible. Note that if an event doesn't exist, a blank object will be created to prevent duplicates.
*/
function get_event()
{
global $EM_Event;
if (is_object($EM_Event) && $EM_Event->event_id == $this->event_id) {
return $EM_Event;
} else {
if (is_numeric($this->event_id) && $this->event_id > 0) {
return em_get_event($this->event_id, 'event_id');
} elseif (count($this->bookings) > 0) {
foreach ($this->bookings as $EM_Booking) {
/* @var $EM_Booking EM_Booking */
return em_get_event($EM_Booking->event_id, 'event_id');
}
}
}
return em_get_event($this->event_id, 'event_id');
}
开发者ID:Olaf1989,项目名称:Cakes-and-more,代码行数:20,代码来源:em-bookings.php
示例17: while
<section id="eventlist" class="wrap wrap--content wrap--shadow">
<h3 class="title title--section">Eventos</h3>
<h3 class="sep">Listado de eventos</h3>
<?php
if (have_posts()) {
?>
<ul class="list">
<?php
while (have_posts()) {
the_post();
$EM_Event = em_get_event($post->ID, 'post_id');
$event_start_date = new DateTime($EM_Event->event_start_date . ' ' . $EM_Event->event_start_time);
$event_end_date = new DateTime($EM_Event->event_end_date . ' ' . $EM_Event->event_end_time);
?>
<!-- content -->
<li class="item wrap wrap--frame wrap--flex">
<div class="wrap wrap--frame__middle">
<a href="<?php
the_permalink();
?>
"><?php
the_title();
?>
</a>
</div>
<div class="wrap wrap--frame__fourth">
<span class="js-date">
<?php
开发者ID:Saigesp,项目名称:wp-design-community,代码行数:31,代码来源:listing-events.php
示例18: em_map_meta_cap
function em_map_meta_cap($caps, $cap, $user_id, $args)
{
/* Handle event reads */
if ('edit_event' == $cap || 'delete_event' == $cap || 'read_event' == $cap) {
$EM_Event = em_get_event($args[0], 'post_id');
$post_type = get_post_type_object($EM_Event->post_type);
/* Set an empty array for the caps. */
$caps = array();
//Filter according to event caps
switch ($cap) {
case 'read_event':
if ('private' != $EM_Event->post_status) {
$caps[] = 'read';
} elseif ($user_id == $EM_Event->event_owner) {
$caps[] = 'read';
} else {
$caps[] = $post_type->cap->read_private_posts;
}
break;
case 'edit_event':
if ($user_id == $EM_Event->event_owner) {
$caps[] = $post_type->cap->edit_posts;
} else {
$caps[] = $post_type->cap->edit_others_posts;
}
break;
case 'delete_event':
if ($user_id == $EM_Event->event_owner) {
$caps[] = $post_type->cap->delete_posts;
} else {
$caps[] = $post_type->cap->delete_others_posts;
}
break;
}
}
if ('edit_recurring_event' == $cap || 'delete_recurring_event' == $cap || 'read_recurring_event' == $cap) {
$EM_Event = em_get_event($args[0], 'post_id');
$post_type = get_post_type_object($EM_Event->post_type);
/* Set an empty array for the caps. */
$caps = array();
//Filter according to recurring_event caps
switch ($cap) {
case 'read_recurring_event':
if ('private' != $EM_Event->post_status) {
$caps[] = 'read';
} elseif ($user_id == $EM_Event->event_owner) {
$caps[] = 'read';
} else {
$caps[] = $post_type->cap->read_private_posts;
}
break;
case 'edit_recurring_event':
if ($user_id == $EM_Event->event_owner) {
$caps[] = $post_type->cap->edit_posts;
} else {
$caps[] = $post_type->cap->edit_others_posts;
}
break;
case 'delete_recurring_event':
if ($user_id == $EM_Event->event_owner) {
$caps[] = $post_type->cap->delete_posts;
} else {
$caps[] = $post_type->cap->delete_others_posts;
}
break;
}
}
if ('edit_location' == $cap || 'delete_location' == $cap || 'read_location' == $cap) {
$EM_Location = em_get_location($args[0], 'post_id');
$post_type = get_post_type_object($EM_Location->post_type);
/* Set an empty array for the caps. */
$caps = array();
//Filter according to location caps
switch ($cap) {
case 'read_location':
if ('private' != $EM_Location->post_status) {
$caps[] = 'read';
} elseif ($user_id == $EM_Location->location_owner) {
$caps[] = 'read';
} else {
$caps[] = $post_type->cap->read_private_posts;
}
break;
case 'edit_location':
if ($user_id == $EM_Location->location_owner) {
$caps[] = $post_type->cap->edit_posts;
} else {
$caps[] = $post_type->cap->edit_others_posts;
}
break;
case 'delete_location':
if ($user_id == $EM_Location->location_owner) {
$caps[] = $post_type->cap->delete_posts;
} else {
$caps[] = $post_type->cap->delete_others_posts;
}
break;
}
}
/* Return the capabilities required by the user. */
//.........这里部分代码省略.........
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:em-posts.php
示例19: em_migrate_uploads
function em_migrate_uploads()
{
//build array of images
global $wpdb;
$mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
require_once ABSPATH . "wp-admin" . '/includes/file.php';
require_once ABSPATH . "wp-admin" . '/includes/image.php';
$pattern = EM_IMAGE_DS == '/' ? EM_IMAGE_UPLOAD_DIR . '*/*' : EM_IMAGE_UPLOAD_DIR . '*';
$files = glob($pattern);
$file_array = array();
foreach ($files as $file) {
$matches = array();
if (preg_match('/\\/(events|locations\\/)?(event|location)-([0-9]+).([a-zA-Z]{3})/', $file, $matches)) {
$file_array[$matches[2]][$matches[3]] = array('file' => $file, 'url' => EM_IMAGE_UPLOAD_URI . $matches[1] . $matches[2] . '-' . $matches[3] . '.' . $matches[4], 'type' => 'image/' . $matches[4]);
}
}
$result = array('success' => 0, 'fail' => 0);
if (count($file_array) > 0) {
foreach ($file_array as $type => $file_type) {
foreach ($file_type as $id => $attachment) {
if ($type == 'event') {
$post = em_get_event($id);
} elseif ($type == 'location') {
$post = em_get_location($id);
}
if (!empty($post->ID)) {
$attachment_data = array('post_mime_type' => $attachment['type'], 'post_title' => $post->post_title, 'post_content' => '', 'post_status' => 'inherit');
$attachment_id = wp_insert_attachment($attachment_data, $attachment['file'], $post->ID);
$attachment_metadata = wp_generate_attachment_metadata($attachment_id, $attachment['file']);
wp_update_attachment_metadata($attachment_id, $attachment_metadata);
//delete the old attachment
update_post_meta($post->post_id, '_thumbnail_id', $attachment_id);
//is it recurring? If so add attachment to recurrences
if ($type == 'event' && $post->is_recurring()) {
$results = $wpdb->get_col('SELECT post_id FROM ' . EM_EVENTS_TABLE . ' WHERE recurrence_id=' . $post->event_id);
foreach ($results as $post_id) {
update_post_meta($post_id, '_thumbnail_id', $attachment_id);
}
}
$result['success']++;
}
}
}
}
delete_option('dbem_migrate_images_nag');
delete_option('dbem_migrate_images');
return $result;
}
开发者ID:sajjadalisiddiqui,项目名称:cms,代码行数:48,代码来源:em-install.php
示例20: widget
public function widget($args, $instance)
{
$title = apply_filters('widget_title', $instance['title']);
if (function_exists('icl_translate')) {
$form_intro = empty($instance['form_intro']) ? ' ' : icl_translate('wpml_custom', 'wpml_custom_' . sanitize_title(substr($instance['form_intro'], 0, 10)), $instance['form_intro']);
$btn_info = empty($instance['btn_info']) ? ' ' : icl_translate('wpml_custom', 'wpml_custom_' . sanitize_title(substr($instance['btn_info'], 0, 10)), $instance['btn_info']);
$btn_transport = empty($instance['btn_transport']) ? ' ' : icl_translate('wpml_custom', 'wpml_custom_' . sanitize_title(substr($instance['btn_transport'], 0, 10)), $instance['btn_transport']);
$btn_pay = empty($instance['btn_pay']) ? ' ' : icl_translate('wpml_custom', 'wpml_custom_' . sanitize_title(substr($instance['btn_pay'], 0, 10)), $instance['btn_pay']);
$btn_book = empty($instance['btn_book']) ? ' ' : icl_translate('wpml_custom', 'wpml_custom_' . sanitize_title(substr($instance['btn_book'], 0, 10)), $instance['btn_book']);
$btn_stay = empty($instance['btn_stay']) ? ' ' : icl_translate('wpml_custom', 'wpml_custom_' . sanitize_title(substr($instance['btn_stay'], 0, 10)), $instance['btn_stay']);
$btn_cancel = empty($instance['btn_cancel']) ? ' ' : icl_translate('wpml_custom', 'wpml_custom_' . sanitize_title(substr($instance['btn_cancel'], 0, 10)), $instance['btn_cancel']);
} else {
$form_intro = empty($instance['form_intro']) ? ' ' : apply_filters('widget_text', $instance['form_intro']);
$btn_info = empty($instance['btn_info']) ? ' ' : apply_filters('widget_text', $instance['btn_info']);
$btn_transport = empty($instance['btn_transport']) ? ' ' : apply_filters('widget_text', $instance['btn_transport']);
$btn_pay = empty($instance['btn_pay']) ? ' ' : apply_filters('widget_text', $instance['btn_pay']);
$btn_book = empty($instance['btn_book']) ? ' ' : apply_filters('widget_text', $instance['btn_book']);
$btn_stay = empty($instance['btn_stay']) ? ' ' : apply_filters('widget_text', $instance['btn_stay']);
$btn_cancel = empty($instance['btn_cancel']) ? ' ' : apply_filters('widget_text', $instance['btn_cancel']);
}
$btn_info_link = apply_filters('widget_text', $instance['btn_info_link']);
$btn_transport_link = apply_filters('widget_text', $instance['btn_transport_link']);
$btn_pay_link = apply_filters('widget_text', $instance['btn_pay_link']);
$btn_book_link = apply_filters('widget_text', $instance['btn_book_link']);
$btn_stay_link = apply_filters('widget_text', $instance['btn_stay_link']);
$btn_cancel_link = apply_filters('widget_text', $instance['btn_cancel_link']);
// get events-manager plugin data on single event posts
if (is_singular('event')) {
$EM_Event = em_get_event(get_queried_object_id(), 'post_id');
$event_data = $EM_Event->output('#d/#m/#Y - #_EVENTNAME');
}
echo $args['before_widget'];
if (!empty($title)) {
echo $args['before_title'] . $title . $args['after_title'];
}
echo '<div class="btn-container">';
if ($form_intro) {
echo '<p>' . $form_intro . '</p>';
}
if ($btn_info_link) {
if (is_singular('event')) {
echo ' <a class="btn btn-form btn-default" href="' . $btn_info_link . '?event_id=' . $event_data . '" title="Link to ' . $btn_info_link . '"><i class="fa fa-info fa-fw"></i> ' . $btn_info . '</a> ';
} else {
echo ' <a class="btn btn-form btn-default" href="' . $btn_info_link . '" title="Link to ' . $btn_info_link . '"><i class="fa fa-info fa-fw"></i> ' . $btn_info . '</a> ';
}
}
if ($btn_book_link) {
if (is_singular('event')) {
echo ' <a class="btn btn-form btn-default" href="' . $btn_book_link . '?event_id=' . $event_data . '" title="Link to ' . $btn_book_link . '"><i class="fa fa-heart fa-fw"></i> ' . $btn_book . '</a> ';
} else {
echo ' <a class="btn btn-form btn-default" href="' . $btn_book_link . '" title="Link to ' . $btn_book_link . '"><i class="fa fa-heart fa-fw"></i> ' . $btn_book . '</a> ';
}
}
if ($btn_stay_link) {
echo ' <a class="btn btn-form btn-default" href="' . $btn_stay_link . '" title="Link to ' . $btn_stay_link . '"><i class="fa fa-star fa-fw"></i> ' . $btn_stay . '</a> ';
}
if ($btn_transport_link) {
echo ' <a class="btn btn-form btn-default" href="' . $btn_transport_link . '" title="Link to ' . $btn_transport_link . '"><i class="fa fa-automobile fa-fw"></i> ' . $btn_transport . '</a> ';
}
if ($btn_pay_link) {
echo ' <a class="btn btn-form btn-default" href="' . $btn_pay_link . '" title="Link to ' . $btn_pay_link . '"><i class="fa fa-upload fa-fw"></i> ' . $btn_pay . '</a> ';
}
if ($btn_cancel_link) {
echo ' <a class="btn btn-form btn-default" href="' . $btn_cancel_link . '" title="Link to ' . $btn_cancel_link . '"><i class="fa fa-close fa-fw"></i> ' . $btn_cancel . '</a> ';
}
echo '</div
|
请发表评论