本文整理汇总了PHP中EM_Object类的典型用法代码示例。如果您正苦于以下问题:PHP EM_Object类的具体用法?PHP EM_Object怎么用?PHP EM_Object使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EM_Object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_bookings
function get_bookings($ids_only = false, $status = false)
{
global $wpdb;
$status_condition = $blog_condition = '';
if (is_multisite()) {
if (!is_main_site()) {
//not the main blog, force single blog search
$blog_condition = "AND e.blog_id=" . get_current_blog_id();
} elseif (is_main_site() && !get_option('dbem_ms_global_events')) {
$blog_condition = "AND (e.blog_id=" . get_current_blog_id() . ' OR e.blog_id IS NULL)';
}
}
if (is_numeric($status)) {
$status_condition = " AND booking_status={$status}";
} elseif (EM_Object::array_is_numeric($status)) {
$status_condition = " AND booking_status IN (" . implode(',', $status) . ")";
}
$EM_Booking = em_get_booking();
//empty booking for fields
$results = $wpdb->get_results("SELECT b." . implode(', b.', array_keys($EM_Booking->fields)) . " FROM " . EM_BOOKINGS_TABLE . " b, " . EM_EVENTS_TABLE . " e WHERE e.event_id=b.event_id AND person_id={$this->ID} {$blog_condition} {$status_condition} ORDER BY " . get_option('dbem_bookings_default_orderby', 'event_start_date') . " " . get_option('dbem_bookings_default_order', 'ASC'), ARRAY_A);
$bookings = array();
if ($ids_only) {
foreach ($results as $booking_data) {
$bookings[] = $booking_data['booking_id'];
}
return apply_filters('em_person_get_bookings', $bookings, $this);
} else {
foreach ($results as $booking_data) {
$bookings[] = em_get_booking($booking_data);
}
return apply_filters('em_person_get_bookings', new EM_Bookings($bookings), $this);
}
}
示例2: bp_em_group_event_can_manage
/**
* Overrides the default capability of the user for another owner's event if the user is a group admin and the event belongs to a group.
* User must have the relevant permissions globally in order to inherit that capability for this event as well.
* @param boolean $result
* @param EM_Event $EM_Event
*/
function bp_em_group_event_can_manage($result, $EM_Event, $owner_capability, $admin_capability, $user_to_check)
{
if (!$result && $EM_Event->event_owner != get_current_user_id() && !empty($EM_Event->group_id) && bp_is_active('groups')) {
//only override if already false, incase it's true
//if the user is an admin of this group, and actually has the relevant permissions globally, they can manage this event
$EM_Object = new EM_Object();
//create new object to prevent infinite loop should we call $EM_Event->can_manage();
if (groups_is_user_admin(get_current_user_id(), $EM_Event->group_id) && $EM_Object->can_manage($owner_capability, $admin_capability, $user_to_check)) {
//This user is an admin of the owner's group, so they can edit this event.
return true;
} else {
$EM_Event->add_error($EM_Object->get_errors());
//add any applicable errors
}
}
return $result;
}
示例3: em_admin_ms_locations
/**
* Looks at the request values, saves/updates and then displays the right menu in the admin
* @return null
*/
function em_admin_ms_locations()
{
//TODO EM_Location is globalized, use it fully here
global $EM_Location;
EM_Object::ms_global_switch();
//Take actions
if (!empty($_REQUEST['action']) && ($_REQUEST['action'] == "edit" || $_REQUEST['action'] == "location_save")) {
em_admin_location();
} else {
// no action, just a locations list
em_admin_locations();
}
EM_Object::ms_global_switch_back();
}
示例4: em_ical_item
/**
* Generates an ics file for a single event
*/
function em_ical_item()
{
global $wpdb, $wp_query, $wp_rewrite;
//check if we're outputting an ical feed
if (!empty($wp_query) && $wp_query->get('ical')) {
$execute_ical = false;
$filename = 'events';
$args = array();
//single event
if ($wp_query->get(EM_POST_TYPE_EVENT)) {
$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)) {
$filename = $wp_query->get(EM_POST_TYPE_EVENT);
$args['event'] = $event_id;
}
//single location
} elseif ($wp_query->get(EM_POST_TYPE_LOCATION)) {
$location_id = $wpdb->get_var('SELECT location_id FROM ' . EM_LOCATIONS_TABLE . " WHERE location_slug='" . $wp_query->get(EM_POST_TYPE_LOCATION) . "' AND location_status=1 LIMIT 1");
if (!empty($location_id)) {
$filename = $wp_query->get(EM_POST_TYPE_LOCATION);
$args['location'] = $location_id;
}
//taxonomies
} else {
$taxonomies = EM_Object::get_taxonomies();
foreach ($taxonomies as $tax_arg => $taxonomy_info) {
$taxonomy_term = $wp_query->get($taxonomy_info['query_var']);
if ($taxonomy_term) {
$filename = $taxonomy_term;
$args[$tax_arg] = $taxonomy_term;
}
}
}
//only output the ical if we have a match from above
if (count($args) > 0) {
//send headers and output ical
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename="' . $filename . '.ics"');
em_locate_template('templates/ical.php', true, array('args' => $args));
exit;
} else {
//no item exists, so redirect to original URL
$url_to_redirect = preg_replace("/ical\\/\$/", '', esc_url_raw(add_query_arg(array('ical' => null))));
wp_redirect($url_to_redirect, '302');
exit;
}
}
}
示例5: ajax_add_booking
function ajax_add_booking()
{
/* Check the nonce */
check_admin_referer('add_booking', '_wpnonce_add_booking');
if (!empty($_REQUEST['event_id']) && is_numeric($_REQUEST['event_id'])) {
$EM_Event = new EM_Event($_REQUEST['event_id']);
$result = $EM_Event->get_bookings()->add_from_post();
if ($result) {
$return = array('result' => true, 'message' => $EM_Event->get_bookings()->feedback_message);
} else {
$return = array('result' => false, 'message' => implode('<br />', $EM_Event->get_bookings()->errors));
}
echo EM_Object::json_encode($return);
exit;
} else {
$return = array('result' => false, 'message' => '');
echo EM_Object::json_encode($return);
exit;
}
}
示例6: get_global
/**
* Shortcode for producing a google map with all the locations. Unfinished and undocumented.
* @param array $atts
* @return string
*/
function get_global($atts)
{
//TODO Finish and document this feature, need to add balloons here
if (get_option('dbem_gmap_is_active') == '1') {
ob_start();
$atts['em_ajax'] = true;
$atts['query'] = 'GlobalMapData';
$rand = substr(md5(rand() . rand()), 0, 5);
//build js array of arguments to send to event query
?>
<div class='em-locations-map' id='em-locations-map-<?php
echo $rand;
?>
' style='width:<?php
echo $atts['width'];
?>
px; height:<?php
echo $atts['height'];
?>
px'><em><?php
_e('Loading Map....', 'dbem');
?>
</em></div>
<div class='em-locations-map-coords' id='em-locations-map-coords-<?php
echo $rand;
?>
' style="display:none; visibility:hidden;"><?php
echo EM_Object::json_encode($atts);
?>
</div>
<?php
return apply_filters('em_map_get_global', ob_get_clean());
} else {
return '';
}
}
示例7: meta_box_ms_categories
public static function meta_box_ms_categories()
{
global $EM_Event;
EM_Object::ms_global_switch();
$categories = EM_Categories::get(array('hide_empty' => false));
?>
<?php
if (count($categories) > 0) {
?>
<p class="ms-global-categories">
<?php
$selected = $EM_Event->get_categories()->get_ids();
?>
<?php
$walker = new EM_Walker_Category();
?>
<?php
$args_em = array('hide_empty' => 0, 'name' => 'event_categories[]', 'hierarchical' => true, 'id' => EM_TAXONOMY_CATEGORY, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $selected, 'walker' => $walker);
?>
<?php
echo walk_category_dropdown_tree($categories, 0, $args_em);
?>
</p>
<?php
} else {
?>
<p><?php
sprintf(__('No categories available, <a href="%s">create one here first</a>', 'dbem'), get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager-categories');
?>
</p>
<?php
}
?>
<!-- END Categories -->
<?php
EM_Object::ms_global_switch_back();
}
示例8: rewrite_rules_array
//.........这里部分代码省略.........
$child_posts = $wpdb->get_results("SELECT ID, post_name FROM {$wpdb->posts} WHERE post_parent={$events_page->ID} AND post_type='page' AND post_status='publish'");
foreach ($child_posts as $child_post) {
$em_rules[$events_page->post_name . '/' . urldecode($child_post->post_name) . '/?$'] = 'index.php?page_id=' . $child_post->ID;
//single event booking form with slug //check if child page has children
$grandchildren = $wpdb->get_results("SELECT ID, post_name FROM {$wpdb->posts} WHERE post_parent={$child_post->ID} AND post_type='page' AND post_status='publish'");
if (count($grandchildren) != 0) {
foreach ($grandchildren as $grandchild) {
$em_rules[$events_slug . urldecode($child_post->post_name) . '/' . urldecode($grandchild->post_name) . '/?$'] = 'index.php?page_id=' . $grandchild->ID;
}
}
}
}
//global links hard-coded
if (EM_MS_GLOBAL && !get_site_option('dbem_ms_global_events_links', true)) {
//MS Mode has slug also for global links
$em_rules[$events_slug . get_site_option('dbem_ms_events_slug', EM_EVENT_SLUG) . '/(.+)$'] = 'index.php?pagename=' . $events_slug . '&em_redirect=1&event_slug=$matches[1]';
//single event from subsite
}
//add redirection for backwards compatability
$em_rules[$events_slug . EM_EVENT_SLUG . '/(.+)$'] = 'index.php?pagename=' . $events_slug . '&em_redirect=1&event_slug=$matches[1]';
//single event
$em_rules[$events_slug . EM_LOCATION_SLUG . '/(.+)$'] = 'index.php?pagename=' . $events_slug . '&em_redirect=1&location_slug=$matches[1]';
//single location page
$em_rules[$events_slug . EM_CATEGORY_SLUG . '/(.+)$'] = 'index.php?pagename=' . $events_slug . '&em_redirect=1&category_slug=$matches[1]';
//single category page slug
//add a rule that ensures that the events page is found and used over other pages
$em_rules[trim($events_slug, '/') . '/?$'] = 'index.php?pagename=' . trim($events_slug, '/');
} else {
$events_slug = EM_POST_TYPE_EVENT_SLUG;
$em_rules[$events_slug . '/(\\d{4}-\\d{2}-\\d{2})$'] = 'index.php?post_type=' . EM_POST_TYPE_EVENT . '&calendar_day=$matches[1]';
//event calendar date search
if (get_option('dbem_rsvp_enabled')) {
if (!get_option('dbem_my_bookings_page') || !is_object(get_post(get_option('dbem_my_bookings_page')))) {
//only added if bookings page isn't assigned
$em_rules[$events_slug . '/my\\-bookings$'] = 'index.php?post_type=' . EM_POST_TYPE_EVENT . '&bookings_page=1';
//page for users to manage bookings
}
}
//check for potentially conflicting posts with the same slug as events
$conflicting_posts = get_posts(array('name' => EM_POST_TYPE_EVENT_SLUG, 'post_type' => 'any', 'numberposts' => 0));
if (count($conflicting_posts) > 0) {
//won't apply on homepage
foreach ($conflicting_posts as $conflicting_post) {
//make sure we hard-code rewrites for child pages of events
$child_posts = get_posts(array('post_type' => 'any', 'post_parent' => $conflicting_post->ID, 'numberposts' => 0));
foreach ($child_posts as $child_post) {
$em_rules[EM_POST_TYPE_EVENT_SLUG . '/' . urldecode($child_post->post_name) . '/?$'] = 'index.php?page_id=' . $child_post->ID;
//single event booking form with slug
//check if child page has children
$grandchildren = get_pages('child_of=' . $child_post->ID);
if (count($grandchildren) != 0) {
foreach ($grandchildren as $grandchild) {
$em_rules[$events_slug . urldecode($child_post->post_name) . '/' . urldecode($grandchild->post_name) . '/?$'] = 'index.php?page_id=' . $grandchild->ID;
}
}
}
}
}
}
$em_rules = apply_filters('em_rewrite_rules_array_events', $em_rules, $events_slug);
//make sure there's no page with same name as archives, that should take precedence as it can easily be deleted wp admin side
$em_query = new WP_Query(array('pagename' => EM_POST_TYPE_EVENT_SLUG));
if ($em_query->have_posts()) {
$em_rules[trim(EM_POST_TYPE_EVENT_SLUG, '/') . '/?$'] = 'index.php?pagename=' . trim(EM_POST_TYPE_EVENT_SLUG, '/');
wp_reset_postdata();
}
//make sure there's no page with same name as archives, that should take precedence as it can easily be deleted wp admin side
$em_query = new WP_Query(array('pagename' => EM_POST_TYPE_LOCATION_SLUG));
if ($em_query->have_posts()) {
$em_rules[trim(EM_POST_TYPE_LOCATION_SLUG, '/') . '/?$'] = 'index.php?pagename=' . trim(EM_POST_TYPE_LOCATION_SLUG, '/');
wp_reset_postdata();
}
//If in MS global mode and locations are linked on same site
if (EM_MS_GLOBAL && !get_site_option('dbem_ms_global_locations_links', true)) {
$locations_page_id = get_option('dbem_locations_page');
$locations_page = get_post($locations_page_id);
if (is_object($locations_page)) {
$locations_slug = preg_replace('/\\/$/', '', str_replace(trailingslashit(home_url()), '', get_permalink($locations_page_id)));
$locations_slug_slashed = !empty($locations_slug) ? trailingslashit($locations_slug) : $locations_slug;
$em_rules[$locations_slug . '/' . get_site_option('dbem_ms_locations_slug', EM_LOCATION_SLUG) . '/(.+)$'] = 'index.php?pagename=' . $locations_slug_slashed . '&location_slug=$matches[1]';
//single event booking form with slug
}
}
//add ical CPT endpoints
$em_rules[EM_POST_TYPE_EVENT_SLUG . "/([^/]+)/ical/?\$"] = 'index.php?' . EM_POST_TYPE_EVENT . '=$matches[1]&ical=1';
if (get_option('dbem_locations_enabled')) {
$em_rules[EM_POST_TYPE_LOCATION_SLUG . "/([^/]+)/ical/?\$"] = 'index.php?' . EM_POST_TYPE_LOCATION . '=$matches[1]&ical=1';
}
//add ical taxonomy endpoints
$taxonomies = EM_Object::get_taxonomies();
foreach ($taxonomies as $tax_arg => $taxonomy_info) {
//set the dynamic rule for this taxonomy
$em_rules[$taxonomy_info['slug'] . "/([^/]+)/ical/?\$"] = 'index.php?' . $taxonomy_info['query_var'] . '=$matches[1]&ical=1';
}
//add RSS location CPT endpoint
if (get_option('dbem_locations_enabled')) {
$em_rules[EM_POST_TYPE_LOCATION_SLUG . "/([^/]+)/rss/?\$"] = 'index.php?' . EM_POST_TYPE_LOCATION . '=$matches[1]&rss=1';
}
return $em_rules + $rules;
}
示例9: em_booking_get_post
/**
* Hooks into em_booking_get_post filter and makes sure that if there's an active gateway for new bookings, if no $_REQUEST['gateway'] is supplied (i.e. hacking, spammer, or js problem with booking button mode).
* @param boolean $result
* @param EM_Booking $EM_Booking
* @return boolean
*/
static function em_booking_get_post($result, $EM_Booking)
{
if (!empty($_REQUEST['manual_booking']) && wp_verify_nonce($_REQUEST['manual_booking'], 'em_manual_booking_' . $_REQUEST['event_id'])) {
return $result;
}
if (get_option('dbem_multiple_bookings') && get_class($EM_Booking) == 'EM_Booking') {
//we only deal with the EM_Multiple_Booking class if we're in multi booking mode
return $result;
}
if (empty($EM_Booking->booking_id) && (empty($_REQUEST['gateway']) || !array_key_exists($_REQUEST['gateway'], self::active_gateways())) && $EM_Booking->get_price() > 0 && count(EM_Gateways::active_gateways()) > 0) {
//spammer or hacker trying to get around no gateway selection
$error = __('Choice of payment method not recognized. If you are seeing this error and selecting a method of payment, we apologize for the inconvenience. Please contact us and we\'ll help you make a booking as soon as possible.', 'em-pro');
$EM_Booking->add_error($error);
$result = false;
if (defined('DOING_AJAX')) {
$return = array('result' => false, 'message' => $error, 'errors' => $error);
echo EM_Object::json_encode($return);
die;
}
}
return $result;
}
示例10: array
<?php
$args = !empty($args) ? $args : array();
/* @var $args array */
?>
<!-- START Category Search -->
<div class="em-search-category em-search-field">
<label><?php
echo esc_html($args['category_label']);
?>
</label>
<?php
EM_Object::ms_global_switch();
//in case in global tables mode of MultiSite, grabs main site categories, if not using MS Global, nothing happens
wp_dropdown_categories(array('hide_empty' => 0, 'orderby' => 'name', 'name' => 'category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $args['category'], 'show_option_none' => $args['categories_label'], 'class' => 'em-events-search-category'));
EM_Object::ms_global_switch_back();
//if switched above, switch back
?>
</div>
<!-- END Category Search -->
示例11: get_option
<?php
/*
* This page will search for either a specific location via GET "id" variable
* or will search for events by name via the GET "q" variable.
*/
require_once '../../../../wp-load.php';
global $wpdb;
$locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
$location_cond = get_option('dbem_permissions_locations') < 1 && !em_verify_admin() ? "AND location_owner=" . get_current_user_id() : '';
$term = isset($_GET['term']) ? '%' . $_GET['term'] . '%' : '%' . $_GET['q'] . '%';
$sql = $wpdb->prepare("\n\tSELECT \n\t\tConcat( location_name, ', ', location_address, ', ', location_town) AS `label`,\n\t\tlocation_name AS `value`,\n\t\tlocation_address AS `address`, \n\t\tlocation_town AS `town`, \n\t\tlocation_id AS `id`\n\tFROM {$locations_table} \n\tWHERE ( `location_name` LIKE %s ) {$location_cond} LIMIT 10\n", $term);
$locations_array = $wpdb->get_results($sql);
echo EM_Object::json_encode($locations_array);
/*
$return_string_array = array();
foreach($locations_array as $location){
$return_string_class = array();
foreach($location as $key => $value ){
$return_string_class[] = "$key : '".addslashes($value)."'";
}
$return_string_array[] = '{'. implode(',', $return_string_class) .'}';
}
echo '['. implode(',', $return_string_array) .']';
*/
示例12: em_admin_init
function em_admin_init()
{
//in MS global mode and locations are stored in the main blog, then a user must have at least a subscriber role
if (EM_MS_GLOBAL && is_user_logged_in() && !is_main_site() && get_site_option('dbem_ms_mainblog_locations')) {
EM_Object::ms_global_switch();
$user = new WP_User(get_current_user_id());
if (count($user->roles) == 0) {
$user->set_role('subscriber');
}
EM_Object::ms_global_switch_back();
}
}
示例13: array
/**
* Save an array into this class
* @param $array
* @return null
*/
function to_object($array = array())
{
//Save event core data
parent::to_object($array);
//Save location info
$this->location = new EM_Location($array['location_id']);
//Save contact person info
}
示例14: get_default_search
public static function get_default_search($array_or_defaults = array(), $array = array())
{
self::$context = EM_POST_TYPE_LOCATION;
$defaults = array('eventful' => false, 'eventless' => false, 'orderby' => 'location_name', 'town' => false, 'state' => false, 'country' => false, 'region' => false, 'status' => 1, 'scope' => 'all', 'blog' => get_current_blog_id(), 'private' => current_user_can('read_private_locations'), 'private_only' => false, 'post_id' => false);
//sort out whether defaults were supplied or just the array of search values
if (empty($array)) {
$array = $array_or_defaults;
} else {
$defaults = array_merge($defaults, $array_or_defaults);
}
//specific functionality
if (EM_MS_GLOBAL) {
if (get_site_option('dbem_ms_mainblog_locations')) {
//when searching in MS Global mode with all locations being stored on the main blog, blog_id becomes redundant as locations are stored in one blog table set
$array['blog'] = false;
} elseif ((!is_admin() || defined('DOING_AJAX')) && empty($array['blog']) && is_main_site() && get_site_option('dbem_ms_global_locations')) {
//if enabled, by default we display all blog locations on main site
$array['blog'] = false;
}
}
$array['eventful'] = !empty($array['eventful']) && $array['eventful'] == true;
$array['eventless'] = !empty($array['eventless']) && $array['eventless'] == true;
if (is_admin() && !defined('DOING_AJAX')) {
$defaults['owner'] = !current_user_can('read_others_locations') ? get_current_user_id() : false;
}
return apply_filters('em_locations_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults);
}
示例15:
/**
* Can the user manage this coupon?
*/
function can_manage($owner_capability = false, $admin_capability = false, $user_to_check = false)
{
return apply_filters('em_coupon_can_manage', parent::can_manage($owner_capability, $admin_capability, $user_to_check), $this, $owner_capability, $admin_capability, $user_to_check);
}