本文整理汇总了PHP中EM_Object::json_encode方法的典型用法代码示例。如果您正苦于以下问题:PHP EM_Object::json_encode方法的具体用法?PHP EM_Object::json_encode怎么用?PHP EM_Object::json_encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EM_Object
的用法示例。
在下文中一共展示了EM_Object::json_encode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: 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 '';
}
}
示例3: 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;
}
示例4: 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) .']';
*/
示例5: em_admin_email_test_ajax
function em_admin_email_test_ajax()
{
if (wp_verify_nonce($_REQUEST['_check_email_nonce'], 'check_email') && current_user_can('activate_plugins')) {
$subject = __("Events Manager Test Email", 'dbem');
$content = __('Congratulations! Your email settings work.', 'dbem');
$current_user = get_user_by('id', get_current_user_id());
//add filters for options used in EM_Mailer so the current supplied ones are used
ob_start();
function pre_option_dbem_mail_sender_name()
{
return sanitize_email($_REQUEST['dbem_mail_sender_name']);
}
add_filter('pre_option_dbem_mail_sender_name', 'pre_option_dbem_mail_sender_name');
function pre_option_dbem_mail_sender_address()
{
return sanitize_text_field($_REQUEST['dbem_mail_sender_address']);
}
add_filter('pre_option_dbem_mail_sender_address', 'pre_option_dbem_mail_sender_address');
function pre_option_dbem_rsvp_mail_send_method()
{
return sanitize_text_field($_REQUEST['dbem_rsvp_mail_send_method']);
}
add_filter('pre_option_dbem_rsvp_mail_send_method', 'pre_option_dbem_rsvp_mail_send_method');
function pre_option_dbem_rsvp_mail_port()
{
return sanitize_text_field($_REQUEST['dbem_rsvp_mail_port']);
}
add_filter('pre_option_dbem_rsvp_mail_port', 'pre_option_dbem_rsvp_mail_port');
function pre_option_dbem_rsvp_mail_SMTPAuth()
{
return sanitize_text_field($_REQUEST['dbem_rsvp_mail_SMTPAuth']);
}
add_filter('pre_option_dbem_rsvp_mail_SMTPAuth', 'pre_option_dbem_rsvp_mail_SMTPAuth');
function pre_option_dbem_smtp_host()
{
return sanitize_text_field($_REQUEST['dbem_smtp_host']);
}
add_filter('pre_option_dbem_smtp_host', 'pre_option_dbem_smtp_host');
function pre_option_dbem_smtp_username()
{
return sanitize_text_field($_REQUEST['dbem_smtp_username']);
}
add_filter('pre_option_dbem_smtp_username', 'pre_option_dbem_smtp_username');
function pre_option_dbem_smtp_password()
{
return sanitize_text_field($_REQUEST['dbem_smtp_password']);
}
add_filter('pre_option_dbem_smtp_password', 'pre_option_dbem_smtp_password');
ob_clean();
//remove any php errors/warnings output
$EM_Event = new EM_Event();
if ($EM_Event->email_send($subject, $content, $current_user->user_email)) {
$result = array('result' => true, 'message' => sprintf(__('Email sent succesfully to %s', 'dbem'), $current_user->user_email));
} else {
$result = array('result' => false, 'message' => __('Email not sent.', 'dbem') . " <ul><li>" . implode('</li><li>', $EM_Event->get_errors()) . '</li></ul>');
}
echo EM_Object::json_encode($result);
}
exit;
}
示例6: em_init_actions
/**
* Performs actions on init. This works for both ajax and normal requests, the return results depends if an em_ajax flag is passed via POST or GET.
*/
function em_init_actions()
{
global $wpdb, $EM_Notices, $EM_Event;
if (defined('DOING_AJAX') && DOING_AJAX) {
$_REQUEST['em_ajax'] = true;
}
//NOTE - No EM objects are globalized at this point, as we're hitting early init mode.
//TODO Clean this up.... use a uniformed way of calling EM Ajax actions
if (!empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action'])) {
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
if (isset($_REQUEST['id'])) {
$EM_Location = new EM_Location($_REQUEST['id'], 'location_id');
$location_array = $EM_Location->to_array();
$location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
echo EM_Object::json_encode($location_array);
}
die;
}
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'delete_ticket') {
if (isset($_REQUEST['id'])) {
$EM_Ticket = new EM_Ticket($_REQUEST['id']);
$result = $EM_Ticket->delete();
if ($result) {
$result = array('result' => true);
} else {
$result = array('result' => false, 'error' => $EM_Ticket->feedback_message);
}
} else {
$result = array('result' => false, 'error' => __('No ticket id provided', 'dbem'));
}
echo EM_Object::json_encode($result);
die;
}
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
$EM_Locations = EM_Locations::get($_REQUEST);
$json_locations = array();
foreach ($EM_Locations as $location_key => $EM_Location) {
$json_locations[$location_key] = $EM_Location->to_array();
$json_locations[$location_key]['location_balloon'] = $EM_Location->output(get_option('dbem_map_text_format'));
}
echo EM_Object::json_encode($json_locations);
die;
}
if (isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
//FIXME if long events enabled originally, this won't show up on ajax call
echo EM_Calendar::output($_REQUEST, false);
die;
}
}
//Event Actions
if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 5) == 'event') {
//Load the event object, with saved event if requested
if (!empty($_REQUEST['event_id'])) {
$EM_Event = new EM_Event($_REQUEST['event_id']);
} else {
$EM_Event = new EM_Event();
}
//Save Event, only via BP or via [event_form]
if ($_REQUEST['action'] == 'event_save' && $EM_Event->can_manage('edit_events', 'edit_others_events')) {
//Check Nonces
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'wpnonce_event_save')) {
exit('Trying to perform an illegal action.');
}
//Grab and validate submitted data
if ($EM_Event->get_post() && $EM_Event->save()) {
//EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
$events_result = true;
//Success notice
if (is_user_logged_in()) {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_form_result_success')), true);
} else {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_anonymous_result_success')), true);
}
$redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
$redirect = em_add_get_params($redirect, array('success' => 1));
wp_redirect($redirect);
exit;
} else {
$EM_Notices->add_error($EM_Event->get_errors());
$events_result = false;
}
}
if ($_REQUEST['action'] == 'event_duplicate' && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_duplicate_' . $EM_Event->event_id)) {
$EM_Event = $EM_Event->duplicate();
if ($EM_Event === false) {
$EM_Notices->add_error($EM_Event->errors, true);
} else {
$EM_Notices->add_confirm($EM_Event->feedback_message, true);
}
wp_redirect(wp_get_referer());
exit;
}
if ($_REQUEST['action'] == 'event_delete' && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_delete_' . $EM_Event->event_id)) {
//DELETE action
$selectedEvents = !empty($_REQUEST['events']) ? $_REQUEST['events'] : '';
if (EM_Object::array_is_numeric($selectedEvents)) {
$events_result = EM_Events::delete($selectedEvents);
//.........这里部分代码省略.........
示例7: substr
* There is one argument passed to you, which is the $args variable. This contains the arguments you could pass into shortcodes, template tags or functions like EM_Events::get().
*
* In this template, we encode the $args array into JSON for javascript to easily parse and request the locations from the server via AJAX.
*/
if (get_option('dbem_gmap_is_active') == '1') {
$args['em_ajax'] = true;
$args['query'] = 'GlobalMapData';
$rand = substr(md5(rand() . rand()), 0, 5);
?>
<div class='em-locations-map' id='em-locations-map-<?php
echo $rand;
?>
' style='width:<?php
echo $args['width'];
?>
px; height:<?php
echo $args['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($args);
?>
</div>
<?php
}
示例8: wpfc_em_ajax
//.........这里部分代码省略.........
$args = array('month' => $month, 'year' => $year, 'owner' => false, 'status' => 1, 'orderby' => 'event_start_time, event_name');
//since wpfc handles date sorting we only care about time and name ordering here
$args['number_of_weeks'] = 6;
//WPFC always has 6 weeks
$limit = $args['limit'] = get_option('wpfc_limit', 3);
$args['long_events'] = isset($_REQUEST['long_events']) && $_REQUEST['long_events'] == 0 ? 0 : 1;
//long events are enabled, unless explicitly told not to in the shortcode
//do some corrections for EM query
if (isset($_REQUEST[EM_TAXONOMY_CATEGORY]) || empty($_REQUEST['category'])) {
$_REQUEST['category'] = !empty($_REQUEST[EM_TAXONOMY_CATEGORY]) ? $_REQUEST[EM_TAXONOMY_CATEGORY] : false;
}
$_REQUEST['tag'] = !empty($_REQUEST[EM_TAXONOMY_TAG]) ? $_REQUEST[EM_TAXONOMY_TAG] : false;
$args = apply_filters('wpfc_fullcalendar_args', array_merge($_REQUEST, $args));
$calendar_array = EM_Calendar::get($args);
$parentArray = $events = $event_ids = $event_date_counts = $event_dates_more = $event_day_counts = array();
//get day link template
global $wp_rewrite;
if (get_option("dbem_events_page") > 0) {
$event_page_link = get_permalink(get_option("dbem_events_page"));
//PAGE URI OF EM
if ($wp_rewrite->using_permalinks()) {
$event_page_link = trailingslashit($event_page_link);
}
} else {
if ($wp_rewrite->using_permalinks()) {
$event_page_link = trailingslashit(home_url()) . EM_POST_TYPE_EVENT_SLUG . '/';
//don't use EM_URI here, since ajax calls this before EM_URI is defined.
} else {
$event_page_link = home_url() . '?post_type=' . EM_POST_TYPE_EVENT;
//don't use EM_URI here, since ajax calls this before EM_URI is defined.
}
}
if ($wp_rewrite->using_permalinks() && !defined('EM_DISABLE_PERMALINKS')) {
$event_page_link .= "%s/";
} else {
$joiner = stristr($event_page_link, "?") ? "&" : "?";
$event_page_link .= $joiner . "calendar_day=%s";
}
foreach ($calendar_array['cells'] as $date => $cell_data) {
if (empty($event_day_counts[$date])) {
$event_day_counts[$date] = 0;
}
/* @var $EM_Event EM_Event */
$orig_color = get_option('dbem_category_default_color');
foreach ($cell_data['events'] as $EM_Event) {
$color = $borderColor = $orig_color;
$textColor = '#fff';
if (get_option('dbem_categories_enabled') && !empty($EM_Event->get_categories()->categories)) {
foreach ($EM_Event->get_categories()->categories as $EM_Category) {
/* @var $EM_Category EM_Category */
if ($EM_Category->get_color() != '') {
$color = $borderColor = $EM_Category->get_color();
if (preg_match("/#fff(fff)?/i", $color)) {
$textColor = '#777';
$borderColor = '#ccc';
}
break;
}
}
}
if (!in_array($EM_Event->event_id, $event_ids)) {
//count events for all days this event may span
if ($EM_Event->event_start_date != $EM_Event->event_end_date) {
for ($i = $EM_Event->start; $i <= $EM_Event->end; $i = $i + 86400) {
$idate = date('Y-m-d', $i);
empty($event_day_counts[$idate]) ? $event_day_counts[$idate] = 1 : $event_day_counts[$idate]++;
}
} else {
$event_day_counts[$date]++;
}
if ($event_day_counts[$date] <= $limit) {
$title = $EM_Event->output(get_option('dbem_emfc_full_calendar_event_format', '#_EVENTNAME'), 'raw');
$allDay = $EM_Event->event_all_day == true;
if ($allDay) {
$start_date = date('Y-m-d\\TH:i:s', $EM_Event->start);
$end_date = date('Y-m-d\\T00:00:00', $EM_Event->end + 60 * 60 * 24);
//on all day events the end date/time is next day of end date at 00:00:00 - see end attribute on http://fullcalendar.io/docs/event_data/Event_Object/
} else {
$start_date = date('Y-m-d\\TH:i:s', $EM_Event->start);
$end_date = date('Y-m-d\\TH:i:s', $EM_Event->end);
}
$event_array = array("title" => $title, "color" => $color, 'textColor' => $textColor, 'borderColor' => $borderColor, "start" => $start_date, "end" => $end_date, "url" => $EM_Event->get_permalink(), 'post_id' => $EM_Event->post_id, 'event_id' => $EM_Event->event_id, 'allDay' => $allDay);
if ($args['long_events'] == 0) {
$event_array['end'] = $event_array['start'];
}
//if long events aren't wanted, make the end date same as start so it shows this way on the calendar
$events[] = apply_filters('wpfc_events_event', $event_array, $EM_Event);
$event_ids[] = $EM_Event->event_id;
}
}
}
if ($cell_data['events_count'] > $limit) {
$event_dates_more[$date] = 1;
$day_ending = $date . "T23:59:59";
$events[] = apply_filters('wpfc_events_more', array("title" => get_option('wpfc_limit_txt', 'more ...'), "color" => get_option('wpfc_limit_color', '#fbbe30'), "start" => $day_ending, "url" => str_replace('%s', $date, $event_page_link), 'post_id' => 0, 'event_id' => 0, 'className' => 'wpfc-more'), $date);
}
}
echo EM_Object::json_encode(apply_filters('wpfc_events', $events));
die;
}
示例9: checkout
public static function checkout()
{
global $EM_Notices, $EM_Booking;
check_ajax_referer('emp_checkout');
$EM_Booking = $EM_Multiple_Booking = self::get_multiple_booking();
//remove filters so that our master booking validates user fields
remove_action('em_booking_form_custom', 'EM_Multiple_Bookings::prevent_user_fields', 1);
//prevent user fields from showing
remove_filter('em_booking_validate', 'EM_Multiple_Bookings::prevent_user_validation', 1);
//prevent user fields validation
//now validate the master booking
$EM_Multiple_Booking->get_post();
$post_validation = $EM_Multiple_Booking->validate();
//re-add filters to prevent individual booking problems
add_action('em_booking_form_custom', 'EM_Multiple_Bookings::prevent_user_fields', 1);
//prevent user fields from showing
add_filter('em_booking_validate', 'EM_Multiple_Bookings::prevent_user_validation', 1);
//prevent user fields validation
$bookings_validation = $EM_Multiple_Booking->validate_bookings();
//fire the equivalent of the em_booking_add action, but multiple variation
do_action('em_multiple_booking_add', $EM_Multiple_Booking->get_event(), $EM_Multiple_Booking, $post_validation && $bookings_validation);
//get_event returns blank, just for backwards-compatabaility
//proceed with saving bookings if all is well
$result = false;
$feedback = '';
if ($bookings_validation && $post_validation) {
//save user registration
$registration = em_booking_add_registration($EM_Multiple_Booking);
//save master booking, which in turn saves the other bookings too
if ($registration && $EM_Multiple_Booking->save_bookings()) {
$result = true;
$EM_Notices->add_confirm($EM_Multiple_Booking->feedback_message);
$feedback = $EM_Multiple_Booking->feedback_message;
self::empty_cart();
//we're done with this checkout!
} else {
$EM_Notices->add_error($EM_Multiple_Booking->get_errors());
$feedback = $EM_Multiple_Booking->feedback_message;
}
global $em_temp_user_data;
$em_temp_user_data = false;
//delete registered user temp info (if exists)
} else {
$EM_Notices->add_error($EM_Multiple_Booking->get_errors());
}
if (defined('DOING_AJAX')) {
header('Content-Type: application/javascript; charset=UTF-8', true);
//add this for HTTP -> HTTPS requests which assume it's a cross-site request
if ($result) {
$return = array('result' => true, 'message' => $feedback, 'checkout' => true);
echo EM_Object::json_encode(apply_filters('em_action_' . $_REQUEST['action'], $return, $EM_Multiple_Booking));
} elseif (!$result) {
$return = array('result' => false, 'message' => $feedback, 'errors' => $EM_Notices->get_errors(), 'checkout' => true);
echo EM_Object::json_encode(apply_filters('em_action_' . $_REQUEST['action'], $return, $EM_Multiple_Booking));
}
die;
}
}
示例10: em_init_actions
/**
* Performs actions on init. This works for both ajax and normal requests, the return results depends if an em_ajax flag is passed via POST or GET.
*/
function em_init_actions()
{
global $wpdb, $EM_Notices, $EM_Event;
if (defined('DOING_AJAX') && DOING_AJAX) {
$_REQUEST['em_ajax'] = true;
}
//NOTE - No EM objects are globalized at this point, as we're hitting early init mode.
//TODO Clean this up.... use a uniformed way of calling EM Ajax actions
if (!empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action'])) {
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
if (isset($_REQUEST['id'])) {
$EM_Location = new EM_Location($_REQUEST['id'], 'location_id');
$location_array = $EM_Location->to_array();
$location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
echo EM_Object::json_encode($location_array);
}
die;
}
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'delete_ticket') {
if (isset($_REQUEST['id'])) {
$EM_Ticket = new EM_Ticket($_REQUEST['id']);
$result = $EM_Ticket->delete();
if ($result) {
$result = array('result' => true);
} else {
$result = array('result' => false, 'error' => $EM_Ticket->feedback_message);
}
} else {
$result = array('result' => false, 'error' => __('No ticket id provided', 'dbem'));
}
echo EM_Object::json_encode($result);
die;
}
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
$EM_Locations = EM_Locations::get($_REQUEST);
$json_locations = array();
foreach ($EM_Locations as $location_key => $EM_Location) {
$json_locations[$location_key] = $EM_Location->to_array();
$json_locations[$location_key]['location_balloon'] = $EM_Location->output(get_option('dbem_map_text_format'));
}
echo EM_Object::json_encode($json_locations);
die;
}
if (isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
//FIXME if long events enabled originally, this won't show up on ajax call
echo EM_Calendar::output($_REQUEST, false);
die;
}
}
//Event Actions
if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 5) == 'event') {
//Load the event object, with saved event if requested
if (!empty($_REQUEST['event_id'])) {
$EM_Event = new EM_Event($_REQUEST['event_id']);
} else {
$EM_Event = new EM_Event();
}
//Save Event, only via BP or via [event_form]
if ($_REQUEST['action'] == 'event_save' && $EM_Event->can_manage('edit_events', 'edit_others_events')) {
//Check Nonces
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'wpnonce_event_save')) {
exit('Trying to perform an illegal action.');
}
//Grab and validate submitted data
if ($EM_Event->get_post() && $EM_Event->save()) {
//EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
$events_result = true;
//Success notice
if (is_user_logged_in()) {
if (empty($_REQUEST['event_id'])) {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_form_result_success')), true);
} else {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_form_result_success_updated')), true);
}
} else {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_anonymous_result_success')), true);
}
$redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
$redirect = em_add_get_params($redirect, array('success' => 1), false, false);
wp_redirect($redirect);
exit;
} else {
$EM_Notices->add_error($EM_Event->get_errors());
$events_result = false;
}
}
if ($_REQUEST['action'] == 'event_duplicate' && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_duplicate_' . $EM_Event->event_id)) {
$event = $EM_Event->duplicate();
if ($event === false) {
$EM_Notices->add_error($EM_Event->errors, true);
wp_redirect(wp_get_referer());
} else {
$EM_Notices->add_confirm($EM_Event->feedback_message, true);
wp_redirect($event->get_edit_url());
}
exit;
}
//.........这里部分代码省略.........
示例11: wpfc_em_ajax
/**
* Replaces the normal WPFC ajax and uses the EM query system to provide event specific results.
*/
function wpfc_em_ajax()
{
$_REQUEST['month'] = false;
//no need for these two, they are the original month and year requested
$_REQUEST['year'] = false;
//get the year and month to show, which would be the month/year between start and end request params
$month_diff = $_REQUEST['end'] - $_REQUEST['start'];
$month_ts = $_REQUEST['start'] + $month_diff / 2;
//get a 'mid-month' timestamp to get year and month
$year = (int) date("Y", $month_ts);
$month = (int) date("m", $month_ts);
$args = array('month' => $month, 'year' => $year, 'owner' => false, 'status' => 1, 'orderby' => 'event_start_date, event_start_time');
$args['number_of_weeks'] = 6;
//WPFC always has 6 weeks
$limit = $args['limit'] = get_option('wpfc_limit', 3);
//do some corrections for EM query
if (isset($_REQUEST[EM_TAXONOMY_CATEGORY]) || empty($_REQUEST['category'])) {
$_REQUEST['category'] = !empty($_REQUEST[EM_TAXONOMY_CATEGORY]) ? $_REQUEST[EM_TAXONOMY_CATEGORY] : false;
}
$_REQUEST['tag'] = !empty($_REQUEST[EM_TAXONOMY_TAG]) ? $_REQUEST[EM_TAXONOMY_TAG] : false;
$args = apply_filters('wpfc_fullcalendar_args', array_merge($_REQUEST, $args));
$calendar_array = EM_Calendar::get($args);
$parentArray = $events = $event_ids = $event_date_counts = $event_dates_more = $event_day_counts = array();
//get day link template
global $wp_rewrite;
if (get_option("dbem_events_page") > 0) {
$event_page_link = get_permalink(get_option("dbem_events_page"));
//PAGE URI OF EM
if ($wp_rewrite->using_permalinks()) {
$event_page_link = trailingslashit($event_page_link);
}
} else {
if ($wp_rewrite->using_permalinks()) {
$event_page_link = trailingslashit(home_url()) . EM_POST_TYPE_EVENT_SLUG . '/';
//don't use EM_URI here, since ajax calls this before EM_URI is defined.
} else {
$event_page_link = home_url() . '?post_type=' . EM_POST_TYPE_EVENT;
//don't use EM_URI here, since ajax calls this before EM_URI is defined.
}
}
if ($wp_rewrite->using_permalinks() && !defined('EM_DISABLE_PERMALINKS')) {
$event_page_link .= "%s/";
} else {
$joiner = stristr($event_page_link, "?") ? "&" : "?";
$event_page_link .= $joiner . "calendar_day=%s";
}
foreach ($calendar_array['cells'] as $date => $cell_data) {
if (empty($event_day_counts[$date])) {
$event_day_counts[$date] = 0;
}
/* @var $EM_Event EM_Event */
$orig_color = get_option('dbem_category_default_color');
foreach ($cell_data['events'] as $EM_Event) {
$color = $borderColor = $orig_color;
$textColor = '#fff';
if (!empty($EM_Event->get_categories()->categories)) {
foreach ($EM_Event->get_categories()->categories as $EM_Category) {
/* @var $EM_Category EM_Category */
if ($EM_Category->get_color() != '') {
$color = $borderColor = $EM_Category->get_color();
if (preg_match("/#fff(fff)?/i", $color)) {
$textColor = '#777';
$borderColor = '#ccc';
}
break;
}
}
}
if (!in_array($EM_Event->event_id, $event_ids)) {
//count events for all days this event may span
if ($EM_Event->event_start_date != $EM_Event->event_end_date) {
for ($i = $EM_Event->start; $i <= $EM_Event->end; $i = $i + 86400) {
$idate = date('Y-m-d', $i);
empty($event_day_counts[$idate]) ? $event_day_counts[$idate] = 1 : $event_day_counts[$idate]++;
}
} else {
$event_day_counts[$date]++;
}
if ($event_day_counts[$date] <= $limit) {
$title = $EM_Event->output(get_option('dbem_emfc_full_calendar_event_format', '#_EVENTNAME'), 'raw');
$event_array = array("title" => $title, "color" => $color, 'textColor' => $textColor, 'borderColor' => $borderColor, "start" => date('Y-m-d\\TH:i:s', $EM_Event->start), "end" => date('Y-m-d\\TH:i:s', $EM_Event->end), "url" => $EM_Event->get_permalink(), 'post_id' => $EM_Event->post_id, 'event_id' => $EM_Event->event_id, 'allDay' => $EM_Event->event_all_day == true);
$events[] = apply_filters('wpfc_events_event', $event_array, $EM_Event);
$event_ids[] = $EM_Event->event_id;
}
}
}
if ($cell_data['events_count'] > $limit) {
$event_dates_more[$date] = 1;
$day_ending = $date . "T23:59:59";
$events[] = apply_filters('wpfc_events_more', array("title" => get_option('wpfc_limit_txt', 'more ...'), "color" => get_option('wpfc_limit_color', '#fbbe30'), "start" => $day_ending, "url" => str_replace('%s', $date, $event_page_link), 'post_id' => 0, 'event_id' => 0, 'allDay' => true), $date);
}
}
echo EM_Object::json_encode(apply_filters('wpfc_events', $events));
die;
}
示例12: em_init_actions
/**
* Performs actions on init. This works for both ajax and normal requests, the return results depends if an em_ajax flag is passed via POST or GET.
*/
function em_init_actions()
{
global $wpdb, $EM_Notices, $EM_Event;
//NOTE - No EM objects are globalized at this point, as we're hitting early init mode.
//TODO Clean this up.... use a uniformed way of calling EM Ajax actions
if (!empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action'])) {
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
if (isset($_REQUEST['id'])) {
$EM_Location = new EM_Location($_REQUEST['id']);
$location_array = $EM_Location->to_array();
$location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
echo EM_Object::json_encode($location_array);
}
die;
}
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'delete_ticket') {
if (isset($_REQUEST['id'])) {
$EM_Ticket = new EM_Ticket($_REQUEST['id']);
$result = $EM_Ticket->delete();
if ($result) {
$result = array('result' => true);
} else {
$result = array('result' => false, 'error' => $EM_Ticket->feedback_message);
}
} else {
$result = array('result' => false, 'error' => __('No ticket id provided', 'dbem'));
}
echo EM_Object::json_encode($result);
die;
}
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
$EM_Locations = EM_Locations::get($_REQUEST);
$json_locations = array();
foreach ($EM_Locations as $location_key => $EM_Location) {
$json_locations[$location_key] = $EM_Location->to_array();
$json_locations[$location_key]['location_balloon'] = $EM_Location->output(get_option('dbem_map_text_format'));
}
echo EM_Object::json_encode($json_locations);
die;
}
if (isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
//FIXME if long events enabled originally, this won't show up on ajax call
echo EM_Calendar::output($_REQUEST);
die;
}
}
//Event Actions
if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 5) == 'event') {
//Load the event object, with saved event if requested
if (!empty($_REQUEST['event_id'])) {
$EM_Event = new EM_Event($_REQUEST['event_id']);
} else {
$EM_Event = new EM_Event();
}
if ($_REQUEST['action'] == 'event_save' && current_user_can('edit_events')) {
//Check Nonces
if (is_admin()) {
if (!wp_verify_nonce($_REQUEST['_wpnonce'] && 'event_save')) {
check_admin_referer('trigger_error');
}
} else {
if (!wp_verify_nonce($_REQUEST['_wpnonce'] && 'event_save')) {
exit('Trying to perform an illegal action.');
}
}
//Grab and validate submitted data
if ($EM_Event->get_post() && $EM_Event->save()) {
//EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
$EM_Notices->add_confirm($EM_Event->feedback_message);
if (is_admin()) {
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
$scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
//wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager&pno='.$page.'&scope='.$scope.'&message='.urlencode($EM_Event->feedback_message));
} else {
$redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
wp_redirect($redirect);
}
$events_result = true;
} else {
$EM_Notices->add_error($EM_Event->get_errors());
$events_result = false;
}
}
if ($_REQUEST['action'] == 'event_duplicate') {
global $EZSQL_ERROR;
$EM_Event = $EM_Event->duplicate();
if ($EM_Event === false) {
$EM_Notices->add_error($EM_Event->errors, true);
} else {
if ($EM_Event->id == $_REQUEST['event_id']) {
$EM_Notices->add_confirm($EM_Event->feedback_message . " " . sprintf(__('You are now viewing the duplicated %s.', 'dbem'), __('event', 'dbem')), true);
} else {
$EM_Notices->add_confirm($EM_Event->feedback_message, true);
}
}
}
if ($_REQUEST['action'] == 'event_delete') {
//.........这里部分代码省略.........
示例13: em_ajax_actions
function em_ajax_actions()
{
//TODO Clean this up.... use a uniformed way of calling EM Ajax actions
if (!empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action'])) {
if (isset($_REQUEST['dbem_ajax_action']) && $_REQUEST['dbem_ajax_action'] == 'booking_data') {
if (isset($_REQUEST['id'])) {
$EM_Event = new EM_Event($_REQUEST['id']);
echo "[{bookedSeats:" . $EM_Event->get_bookings()->get_booked_seats() . ", availableSeats:" . $EM_Event->get_bookings()->get_available_seats() . "}]";
}
die;
}
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
if (isset($_REQUEST['id'])) {
$EM_Location = new EM_Location($_REQUEST['id']);
$location_array = $EM_Location->to_array();
$location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
echo EM_Object::json_encode($location_array);
}
die;
}
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
$locations = EM_Locations::get($_REQUEST);
$json_locations = array();
foreach ($locations as $location_key => $location) {
$json_locations[$location_key] = $location->to_array();
$json_locations[$location_key]['location_balloon'] = $location->output(get_option('dbem_map_text_format'));
}
echo EM_Object::json_encode($json_locations);
die;
}
if (isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
//FIXME if long events enabled originally, this won't show up on ajax call
echo EM_Calendar::output($_REQUEST);
die;
}
//EM Ajax requests require this flag.
if (is_admin()) {
//Admin operations
//Booking Actions
global $EM_Booking;
if (!empty($_REQUEST['bookings']) || is_object($EM_Booking)) {
if (is_object($EM_Booking)) {
$_REQUEST['bookings'] = $EM_Booking;
//small hack to prevent unecessary db reads
}
$EM_Bookings = new EM_Bookings();
//Empty, not bound to event.
if ($_REQUEST['action'] == 'bookings_approve') {
$EM_Bookings->approve($_REQUEST['bookings']);
echo $EM_Bookings->feedback_message;
die;
} elseif ($_REQUEST['action'] == 'bookings_reject') {
$EM_Bookings->reject($_REQUEST['bookings']);
echo $EM_Bookings->feedback_message;
die;
} elseif ($_REQUEST['action'] == 'bookings_unapprove') {
$EM_Bookings->unapprove($_REQUEST['bookings']);
echo $EM_Bookings->feedback_message;
die;
} elseif ($_REQUEST['action'] == 'bookings_delete') {
//Just do it here, since we may be deleting bookings of different events.
$result = false;
if (EM_Object::array_is_numeric($_REQUEST['bookings'])) {
$results = array();
foreach ($_REQUEST['bookings'] as $booking_id) {
$EM_Booking = new EM_Booking($booking_id);
$results[] = $EM_Booking->delete();
}
$result = !in_array(false, $results);
} elseif (is_numeric($_REQUEST['bookings'])) {
$EM_Booking = new EM_Booking($_REQUEST['bookings']);
$result = $EM_Booking->delete();
} elseif (is_object($EM_Booking)) {
$result = $EM_Booking->delete();
}
if ($result) {
echo __('Booking Deleted', 'dbem');
} else {
echo '<span style="color:red">' . __('Booking deletion unsuccessful', 'dbem') . '</span>';
}
die;
}
}
//Specific Oject Ajax
if (!empty($_REQUEST['em_obj'])) {
switch ($_REQUEST['em_obj']) {
case 'em_bookings_events_table':
case 'em_bookings_pending_table':
case 'em_bookings_confirmed_table':
call_user_func($_REQUEST['em_obj']);
break;
}
die;
}
}
}
}
示例14: coupon_check_ajax
public static function coupon_check_ajax()
{
$result = array('result' => false, 'message' => __('Coupon Not Found', 'em-pro'));
if (!empty($_REQUEST['event_id'])) {
$EM_Event = new EM_Event($_REQUEST['event_id']);
$EM_Coupon = self::event_get_coupon($_REQUEST['coupon_code'], $EM_Event);
if (!empty($EM_Event->event_id) && is_object($EM_Coupon)) {
if ($EM_Coupon->is_valid()) {
$result['result'] = true;
$result['message'] = $EM_Coupon->get_discount_text();
} else {
$result['message'] = __('Coupon Invalid', 'em-pro');
}
}
}
echo EM_Object::json_encode($result);
exit;
}
示例15: wpfc_em_ajax
/**
* Replaces the normal WPFC ajax and uses the EM query system to provide event specific results.
*/
function wpfc_em_ajax()
{
$_REQUEST['month'] = false;
//no need for these two
$_REQUEST['year'] = false;
$year = date("Y", $_REQUEST['start']);
$temp = date("Y-m-d", $_REQUEST['start']);
$tomorrow = mktime(0, 0, 0, date("m", strtotime($temp)) + 1, date("d", strtotime($temp)), date("Y", strtotime($temp)));
$month = date("m", $tomorrow);
$args = array('month' => $month, 'year' => $year, 'owner' => false, 'status' => 1, 'orderby' => 'event_start_date, event_start_time');
$args['long_events'] = 0;
//since fullcalendar takes the start-end dates for long events, we don't need long events
$limit = $args['limit'] = get_option('wpfc_limit', 3);
//do some corrections for EM query
if (isset($_REQUEST[EM_TAXONOMY_CATEGORY]) || empty($_REQUEST['category'])) {
$_REQUEST['category'] = !empty($_REQUEST[EM_TAXONOMY_CATEGORY]) ? $_REQUEST[EM_TAXONOMY_CATEGORY] : false;
}
$_REQUEST['tag'] = !empty($_REQUEST[EM_TAXONOMY_TAG]) ? $_REQUEST[EM_TAXONOMY_TAG] : false;
$args = apply_filters('wpfc_fullcalendar_args', array_merge($_REQUEST, $args));
$EM_Events = EM_Events::get($args);
$calendar_array = EM_Calendar::get($args);
$parentArray = array();
$events = array();
$event_date_counts = array();
$event_dates_more = array();
//get day link template
global $wp_rewrite;
if (get_option("dbem_events_page") > 0) {
$event_page_link = get_permalink(get_option("dbem_events_page"));
//PAGE URI OF EM
if ($wp_rewrite->using_permalinks()) {
$event_page_link = trailingslashit($event_page_link);
}
} else {
if ($wp_rewrite->using_permalinks()) {
$event_page_link = trailingslashit(home_url()) . EM_POST_TYPE_EVENT_SLUG . '/';
//don't use EM_URI here, since ajax calls this before EM_URI is defined.
} else {
$event_page_link = home_url() . '?post_type=' . EM_POST_TYPE_EVENT;
//don't use EM_URI here, since ajax calls this before EM_URI is defined.
}
}
if ($wp_rewrite->using_permalinks() && !defined('EM_DISABLE_PERMALINKS')) {
$event_page_link .= "%s/";
} else {
$joiner = stristr($event_page_link, "?") ? "&" : "?";
$event_page_link .= $joiner . "calendar_day=%s";
}
$event_day_counts = array();
foreach ($calendar_array['cells'] as $date => $cell_data) {
if (empty($event_day_counts[$date])) {
$event_day_counts[$date] = 0;
}
/* @var $EM_Event EM_Event */
$color = "#a8d144";
$textColor = '#fff';
$borderColor = '#a8d144';
foreach ($cell_data['events'] as $EM_Event) {
if (!empty($EM_Event->get_categories()->categories)) {
foreach ($EM_Event->get_categories()->categories as $EM_Category) {
/* @var $EM_Category EM_Category */
if ($EM_Category->get_color() != '') {
$color = $borderColor = $EM_Category->get_color();
if (preg_match("/#fff(fff)?/i", $color)) {
$textColor = '#777';
$borderColor = '#ccc';
}
break;
}
}
}
//count events for all days this event may span
if ($EM_Event->event_start_date != $EM_Event->event_end_date) {
for ($i = $EM_Event->start; $i <= $EM_Event->end; $i = $i + 86400) {
$idate = date('Y-m-d', $i);
empty($event_day_counts[$idate]) ? $event_day_counts[$idate] = 1 : $event_day_counts[$idate]++;
}
} else {
$event_day_counts[$date]++;
}
if ($event_day_counts[$date] <= $limit) {
$title = $EM_Event->output(get_option('dbem_emfc_full_calendar_event_format', '#_EVENTNAME'), 'raw');
$event_array = array("title" => $title, "color" => $color, 'textColor' => $textColor, 'borderColor' => $borderColor, "start" => date('Y-m-d\\TH:i:s', $EM_Event->start), "end" => date('Y-m-d\\TH:i:s', $EM_Event->end), "url" => $EM_Event->get_permalink(), 'post_id' => $EM_Event->post_id, 'event_id' => $EM_Event->event_id, 'allDay' => $EM_Event->event_all_day == true);
$events[] = apply_filters('wpfc_events_event', $event_array, $EM_Event);
}
}
if ($cell_data['events_count'] > $limit) {
$event_dates_more[$date] = 1;
$day_ending = $date . "T23:59:59";
$events[] = apply_filters('wpfc_events_more', array("title" => get_option('wpfc_limit_txt', 'more ...'), "color" => get_option('wpfc_limit_color', '#fbbe30'), "start" => $day_ending, "url" => str_replace('%s', $date, $event_page_link), 'post_id' => 0, 'event_id' => 0, 'allDay' => true), $date);
}
}
echo EM_Object::json_encode(apply_filters('wpfc_events', $events));
die;
}