0;');
return (count(array_filter($array, $my_not_empty)) == 0) ? 1 : 0;
}
function espresso_edit_attendee($registration_id, $attendee_id, $event_id = 0, $type = '', $text = '') {
global $org_options;
$html = '';
if ($text == '')
$text = __('Edit Attendee', 'event_espresso');
switch ($type) {
case'admin':
$html .= '' . $text . '';
break;
case'attendee':
default:
$array = array('r_id' => $registration_id, 'id' => $attendee_id, 'event_id' => $event_id, 'edit_attendee' => 'true', 'single' => 'true');
$url = add_query_arg($array, get_permalink($org_options['event_page_id']));
$html .= '' . $text . '';
//$html .= '' . $text . '';
break;
}
return $html;
}
function espresso_reg_url($event_id = 0) {
global $org_options;
if ($event_id > 0) {
//return espresso_getTinyUrl(home_url().'/?page_id='.$org_options['event_page_id'].'®event_action=register&event_id='.$event_id);
$new_url = add_query_arg('ee', $event_id, get_permalink($org_options['event_page_id']));
return $new_url;
}/* else {
echo 'No event id supplied'; */
return;
//}
}
function espresso_getTinyUrl($url) {
return file_get_contents("http://tinyurl.com/api-create.php?url=" . $url);
}
//Text formatting function.
//This should fix all of the formatting issues of text output from the database.
function espresso_format_content($content = '') {
return wpautop(stripslashes_deep(html_entity_decode(do_shortcode($content), ENT_QUOTES, "UTF-8")));
}
//This function pulls HTML entities back into HTML format first then strips it.
//Use it if you want to strip the HTML from the event_desc column in the daatabase.
//I have to store HTML as special chars in the database, because the html was breaking the sql queries.
//I tried doing add_slashes, then strip_slashes, but it kept adding to many slashes and not removing the extras. It was a nightmare so i decided to jsut make all HTML into special chars.
function event_espresso_strip_html_from_entity($html_entity) {
$stripped_html_entity = strip_tags(html_entity_decode($html_entity));
return $stripped_html_entity;
}
/* This function checks a registration id to see if their session is registered more than once, if so, it returns the session id */
function event_espresso_more_than_one($registration_id) {
global $wpdb;
$sql = "SELECT a.attendee_session FROM " . EVENTS_ATTENDEE_TABLE . " a JOIN " . EVENTS_ATTENDEE_TABLE . " b ON b.attendee_session = a.attendee_session WHERE b.registration_id='" . $registration_id . "' GROUP BY a.id";
$res = $wpdb->get_results($sql);
if ($wpdb->num_rows > 1) {
$attendee_session = $wpdb->get_var($sql . " ORDER BY a.id LIMIT 1 ");
return $attendee_session;
}
return null;
}
//For testing email functions
function event_espresso_test_email($optional_message = 'None') {
global $org_options;
$to = $org_options['contact_email'];
$subject = 'Event Espresso Test Message from' . $org_options['organization'];
$message = 'Event Espresso email is working properly. Optional message: ' . $optional_message;
$headers = 'From: ' . $org_options['contact_email'] . "\r\n" .
'Reply-To: ' . $org_options['contact_email'] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
wp_mail($to, $subject, $message, $headers);
}
//This function is not currently used
function event_espresso_session_start() {
/* if(!isset($_SESSION['event_espresso_sessionid'])){
$sessionid = (mt_rand(100,999).time());
$_SESSION['event_espresso_sessionid'] = $sessionid;
} */
//print_r( $_SESSION['event_espresso_sessionid']); //See if the session already exists
}
//This function just returns the session id.
function event_espresso_session_id() {
if (!isset($_SESSION['espresso_session']['id'])) {
$sessionid = (mt_rand(100, 999) . time());
$_SESSION['espresso_session']['id'] = $sessionid;
}
return $_SESSION['espresso_session']['id'];
}
//This function just returns the session id.
function espresso_reg_sessionid($registration_id) {
/* if(empty($_SESSION['espresso_reg_sessionid'])){
$sessionid = $registration_id;
//$sessionid = (mt_rand(100,999).time());
$_SESSION['espresso_reg_sessionid'] = $sessionid;
}
return $_SESSION['espresso_reg_sessionid']; */
}
//Function to display additional attendee fields.
if (!function_exists('event_espresso_additional_attendees')) {
function event_espresso_additional_attendees($event_id = 0, $additional_limit = 2, $available_spaces = 999, $label = '', $show_label = true, $event_meta = '') {
$event_id = $event_id == 0 ? $_REQUEST['event_id'] : $event_id;
if ($event_meta == 'admin') {
$admin = true;
$event_meta = '';
}
if ($event_meta == '' && ($event_id != '' || $event_id != 0)) {
$event_meta = event_espresso_get_event_meta($event_id);
}
//If the additional attednee questions are empty, then default to the first question group
if (empty($event_meta['add_attendee_question_groups']))
$event_meta['add_attendee_question_groups'] = array(1 => 1);
$i = 0;
if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == 1) {
$label = $label == '' ? __('Number of Tickets', 'event_espresso') : $label;
$html = '';
$html .= $show_label == true ? '' : '';
$html .= '';
//$html .= '
';
$html .= '';
$html .= '';
$buffer = '';
} else {
while (($i <= $additional_limit) && ($i < $available_spaces)) {
$i++;
}
$i = $i - 1;
$html = '
';
$htm .= '';
$htm .= '';
$htm .= '
[' . __('If you do not select a seat this attendee will not be added', 'event_espresso') . ']';
$htm .= '
'; $htm .= ''; $htm .= ''; $htm .= '
'; $htm .= ''; $htm .= ''; $htm .= ''; $htm .= '
'; $htm .= ''; $htm .= ''; $htm .= ''; $htm .= '
'; } else { $meta = array("x_attendee" => true); if(!empty($admin)) { $meta['admin_only'] = true; } $htm .= event_espresso_add_question_groups($event_meta['add_attendee_question_groups'], '', null, 0, $meta); } $htm .= ' tags from wrapping around our js scripts
Add this to your themes function.php file:
if ( !is_admin() ){
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'espresso_raw_formatter', 99);
}
*/
function espresso_raw_formatter($content) {
$new_content = '';
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($pieces as $piece) {
if (preg_match($pattern_contents, $piece, $matches)) {
$new_content .= $matches[1];
} else {
$new_content .= wptexturize(wpautop($piece));
}
}
return $new_content;
}
function event_espresso_get_event_meta($event_id) {
global $wpdb;
$event_meta = array();
$sql = "SELECT event_meta FROM " . EVENTS_DETAIL_TABLE . " e WHERE e.id = '" . $event_id . "' LIMIT 0,1";
if ($wpdb->get_results($sql)) {
$events = $wpdb->get_results($sql);
foreach ($events as $event) {
$event_meta = $event->event_meta;
$event_meta = unserialize($event_meta);
}
}
return $event_meta;
}
//This function returns the condition of an event
if (!function_exists('event_espresso_get_is_active')) {
function event_espresso_get_is_active($event_id, $event_meta = '') {
global $wpdb, $org_options;
//If the timezome is set in the wordpress database, then lets use it as the default timezone.
if (get_option('timezone_string') != '') {
date_default_timezone_set(get_option('timezone_string'));
}
if (!empty($event_meta)) {
$is_active = $event_meta['is_active'];
$event_status = $event_meta['event_status'];
$start_time = $event_meta['start_time'];
$start_date = $event_meta['start_date'];
$registration_start = $event_meta['registration_start'];
$registration_startT = $event_meta['registration_startT'];
$registration_end = $event_meta['registration_end'];
$registration_endT = $event_meta['registration_endT'];
$registration_start = $registration_start . " " . $registration_startT;
$registration_end = $registration_end . " " . $registration_endT;
} else {
$sql = "SELECT e.id, e.start_date start_date, e.is_active is_active, e.event_status event_status, e.registration_start, e.registration_startT, e.registration_end, e.registration_endT, ese.start_time start_time ";
$sql .= "FROM " . EVENTS_DETAIL_TABLE . " e ";
$sql .= "LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id ";
$sql .= "WHERE e.id = '" . $event_id . "' LIMIT 0,1";
$events = $wpdb->get_results($sql);
$start_date = $wpdb->last_result[0]->start_date;
$is_active = $wpdb->last_result[0]->is_active;
$event_status = $wpdb->last_result[0]->event_status;
$start_time = $wpdb->last_result[0]->start_time;
$registration_start = $wpdb->last_result[0]->registration_start . " " . $wpdb->last_result[0]->registration_startT;
$registration_end = $wpdb->last_result[0]->registration_end . " " . $wpdb->last_result[0]->registration_endT;
}
//$timezone_string = $wpdb->last_result[0]->timezone_string;
//$t = time();
//$today = date_at_timezone("Y-m-d H:i", $timezone_string, $t);
//Build the timestamps
$timestamp = strtotime($start_date . ' ' . $start_time); //Creates a timestamp from the event start date and start time
$registration_start_timestamp = strtotime($registration_start); //Creates a timestamp from the event registration start date
$registration_end_timestamp = strtotime($registration_end); //Creates a timestamp from the event registration start date
//echo $timestamp;
//echo date('Y-m-d h:i:s A', time());
//echo time('', $timestamp);
//echo date(time());
//echo ' event date = '.date( $timestamp);
//$org_options['expire_on_registration_end'] = 'Y';
//IF the event is ongoing, then display ongoing
if ($is_active == "Y" && $event_status == "O") {
$event_status = array('status' => 'ONGOING', 'display' => '' . __('ONGOING', 'event_espresso') . '', 'display_custom' => '' . __('Ongoing', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
//IF the event is a secondary event, show as waitlist
elseif ($is_active == "Y" && $event_status == "S") {
$event_status = array('status' => 'SECONDARY', 'display' => '' . __('WAITLIST', 'event_espresso') . '', 'display_custom' => '' . __('Waitlist', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
//IF the event is a waitlist/secondary event, show as waitlist
elseif ($is_active == "Y" && $event_status == "R") {
$event_status = array('status' => 'DRAFT', 'display' => '' . __('DRAFT', 'event_espresso') . '', 'display_custom' => '' . __('Draft', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
//IF the event is a pending event, show as pending
elseif ($is_active == "Y" && $event_status == "P") {
$event_status = array('status' => 'PENDING', 'display' => '' . __('PENDING', 'event_espresso') . '', 'display_custom' => '' . __('Pending', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
//IF the event is a denied event, show as denied
elseif ($is_active == "Y" && $event_status == "X") {
$event_status = array('status' => 'DENIED', 'display' => '' . __('DENIED', 'event_espresso') . '', 'display_custom' => '' . __('Denied', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
/* * * Check registration dates ** */
//If the registration end date is greater than the current date
elseif ($is_active == "Y" && date($registration_end_timestamp) <= date(time()) && $event_status != "D") {
$event_status = array('status' => 'REGISTRATION_CLOSED', 'display' => '' . __('CLOSED', 'event_espresso') . '', 'display_custom' => '' . __('Closed', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
//If the registration start date is less than the current date
elseif ($is_active == "Y" && date($registration_start_timestamp) >= date(time()) && $event_status != "D") {
$event_status = array('status' => 'REGISTRATION_NOT_OPEN', 'display' => '' . __('NOT_OPEN', 'event_espresso') . '', 'display_custom' => '' . __('Not Open', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
//If the registration start date is less than the current date
elseif ($is_active == "Y" && date($registration_start_timestamp) <= date(time()) && $event_status != "D") {
$event_status = array('status' => 'REGISTRATION_OPEN', 'display' => '' . __('OPEN', 'event_espresso') . '', 'display_custom' => '' . __('Open', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
/* * * End Check registration dates ** */
//If the start date and time has passed, show as expired.
elseif ($is_active == "Y" && date($timestamp) <= date(time()) && $event_status != "D") {
$event_status = array('status' => 'EXPIRED', 'display' => '' . __('EXPIRED', 'event_espresso') . '', 'display_custom' => '' . __('Expired', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
//If the start date and time has not passed, show as active.
elseif ($is_active == "Y" && date($timestamp) >= date(time()) && $event_status != "D") {
$event_status = array('status' => 'ACTIVE', 'display' => '' . __('ACTIVE', 'event_espresso') . '', 'display_custom' => '' . __('Active', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
//IF the event is not active, show as Not Active
elseif ($is_active == "N" && $event_status != "D") {
$event_status = array('status' => 'NOT_ACTIVE', 'display' => '' . __('NOT_ACTIVE', 'event_espresso') . '', 'display_custom' => '' . __('Not Active', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
//IF the event was deleted, show as deleted
elseif ($event_status == "D") {
$event_status = array('status' => 'DELETED', 'display' => '' . __('DELETED', 'event_espresso') . '', 'display_custom' => '' . __('Deleted', 'event_espresso') . '');
//print_r( $event_status);
return $event_status;
}
}
}
//This function returns the overall status of an event
if (!function_exists('event_espresso_get_status')) {
function event_espresso_get_status($event_id, $event_meta = '') {
$event_status = event_espresso_get_is_active($event_id, $event_meta);
switch ($event_status['status']) {
case 'EXPIRED':
case 'NOT_ACTIVE':
case 'DELETED':
case 'REGISTRATION_CLOSED':
case 'DENIED':
//case 'REGISTRATION_NOT_OPEN':
return 'NOT_ACTIVE';
break;
case 'PENDING':
case 'DRAFT':
return 'PENDING';
break;
case 'ACTIVE':
case 'ONGOING':
case 'SECONDARY':
case 'REGISTRATION_OPEN':
return 'ACTIVE';
break;
default:
break;
}
}
}
if (!function_exists('espresso_status_detail')) {
function espresso_status_detail($event_id) {
}
}
/* Formats the event address */
if (!function_exists('event_espresso_format_address')) {
function event_espresso_format_address($event_address) {
$event_address = str_replace(array("\r\n", "\n", "\r"), "
", $event_address);
return $event_address;
}
}
//Function for merging arrrays
function event_espresso_array_merge($array1, $array2) {
$result = array_merge($array1, $array2);
return $result;
}
// Append associative array elements
function event_espresso_array_push_associative(&$arr) {
$args = func_get_args();
foreach ($args as $arg) {
if (is_array($arg)) {
foreach ($arg as $key => $value) {
$arr[$key] = $value;
}
} else {
$arr[$arg] = "";
}
}
}
/*
* Display the amount of attendees and/or registration limit
* Available parameters for the get_number_of_attendees_reg_limit() function
* @ $event_id - required
* @ $type -
* available_spaces = returns the number of available spaces
* num_attendees = returns the number of attendees
* all_attendees = returns the number of all paid attendees
* reg_limit = returns the total number of spaces
* num_incomplete = returns the number of incomplete (non paid) registrations
* num_completed = returns the number of completed (paid) registrations
* num_completed_slash_incomplete = returns the number of completed and incomplete registrations separated by a slash (eg. 3/1)
* num_attendees_slash_reg_limit = returns the number of attendees and the registration limit separated by a slash (eg. 4/30)
* @ $full_text - the text to display when the event is full
*/
if (!function_exists('get_number_of_attendees_reg_limit')) {
function get_number_of_attendees_reg_limit($event_id, $type = 'NULL', $full_text = 'EVENT FULL') {
global $wpdb;
switch ($type) {
case 'available_spaces' :
case 'num_attendees' :
case 'number_available_spaces' :
case 'num_completed_slash_incomplete' :
case 'num_attendees_slash_reg_limit' :
case 'avail_spaces_slash_reg_limit' :
$num_attendees = 0;
$a_sql = "SELECT SUM(quantity) quantity FROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id='" . $event_id . "' AND (payment_status='Completed' OR payment_status='Pending') ";
$wpdb->get_results($a_sql, ARRAY_A);
if ($wpdb->num_rows > 0 && $wpdb->last_result[0]->quantity != NULL) {
$num_attendees = $wpdb->last_result[0]->quantity;
}
//break;
case 'reg_limit' :
case 'available_spaces' :
case 'number_available_spaces' :
case 'avail_spaces_slash_reg_limit' :
case 'num_attendees_slash_reg_limit' :
$number_available_spaces = 0;
$sql_reg_limit = "SELECT reg_limit FROM " . EVENTS_DETAIL_TABLE . " WHERE id='" . $event_id . "'";
$reg_limit = $wpdb->get_var($sql_reg_limit);
if (empty($num_attendees))
$num_attendees = 0;
if ($reg_limit > $num_attendees) {
$number_available_spaces = $reg_limit - $num_attendees;
}
//break;
case 'num_incomplete' :
case 'num_completed_slash_incomplete' :
$num_incomplete = 0;
$a_sql = "SELECT SUM(quantity) quantity FROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id='" . $event_id . "' AND payment_status='Incomplete'";
$wpdb->get_results($a_sql);
if ($wpdb->num_rows > 0 && $wpdb->last_result[0]->quantity != NULL) {
$num_incomplete = $wpdb->last_result[0]->quantity;
}
//break;
}
switch ($type) {
case 'number_available_spaces' :
return $number_available_spaces;
break;
case 'available_spaces' :
if ($reg_limit >= 999) {
$number_available_spaces = "Unlimited";
}
return $number_available_spaces;
break;
case 'num_attendees' :
return $num_attendees;
break;
case 'all_attendees' :
$a_sql = "SELECT SUM(quantity) quantity FROM " . EVENTS_ATTENDEE_TABLE . " WHERE quantity >= 1 ";
$attendees = $wpdb->get_results($a_sql);
if ($wpdb->num_rows > 0 && $wpdb->last_result[0]->quantity != NULL) {
$num_attendees = $wpdb->last_result[0]->quantity;
}
return $num_attendees;
break;
case 'reg_limit' :
return $reg_limit;
break;
case 'num_incomplete' :
return $num_incomplete;
break;
case 'num_completed' :
$num_completed = 0;
$a_sql = "SELECT SUM(quantity) quantity FROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id='" . $event_id . "' AND (payment_status='Completed' OR payment_status='Pending') ";
$wpdb->get_results($a_sql);
if ($wpdb->num_rows > 0 && $wpdb->last_result[0]->quantity != NULL) {
$num_completed = $wpdb->last_result[0]->quantity;
}
return $num_completed;
break;
case 'num_pending' :
$num_pending = 0;
$a_sql = "SELECT SUM(quantity) quantity FROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id='" . $event_id . "' AND payment_status='Pending'";
$wpdb->get_results($a_sql);
if ($wpdb->num_rows > 0 && $wpdb->last_result[0]->quantity != NULL) {
$num_pending = $wpdb->last_result[0]->quantity;
}
return $num_pending;
break;
case 'num_declined' :
$num_declined = 0;
$a_sql = "SELECT SUM(quantity) quantity FROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id='" . $event_id . "' AND payment_status='Payment Declined'";
$wpdb->get_results($a_sql);
if ($wpdb->num_rows > 0 && $wpdb->last_result[0]->quantity != NULL) {
$num_declined = $wpdb->last_result[0]->quantity;
}
return $num_declined;
break;
case 'num_completed_slash_incomplete' :
return '' . $num_attendees . '/' . $num_incomplete . '';
break;
case 'avail_spaces_slash_reg_limit' :
return $number_available_spaces . '/' . $reg_limit;
break;
case 'num_attendees_slash_reg_limit' :
default:
return $num_attendees . '/' . $reg_limit;
break;
}
}
}
function event_espresso_update_alert($url = '') {
return wp_remote_retrieve_body(wp_remote_get($url));
}
function espresso_registration_footer() {
global $espresso_premium, $org_options;
$url = (!isset($org_options['affiliate_id']) || $org_options['affiliate_id'] == '' || $org_options['affiliate_id'] == 0) ? 'http://eventespresso.com/' : 'https://www.e-junkie.com/ecom/gb.php?cl=113214&c=ib&aff=' . $org_options['affiliate_id'];
if ($espresso_premium != true || (isset($org_options['show_reg_footer']) && $org_options['show_reg_footer'] == 'Y')) {
return '
Event Registration and Ticketing Powered by Event Espresso
'; } } //Gets the current page url. Used for redirecting back to a page function event_espresso_cur_pageURL() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL; } //This function simply returns a custom capability, nothing else. Can be used to change admin capability of the Event Manager menu without the admin losing rights to certain menus. Should be used with the custom files addon. Credit goes to Justin Tadlock (http://justintadlock.com/archives/2009/09/18/custom-capabilities-in-plugins-and-themes) if (!function_exists('event_espresso_management_capability')) { function event_espresso_management_capability($default, $custom) { return $custom; } add_filter('event_espresso_management_capability', 'event_espresso_management_capability', 10, 3); } //Build the form questions. This function can be overridden using the custom files addon if (!function_exists('event_espresso_add_question_groups')) { function event_espresso_add_question_groups($question_groups, $answer = '', $event_id = null, $multi_reg = 0, $meta = array(), $class = 'my_class') { global $wpdb, $member_options; //If memebers addon is installed, check to see if we want to disable the form fields for members $disabled = ''; if ( function_exists('espresso_members_installed') && espresso_members_installed() == true ) { if ( is_user_logged_in() && $member_options['autofilled_editable'] == 'N' ) $disabled = 'disabled="disabled"'; } $event_id = empty($_REQUEST['event_id']) ? $event_id : $_REQUEST['event_id']; if (count($question_groups) > 0) { $questions_in = ''; $FILTER = ''; if (isset($_REQUEST['regevent_action'])) $FILTER = " AND q.admin_only = 'N' "; //echo 'additional_attendee_reg_info = '.$meta['additional_attendee_reg_info'].'".print_r($question_groups,true).""; foreach ($question_groups as $g_id) { $questions_in .= $g_id . ','; } $questions_in = substr($questions_in, 0, -1); $group_name = ''; $counter = 0; $sql = "SELECT q.*, qg.group_name, qg.group_description, qg.show_group_name, qg.show_group_description, qg.group_identifier FROM " . EVENTS_QUESTION_TABLE . " q JOIN " . EVENTS_QST_GROUP_REL_TABLE . " qgr ON q.id = qgr.question_id JOIN " . EVENTS_QST_GROUP_TABLE . " qg ON qg.id = qgr.group_id WHERE qgr.group_id in ( " . $questions_in . ") " . $FILTER . " ORDER BY qg.group_order ASC, qg.id, q.sequence, q.id ASC"; //echo $sql; $questions = $wpdb->get_results($sql); $num_rows = $wpdb->num_rows; $html = ''; if ($num_rows > 0) { $questions_displayed = array(); foreach ($questions as $question) { $counter++; if (!in_array($question->id, $questions_displayed)) { $questions_displayed[] = $question->id; //if new group, close fieldset $html .= ($group_name != '' && $group_name != $question->group_name) ? '' : ''; if ($group_name != $question->group_name) { $html .= '
' . $question->group_description . '
' : ''; $group_name = $question->group_name; } $html .= event_form_build($question, $answer, $event_id, $multi_reg, $meta, $class, $disabled); } $html .= $counter == $num_rows ? '' . __('Jquery is not loaded!', 'event_espresso') . '
' . __('Event Espresso is unable to load Jquery do to a conflict with your theme or another plugin.', 'event_espresso') . '
' . __('Missing wp_head() Function', 'event_espresso') . '
' . __('The WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso') . '
' . __('Missing wp_footer() Function', 'event_espresso') . '
' . __('The WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso') . '
' . $group . $ticket_link . '
'; } } /** * Function espresso_get_attendee_coupon_discount * Get discount amount for a given attendee id and cost * * @global wpdb $wpdb * @param int $attendee_id * @param double $cost */ function espresso_get_attendee_coupon_discount($attendee_id, $cost) { global $wpdb; $coupon_code = ""; $row = $wpdb->get_row($wpdb->prepare("select * from " . EVENTS_ATTENDEE_TABLE . " where id = %d", $attendee_id), ARRAY_A); if (!is_null($row['coupon_code']) && !empty($row['coupon_code'])) { $coupon_code = $row['coupon_code']; $event_id = $row['event_id']; //$results = $wpdb->get_results("SELECT * FROM ". EVENTS_DISCOUNT_CODES_TABLE ." WHERE coupon_code = '".$_REQUEST['coupon_code']."'"); $discounts = $wpdb->get_results("SELECT d.* FROM " . EVENTS_DISCOUNT_CODES_TABLE . " d JOIN " . EVENTS_DISCOUNT_REL_TABLE . " r ON r.discount_id = d.id WHERE d.coupon_code = '" . $coupon_code . "' AND r.event_id = '" . $event_id . "' "); if ($wpdb->num_rows > 0) { $valid_discount = true; foreach ($discounts as $discount) { $discount_id = $discount->id; $coupon_code = $discount->coupon_code; $coupon_code_price = $discount->coupon_code_price; $coupon_code_description = $discount->coupon_code_description; $use_percentage = $discount->use_percentage; } $discount_type_price = $use_percentage == 'Y' ? $coupon_code_price . '%' : $org_options['currency_symbol'] . $coupon_code_price; if ($use_percentage == 'Y') { $pdisc = $coupon_code_price / 100; $cost = $cost - ($cost * $pdisc); } else { $cost = $cost - $coupon_code_price; } } } return $cost; } //Returns the registration id from a url string function espresso_return_reg_id(){ if( isset($_REQUEST['registration_id']) && !empty($_REQUEST['registration_id']) ){ return $_REQUEST['registration_id']; }elseif ( isset($_REQUEST['r_id']) && !empty($_REQUEST['r_id']) ){ return $_REQUEST['r_id']; }else{ return false; } } //Build the registration id function espresso_build_registration_id($event_id){ return uniqid($event_id . '-'); } //Registration id filter add_filter('filter_hook_espresso_registration_id', 'espresso_build_registration_id', 10, 1);