/**
  * @param Object $object
  * @return array()
  */
 function get_row($object, $csv = false)
 {
     /* @var $EM_Ticket EM_Ticket */
     /* @var $EM_Ticket_Booking EM_Ticket_Booking */
     /* @var $EM_Booking EM_Booking */
     if (get_class($object) == 'EM_Ticket_Booking') {
         $EM_Ticket_Booking = $object;
         $EM_Ticket = $EM_Ticket_Booking->get_ticket();
         $EM_Booking = $EM_Ticket_Booking->get_booking();
     } else {
         $EM_Booking = $object;
     }
     $cols = array();
     foreach ($this->cols as $col) {
         //is col a user col or else?
         //TODO fix urls so this works in all pages in front as well
         if ($col == 'user_email') {
             $cols[] = $EM_Booking->get_person()->user_email;
         } elseif ($col == 'dbem_phone') {
             $cols[] = $EM_Booking->get_person()->phone;
         } elseif ($col == 'user_name') {
             if ($csv || get_option('dbem_bookings_registration_disable') && $EM_Booking->get_person()->ID == get_option('dbem_bookings_registration_user')) {
                 $cols[] = $EM_Booking->get_person()->get_name();
             } else {
                 $cols[] = '<a href="' . add_query_arg(array('person_id' => $EM_Booking->person_id, 'event_id' => null), $EM_Booking->get_event()->get_bookings_url()) . '">' . $EM_Booking->person->get_name() . '</a>';
             }
         } elseif ($col == 'first_name') {
             $cols[] = $EM_Booking->get_person()->first_name;
         } elseif ($col == 'last_name') {
             $cols[] = $EM_Booking->get_person()->last_name;
         } elseif ($col == 'event_name') {
             if ($csv) {
                 $cols[] = $EM_Booking->get_event()->event_name;
             } else {
                 $cols[] = '<a href="' . $EM_Booking->get_event()->get_bookings_url() . '">' . $this->events[$EM_Booking->event_id]->name . '</a>';
             }
         } elseif ($col == 'event_date') {
             $cols[] = $EM_Booking->get_event()->output('#_EVENTDATES');
         } elseif ($col == 'event_time') {
             $cols[] = $EM_Booking->get_event()->output('#_EVENTTIMES');
         } elseif ($col == 'booking_price') {
             if ($this->show_tickets && !empty($EM_Ticket)) {
                 $cols[] = em_get_currency_formatted(apply_filters('em_bookings_table_row_booking_price_ticket', $EM_Ticket_Booking->get_price(false, false, true), $EM_Booking, true));
             } else {
                 $cols[] = $EM_Booking->get_price(true);
             }
         } elseif ($col == 'booking_status') {
             $cols[] = $EM_Booking->get_status(true);
         } elseif ($col == 'booking_date') {
             $cols[] = date_i18n(get_option('dbem_date_format') . ' ' . get_option('dbem_time_format'), $EM_Booking->timestamp);
         } elseif ($col == 'actions') {
             if (!$csv) {
                 $cols[] = implode(' | ', $this->get_booking_actions($EM_Booking));
             }
         } elseif ($col == 'booking_spaces') {
             $cols[] = $this->show_tickets && !empty($EM_Ticket) ? $EM_Ticket_Booking->get_spaces() : $EM_Booking->get_spaces();
         } elseif ($col == 'booking_id') {
             $cols[] = $EM_Booking->booking_id;
         } elseif ($col == 'ticket_name' && $this->show_tickets && !empty($EM_Ticket)) {
             $cols[] = $EM_Ticket->{$col};
         } elseif ($col == 'ticket_description' && $this->show_tickets && !empty($EM_Ticket)) {
             $cols[] = $EM_Ticket->{$col};
         } elseif ($col == 'ticket_price' && $this->show_tickets && !empty($EM_Ticket)) {
             $cols[] = $EM_Ticket->get_price(true);
         } elseif ($col == 'ticket_id' && $this->show_tickets && !empty($EM_Ticket)) {
             $cols[] = $EM_Ticket->ticket_id;
         } elseif ($col == 'booking_comment') {
             $cols[] = $EM_Booking->booking_comment;
         } else {
             $val = apply_filters('em_bookings_table_rows_col_' . $col, '', $EM_Booking, $this, $csv);
             $cols[] = apply_filters('em_bookings_table_rows_col', $val, $col, $EM_Booking, $this, $csv);
         }
     }
     //clean up the cols to prevent nasty html or xss
     global $allowedposttags;
     foreach ($cols as $key => $col) {
         $cols[$key] = wp_kses($col, $allowedposttags);
     }
     return $cols;
 }
Exemplo n.º 2
0
 /**
  * Puts the coupon into a text representation in terms of discount
  */
 function get_discount_text()
 {
     $text = "";
     switch ($this->coupon_type) {
         case '%':
             //discount by percent
             $text = sprintf(__('%s Off', 'em-pro'), '%' . number_format($this->coupon_discount, 2));
             break;
         case '#':
             //discount by price
             $text = sprintf(__('%s Off', 'em-pro'), em_get_currency_formatted($this->coupon_discount));
             break;
     }
     return $text;
 }
Exemplo n.º 3
0
 function output($format, $target = "html")
 {
     preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $format, $placeholders);
     foreach ($this->get_tickets() as $EM_Ticket) {
         break;
     }
     //Get first ticket for single ticket placeholders
     $output_string = $format;
     $replaces = array();
     foreach ($placeholders[1] as $key => $result) {
         $replace = '';
         $full_result = $placeholders[0][$key];
         switch ($result) {
             case '#_BOOKINGID':
                 $replace = $this->booking_id;
                 break;
             case '#_RESPNAME':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGNAME':
                 $replace = $this->get_person()->get_name();
                 break;
             case '#_RESPEMAIL':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGEMAIL':
                 $replace = $this->get_person()->user_email;
                 break;
             case '#_RESPPHONE':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGPHONE':
                 $replace = $this->get_person()->phone;
                 break;
             case '#_BOOKINGSPACES':
                 $replace = $this->get_spaces();
                 break;
             case '#_BOOKINGLISTURL':
                 $replace = em_get_my_bookings_url();
                 break;
             case '#_COMMENT':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGCOMMENT':
                 $replace = $this->booking_comment;
                 break;
             case '#_BOOKINGPRICEWITHTAX':
                 $replace = em_get_currency_formatted($this->get_price(false, false, true));
                 break;
             case '#_BOOKINGPRICEWITHOUTTAX':
                 $replace = em_get_currency_formatted($this->get_price(false, false, false));
                 break;
             case '#_BOOKINGPRICETAX':
                 $replace = em_get_currency_formatted($this->get_price(false, false, false) * (get_option('dbem_bookings_tax') / 100));
                 break;
             case '#_BOOKINGPRICE':
                 $replace = em_get_currency_formatted($this->get_price());
                 break;
             case '#_BOOKINGTICKETNAME':
                 $replace = $EM_Ticket->name;
                 break;
             case '#_BOOKINGTICKETDESCRIPTION':
                 $replace = $EM_Ticket->description;
                 break;
             case '#_BOOKINGTICKETPRICEWITHTAX':
                 $replace = em_get_currency_formatted($EM_Ticket->get_price(false, true));
                 break;
             case '#_BOOKINGTICKETPRICEWITHOUTTAX':
                 $replace = em_get_currency_formatted($EM_Ticket->get_price(false, false));
                 break;
             case '#_BOOKINGTICKETTAX':
                 $replace = em_get_currency_formatted($EM_Ticket->get_price(false, false) * (get_option('dbem_bookings_tax') / 100));
                 break;
             case '#_BOOKINGTICKETPRICE':
                 $replace = em_get_currency_formatted($EM_Ticket->get_price());
                 break;
             case '#_BOOKINGTICKETS':
                 ob_start();
                 em_locate_template('emails/bookingtickets.php', true, array('EM_Booking' => $this));
                 $replace = ob_get_clean();
                 break;
             default:
                 $replace = $full_result;
                 break;
         }
         $replaces[$full_result] = apply_filters('em_booking_output_placeholder', $replace, $this, $full_result, $target);
     }
     //sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
     krsort($replaces);
     foreach ($replaces as $full_result => $replacement) {
         $output_string = str_replace($full_result, $replacement, $output_string);
     }
     //run event output too, since this is never run from within events and will not infinitely loop
     $output_string = $this->get_event()->output($output_string, $target);
     return apply_filters('em_booking_output', $output_string, $this, $format, $target);
 }
Exemplo n.º 4
0
/**
 * Shows a single booking for a single person. 
 */
function em_bookings_single()
{
    global $EM_Booking, $EM_Notices;
    //check that user can access this page
    if (is_object($EM_Booking) && !$EM_Booking->can_manage()) {
        ?>
		<div class="wrap"><h2><?php 
        _e('Unauthorized Access', 'dbem');
        ?>
</h2><p><?php 
        _e('You do not have the rights to manage this event.', 'dbem');
        ?>
</p></div>
		<?php 
        return false;
    }
    ?>
	<div class='wrap' id="em-bookings-admin-booking">
		<div class="icon32" id="icon-bookings"><br></div>
  		<h2>
  			<?php 
    _e('Edit Booking', 'dbem');
    ?>
  		</h2>
  		<?php 
    if (!is_admin()) {
        echo $EM_Notices;
    }
    ?>
  		<div id="poststuff" class="metabox-holder">
	  		<div id="post-body">
				<div id="post-body-content">
					<div class="stuffbox">
						<h3>
							<?php 
    _e('Event Details', 'dbem');
    ?>
						</h3>
						<div class="inside">
							<?php 
    $EM_Event = $EM_Booking->get_event();
    $localised_start_date = date_i18n(get_option('dbem_date_format'), $EM_Event->start);
    $localised_end_date = date_i18n(get_option('dbem_date_format'), $EM_Event->end);
    ?>
							<table>
								<tr><td><strong><?php 
    _e('Name', 'dbem');
    ?>
</strong></td><td><a class="row-title" href="<?php 
    echo $EM_Event->get_bookings_url();
    ?>
"><?php 
    echo $EM_Event->event_name;
    ?>
</a></td></tr>
								<tr>
									<td><strong><?php 
    _e('Date/Time', 'dbem');
    ?>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td>
									<td>
										<?php 
    echo $localised_start_date;
    ?>
										<?php 
    echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : '';
    ?>
										<?php 
    echo substr($EM_Event->start_time, 0, 5) . " - " . substr($EM_Event->end_time, 0, 5);
    ?>
									</td>
								</tr>
							</table>
							<?php 
    do_action('em_bookings_admin_booking_event', $EM_Event);
    ?>
						</div>
					</div> 		
					<div class="stuffbox">
						<h3>
							<?php 
    _e('Personal Details', 'dbem');
    ?>
						</h3>
						<div class="inside">
							<?php 
    echo $EM_Booking->get_person()->display_summary();
    ?>
							<?php 
    do_action('em_bookings_admin_booking_person', $EM_Booking);
    ?>
						</div>
					</div> 	
					<div class="stuffbox">
						<h3>
							<?php 
    _e('Booking Details', 'dbem');
    ?>
						</h3>
						<div class="inside">
							<?php 
    $EM_Event = $EM_Booking->get_event();
    $localised_start_date = date_i18n(get_option('date_format'), $EM_Event->start);
    $localised_end_date = date_i18n(get_option('date_format'), $EM_Event->end);
    $shown_tickets = array();
    ?>
							<div>
								<form action="" method="post" class="em-booking-single-status-info">
									<strong><?php 
    _e('Status', 'dbem');
    ?>
 : </strong>
									<?php 
    echo $EM_Booking->get_status();
    ?>
									<input type="button" class="em-booking-submit-status-modify" id="em-booking-submit-status-modify" value="<?php 
    _e('Change', 'dbem');
    ?>
" />
									<input type="submit" class="em-booking-resend-email" id="em-booking-resend-email" value="<?php 
    _e('Resend Email', 'dbem');
    ?>
" />
								 	<input type='hidden' name='action' value='booking_resend_email'/>
								 	<input type='hidden' name='booking_id' value='<?php 
    echo $EM_Booking->booking_id;
    ?>
'/>
								 	<input type='hidden' name='event_id' value='<?php 
    echo $EM_Event->event_id;
    ?>
'/>
								 	<input type='hidden' name='_wpnonce' value='<?php 
    echo wp_create_nonce('booking_resend_email_' . $EM_Booking->booking_id);
    ?>
'/>
								</form>
								<form action="" method="post" class="em-booking-single-status-edit">
									<strong><?php 
    _e('Status', 'dbem');
    ?>
 : </strong>
									<select name="booking_status">
										<?php 
    foreach ($EM_Booking->status_array as $status => $status_name) {
        ?>
										<option value="<?php 
        echo esc_attr($status);
        ?>
" <?php 
        if ($status == $EM_Booking->booking_status) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo esc_html($status_name);
        ?>
</option>
										<?php 
    }
    ?>
									</select>
									<input type="checkbox" checked="checked" name="send_email" value="1" />
									<?php 
    _e('Send Email', 'dbem');
    ?>
									<input type="submit" class="em-booking-submit-status" id="em-booking-submit-status" value="<?php 
    _e('Submit Changes', 'dbem');
    ?>
" />
									<input type="button" class="em-booking-submit-status-cancel" id="em-booking-submit-status-cancel" value="<?php 
    _e('Cancel', 'dbem');
    ?>
" />
								 	<input type='hidden' name='action' value='booking_set_status'/>
								 	<input type='hidden' name='booking_id' value='<?php 
    echo $EM_Booking->booking_id;
    ?>
'/>
								 	<input type='hidden' name='event_id' value='<?php 
    echo $EM_Event->event_id;
    ?>
'/>
								 	<input type='hidden' name='_wpnonce' value='<?php 
    echo wp_create_nonce('booking_set_status_' . $EM_Booking->booking_id);
    ?>
'/>
									<br /><em><?php 
    _e('<strong>Notes:</strong> Ticket availability not taken into account when approving new bookings (i.e. you can overbook).', 'dbem');
    ?>
</em>
								</form>
							</div>
							<form action="" method="post" class="em-booking-form">
								<table class="em-tickets-bookings-table" cellpadding="0" cellspacing="0">
									<thead>
									<tr>
										<th><?php 
    _e('Ticket Type', 'dbem');
    ?>
</th>
										<th><?php 
    _e('Spaces', 'dbem');
    ?>
</th>			
										<th><?php 
    _e('Price', 'dbem');
    ?>
</th>
									</tr>
									</thead>
									<tbody>
										<?php 
    foreach ($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking) {
        ?>
										<tr>
											<td class="ticket-type"><a class="row-title" href="<?php 
        echo em_add_get_params($EM_Event->get_bookings_url(), array('ticket_id' => $EM_Ticket_Booking->ticket_id));
        ?>
"><?php 
        echo $EM_Ticket_Booking->get_ticket()->ticket_name;
        ?>
</a></td>
											<td>
												<span class="em-booking-single-info"><?php 
        echo $EM_Ticket_Booking->get_spaces();
        ?>
</span>
												<div class="em-booking-single-edit"><input name="em_tickets[<?php 
        echo $EM_Ticket_Booking->ticket_id;
        ?>
][spaces]" class="em-ticket-select" id="em-ticket-spaces-<?php 
        echo $EM_Ticket_Booking->ticket_id;
        ?>
" value="<?php 
        echo $EM_Ticket_Booking->get_spaces();
        ?>
" /></div>
											</td>
											<td><?php 
        echo $EM_Ticket_Booking->get_price(true, true);
        ?>
</td>
										</tr>
										<?php 
        $shown_tickets[] = $EM_Ticket_Booking->ticket_id;
        do_action('em_bookings_admin_ticket_row', $EM_Ticket_Booking->get_ticket(), $EM_Booking);
        ?>
										<?php 
    }
    ?>
										<?php 
    if (count($shown_tickets) < count($EM_Event->get_bookings()->get_tickets()->tickets)) {
        ?>
<tr>
											<?php 
        foreach ($EM_Event->get_bookings()->get_tickets()->tickets as $EM_Ticket) {
            ?>
												<?php 
            if (!in_array($EM_Ticket->ticket_id, $shown_tickets)) {
                ?>
												<tr>
													<td class="ticket-type"><a class="row-title" href="<?php 
                echo em_add_get_params($EM_Event->get_bookings_url(), array('ticket_id' => $EM_Ticket->ticket_id));
                ?>
"><?php 
                echo $EM_Ticket->ticket_name;
                ?>
</a></td>
													<td>
														<span class="em-booking-single-info">0</span>
														<div class="em-booking-single-edit"><input name="em_tickets[<?php 
                echo $EM_Ticket->ticket_id;
                ?>
][spaces]" class="em-ticket-select" id="em-ticket-spaces-<?php 
                echo $EM_Ticket_Booking->ticket_id;
                ?>
" value="0" /></div>
													</td>
													<td><?php 
                echo em_get_currency_symbol();
                ?>
0.00</td>
												</tr>
												<?php 
                do_action('em_bookings_admin_ticket_row', $EM_Ticket, $EM_Booking);
                ?>
												<?php 
            }
            ?>
											<?php 
        }
        ?>
										<?php 
    }
    ?>
									</tbody>
									<tfoot>
										<?php 
    do_action('em_bookings_admin_ticket_totals_header');
    ?>
										<tr>
											<th><?php 
    _e('Total Price', 'dbem');
    ?>
</th>
											<th><?php 
    echo sprintf(__('%d Spaces', 'dbem'), $EM_Booking->get_spaces());
    ?>
</th>
											<th><?php 
    echo $EM_Booking->get_price(true, true);
    ?>
</th>
										</tr>
										<?php 
    if (!get_option('dbem_bookings_tax_auto_add') && is_numeric(get_option('dbem_bookings_tax')) && get_option('dbem_bookings_tax') > 0) {
        ?>
										<tr>
											<th><?php 
        _e('Tax', 'dbem');
        ?>
</th>
											<th><?php 
        echo get_option('dbem_bookings_tax');
        ?>
%</th>
											<th><?php 
        echo em_get_currency_formatted($EM_Booking->get_price() * (get_option('dbem_bookings_tax') / 100), 2);
        ?>
</th>
										</tr>
										<tr>
											<th><?php 
        _e('Total Price (inc. tax)', 'dbem');
        ?>
</th>
											<th>&nbsp;</th>
											<th><?php 
        echo $EM_Booking->get_price(false, true, true);
        ?>
</th>
										</tr>
										<?php 
    }
    ?>
										<?php 
    do_action('em_bookings_admin_ticket_totals_footer');
    ?>
									</tfoot>
								</table>
								<table class="em-form-fields" cellspacing="0" cellpadding="0">
									<?php 
    if (!has_action('em_bookings_single_custom')) {
        //default behaviour
        ?>
									<tr>
										<th><?php 
        _e('Comment', 'dbem');
        ?>
</th>
										<td>
											<span class="em-booking-single-info"><?php 
        echo $EM_Booking->booking_comment;
        ?>
</span>
											<div class="em-booking-single-edit"><textarea name="booking_comment"><?php 
        echo $EM_Booking->booking_comment;
        ?>
</textarea></div>
										</td>
									</tr>
									<?php 
    } else {
        do_action('em_bookings_single_custom', $EM_Booking);
        //do your own thing, e.g. pro
        ?>
									<?php 
    }
    ?>
								</table>
								<p class="em-booking-single-info">
									<input type="button" class="em-booking-submit-modify" id="em-booking-submit-modify" value="<?php 
    _e('Modify Booking', 'dbem');
    ?>
" />
								</p>
								<p class="em-booking-single-edit">
									<em><?php 
    _e('<strong>Notes:</strong> Ticket availability not taken into account (i.e. you can overbook). Emails are not resent automatically.', 'dbem');
    ?>
</em>
									<br /><br />
									<input type="submit" class="em-booking-submit" id="em-booking-submit" value="<?php 
    _e('Submit Changes', 'dbem');
    ?>
" />
									<input type="button" class="em-booking-submit-cancel" id="em-booking-submit-cancel" value="<?php 
    _e('Cancel', 'dbem');
    ?>
" />
								 	<input type='hidden' name='action' value='booking_save'/>
								 	<input type='hidden' name='booking_id' value='<?php 
    echo $EM_Booking->booking_id;
    ?>
'/>
								 	<input type='hidden' name='event_id' value='<?php 
    echo $EM_Event->event_id;
    ?>
'/>
								 	<input type='hidden' name='_wpnonce' value='<?php 
    echo wp_create_nonce('booking_save_' . $EM_Booking->booking_id);
    ?>
'/>
								</p>
							</form>
							<script type="text/javascript">
								jQuery(document).ready( function($){
									$('#em-booking-submit-modify').click(function(){
										$('.em-booking-single-info').hide();
										$('.em-booking-single-edit').show();
									});
									$('#em-booking-submit-cancel').click(function(){
										$('.em-booking-single-info').show();
										$('.em-booking-single-edit').hide();
									});	
									$('.em-booking-single-info').show();
									$('.em-booking-single-edit').hide();

									$('#em-booking-submit-status-modify').click(function(){
										$('.em-booking-single-status-info').hide();
										$('.em-booking-single-status-edit').show();
									});
									$('#em-booking-submit-status-cancel').click(function(){
										$('.em-booking-single-status-info').show();
										$('.em-booking-single-status-edit').hide();
									});	
									$('.em-booking-single-status-info').show();
									$('.em-booking-single-status-edit').hide();
								});
							</script>
						</div>
					</div>
					<div id="em-booking-notes" class="stuffbox">
						<h3>
							<?php 
    _e('Booking Notes', 'dbem');
    ?>
						</h3>
						<div class="inside">
							<p><?php 
    _e('You can add private notes below for internal reference that only event managers will see.', 'dbem');
    ?>
</p>
							<?php 
    foreach ($EM_Booking->get_notes() as $note) {
        $user = new EM_Person($note['author']);
        ?>
							<div>
								<?php 
        echo date(get_option('date_format'), $note['timestamp']) . ' - ' . $user->get_name();
        ?>
 <?php 
        _e('wrote', 'dbem');
        ?>
: 
								<p style="background:#efefef; padding:5px;"><?php 
        echo nl2br($note['note']);
        ?>
</p> 
							</div>
							<?php 
    }
    ?>
							<form method="post" action="" style="padding:5px;">
								<textarea class="widefat" rows="5" name="booking_note"></textarea>
								<input type="hidden" name="action" value="bookings_add_note" />
								<input type="submit" value="Add Note" />
							</form>
						</div>
					</div> 
					<?php 
    do_action('em_bookings_single_metabox_footer', $EM_Booking);
    ?>
 
				</div>
			</div>
		</div>
		<br style="clear:both;" />
		<?php 
    do_action('em_bookings_single_footer', $EM_Booking);
    ?>
	</div>
	<?php 
}
    static function view_page()
    {
        global $EM_Notices, $EM_Coupon, $wpdb;
        //check that user can access this page
        if (is_object($EM_Coupon) && !$EM_Coupon->can_manage('manage_bookings', 'manage_others_bookings')) {
            ?>
			<div class="wrap"><h2><?php 
            esc_html_e_emp('Unauthorized Access', 'dbem');
            ?>
</h2><p><?php 
            echo sprintf(esc_html__emp('You do not have the rights to manage this %s.', 'dbem'), __('coupon', 'em-pro'));
            ?>
</p></div>
			<?php 
            return false;
        } elseif (!is_object($EM_Coupon)) {
            $EM_Coupon = new EM_Coupon();
        }
        $limit = !empty($_GET['limit']) ? $_GET['limit'] : 20;
        //Default limit
        $page = !empty($_GET['pno']) ? $_GET['pno'] : 1;
        $offset = $page > 1 ? ($page - 1) * $limit : 0;
        //a bit hacky, but this is the only way at least for now
        $coupon_search = str_replace('a:1:{', '', serialize(array('coupon_code' => $EM_Coupon->coupon_code)));
        $coupon_search = substr($coupon_search, 0, strlen($coupon_search) - 1);
        $bookings = $wpdb->get_col('SELECT booking_id FROM ' . EM_BOOKINGS_TABLE . " WHERE booking_meta LIKE '%{$coupon_search}%' LIMIT {$limit} OFFSET {$offset}");
        //FIXME : coupon count not syncing correctly, using this as a fallback
        $coupons_count = $wpdb->get_var('SELECT COUNT(*) FROM ' . EM_BOOKINGS_TABLE . " WHERE booking_meta LIKE '%{$coupon_search}%'");
        $bookings_count = 0;
        $EM_Bookings = array();
        foreach ($bookings as $booking_id) {
            $EM_Booking = em_get_booking($booking_id);
            if (!empty($EM_Booking->booking_meta['coupon'])) {
                $coupon = new EM_Coupon($EM_Booking->booking_meta['coupon']);
                if ($EM_Coupon->coupon_code == $coupon->coupon_code && $EM_Coupon->coupon_id == $coupon->coupon_id) {
                    $bookings_count++;
                    $EM_Bookings[] = $EM_Booking;
                }
            }
        }
        ?>
		<div class='wrap nosubsub'>
			<div class="icon32" id="icon-bookings"><br></div>
			<h2><?php 
        _e('Coupon Usage History', 'em-pro');
        ?>
</h2>
			<?php 
        echo $EM_Notices;
        ?>
			<p><?php 
        echo sprintf(__('You are viewing the details of coupon %s - <a href="%s">edit</a>', 'em-pro'), '<code>' . $EM_Coupon->coupon_code . '</code>', add_query_arg(array('action' => 'edit')));
        ?>
</p>
			<p>
				<strong><?php 
        echo __('Uses', 'em-pro');
        ?>
:</strong> 
				<?php 
        if (!empty($EM_Coupon->coupon_max)) {
            echo esc_html($coupons_count . ' / ' . $EM_Coupon->coupon_max);
        } else {
            echo esc_html($coupons_count . '/' . __('Unlimited', 'em-pro'));
        }
        ?>
			</p>
			<?php 
        if ($coupons_count >= $limit) {
            ?>
			<div class='tablenav'>
				<?php 
            $bookings_nav = em_admin_paginate($coupons_count, $limit, $page, array());
            echo $bookings_nav;
            ?>
				<div class="clear"></div>
			</div>
			<?php 
        }
        ?>
			<div class="clear"></div>
			<?php 
        if ($bookings_count > 0) {
            ?>
			<div class='table-wrap'>
				<table id='dbem-bookings-table' class='widefat post '>
					<thead>
						<tr>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Event', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Booker', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Spaces', 'dbem');
            ?>
</th>
							<th><?php 
            _e('Original Total Price', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Coupon Discount', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Final Price', 'em-pro');
            ?>
</th>
							<th>&nbsp;</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Event', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Booker', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Spaces', 'dbem');
            ?>
</th>
							<th><?php 
            _e('Original Total Price', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Coupon Discount', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Final Price', 'em-pro');
            ?>
</th>
							<th>&nbsp;</th>
						</tr>
					</tfoot>
					<tbody>
						<?php 
            foreach ($EM_Bookings as $EM_Booking) {
                ?>
							<tr>
								<td><?php 
                echo $EM_Booking->output('#_BOOKINGSLINK');
                ?>
</td>
								<td><a href="<?php 
                echo EM_ADMIN_URL;
                ?>
&amp;page=events-manager-bookings&amp;person_id=<?php 
                echo $EM_Booking->person_id;
                ?>
"><?php 
                echo $EM_Booking->person->get_name();
                ?>
</a></td>
								<td><?php 
                echo $EM_Booking->get_spaces();
                ?>
</td>
								<td><?php 
                echo em_get_currency_formatted($EM_Booking->booking_meta['original_price']);
                ?>
</td>
								<td><?php 
                echo em_get_currency_formatted($EM_Booking->booking_meta['original_price'] - $EM_Booking->get_price());
                ?>
 <em>(<?php 
                echo $EM_Coupon->get_discount_text();
                ?>
)</em></td>
								<td><?php 
                echo em_get_currency_formatted($EM_Booking->get_price());
                ?>
</td>
								<td>										
									<?php 
                $edit_url = em_add_get_params($_SERVER['REQUEST_URI'], array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null));
                ?>
									<?php 
                if ($EM_Booking->can_manage()) {
                    ?>
									<a class="em-bookings-edit" href="<?php 
                    echo $edit_url;
                    ?>
"><?php 
                    esc_html_e_emp('Edit/View', 'dbem');
                    ?>
</a>
									<?php 
                }
                ?>
								</td>
							</tr>
							<?php 
            }
            ?>
					</tbody>
				</table>
			</div> <!-- table-wrap -->
			<?php 
        } else {
            ?>
			<p><?php 
            _e('Your coupon hasn\'t been used yet!', 'em-pro');
            ?>
</p>
			<?php 
        }
        ?>
		</div> <!-- wrap -->
		<?php 
    }
Exemplo n.º 6
0
 /**
  * Formats a price according to settings and currency
  * @param double $price
  * @return string
  */
 function format_price($price)
 {
     return em_get_currency_formatted($price);
 }
		<?php 
if ($has_taxes) {
    ?>
		<tr class="em-checkout-totals-tax">
			<th colspan="<?php 
    echo $cols;
    ?>
"><?php 
    _e('Taxes', 'em-pro');
    ?>
 ( <?php 
    echo $EM_Multiple_Booking->get_tax_rate();
    ?>
% )</th>
			<td><?php 
    echo em_get_currency_formatted($EM_Multiple_Booking->get_price(false, false, false) * (get_option('dbem_bookings_tax') / 100));
    ?>
</td>
		</tr>
		<?php 
}
?>
		<?php 
if ($has_discounts) {
    ?>
		<tr class="em-checkout-totals-discount">
			<th colspan="<?php 
    echo $cols;
    ?>
"><?php 
    _e('Discounts', 'em-pro');
Exemplo n.º 8
0
    /**
     * Will output a event in the format passed in $format by replacing placeholders within the format.
     * @param string $format
     * @param string $target
     * @return string
     */
    function output($format, $target = "html")
    {
        $event_string = $format;
        //Time place holder that doesn't show if empty.
        //TODO add filter here too
        preg_match_all('/#@?_\\{[^}]+\\}/', $format, $results);
        foreach ($results[0] as $result) {
            if (substr($result, 0, 3) == "#@_") {
                $date = 'end_date';
                $offset = 4;
            } else {
                $date = 'start_date';
                $offset = 3;
            }
            if ($date == 'end_date' && $this->event_end_date == $this->event_start_date) {
                $replace = __(apply_filters('em_event_output_placeholder', '', $this, $result, $target));
            } else {
                $replace = __(apply_filters('em_event_output_placeholder', mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $this->{$date}), $this, $result, $target));
            }
            $event_string = str_replace($result, $replace, $event_string);
        }
        //This is for the custom attributes
        preg_match_all('/#_ATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $format, $results);
        foreach ($results[0] as $resultKey => $result) {
            //Strip string of placeholder and just leave the reference
            $attRef = substr(substr($result, 0, strpos($result, '}')), 6);
            $attString = '';
            if (is_array($this->event_attributes) && array_key_exists($attRef, $this->event_attributes)) {
                $attString = $this->event_attributes[$attRef];
            } elseif (!empty($results[3][$resultKey])) {
                //Check to see if we have a second set of braces;
                $attString = $results[3][$resultKey];
            }
            $attString = apply_filters('em_event_output_placeholder', $attString, $this, $result, $target);
            $event_string = str_replace($result, $attString, $event_string);
        }
        //First let's do some conditional placeholder removals
        for ($i = 0; $i < get_option('dbem_conditional_recursions', 1); $i++) {
            //you can add nested recursions by modifying this setting in your wp_options table
            preg_match_all('/\\{([a-zA-Z0-9_]+)\\}(.+?)\\{\\/\\1\\}/s', $event_string, $conditionals);
            if (count($conditionals[0]) > 0) {
                //Check if the language we want exists, if not we take the first language there
                foreach ($conditionals[1] as $key => $condition) {
                    $show_condition = false;
                    if ($condition == 'has_bookings') {
                        //check if there's a booking, if not, remove this section of code.
                        $show_condition = $this->event_rsvp && get_option('dbem_rsvp_enabled');
                    } elseif ($condition == 'no_bookings') {
                        //check if there's a booking, if not, remove this section of code.
                        $show_condition = !$this->event_rsvp && get_option('dbem_rsvp_enabled');
                    } elseif ($condition == 'no_location') {
                        //does this event have a valid location?
                        $show_condition = empty($this->location_id) || !$this->get_location()->location_status;
                    } elseif ($condition == 'has_location') {
                        //does this event have a valid location?
                        $show_condition = !empty($this->location_id) && $this->get_location()->location_status;
                    } elseif ($condition == 'has_image') {
                        //does this event have an image?
                        $show_condition = $this->get_image_url() != '';
                    } elseif ($condition == 'no_image') {
                        //does this event have an image?
                        $show_condition = $this->get_image_url() == '';
                    } elseif ($condition == 'has_time') {
                        //are the booking times different and not an all-day event
                        $show_condition = $this->start != $this->end && !$this->event_all_day;
                    } elseif ($condition == 'no_time') {
                        //are the booking times exactly the same and it's not an all-day event.
                        $show_condition = $this->event_start_time == $this->event_end_time && !$this->event_all_day;
                    } elseif ($condition == 'all_day') {
                        //is it an all day event
                        $show_condition = !empty($this->event_all_day);
                    } elseif ($condition == 'logged_in') {
                        //user is logged in
                        $show_condition = is_user_logged_in();
                    } elseif ($condition == 'not_logged_in') {
                        //not logged in
                        $show_condition = !is_user_logged_in();
                    } elseif ($condition == 'has_spaces') {
                        //is it an all day event
                        $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() > 0;
                    } elseif ($condition == 'fully_booked') {
                        //is it an all day event
                        $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() <= 0;
                    } elseif ($condition == 'is_long') {
                        //is it an all day event
                        $show_condition = $this->event_start_date != $this->event_end_date;
                    } elseif ($condition == 'not_long') {
                        //is it an all day event
                        $show_condition = $this->event_start_date == $this->event_end_date;
                    } elseif ($condition == 'is_past') {
                        //if event is past
                        $show_condition = $this->start <= current_time('timestamp');
                    } elseif ($condition == 'is_future') {
                        //if event is upcoming
                        $show_condition = $this->start > current_time('timestamp');
                    }
                    $show_condition = apply_filters('em_event_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this);
                    if ($show_condition) {
                        //calculate lengths to delete placeholders
                        $placeholder_length = strlen($condition) + 2;
                        $replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key]) - ($placeholder_length * 2 + 1));
                    } else {
                        $replacement = '';
                    }
                    $event_string = str_replace($conditionals[0][$key], apply_filters('em_event_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $event_string);
                }
            }
        }
        //Now let's check out the placeholders.
        preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9_,]+)})?/", $format, $placeholders);
        $replaces = array();
        foreach ($placeholders[1] as $key => $result) {
            $match = true;
            $replace = '';
            $full_result = $placeholders[0][$key];
            switch ($result) {
                //Event Details
                case '#_EVENTID':
                    $replace = $this->event_id;
                    break;
                case '#_EVENTPOSTID':
                    $replace = $this->post_id;
                    break;
                case '#_NAME':
                    //depreciated
                //depreciated
                case '#_EVENTNAME':
                    $replace = $this->event_name;
                    break;
                case '#_NOTES':
                    //depreciated
                //depreciated
                case '#_EXCERPT':
                    //depreciated
                //depreciated
                case '#_EVENTNOTES':
                case '#_EVENTEXCERPT':
                    $replace = $this->post_content;
                    if ($result == "#_EXCERPT" || $result == "#_EVENTEXCERPT") {
                        if (!empty($this->post_excerpt)) {
                            $replace = $this->post_excerpt;
                        } else {
                            $matches = explode('<!--more', $this->post_content);
                            $replace = $matches[0];
                        }
                    }
                    break;
                case '#_EVENTIMAGEURL':
                case '#_EVENTIMAGE':
                    if ($this->get_image_url() != '') {
                        if ($result == '#_EVENTIMAGEURL') {
                            $replace = esc_url($this->image_url);
                        } else {
                            if (empty($placeholders[3][$key])) {
                                $replace = "<img src='" . esc_url($this->image_url) . "' alt='" . esc_attr($this->event_name) . "'/>";
                            } else {
                                $image_size = explode(',', $placeholders[3][$key]);
                                $image_src = $this->image_url;
                                if ($this->array_is_numeric($image_size) && count($image_size) > 1) {
                                    global $blog_id;
                                    if (is_multisite() && $blog_id > 0) {
                                        $imageParts = explode('/blogs.dir/', $image_src);
                                        if (isset($imageParts[1])) {
                                            $image_src = network_site_url('/wp-content/blogs.dir/' . $blog_id . '/' . $imageParts[1]);
                                        }
                                    }
                                    $replace = "<img src='" . esc_url(em_get_thumbnail_url($image_src, $image_size[0], $image_size[1])) . "' alt='" . esc_attr($this->event_name) . "'/>";
                                } else {
                                    $replace = "<img src='" . esc_url($image_src) . "' alt='" . esc_attr($this->event_name) . "'/>";
                                }
                            }
                        }
                    }
                    break;
                    //Times & Dates
                //Times & Dates
                case '#_24HSTARTTIME':
                case '#_24HENDTIME':
                    $time = $result == '#_24HSTARTTIME' ? $this->event_start_time : $this->event_end_time;
                    $replace = substr($time, 0, 5);
                    break;
                case '#_12HSTARTTIME':
                case '#_12HENDTIME':
                    $time = $result == '#_12HSTARTTIME' ? $this->event_start_time : $this->event_end_time;
                    $replace = date('g:i A', strtotime($time));
                    break;
                case '#_EVENTTIMES':
                    //get format of time to show
                    if (!$this->event_all_day) {
                        $time_format = get_option('dbem_time_format') ? get_option('dbem_time_format') : get_option('time_format');
                        if ($this->event_start_time != $this->event_end_time) {
                            $replace = date_i18n($time_format, $this->start) . get_option('dbem_times_seperator') . date_i18n($time_format, $this->end);
                        } else {
                            $replace = date_i18n($time_format, $this->start);
                        }
                    } else {
                        $replace = get_option('dbem_event_all_day_message');
                    }
                    break;
                case '#_EVENTDATES':
                    //get format of time to show
                    $date_format = get_option('dbem_date_format') ? get_option('dbem_date_format') : get_option('date_format');
                    if ($this->event_start_date != $this->event_end_date) {
                        $replace = date_i18n($date_format, $this->start) . get_option('dbem_dates_seperator') . date_i18n($date_format, $this->end);
                    } else {
                        $replace = date_i18n($date_format, $this->start);
                    }
                    break;
                    //Links
                //Links
                case '#_EVENTPAGEURL':
                    //Depreciated
                //Depreciated
                case '#_LINKEDNAME':
                    //Depreciated
                //Depreciated
                case '#_EVENTURL':
                    //Just the URL
                //Just the URL
                case '#_EVENTLINK':
                    //HTML Link
                    $event_link = esc_url($this->get_permalink());
                    if ($result == '#_LINKEDNAME' || $result == '#_EVENTLINK') {
                        $replace = '<a href="' . $event_link . '" title="' . esc_attr($this->event_name) . '">' . esc_attr($this->event_name) . '</a>';
                    } else {
                        $replace = $event_link;
                    }
                    break;
                case '#_EDITEVENTURL':
                case '#_EDITEVENTLINK':
                    if ($this->can_manage('edit_events', 'edit_others_events')) {
                        $link = esc_url($this->get_edit_url());
                        if ($result == '#_EDITEVENTLINK') {
                            $replace = '<a href="' . $link . '">' . esc_html(sprintf(__('Edit %s', 'dbem'), __('Event', 'dbem'))) . '</a>';
                        } else {
                            $replace = $link;
                        }
                    }
                    break;
                    //Bookings
                //Bookings
                case '#_ADDBOOKINGFORM':
                    //Depreciated
                //Depreciated
                case '#_REMOVEBOOKINGFORM':
                    //Depreciated
                //Depreciated
                case '#_BOOKINGFORM':
                    if (get_option('dbem_rsvp_enabled')) {
                        ob_start();
                        $template = em_locate_template('placeholders/bookingform.php', true, array('EM_Event' => $this));
                        if (!defined('EM_BOOKING_JS_LOADED')) {
                            //this kicks off the Javascript required by booking forms. This is fired once for all booking forms on a page load and appears at the bottom of the page
                            //your theme must call the wp_footer() function for this to work (as required by many other plugins too)
                            function em_booking_js_footer()
                            {
                                ?>
		
								<script type="text/javascript">
									jQuery(document).ready( function($){	
										<?php 
                                //we call the segmented JS files and include them here
                                include WP_PLUGIN_DIR . '/events-manager/includes/js/bookingsform.js';
                                do_action('em_gateway_js');
                                ?>
							
									});
								</script>
								<?php 
                            }
                            add_action('wp_footer', 'em_booking_js_footer');
                            add_action('admin_footer', 'em_booking_js_footer');
                            define('EM_BOOKING_JS_LOADED', true);
                        }
                        $replace = ob_get_clean();
                    }
                    break;
                case '#_BOOKINGBUTTON':
                    if (get_option('dbem_rsvp_enabled')) {
                        ob_start();
                        $template = em_locate_template('placeholders/bookingbutton.php', true, array('EM_Event' => $this));
                        $replace = ob_get_clean();
                    }
                    break;
                case '#_EVENTPRICERANGE':
                    //get the range of prices
                    $min = false;
                    $max = 0;
                    foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                        if ($EM_Ticket->get_price() > $max) {
                            $max = $EM_Ticket->get_price();
                        }
                        if ($EM_Ticket->get_price() < $min || $min === false) {
                            $min = $EM_Ticket->get_price();
                        }
                    }
                    if ($min === false) {
                        $min = 0;
                    }
                    if ($min != $max) {
                        $replace = em_get_currency_formatted($min) . ' - ' . em_get_currency_formatted($max);
                    } else {
                        $replace = em_get_currency_formatted($min);
                    }
                    break;
                case '#_EVENTPRICEMIN':
                    //get the range of prices
                    $min = false;
                    foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                        if ($EM_Ticket->get_price() < $min || $min === false) {
                            $min = $EM_Ticket->get_price();
                        }
                    }
                    if ($min === false) {
                        $min = 0;
                    }
                    $replace = em_get_currency_formatted($min);
                    break;
                case '#_EVENTPRICEMAX':
                    //get the range of prices
                    $max = 0;
                    foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                        if ($EM_Ticket->get_price() > $max) {
                            $max = $EM_Ticket->get_price();
                        }
                    }
                    $replace = em_get_currency_formatted($max);
                    break;
                case '#_AVAILABLESEATS':
                    //Depreciated
                //Depreciated
                case '#_AVAILABLESPACES':
                    if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                        $replace = $this->get_bookings()->get_available_spaces();
                    } else {
                        $replace = "0";
                    }
                    break;
                case '#_BOOKEDSEATS':
                    //Depreciated
                //Depreciated
                case '#_BOOKEDSPACES':
                    //This placeholder is actually a little misleading, as it'll consider reserved (i.e. pending) bookings as 'booked'
                    if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                        $replace = $this->get_bookings()->get_booked_spaces();
                        if (get_option('dbem_bookings_approval_reserved')) {
                            $replace += $this->get_bookings()->get_pending_spaces();
                        }
                    } else {
                        $replace = "0";
                    }
                    break;
                case '#_PENDINGSPACES':
                    if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                        $replace = $this->get_bookings()->get_pending_spaces();
                    } else {
                        $replace = "0";
                    }
                    break;
                case '#_SEATS':
                    //Depreciated
                //Depreciated
                case '#_SPACES':
                    $replace = $this->get_spaces();
                    break;
                case '#_BOOKINGSURL':
                case '#_BOOKINGSLINK':
                    if ($this->can_manage('manage_bookings', 'manage_others_bookings')) {
                        $bookings_link = esc_url($this->get_bookings_url());
                        if ($result == '#_BOOKINGSLINK') {
                            $replace = '<a href="' . $bookings_link . '" title="' . esc_attr($this->event_name) . '">' . esc_html($this->event_name) . '</a>';
                        } else {
                            $replace = $bookings_link;
                        }
                    }
                    break;
                    //Contact Person
                //Contact Person
                case '#_CONTACTNAME':
                case '#_CONTACTPERSON':
                    //Depreciated (your call, I think name is better)
                    $replace = $this->get_contact()->display_name;
                    break;
                case '#_CONTACTUSERNAME':
                    $replace = $this->get_contact()->user_login;
                    break;
                case '#_CONTACTEMAIL':
                case '#_CONTACTMAIL':
                    //Depreciated
                    $replace = $this->get_contact()->user_email;
                    break;
                case '#_CONTACTID':
                    $replace = $this->get_contact()->ID;
                    break;
                case '#_CONTACTPHONE':
                    $replace = $this->get_contact()->phone != '' ? $this->get_contact()->phone : __('N/A', 'dbem');
                    break;
                case '#_CONTACTAVATAR':
                    $replace = get_avatar($this->get_contact()->ID, $size = '50');
                    break;
                case '#_CONTACTPROFILELINK':
                case '#_CONTACTPROFILEURL':
                    if (function_exists('bp_core_get_user_domain')) {
                        $replace = bp_core_get_user_domain($this->get_contact()->ID);
                        if ($result == '#_CONTACTPROFILELINK') {
                            $replace = '<a href="' . esc_url($replace) . '">' . __('Profile', 'dbem') . '</a>';
                        }
                    }
                    break;
                case '#_CONTACTMETA':
                    if (!empty($placeholders[3][$key])) {
                        $replace = get_user_meta($this->event_owner, $placeholders[3][$key], true);
                    }
                    break;
                case '#_ATTENDEES':
                    ob_start();
                    $template = em_locate_template('placeholders/attendees.php', true, array('EM_Event' => $this));
                    $replace = ob_get_clean();
                    break;
                case '#_ATTENDEESLIST':
                    ob_start();
                    $template = em_locate_template('placeholders/attendeeslist.php', true, array('EM_Event' => $this));
                    $replace = ob_get_clean();
                    break;
                    //Categories and Tags
                //Categories and Tags
                case '#_EVENTCATEGORIESIMAGES':
                    ob_start();
                    $template = em_locate_template('placeholders/eventcategoriesimages.php', true, array('EM_Event' => $this));
                    $replace = ob_get_clean();
                    break;
                case '#_EVENTTAGS':
                    ob_start();
                    $template = em_locate_template('placeholders/eventtags.php', true, array('EM_Event' => $this));
                    $replace = ob_get_clean();
                    break;
                case '#_CATEGORIES':
                    //depreciated
                //depreciated
                case '#_EVENTCATEGORIES':
                    ob_start();
                    $template = em_locate_template('placeholders/categories.php', true, array('EM_Event' => $this));
                    $replace = ob_get_clean();
                    break;
                    //Ical Stuff
                //Ical Stuff
                case '#_EVENTICALURL':
                case '#_EVENTICALLINK':
                    $replace = $this->get_ical_url();
                    if ($result == '#_EVENTICALLINK') {
                        $replace = '<a href="' . esc_url($replace) . '">iCal</a>';
                    }
                    break;
                case '#_EVENTGCALURL':
                case '#_EVENTGCALLINK':
                    //get dates
                    if ($this->event_all_day && $this->event_start_date == $this->event_end_date) {
                        $dateStart = date('Ymd', $this->start - 60 * 60 * get_option('gmt_offset'));
                        $dateEnd = date('Ymd', $this->start + 60 * 60 * 24 - 60 * 60 * get_option('gmt_offset'));
                    } else {
                        $dateStart = date('Ymd\\THis\\Z', $this->start - 60 * 60 * get_option('gmt_offset'));
                        $dateEnd = date('Ymd\\THis\\Z', $this->end - 60 * 60 * get_option('gmt_offset'));
                    }
                    //build url
                    $gcal_url = 'http://www.google.com/calendar/event?action=TEMPLATE&text=event_name&dates=start_date/end_date&details=post_content&location=location_name&trp=false&sprop=event_url&sprop=name:blog_name';
                    $gcal_url = str_replace('event_name', urlencode($this->event_name), $gcal_url);
                    $gcal_url = str_replace('start_date', urlencode($dateStart), $gcal_url);
                    $gcal_url = str_replace('end_date', urlencode($dateEnd), $gcal_url);
                    $gcal_url = str_replace('location_name', urlencode($this->output('#_LOCATION')), $gcal_url);
                    $gcal_url = str_replace('blog_name', urlencode(get_bloginfo()), $gcal_url);
                    $gcal_url = str_replace('event_url', urlencode($this->get_permalink()), $gcal_url);
                    //calculate URL length so we know how much we can work with to make a description.
                    if (!empty($this->post_excerpt)) {
                        $gcal_url_description = $this->post_excerpt;
                    } else {
                        $matches = explode('<!--more', $this->post_content);
                        $gcal_url_description = wp_kses_data($matches[0]);
                    }
                    $gcal_url_length = strlen($gcal_url) - 9;
                    if (strlen($gcal_url_description) + $gcal_url_length > 1500) {
                        $gcal_url_description = substr($gcal_url_description, 0, 1530 - $gcal_url_length - 3) . '...';
                    }
                    $gcal_url = str_replace('post_content', urlencode($gcal_url_description), $gcal_url);
                    //get the final url
                    $replace = $gcal_url;
                    if ($result == '#_EVENTGCALLINK') {
                        $img_url = 'www.google.com/calendar/images/ext/gc_button2.gif';
                        $img_url = is_ssl() ? 'https://' . $img_url : 'http://' . $img_url;
                        $replace = '<a href="' . esc_url($replace) . '" target="_blank"><img src="' . esc_url($img_url) . '" alt="0" border="0"></a>';
                    }
                    break;
                default:
                    $replace = $full_result;
                    break;
            }
            $replaces[$full_result] = apply_filters('em_event_output_placeholder', $replace, $this, $full_result, $target);
        }
        //sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
        krsort($replaces);
        foreach ($replaces as $full_result => $replacement) {
            $event_string = str_replace($full_result, $replacement, $event_string);
        }
        //Time placeholders
        foreach ($placeholders[1] as $result) {
            // matches all PHP START date and time placeholders
            if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
                $replace = date_i18n(ltrim($result, "#"), $this->start);
                $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
                $event_string = str_replace($result, $replace, $event_string);
            }
            // matches all PHP END time placeholders for endtime
            if (preg_match('/^#@[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
                $replace = date_i18n(ltrim($result, "#@"), $this->end);
                $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
                $event_string = str_replace($result, $replace, $event_string);
            }
        }
        //Now do dependent objects
        if (!empty($this->location_id) && $this->get_location()->location_status) {
            $event_string = $this->get_location()->output($event_string, $target);
        } else {
            $EM_Location = new EM_Location();
            $event_string = $EM_Location->output($event_string, $target);
        }
        //for backwards compat and easy use, take over the individual category placeholders with the frirst cat in th elist.
        $EM_Categories = $this->get_categories();
        if (count($EM_Categories->categories) > 0) {
            $EM_Category = $EM_Categories->get_first();
        }
        if (empty($EM_Category)) {
            $EM_Category = new EM_Category();
        }
        $event_string = $EM_Category->output($event_string, $target);
        return apply_filters('em_event_output', $event_string, $this, $format, $target);
    }
Exemplo n.º 9
0
	<div  class="postbox " id="em-opt-pricing-options" >
	<div class="handlediv" title="<?php 
__('Click to toggle', 'dbem');
?>
"><br /></div><h3><span><?php 
echo sprintf(__('%s Options', 'dbem'), __('Pricing', 'dbem'));
?>
 </span></h3>
	<div class="inside">
		<table class='form-table'>
			<?php 
/* Tax & Currency */
em_options_select(__('Currency', 'dbem'), 'dbem_bookings_currency', em_get_currencies()->names, __('Choose your currency for displaying event pricing.', 'dbem'));
em_options_input_text(__('Thousands Separator', 'dbem'), 'dbem_bookings_currency_thousands_sep', '<code>' . get_option('dbem_bookings_currency_thousands_sep') . " = " . em_get_currency_symbol() . '100<strong>' . get_option('dbem_bookings_currency_thousands_sep') . '</strong>000<strong>' . get_option('dbem_bookings_currency_decimal_point') . '</strong>00</code>');
em_options_input_text(__('Decimal Point', 'dbem'), 'dbem_bookings_currency_decimal_point', '<code>' . get_option('dbem_bookings_currency_decimal_point') . " = " . em_get_currency_symbol() . '100<strong>' . get_option('dbem_bookings_currency_decimal_point') . '</strong>00</code>');
em_options_input_text(__('Currency Format', 'dbem'), 'dbem_bookings_currency_format', __('Choose how prices are displayed. <code>@</code> will be replaced by the currency symbol, and <code>#</code> will be replaced by the number.', 'dbem') . ' <code>' . get_option('dbem_bookings_currency_format') . " = " . em_get_currency_formatted('10000000') . '</code>');
em_options_input_text(__('Tax Rate', 'dbem'), 'dbem_bookings_tax', __('Add a tax rate to your ticket prices (entering 10 will add 10% to the ticket price).', 'dbem'));
em_options_radio_binary(__('Add tax to ticket price?', 'dbem'), 'dbem_bookings_tax_auto_add', __('When displaying ticket prices and booking totals, include the tax automatically?', 'dbem'));
echo $save_button;
?>

		</table>
	</div> <!-- . inside -->
	</div> <!-- .postbox --> 
	
	<div  class="postbox " id="em-opt-booking-feedbacks" >
	<div class="handlediv" title="<?php 
__('Click to toggle', 'dbem');
?>
"><br /></div><h3><span><?php 
_e('Customize Feedback Messages', 'dbem');
Exemplo n.º 10
0
    ?>

======================================

<?php 
    foreach ($EM_Booking->get_tickets_bookings() as $EM_Ticket_Booking) {
        /* @var $EM_Ticket_Booking EM_Ticket_Booking */
        echo $EM_Ticket_Booking->get_ticket()->ticket_name;
        ?>

Quantity: <?php 
        echo $EM_Ticket_Booking->get_spaces();
        ?>

Price: <?php 
        echo em_get_currency_formatted($EM_Ticket_Booking->get_price());
        ?>

<?php 
    }
    ?>

--------------------------------------
Spaces : <?php 
    echo $EM_Booking->get_spaces();
    ?>

Total : <?php 
    echo $EM_Booking->get_price(true);
    ?>
Exemplo n.º 11
0
 /**
  * Gets the total price for this whole booking. Seting $force_reset to true will recheck spaces, even if previously done so.
  * @param boolean $force_refresh
  * @param boolean $format
  * @param boolean $add_tax
  * @return float
  */
 function get_price($force_refresh = false, $format = false, $add_tax = 'x')
 {
     if ($force_refresh || $this->booking_price == 0 || $add_tax !== 'x' || get_option('dbem_bookings_tax_auto_add')) {
         $this->booking_price = $this->get_tickets_bookings()->get_price($force_refresh, false, $add_tax);
         $this->booking_price = apply_filters('em_booking_get_price', $this->booking_price, $this, $add_tax);
     }
     if ($format) {
         return em_get_currency_formatted($this->booking_price);
     }
     return $this->booking_price;
 }
Exemplo n.º 12
0
 /**
  * Gets the total price for this whole booking. Seting $force_reset to true will recheck spaces, even if previously done so.
  * @param boolean $force_refresh
  * @return float
  */
 function get_price($force_refresh = false, $format = false, $add_tax = 'x')
 {
     if ($force_refresh || $this->ticket_booking_price == 0 || $add_tax !== 'x' || get_option('dbem_bookings_tax_auto_add')) {
         //get the ticket, calculate price on spaces
         $this->ticket_booking_price = round($this->get_ticket()->get_price(false, $add_tax) * $this->ticket_booking_spaces, 2);
         $this->ticket_booking_price = apply_filters('em_ticket_booking_get_price', $this->ticket_booking_price, $this, $add_tax);
     }
     if ($format) {
         return em_get_currency_formatted($this->ticket_booking_price);
     }
     return $this->ticket_booking_price;
 }
Exemplo n.º 13
0
 /**
  * Gets the total price for this whole booking by adding up subtotals of booked tickets. Seting $force_reset to true will recheck spaces, even if previously done so.
  * @param boolean $force_refresh
  * @return float
  */
 function get_price($force_refresh = false, $format = false, $add_tax = 'x')
 {
     if ($force_refresh || $this->price == 0 || $add_tax !== 'x' || get_option('dbem_bookings_tax_auto_add')) {
         $price = 0;
         foreach ($this->tickets_bookings as $EM_Ticket_Booking) {
             $price += $EM_Ticket_Booking->get_price($force_refresh, false, $add_tax);
         }
         $this->price = apply_filters('em_tickets_bookings_get_price', $price, $this, $add_tax);
     }
     if ($format) {
         return em_get_currency_formatted($this->price);
     }
     return $this->price;
 }
function em_admin_options_page()
{
    global $wpdb, $EM_Notices;
    //Check for uninstall/reset request
    if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'uninstall') {
        em_admin_options_uninstall_page();
        return;
    }
    if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset') {
        em_admin_options_reset_page();
        return;
    }
    //TODO place all options into an array
    global $events_placeholder_tip, $locations_placeholder_tip, $categories_placeholder_tip, $bookings_placeholder_tip;
    $events_placeholders = '<a href="' . EM_ADMIN_URL . '&amp;page=events-manager-help#event-placeholders">' . __('Event Related Placeholders', 'dbem') . '</a>';
    $locations_placeholders = '<a href="' . EM_ADMIN_URL . '&amp;page=events-manager-help#location-placeholders">' . __('Location Related Placeholders', 'dbem') . '</a>';
    $bookings_placeholders = '<a href="' . EM_ADMIN_URL . '&amp;page=events-manager-help#booking-placeholders">' . __('Booking Related Placeholders', 'dbem') . '</a>';
    $categories_placeholders = '<a href="' . EM_ADMIN_URL . '&amp;page=events-manager-help#category-placeholders">' . __('Category Related Placeholders', 'dbem') . '</a>';
    $events_placeholder_tip = " " . sprintf(__('This accepts %s and %s placeholders.', 'dbem'), $events_placeholders, $locations_placeholders);
    $locations_placeholder_tip = " " . sprintf(__('This accepts %s placeholders.', 'dbem'), $locations_placeholders);
    $categories_placeholder_tip = " " . sprintf(__('This accepts %s placeholders.', 'dbem'), $categories_placeholders);
    $bookings_placeholder_tip = " " . sprintf(__('This accepts %s, %s and %s placeholders.', 'dbem'), $bookings_placeholders, $events_placeholders, $locations_placeholders);
    global $save_button;
    $save_button = '<tr><th>&nbsp;</th><td><p class="submit" style="margin:0px; padding:0px; text-align:right;"><input type="submit" class="button-primary" id="dbem_options_submit" name="Submit" value="' . __('Save Changes', 'dbem') . ' (' . __('All', 'dbem') . ')" /></p></ts></td></tr>';
    ?>
	<script type="text/javascript" charset="utf-8">
		jQuery(document).ready(function($){
			//Meta Box Options
			var close_text = '<?php 
    _e('Collapse All', 'dbem');
    ?>
';
			var open_text = '<?php 
    _e('Expand All', 'dbem');
    ?>
';
			var open_close = $('<a href="#" style="display:block; float:right; clear:right; margin:10px;">'+open_text+'</a>');
			$('#em-options-title').before(open_close);
			open_close.click( function(e){
				e.preventDefault();
				if($(this).text() == close_text){
					$(".postbox").addClass('closed');
					$(this).text(open_text);
				}else{
					$(".postbox").removeClass('closed');
					$(this).text(close_text);
				} 
			});
			$(".postbox > h3").click(function(){ $(this).parent().toggleClass('closed'); });
			$(".postbox").addClass('closed');
			//Navigation Tabs
			$('.nav-tab-wrapper .nav-tab').click(function(){
				$('.nav-tab-wrapper .nav-tab').removeClass('nav-tab-active');
				el = $(this);
				elid = el.attr('id');
				$('.em-menu-group').hide(); 
				$('.'+elid).show();
				el.addClass('nav-tab-active');
				$(".postbox").addClass('closed');
				open_close.text(open_text);
			});
			var navUrl = document.location.toString();
			if (navUrl.match('#')) { //anchor-based navigation
				var current_tab = 'a#em-menu-' + navUrl.split('#')[1];
				$(current_tab).trigger('click');
			}
			$('.nav-tab-link').click(function(){ $($(this).attr('rel')).trigger('click'); }); //links to mimick tabs
			//Page Options
			$('input[name="dbem_cp_events_has_archive"]').change(function(){ //event archives
				if( $('input:radio[name="dbem_cp_events_has_archive"]:checked').val() == 1 ){
					$('tbody.em-event-archive-sub-options').show();
				}else{
					$('tbody.em-event-archive-sub-options').hide();
				}
			}).trigger('change');
			$('select[name="dbem_events_page"]').change(function(){
				if( $('select[name="dbem_events_page"]').val() == 0 ){
					$('tbody.em-event-page-options').hide();
				}else{
					$('tbody.em-event-page-options').show();
				}
			}).trigger('change');
			$('input[name="dbem_cp_locations_has_archive"]').change(function(){ //location archives
				if( $('input:radio[name="dbem_cp_locations_has_archive"]:checked').val() == 1 ){
					$('tbody.em-location-archive-sub-options').show();
				}else{
					$('tbody.em-location-archive-sub-options').hide();
				}
			}).trigger('change');
			//For rewrite titles
			$('input:radio[name=dbem_disable_title_rewrites]').live('change',function(){
				checked_check = $('input:radio[name=dbem_disable_title_rewrites]:checked');
				if( checked_check.val() == 1 ){
					$('#dbem_title_html_row').show();
				}else{
					$('#dbem_title_html_row').hide();	
				}
			});
			$('input:radio[name=dbem_disable_title_rewrites]').trigger('change');
			//ML Stuff
			$('.em-translatable').click(function(){
				$(this).nextAll('.em-ml-options').toggle();
			});
		});
	</script>
	<style type="text/css">.postbox h3 { cursor:pointer; }</style>
	<div class="wrap">		
		<div id='icon-options-general' class='icon32'><br /></div>
		<h2 class="nav-tab-wrapper">
			<a href="#general" id="em-menu-general" class="nav-tab nav-tab-active"><?php 
    _e('General', 'dbem');
    ?>
</a>
			<a href="#pages" id="em-menu-pages" class="nav-tab"><?php 
    _e('Pages', 'dbem');
    ?>
</a>
			<a href="#formats" id="em-menu-formats" class="nav-tab"><?php 
    _e('Formatting', 'dbem');
    ?>
</a>
			<?php 
    if (get_option('dbem_rsvp_enabled')) {
        ?>
			<a href="#bookings" id="em-menu-bookings" class="nav-tab"><?php 
        _e('Bookings', 'dbem');
        ?>
</a>
			<?php 
    }
    ?>
			<a href="#emails" id="em-menu-emails" class="nav-tab"><?php 
    _e('Emails', 'dbem');
    ?>
</a>
		</h2>
		<h3 id="em-options-title"><?php 
    _e('Event Manager Options', 'dbem');
    ?>
</h3>
		<form id="em-options-form" method="post" action="">
			<div class="metabox-holder">         
			<!-- // TODO Move style in css -->
			<div class='postbox-container' style='width: 99.5%'>
			<div id="">
		  
		  	<div class="em-menu-general em-menu-group">
			  
			  	<!-- GENERAL OPTIONS -->
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('General Options', 'dbem');
    ?>
 </span></h3>
				<div class="inside">
		            <table class="form-table">
			            <?php 
    em_options_radio_binary(__('Disable thumbnails?', 'dbem'), 'dbem_thumbnails_enabled', __('Select yes to disable Events Manager from enabling thumbnails (some themes may already have this enabled, which we cannot be turned off here).', 'dbem'));
    ?>
					
						<tr>
							<td colspan="2">
								<h4><?php 
    echo sprintf(__('%s Settings', 'dbem'), __('Event', 'dbem'));
    ?>
</h4>
							</td>
						</tr>
						<?php 
    em_options_radio_binary(__('Enable recurrence?', 'dbem'), 'dbem_recurrence_enabled', __('Select yes to enable the recurrence features feature', 'dbem'));
    em_options_radio_binary(__('Enable bookings?', 'dbem'), 'dbem_rsvp_enabled', __('Select yes to allow bookings and tickets for events.', 'dbem'));
    em_options_radio_binary(__('Enable tags?', 'dbem'), 'dbem_tags_enabled', __('Select yes to enable the tag features', 'dbem'));
    if (!(EM_MS_GLOBAL && !is_main_site())) {
        em_options_radio_binary(__('Enable categories?', 'dbem'), 'dbem_categories_enabled', __('Select yes to enable the category features', 'dbem'));
        if (get_option('dbem_categories_enabled')) {
            /*default category*/
            $category_options = array();
            $category_options[0] = __('no default category', 'dbem');
            $EM_Categories = EM_Categories::get();
            foreach ($EM_Categories as $EM_Category) {
                $category_options[$EM_Category->id] = $EM_Category->name;
            }
            echo "<tr><td>" . __('Default Category', 'dbem') . "</td><td>";
            wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'dbem_default_category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => get_option('dbem_default_category'), 'show_option_none' => __('None', 'dbem'), 'class' => ''));
            echo "</br><em>" . __('This option allows you to select the default category when adding an event.', 'dbem') . ' ' . __('If an event does not have a category assigned when editing, this one will be assigned automatically.', 'dbem') . "</em>";
            echo "</td></tr>";
        }
    }
    em_options_radio_binary(sprintf(__('Enable %s attributes?', 'dbem'), __('event', 'dbem')), 'dbem_attributes_enabled', __('Select yes to enable the attributes feature', 'dbem'));
    em_options_radio_binary(sprintf(__('Enable %s custom fields?', 'dbem'), __('event', 'dbem')), 'dbem_cp_events_custom_fields', __('Custom fields are the same as attributes, except you cannot restrict specific values, users can add any kind of custom field name/value pair. Only available in the WordPress admin area.', 'dbem'));
    if (get_option('dbem_attributes_enabled')) {
        em_options_textarea(sprintf(__('%s Attributes', 'dbem'), __('Event', 'dbem')), 'dbem_placeholders_custom', sprintf(__("You can also add event attributes here, one per line in this format <code>#_ATT{key}</code>. They will not appear on event pages unless you insert them into another template below, but you may want to store extra information about an event for other uses. <a href='%s'>More information on placeholders.</a>", 'dbem'), EM_ADMIN_URL . '&amp;page=events-manager-help'));
    }
    if (get_option('dbem_locations_enabled')) {
        /*default location*/
        $location_options = array();
        $location_options[0] = __('no default location', 'dbem');
        $EM_Locations = EM_Locations::get();
        foreach ($EM_Locations as $EM_Location) {
            $location_options[$EM_Location->location_id] = $EM_Location->location_name;
        }
        em_options_select(__('Default Location', 'dbem'), 'dbem_default_location', $location_options, __('This option allows you to select the default location when adding an event.', 'dbem') . " " . __('(not applicable with event ownership on presently, coming soon!)', 'dbem'));
        /*default location country*/
        em_options_select(__('Default Location Country', 'dbem'), 'dbem_location_default_country', em_get_countries(__('no default country', 'dbem')), __('If you select a default country, that will be pre-selected when creating a new location.', 'dbem'));
    }
    ?>
						<tr>
							<td colspan="2">
								<h4><?php 
    echo sprintf(__('%s Settings', 'dbem'), __('Location', 'dbem'));
    ?>
</h4>
							</td>
						</tr>
						<?php 
    em_options_radio_binary(__('Enable locations?', 'dbem'), 'dbem_locations_enabled', __('If you disable locations, bear in mind that you should remove your location page, shortcodes and related placeholders from your <a href="#formats" class="nav-tab-link" rel="#em-menu-formats">formats</a>.', 'dbem'));
    if (get_option('dbem_locations_enabled')) {
        em_options_radio_binary(__('Require locations for events?', 'dbem'), 'dbem_require_location', __('Setting this to no will allow you to submit events without locations. You can use the <code>{no_location}...{/no_location}</code> or <code>{has_location}..{/has_location}</code> conditional placeholder to selectively display location information.', 'dbem'));
        em_options_radio_binary(__('Use dropdown for locations?', 'dbem'), 'dbem_use_select_for_locations', __('Select yes to select location from a drow-down menu; location selection will be faster, but you will lose the ability to insert locations with events', 'dbem'));
        em_options_radio_binary(sprintf(__('Enable %s attributes?', 'dbem'), __('location', 'dbem')), 'dbem_location_attributes_enabled', __('Select yes to enable the attributes feature', 'dbem'));
        em_options_radio_binary(sprintf(__('Enable %s custom fields?', 'dbem'), __('location', 'dbem')), 'dbem_cp_locations_custom_fields', __('Custom fields are the same as attributes, except you cannot restrict specific values, users can add any kind of custom field name/value pair. Only available in the WordPress admin area.', 'dbem'));
        if (get_option('dbem_location_attributes_enabled')) {
            em_options_textarea(sprintf(__('%s Attributes', 'dbem'), __('Location', 'dbem')), 'dbem_location_placeholders_custom', sprintf(__("You can also add location attributes here, one per line in this format <code>#_LATT{key}</code>. They will not appear on location pages unless you insert them into another template below, but you may want to store extra information about an event for other uses. <a href='%s'>More information on placeholders.</a>", 'dbem'), EM_ADMIN_URL . '&amp;page=events-manager-help'));
        }
    }
    ?>
						<tr>
							<td colspan="2">
								<h4><?php 
    echo sprintf(__('%s Settings', 'dbem'), __('Other', 'dbem'));
    ?>
</h4>
							</td>
						</tr>
						<?php 
    em_options_radio_binary(__('Show some love?', 'dbem'), 'dbem_credits', __('Hundreds of free hours have gone into making this free plugin, show your support and add a small link to the plugin website at the bottom of your event pages.', 'dbem'));
    echo $save_button;
    ?>
					</table>
					    
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->
				
				<?php 
    if (!is_multisite()) {
        em_admin_option_box_image_sizes();
    }
    ?>
				
				<?php 
    if (!is_multisite() || is_super_admin() && !get_site_option('dbem_ms_global_caps')) {
        em_admin_option_box_caps();
    }
    ?>
				
				<div  class="postbox" >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('Event Submission Forms', 'dbem');
    ?>
</span></h3>
				<div class="inside">
			            <table class="form-table">
			            <tr><td colspan="2">
			            	<?php 
    echo sprintf(__('You can allow users to publicly submit events on your blog by using the %s shortcode, and enabling anonymous submissions below.', 'dbem'), '<code>[event_form]</code>');
    ?>
						</td></tr>
						<?php 
    em_options_radio_binary(__('Use Visual Editor?', 'dbem'), 'dbem_events_form_editor', __('Users can now use the WordPress editor for easy HTML entry in the submission form.', 'dbem'));
    em_options_radio_binary(__('Show form again?', 'dbem'), 'dbem_events_form_reshow', __('When a user submits their event, you can display a new event form again.', 'dbem'));
    em_options_textarea(__('Success Message', 'dbem'), 'dbem_events_form_result_success', __('Customize the message your user sees when they submitted their event.', 'dbem') . $events_placeholder_tip);
    em_options_textarea(__('Successfully Updated Message', 'dbem'), 'dbem_events_form_result_success_updated', __('Customize the message your user sees when they resubmit/update their event.', 'dbem') . $events_placeholder_tip);
    ?>
			            <tr><td colspan="2">
			            	<strong><?php 
    echo sprintf(__('Anonymous event submissions', 'dbem'), '<code>[event_form]</code>');
    ?>
</strong>
						</td></tr>
			            <?php 
    em_options_radio_binary(__('Allow anonymous event submissions?', 'dbem'), 'dbem_events_anonymous_submissions', __('Would you like to allow users to submit bookings anonymously? If so, you can use the new [event_form] shortcode or <code>em_event_form()</code> template tag with this enabled.', 'dbem'));
    em_options_select(__('Guest Default User', 'dbem'), 'dbem_events_anonymous_user', em_get_wp_users(), __('Events require a user to own them. In order to allow events to be submitted anonymously you need to assign that event a specific user. We recommend you create a "Anonymous" subscriber with a very good password and use that. Guests will have the same event permissions as this user when submitting.', 'dbem'));
    em_options_textarea(__('Success Message', 'dbem'), 'dbem_events_anonymous_result_success', __('Anonymous submitters cannot see or modify their event once submitted. You can customize the success message they see here.', 'dbem') . $events_placeholder_tip);
    ?>
				        <?php 
    echo $save_button;
    ?>
					</table>
				</div> <!-- . inside --> 
				</div> <!-- .postbox --> 

				<?php 
    do_action('em_options_page_footer');
    ?>
				
				<div  class="postbox" >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('Performance Optimization', 'dbem');
    ?>
 (<?php 
    _e('Advanced', 'dbem');
    ?>
) <em>Beta</em></span></h3>
				<div class="inside">
					<?php 
    $performance_opt_page_instructions = __('In the boxes below, you are expected to write the page IDs. For multiple pages, use comma-seperated values e.g. 1,2,3. Entering 0 means EVERY page, -1 means the home page.', 'dbem');
    ?>
					<p><?php 
    _e('This section allows you to configure parts of this plugin that will improve performance on your site and increase page speeds by reducing extra files from being unnecessarily included on pages as well as reducing server loads where possible. This only applies to pages outside the admin area.', 'dbem');
    ?>
</p>
					<p><em><strong><?php 
    _e('Warning!', 'dbem');
    ?>
</strong> <?php 
    echo sprintf(__('This is for advanced users, you should know what you\'re doing here or things will not work properly. For more information on how these options work see our <a href="%s" target="_blank">optimization recommendations</a>', 'dbem'), 'http://wp-events-plugin.com/documentation/optimization-recommendations/');
    ?>
</em></p>
			            <table class="form-table">
			            <tr><td colspan="2">
			            	<strong><?php 
    _e('JavaScript Files', 'dbem');
    ?>
</strong>
			            	<p><?php 
    echo sprintf(__('If you are not using it already, we recommend you try the <a href="%s" target="_blank">Use Google Libraries</a> plugin, because without further optimization options below it already significantly reduces the number of files needed to display your Event pages and will most likely speed up your overall website loading time.', 'dbem'), 'http://wordpress.org/extend/plugins/use-google-libraries/');
    ?>
						</td></tr>
						<?php 
    em_options_radio_binary(__('Limit JS file loading?', 'dbem'), 'dbem_js_limit', __('Prevent unnecessary loading of JavaScript files on pages where they are not needed.', 'dbem'));
    ?>
						<tbody id="dbem-js-limit-options">
							<tr><td colspan="2">
				            	<?php 
    _e('Aside from pages we automatically generate and include certain jQuery files, if you are using Widgets, Shortcode or PHP to display specific items you may need to tell us where you are using them for them to work properly. Below are options for you to include specific jQuery dependencies only on certain pages.', 'dbem');
    echo $performance_opt_page_instructions;
    ?>
							</td></tr>
							<?php 
    em_options_input_text(__('General JS', 'dbem'), 'dbem_js_limit_general', __('Loads our own JS file if no other dependencies are already loaded, which is still needed for many items generated by EM using JavaScript such as Calendars, Maps and Booking Forms/Buttons', 'dbem'), 0);
    em_options_input_text(__('Search Forms', 'dbem'), 'dbem_js_limit_search', __('Include pages where you use shortcodes or widgets to display event search forms.', 'dbem'));
    em_options_input_text(__('Event Edit and Submission Forms', 'dbem'), 'dbem_js_limit_events_form', __('Include pages where you use shortcode or PHP to display event submission forms.', 'dbem'));
    em_options_input_text(__('Booking Management Pages', 'dbem'), 'dbem_js_limit_edit_bookings', __('Include pages where you use shortcode or PHP to display event submission forms.', 'dbem'));
    ?>
						</tbody>
			            <tr><td colspan="2" style="font-weight:bold;">
			            	<?php 
    _e('CSS File', 'dbem');
    ?>
						</td></tr>
			            <?php 
    em_options_radio_binary(__('Limit loading of our CSS files?', 'dbem'), 'dbem_css_limit', __('Enabling this will prevent us from loading our CSS file on every page, and will only load on specific pages generated by Events Manager.', 'dbem'));
    ?>
							<tbody id="dbem-css-limit-options">
							<tr><td colspan="2">
				            	<?php 
    echo $performance_opt_page_instructions;
    ?>
							</td></tr>
							<?php 
    em_options_input_text(__('Include on', 'dbem'), 'dbem_css_limit_include', __('Our CSS file will only be INCLUDED on all of these pages.', 'dbem'), 0);
    em_options_input_text(__('Exclude on', 'dbem'), 'dbem_css_limit_exclude', __('Our CSS file will be EXCLUDED on all of these pages. Takes precedence over inclusion rules.', 'dbem'), 0);
    ?>
			            	</tbody>
			            	<?php 
    ?>
			            <tr><td colspan="2">
			            	<strong><?php 
    _e('Thumbnails', 'dbem');
    ?>
</strong>
			            	<p><?php 
    _e('By default we used to use TimThumb (in some cases we still do), which is supplied with our plugin, to generate all your thumbnails, alternatively you can use the default WordPress thumbnail generator which is less resource intensive.', 'dbem');
    ?>
						</td></tr>
			            <?php 
    em_options_radio_binary(__('Use WordPress thumbnails?', 'dbem'), 'dbem_disable_timthumb', __('Recommended you enable this, as it will speed up your site page loading times if displaying many thumbnails on your pages.', 'dbem'));
    ?>
				        <?php 
    echo $save_button;
    ?>
					</table>
					<script type="text/javascript">
						jQuery(document).ready(function($){
							$('input:radio[name="dbem_js_limit"]').change(function(){
								if( $('input:radio[name="dbem_js_limit"]:checked').val() == 1 ){
									$('tbody#dbem-js-limit-options').show();
								}else{
									$('tbody#dbem-js-limit-options').hide();					
								}
							}).trigger('change');
						});
						jQuery(document).ready(function($){
							$('input:radio[name="dbem_css_limit"]').change(function(){
								if( $('input:radio[name="dbem_css_limit"]:checked').val() == 1 ){
									$('tbody#dbem-css-limit-options').show();
								}else{
									$('tbody#dbem-css-limit-options').hide();					
								}
							}).trigger('change');
						});
					</script>
				</div> <!-- . inside --> 
				</div> <!-- .postbox --> 
				
				<?php 
    if (!is_multisite()) {
        em_admin_option_box_uninstall();
    }
    ?>
				
				<?php 
    if (get_option('dbem_migrate_images')) {
        ?>
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span>Migrate Images From Version 4</span></h3>
				<div class="inside">
					<?php 
        /* Not translating as it's temporary */
        ?>
				   <p>You have the option of migrating images from version 4 so they become the equivalent of 'featured images' like with regular WordPress posts and pages and are also available in your media library.</p>
				   <p>Your event and location images will still display correctly on the front-end even if you don't migrate, but will not show up within your edit location/event pages in the admin area.</p>
				   <p>
				      <a href="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
&amp;em_migrate_images=1&amp;_wpnonce=<?php 
        echo wp_create_nonce('em_migrate_images');
        ?>
" />Migrate Images</a><br />
				      <a href="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
&amp;em_not_migrate_images=1&amp;_wpnonce=<?php 
        echo wp_create_nonce('em_not_migrate_images');
        ?>
" />Do Not Migrate Images</a>
				   </p>
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->
				<?php 
    }
    ?>
			</div> <!-- .em-menu-general -->
			
			<!-- PAGE OPTIONS -->
		  	<div class="em-menu-pages em-menu-group" style="display:none;">			
            	<?php 
    $template_page_tip = __("Many themes display extra meta information on post pages such as 'posted by' or 'post date' information, which may not be desired. Usually, page templates contain less clutter.", 'dbem');
    $template_page_tip .= str_replace('#', 'http://codex.wordpress.org/Post_Types#Template_Files', __("Be aware that some themes will not work with this option, if so (or you want to make your own changes), you can create a file named <code>single-%s.php</code> <a href='#'>as shown on the wordpress codex</a>, and leave this set to Posts.", 'dbem'));
    $format_override_tip = __("By using formats, you can control how your %s are displayed from within the Events Manager <a href='#formats' class='nav-tab-link' rel='#em-menu-formats'>Formating</a> tab above without having to edit your theme files.");
    ?>
            	<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    echo sprintf(__('Permalink Slugs', 'dbem'));
    ?>
</span></h3>
				<div class="inside">
					<p><?php 
    _e('You can change the permalink structure of your events, locations, categories and tags here. Be aware that you may want to set up redirects if you change your permalink structures to maintain SEO rankings.', 'dbem');
    ?>
</p>
	            	<table class="form-table">
	            	<?php 
    em_options_input_text(__('Events', 'dbem'), 'dbem_cp_events_slug', sprintf(__('e.g. %s - you can use / Separators too', 'dbem'), '<strong>' . home_url() . '/<code>' . get_option('dbem_cp_events_slug', EM_POST_TYPE_EVENT_SLUG) . '</code>/2012-olympics/</strong>'), EM_POST_TYPE_EVENT_SLUG);
    if (get_option('dbem_locations_enabled')) {
        em_options_input_text(__('Locations', 'dbem'), 'dbem_cp_locations_slug', sprintf(__('e.g. %s - you can use / Separators too', 'dbem'), '<strong>' . home_url() . '/<code>' . get_option('dbem_cp_locations_slug', EM_POST_TYPE_LOCATION_SLUG) . '</code>/wembley-stadium/</strong>'), EM_POST_TYPE_LOCATION_SLUG);
    }
    if (get_option('dbem_categories_enabled') && !(EM_MS_GLOBAL && !is_main_site())) {
        em_options_input_text(__('Event Categories', 'dbem'), 'dbem_taxonomy_category_slug', sprintf(__('e.g. %s - you can use / Separators too', 'dbem'), '<strong>' . home_url() . '/<code>' . get_option('dbem_taxonomy_category_slug', EM_TAXONOMY_CATEGORY_SLUG) . '</code>/sports/</strong>'), EM_TAXONOMY_CATEGORY_SLUG);
    }
    if (get_option('dbem_tags_enabled')) {
        em_options_input_text(__('Event Tags', 'dbem'), 'dbem_taxonomy_tag_slug', sprintf(__('e.g. %s - you can use / Separators too', 'dbem'), '<strong>' . home_url() . '/<code>' . get_option('dbem_taxonomy_tag_slug', EM_TAXONOMY_TAG_SLUG) . '</code>/running/</strong>'), EM_TAXONOMY_TAG_SLUG);
    }
    echo $save_button;
    ?>
	            	</table>
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->	

				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    echo sprintf(__('%s Pages', 'dbem'), __('Event', 'dbem'));
    ?>
</span></h3>
				<div class="inside">
	            	<table class="form-table">
	            	<?php 
    em_options_radio_binary(sprintf(__('Display %s as', 'dbem'), __('events', 'dbem')), 'dbem_cp_events_template_page', sprintf($template_page_tip, EM_POST_TYPE_EVENT), array(__('Posts'), __('Pages')));
    em_options_radio_binary(__('Override with Formats?', 'dbem'), 'dbem_cp_events_formats', sprintf($format_override_tip, __('events', 'dbem')));
    em_options_radio_binary(__('Enable Comments?', 'dbem'), 'dbem_cp_events_comments', sprintf(__('If you would like to disable comments entirely, disable this, otherwise you can disable comments on each single %s. Note that %s with comments enabled will still be until you resave them.', 'dbem'), __('event', 'dbem'), __('events', 'dbem')));
    echo $save_button;
    ?>
	            	</table>
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->	
            		
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    echo sprintf(__('%s List/Archives', 'dbem'), __('Event', 'dbem'));
    ?>
</span></h3>
				<div class="inside">
	            	<table class="form-table">
					<tr>
						<td><?php 
    echo sprintf(__('Events page', 'dbem'));
    ?>
</td>
						<td>
							<?php 
    wp_dropdown_pages(array('name' => 'dbem_events_page', 'selected' => get_option('dbem_events_page'), 'show_option_none' => sprintf(__('[No %s Page]', 'dbem'), __('Events', 'dbem'))));
    ?>
							<br />
							<em><?php 
    echo __('This option allows you to select which page to use as an events page. If you do not select an events page, to display event lists you can enable event archives or use the appropriate shortcodes and/or template tags.', 'dbem');
    ?>
</em>
						</td>
					</tr>
					<tbody class="em-event-page-options">
						<?php 
    em_options_radio_binary(__('Show events search?', 'dbem'), 'dbem_events_page_search', __("If set to yes, a search form will appear just above your list of events.", 'dbem'));
    em_options_radio_binary(__('Display calendar in events page?', 'dbem'), 'dbem_display_calendar_in_events_page', __('This options allows to display the calendar in the events page, instead of the default list. It is recommended not to display both the calendar widget and a calendar page.', 'dbem') . ' ' . __('If you would like to show events that span over more than one day, see the Calendar section on this page.', 'dbem'));
    em_options_radio_binary(__('Disable title rewriting?', 'dbem'), 'dbem_disable_title_rewrites', __("Some WordPress themes don't follow best practices when generating navigation menus, and so the automatic title rewriting feature may cause problems, if your menus aren't working correctly on the event pages, try setting this to 'Yes', and provide an appropriate HTML title format below.", 'dbem'));
    em_options_input_text(__('Event Manager titles', 'dbem'), 'dbem_title_html', __("This only setting only matters if you selected 'Yes' to above. You will notice the events page titles aren't being rewritten, and you have a new title underneath the default page name. This is where you control the HTML of this title. Make sure you keep the #_PAGETITLE placeholder here, as that's what is rewritten by events manager. To control what's rewritten in this title, see settings further down for page titles.", 'dbem'));
    ?>
				
					</tbody>
					<tr>
						<td colspan="2">
							<h4><?php 
    echo sprintf(__('WordPress %s Archives', 'dbem'), __('Event', 'dbem'));
    ?>
</h4>
							<p><?php 
    echo sprintf(__('%s custom post types can have archives, just like normal WordPress posts. If enabled, should you visit your base slug url %s and you will see an post-formatted archive of previous %s'), __('Event', 'dbem'), '<code>' . home_url() . '/' . get_option('dbem_cp_events_slug', EM_POST_TYPE_EVENT_SLUG) . '/</code>', __('events', 'dbem'));
    ?>
</p>
							<p><?php 
    echo sprintf(__('Note that assigning a %s page above will override this archive if the URLs collide (which is the default settings, and is recommended). You can have both at the same time, but you must ensure that your page and %s slugs are different.'), __('events', 'dbem'), __('event', 'dbem'));
    ?>
</p>
						</td>
					</tr>
					<tbody class="em-event-archive-options">
						<?php 
    em_options_radio_binary(__('Enable Archives?', 'dbem'), 'dbem_cp_events_has_archive', __("Allow WordPress post-style archives.", 'dbem'));
    ?>
					</tbody>
					<tbody class="em-event-archive-options em-event-archive-sub-options">
						<tr valign="top">
					   		<th scope="row"><?php 
    _e('Default event archive ordering', 'dbem');
    ?>
</th>
					   		<td>   
								<select name="dbem_events_default_archive_orderby" >
									<?php 
    $event_archive_orderby_options = apply_filters('em_settings_events_default_archive_orderby_ddm', array('_start_ts' => __('Order by start date, start time', 'dbem'), 'title' => __('Order by name', 'dbem')));
    ?>
									<?php 
    foreach ($event_archive_orderby_options as $key => $value) {
        ?>
   
					 				<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_events_default_archive_orderby') ? "selected='selected'" : '';
        ?>
>
					 					<?php 
        echo $value;
        ?>
					 				</option>
									<?php 
    }
    ?>
								</select> 
								<select name="dbem_events_default_archive_order" >
									<?php 
    $ascending = __('Ascending', 'dbem');
    $descending = __('Descending', 'dbem');
    $event_archive_order_options = apply_filters('em_settings_events_default_archive_order_ddm', array('ASC' => __('Ascending', 'dbem'), 'DESC' => __('Descending', 'dbem')));
    ?>
									<?php 
    foreach ($event_archive_order_options as $key => $value) {
        ?>
   
					 				<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_events_default_archive_order') ? "selected='selected'" : '';
        ?>
>
					 					<?php 
        echo $value;
        ?>
					 				</option>
									<?php 
    }
    ?>
								</select>
								<br/>
								<em><?php 
    _e('When Events Manager displays lists of events the default behaviour is ordering by start date in ascending order. To change this, modify the values above.', 'dbem');
    ?>
</em>
							</td>
					   	</tr>	
					</tbody>
					<tr>
						<td colspan="2">
							<h4><?php 
    echo _e('General settings', 'dbem');
    ?>
</h4>
						</td>
					</tr>	
					<?php 
    em_options_radio_binary(__('Override with Formats?', 'dbem'), 'dbem_cp_events_archive_formats', sprintf($format_override_tip, __('events', 'dbem')));
    em_options_radio_binary(__('Are current events past events?', 'dbem'), 'dbem_events_current_are_past', __("By default, events that are have an end date later than today will be included in searches, set this to yes to consider events that started 'yesterday' as past.", 'dbem'));
    em_options_radio_binary(__('Include in WordPress Searches?', 'dbem'), 'dbem_cp_events_search_results', sprintf(__("Allow %s to appear in the built-in search results.", 'dbem'), __('events', 'dbem')));
    ?>
					<tr>
						<td colspan="2">
							<h4><?php 
    echo sprintf(__('Default %s list options', 'dbem'), __('event', 'dbem'));
    ?>
</h4>
							<p><?php 
    _e('These can be overriden when using shortcode or template tags.', 'dbem');
    ?>
</p>
						</td>
					</tr>							
					<tr valign="top" id='dbem_events_default_orderby_row'>
				   		<th scope="row"><?php 
    _e('Default event list ordering', 'dbem');
    ?>
</th>
				   		<td>   
							<select name="dbem_events_default_orderby" >
								<?php 
    $orderby_options = apply_filters('em_settings_events_default_orderby_ddm', array('event_start_date,event_start_time,event_name' => __('Order by start date, start time, then event name', 'dbem'), 'event_name,event_start_date,event_start_time' => __('Order by name, start date, then start time', 'dbem'), 'event_name,event_end_date,event_end_time' => __('Order by name, end date, then end time', 'dbem'), 'event_end_date,event_end_time,event_name' => __('Order by end date, end time, then event name', 'dbem')));
    ?>
								<?php 
    foreach ($orderby_options as $key => $value) {
        ?>
   
				 				<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_events_default_orderby') ? "selected='selected'" : '';
        ?>
>
				 					<?php 
        echo $value;
        ?>
				 				</option>
								<?php 
    }
    ?>
							</select> 
							<select name="dbem_events_default_order" >
								<?php 
    $ascending = __('Ascending', 'dbem');
    $descending = __('Descending', 'dbem');
    $order_options = apply_filters('em_settings_events_default_order_ddm', array('ASC' => __('All Ascending', 'dbem'), 'DESC,ASC,ASC' => __("{$descending}, {$ascending}, {$ascending}", 'dbem'), 'DESC,DESC,ASC' => __("{$descending}, {$descending}, {$ascending}", 'dbem'), 'DESC' => __('All Descending', 'dbem'), 'ASC,DESC,ASC' => __("{$ascending}, {$descending}, {$ascending}", 'dbem'), 'ASC,DESC,DESC' => __("{$ascending}, {$descending}, {$descending}", 'dbem'), 'ASC,ASC,DESC' => __("{$ascending}, {$ascending}, {$descending}", 'dbem'), 'DESC,ASC,DESC' => __("{$descending}, {$ascending}, {$descending}", 'dbem')));
    ?>
								<?php 
    foreach ($order_options as $key => $value) {
        ?>
   
				 				<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_events_default_order') ? "selected='selected'" : '';
        ?>
>
				 					<?php 
        echo $value;
        ?>
				 				</option>
								<?php 
    }
    ?>
							</select>
							<br/>
							<em><?php 
    _e('When Events Manager displays lists of events the default behaviour is ordering by start date in ascending order. To change this, modify the values above.', 'dbem');
    ?>
</em>
						</td>
				   	</tr>										   	
					<tr valign="top" id='dbem_events_display_time_limit'>
				   		<th scope="row"><?php 
    _e('Event list scope', 'dbem');
    ?>
</th>
						<td>
							<select name="dbem_events_page_scope" >
								<?php 
    foreach (em_get_scopes() as $key => $value) {
        ?>
   
								<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_events_page_scope') ? "selected='selected'" : '';
        ?>
>
									<?php 
        echo $value;
        ?>
								</option>
								<?php 
    }
    ?>
							</select>
							<br />
							<em><?php 
    _e('Only show events starting within a certain time limit on the events page. Default is future events with no end time limit.', 'dbem');
    ?>
</em>
						</td>
					</tr>
					<?php 
    em_options_input_text(__('Event List Limits', 'dbem'), 'dbem_events_default_limit', __("This will control how many events are shown on one list by default.", 'dbem'));
    echo $save_button;
    ?>
	            	</table>
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->	
				
				<?php 
    if (get_option('dbem_locations_enabled')) {
        ?>
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        echo sprintf(__('%s Pages', 'dbem'), __('Location', 'dbem'));
        ?>
</span></h3>
				<div class="inside">
	            	<table class="form-table">
	            	<?php 
        em_options_radio_binary(sprintf(__('Display %s as', 'dbem'), __('locations', 'dbem')), 'dbem_cp_locations_template_page', sprintf($template_page_tip, EM_POST_TYPE_LOCATION), array(__('Posts'), __('Pages')));
        em_options_radio_binary(__('Override with Formats?', 'dbem'), 'dbem_cp_locations_formats', sprintf($format_override_tip, __('locations', 'dbem')));
        em_options_radio_binary(__('Enable Comments?', 'dbem'), 'dbem_cp_locations_comments', sprintf(__('If you would like to disable comments entirely, disable this, otherwise you can disable comments on each single %s. Note that %s with comments enabled will still be until you resave them.', 'dbem'), __('location', 'dbem'), __('locations', 'dbem')));
        em_options_input_text(__('Event List Limits', 'dbem'), 'dbem_location_event_list_limit', sprintf(__("Controls how many events being held at a location are shown per page when using placeholders such as %s. Leave blank for no limit.", 'dbem'), '<code>#_LOCATIONNEXTEVENTS</code>'));
        echo $save_button;
        ?>
	            	</table>
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->	
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        echo sprintf(__('%s List/Archives', 'dbem'), __('Location', 'dbem'));
        ?>
</span></h3>
				<div class="inside">
	            	<table class="form-table">
					<tr>
						<td><?php 
        echo sprintf(__('%s page', 'dbem'), __('Locations', 'dbem'));
        ?>
</td>
						<td>
							<?php 
        wp_dropdown_pages(array('name' => 'dbem_locations_page', 'selected' => get_option('dbem_locations_page'), 'show_option_none' => sprintf(__('[No %s Page]', 'dbem'), __('Locations', 'dbem'))));
        ?>
							<br />
							<em><?php 
        echo sprintf(__('This option allows you to select which page to use as the %s page. If you do not select a %s page, to display lists you can enable archives or use the appropriate shortcodes and/or template tags.', 'dbem'), __('locations', 'dbem'), __('locations', 'dbem'));
        ?>
</em>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<h4><?php 
        echo sprintf(__('WordPress %s Archives', 'dbem'), __('Location', 'dbem'));
        ?>
</h4>
							<p><?php 
        echo sprintf(__('%s custom post types can have archives, just like normal WordPress posts. If enabled, should you visit your base slug url %s and you will see an post-formatted archive of previous %s'), __('Location', 'dbem'), '<code>' . home_url() . '/' . get_option('dbem_cp_events_slug', EM_POST_TYPE_EVENT_SLUG) . '/</code>', __('locations', 'dbem'));
        ?>
</p>
							<p><?php 
        echo sprintf(__('Note that assigning a %s page above will override this archive if the URLs collide (which is the default settings, and is recommended for maximum plugin compatability). You can have both at the same time, but you must ensure that your page and %s slugs are different.'), __('locations', 'dbem'), __('location', 'dbem'));
        ?>
</p>
						</td>
					</tr>
					<tbody class="em-location-archive-options">
						<?php 
        em_options_radio_binary(__('Enable Archives?', 'dbem'), 'dbem_cp_locations_has_archive', __("Allow WordPress post-style archives.", 'dbem'));
        ?>
					</tbody>
					<tbody class="em-location-archive-options em-location-archive-sub-options">
						<tr valign="top">
					   		<th scope="row"><?php 
        _e('Default archive ordering', 'dbem');
        ?>
</th>
					   		<td>   
								<select name="dbem_locations_default_archive_orderby" >
									<?php 
        $orderby_options = apply_filters('em_settings_locations_default_archive_orderby_ddm', array('_country' => sprintf(__('Order by %s', 'dbem'), __('Country', 'dbem')), '_town' => sprintf(__('Order by %s', 'dbem'), __('Town', 'dbem')), 'title' => sprintf(__('Order by %s', 'dbem'), __('Name', 'dbem'))));
        ?>
									<?php 
        foreach ($orderby_options as $key => $value) {
            ?>
   
					 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_locations_default_archive_orderby') ? "selected='selected'" : '';
            ?>
>
					 					<?php 
            echo $value;
            ?>
					 				</option>
									<?php 
        }
        ?>
								</select> 
								<select name="dbem_locations_default_archive_order" >
									<?php 
        $ascending = __('Ascending', 'dbem');
        $descending = __('Descending', 'dbem');
        $order_options = apply_filters('em_settings_locations_default_archive_order_ddm', array('ASC' => __('Ascending', 'dbem'), 'DESC' => __('Descending', 'dbem')));
        ?>
									<?php 
        foreach ($order_options as $key => $value) {
            ?>
   
					 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_locations_default_archive_order') ? "selected='selected'" : '';
            ?>
>
					 					<?php 
            echo $value;
            ?>
					 				</option>
									<?php 
        }
        ?>
								</select>
							</td>
					   	</tr>	
					</tbody>
					<tr>
						<td colspan="2">
							<h4><?php 
        echo _e('General settings', 'dbem');
        ?>
</h4>
						</td>
					</tr>
					<?php 
        em_options_radio_binary(__('Override with Formats?', 'dbem'), 'dbem_cp_locations_archive_formats', sprintf($format_override_tip, __('locations', 'dbem')));
        em_options_radio_binary(__('Include in WordPress Searches?', 'dbem'), 'dbem_cp_locations_search_results', sprintf(__("Allow %s to appear in the built-in search results.", 'dbem'), __('locations', 'dbem')));
        ?>
					<tr>
						<td colspan="2">
							<h4><?php 
        echo sprintf(__('Default %s list options', 'dbem'), __('location', 'dbem'));
        ?>
</h4>
							<p><?php 
        _e('These can be overriden when using shortcode or template tags.', 'dbem');
        ?>
</p>
						</td>
					</tr>							
					<tr valign="top" id='dbem_locations_default_orderby_row'>
				   		<th scope="row"><?php 
        _e('Default list ordering', 'dbem');
        ?>
</th>
				   		<td>   
							<select name="dbem_locations_default_orderby" >
								<?php 
        $orderby_options = apply_filters('em_settings_locations_default_orderby_ddm', array('location_country' => sprintf(__('Order by %s', 'dbem'), __('Country', 'dbem')), 'location_town' => sprintf(__('Order by %s', 'dbem'), __('Town', 'dbem')), 'location_name' => sprintf(__('Order by %s', 'dbem'), __('Name', 'dbem'))));
        ?>
								<?php 
        foreach ($orderby_options as $key => $value) {
            ?>
				 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_locations_default_orderby') ? "selected='selected'" : '';
            ?>
>
				 					<?php 
            echo $value;
            ?>
				 				</option>
								<?php 
        }
        ?>
							</select> 
							<select name="dbem_locations_default_order" >
								<?php 
        $ascending = __('Ascending', 'dbem');
        $descending = __('Descending', 'dbem');
        $order_options = apply_filters('em_settings_locations_default_order_ddm', array('ASC' => __('Ascending', 'dbem'), 'DESC' => __('Descending', 'dbem')));
        ?>
								<?php 
        foreach ($order_options as $key => $value) {
            ?>
   
				 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_locations_default_order') ? "selected='selected'" : '';
            ?>
>
				 					<?php 
            echo $value;
            ?>
				 				</option>
								<?php 
        }
        ?>
							</select>
						</td>
				   	</tr>
					<?php 
        em_options_input_text(__('List Limits', 'dbem'), 'dbem_locations_default_limit', sprintf(__("This will control how many %s are shown on one list by default.", 'dbem'), __('locations', 'dbem')));
        echo $save_button;
        ?>
	            	</table>
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->
				<?php 
    }
    ?>
				
				<?php 
    if (get_option('dbem_categories_enabled') && !(EM_MS_GLOBAL && !is_main_site())) {
        ?>
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        echo __('Event Categories', 'dbem');
        ?>
</span></h3>
				<div class="inside">
	            	<table class="form-table">
					<tr>
						<td><?php 
        echo sprintf(__('%s page', 'dbem'), __('Categories', 'dbem'));
        ?>
</td>
						<td>
							<?php 
        wp_dropdown_pages(array('name' => 'dbem_categories_page', 'selected' => get_option('dbem_categories_page'), 'show_option_none' => sprintf(__('[No %s Page]', 'dbem'), __('Categories', 'dbem'))));
        ?>
							<br />
							<em><?php 
        echo sprintf(__('This option allows you to select which page to use as the %s page.', 'dbem'), __('categories', 'dbem'), __('categories', 'dbem'));
        ?>
</em>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<h4><?php 
        echo _e('General settings', 'dbem');
        ?>
</h4>
						</td>
					</tr>
					<?php 
        em_options_radio_binary(__('Override with Formats?', 'dbem'), 'dbem_cp_categories_formats', sprintf($format_override_tip, __('categories', 'dbem')) . " " . __('Setting this to yes will make categories display as a page rather than an archive.', 'dbem'));
        ?>
					<tr valign="top">
				   		<th scope="row"><?php 
        _e('Default archive ordering', 'dbem');
        ?>
</th>
				   		<td>   
							<select name="dbem_categories_default_archive_orderby" >
								<?php 
        foreach ($event_archive_orderby_options as $key => $value) {
            ?>
   
				 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_categories_default_archive_orderby') ? "selected='selected'" : '';
            ?>
>
				 					<?php 
            echo $value;
            ?>
				 				</option>
								<?php 
        }
        ?>
							</select> 
							<select name="dbem_categories_default_archive_order" >
								<?php 
        foreach ($event_archive_order_options as $key => $value) {
            ?>
   
				 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_categories_default_archive_order') ? "selected='selected'" : '';
            ?>
>
				 					<?php 
            echo $value;
            ?>
				 				</option>
								<?php 
        }
        ?>
							</select>
							<br /><?php 
        echo __('When listing events for a category, this order is applied.', 'dbem');
        ?>
						</td>
				   	</tr>
					<tr>
						<td colspan="2">
							<h4><?php 
        echo sprintf(__('Default %s list options', 'dbem'), __('category', 'dbem'));
        ?>
</h4>
							<p><?php 
        _e('These can be overriden when using shortcode or template tags.', 'dbem');
        ?>
</p>
						</td>
					</tr>							
					<tr valign="top" id='dbem_categories_default_orderby_row'>
				   		<th scope="row"><?php 
        _e('Default list ordering', 'dbem');
        ?>
</th>
				   		<td>   
							<select name="dbem_categories_default_orderby" >
								<?php 
        $orderby_options = apply_filters('em_settings_categories_default_orderby_ddm', array('id' => sprintf(__('Order by %s', 'dbem'), __('ID', 'dbem')), 'count' => sprintf(__('Order by %s', 'dbem'), __('Count', 'dbem')), 'name' => sprintf(__('Order by %s', 'dbem'), __('Name', 'dbem')), 'slug' => sprintf(__('Order by %s', 'dbem'), __('Slug', 'dbem')), 'term_group' => sprintf(__('Order by %s', 'dbem'), 'term_group')));
        ?>
								<?php 
        foreach ($orderby_options as $key => $value) {
            ?>
				 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_categories_default_orderby') ? "selected='selected'" : '';
            ?>
>
				 					<?php 
            echo $value;
            ?>
				 				</option>
								<?php 
        }
        ?>
							</select> 
							<select name="dbem_categories_default_order" >
								<?php 
        $ascending = __('Ascending', 'dbem');
        $descending = __('Descending', 'dbem');
        $order_options = apply_filters('em_settings_categories_default_order_ddm', array('ASC' => __('Ascending', 'dbem'), 'DESC' => __('Descending', 'dbem')));
        ?>
								<?php 
        foreach ($order_options as $key => $value) {
            ?>
   
				 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_categories_default_order') ? "selected='selected'" : '';
            ?>
>
				 					<?php 
            echo $value;
            ?>
				 				</option>
								<?php 
        }
        ?>
							</select>
							<br /><?php 
        echo __('When listing categories, this order is applied.', 'dbem');
        ?>
						</td>
				   	</tr>
					<?php 
        em_options_input_text(__('List Limits', 'dbem'), 'dbem_categories_default_limit', sprintf(__("This will control how many %s are shown on one list by default.", 'dbem'), __('categories', 'dbem')));
        em_options_input_text(__('Event List Limits', 'dbem'), 'dbem_category_event_list_limit', sprintf(__("Controls how many events belonging to a category are shown per page when using placeholders such as %s. Leave blank for no limit.", 'dbem'), '<code>#_CATEGORYNEXTEVENTS</code>'));
        echo $save_button;
        ?>
	            	</table>
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->
				<?php 
    }
    ?>
	
				
				<?php 
    if (get_option('dbem_tags_enabled')) {
        //disabled for now, will add tag stuff later
        ?>
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        echo __('Event Tags', 'dbem');
        ?>
</span></h3>
				<div class="inside">
		            	<table class="form-table">
						<?php 
        em_options_radio_binary(__('Override with Formats?', 'dbem'), 'dbem_cp_tags_formats', sprintf($format_override_tip, __('tags', 'dbem')));
        ?>
						<tr valign="top">
					   		<th scope="row"><?php 
        _e('Default archive ordering', 'dbem');
        ?>
</th>
					   		<td>   
								<select name="dbem_tags_default_archive_orderby" >
									<?php 
        foreach ($event_archive_orderby_options as $key => $value) {
            ?>
   
					 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_tags_default_archive_orderby') ? "selected='selected'" : '';
            ?>
>
					 					<?php 
            echo $value;
            ?>
					 				</option>
									<?php 
        }
        ?>
								</select> 
								<select name="dbem_tags_default_archive_order" >
									<?php 
        foreach ($event_archive_order_options as $key => $value) {
            ?>
   
					 				<option value='<?php 
            echo $key;
            ?>
' <?php 
            echo $key == get_option('dbem_tags_default_archive_order') ? "selected='selected'" : '';
            ?>
>
					 					<?php 
            echo $value;
            ?>
					 				</option>
									<?php 
        }
        ?>
								</select>
							</td>
					   	</tr>
				   		<?php 
        echo $save_button;
        ?>
		            	</table>					    
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->
				<?php 
    }
    ?>
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    echo sprintf(__('%s Pages', 'dbem'), __('Other', 'dbem'));
    ?>
</span></h3>
				<div class="inside">
					<p><?php 
    _e('These pages allow you to provide an event management interface outside the admin area on whatever page you want on your website. Bear in mind that this is overriden by BuddyPress if activated.');
    ?>
</p>
	            	<table class="form-table">
					<?php 
    $other_pages_tip = 'Using the %s shortcode, you can allow users to manage %s outside the admin area.';
    ?>
					<tr><td colspan="2"><h4><?php 
    echo _e('My Bookings', 'dbem');
    ?>
</h4></td></tr>
					<tr>
						<td><?php 
    echo sprintf(__('%s page', 'dbem'), __('My bookings', 'dbem'));
    ?>
</td>
						<td>
							<?php 
    wp_dropdown_pages(array('name' => 'dbem_my_bookings_page', 'selected' => get_option('dbem_my_bookings_page'), 'show_option_none' => '[' . __('None', 'dbem') . ']'));
    ?>
							<br />
							<em><?php 
    echo sprintf(__('Users can view their bookings for other events on this page.', 'dbem'), '<code>[my_bookings]</code>', __('bookings', 'dbem'));
    ?>
</em>
						</td>
					</tr>	
					<tr valign="top" id='dbem_bookings_default_orderby_row'>
				   		<th scope="row"><?php 
    _e('Default list ordering', 'dbem');
    ?>
</th>
				   		<td>   
							<select name="dbem_bookings_default_orderby" >
								<?php 
    $orderby_options = apply_filters('em_settings_bookings_default_orderby_ddm', array('event_name' => sprintf(__('Order by %s', 'dbem'), __('Event Name', 'dbem')), 'event_start_date' => sprintf(__('Order by %s', 'dbem'), __('Start Date', 'dbem')), 'booking_date' => sprintf(__('Order by %s', 'dbem'), __('Booking Date', 'dbem'))));
    ?>
								<?php 
    foreach ($orderby_options as $key => $value) {
        ?>
				 				<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_bookings_default_orderby') ? "selected='selected'" : '';
        ?>
>
				 					<?php 
        echo $value;
        ?>
				 				</option>
								<?php 
    }
    ?>
							</select> 
							<select name="dbem_bookings_default_order" >
								<?php 
    $ascending = __('Ascending', 'dbem');
    $descending = __('Descending', 'dbem');
    $order_options = apply_filters('em_settings_bookings_default_order_ddm', array('ASC' => __('Ascending', 'dbem'), 'DESC' => __('Descending', 'dbem')));
    ?>
								<?php 
    foreach ($order_options as $key => $value) {
        ?>
   
				 				<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_bookings_default_order') ? "selected='selected'" : '';
        ?>
>
				 					<?php 
        echo $value;
        ?>
				 				</option>
								<?php 
    }
    ?>
							</select>
						</td>
				   	</tr>
					<tr><td colspan="2"><h4><?php 
    echo _e('Front-end management pages', 'dbem');
    ?>
</h4></td></tr>
					<tr><td colspan="2"><?php 
    echo _e('Users can create and edit events and locations, as well as managing bookings for their events.', 'dbem');
    ?>
</td></tr>
					<tr>
						<td><?php 
    echo sprintf(__('%s page', 'dbem'), __('Edit events', 'dbem'));
    ?>
</td>
						<td>
							<?php 
    wp_dropdown_pages(array('name' => 'dbem_edit_events_page', 'selected' => get_option('dbem_edit_events_page'), 'show_option_none' => '[' . __('None', 'dbem') . ']'));
    ?>
							<br />
							<em><?php 
    echo sprintf(__('Users can view, add and edit their %s on this page.', 'dbem'), __('events', 'dbem'));
    ?>
</em>
						</td>
					</tr>	            	
					<tr>
						<td><?php 
    echo sprintf(__('%s page', 'dbem'), __('Edit locations', 'dbem'));
    ?>
</td>
						<td>
							<?php 
    wp_dropdown_pages(array('name' => 'dbem_edit_locations_page', 'selected' => get_option('dbem_edit_locations_page'), 'show_option_none' => '[' . __('None', 'dbem') . ']'));
    ?>
							<br />
							<em><?php 
    echo sprintf(__('Users can view, add and edit their %s on this page.', 'dbem'), __('locations', 'dbem'));
    ?>
</em>
						</td>
					</tr>	            	
					<tr>
						<td><?php 
    echo sprintf(__('%s page', 'dbem'), __('Manage bookings', 'dbem'));
    ?>
</td>
						<td>
							<?php 
    wp_dropdown_pages(array('name' => 'dbem_edit_bookings_page', 'selected' => get_option('dbem_edit_bookings_page'), 'show_option_none' => '[' . __('None', 'dbem') . ']'));
    ?>
							<br />
							<em><?php 
    _e('Users can manage bookings for their events on this page.', 'dbem');
    ?>
</em>
						</td>
					</tr>
					<?php 
    echo $save_button;
    ?>
	            	</table>
				</div> <!-- . inside --> 
				</div> <!-- .postbox -->
				
				<?php 
    do_action('em_options_page_footer_pages');
    ?>
				
			</div> <!-- .em-menu-pages -->
			
			<!-- FORMAT OPTIONS -->
		  	<div class="em-menu-formats em-menu-group" style="display:none;">				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('Events', 'dbem');
    ?>
 </span></h3>
				<div class="inside">
	            	<table class="form-table">
					 	<tr><td colspan="2">
					 		<strong><?php 
    echo sprintf(__('%s Page', 'dbem'), __('Events', 'dbem'));
    ?>
</strong>
					 		<p><?php 
    _e('These formats will be used on your events page. This will also be used if you do not provide specified formats in other event lists, like in shortcodes.', 'dbem');
    ?>
</p>
					 	</td></tr>
						<?php 
    $grouby_modes = array(0 => __('None', 'dbem'), 'yearly' => __('Yearly', 'dbem'), 'monthly' => __('Monthly', 'dbem'), 'weekly' => __('Weekly', 'dbem'), 'daily' => __('Daily', 'dbem'));
    em_options_select(__('Events page grouping', 'dbem'), 'dbem_event_list_groupby', $grouby_modes, __('If you choose a group by mode, your events page will display events in groups of your chosen time range.', 'dbem'));
    em_options_input_text(__('Events page grouping', 'dbem'), 'dbem_event_list_groupby_format', __('Choose how to format your group headings. Leave blank for defaults.', 'dbem') . ' ' . sprintf(__('Date and Time formats follow the <a href="%s">WordPress time formatting conventions</a>', 'dbem'), 'http://codex.wordpress.org/Formatting_Date_and_Time'));
    em_options_textarea(__('Default event list format header', 'dbem'), 'dbem_event_list_item_format_header', __('This content will appear just above your code for the default event list format. Default is blank', 'dbem'));
    em_options_textarea(__('Default event list format', 'dbem'), 'dbem_event_list_item_format', __('The format of any events in a list.', 'dbem') . $events_placeholder_tip);
    em_options_textarea(__('Default event list format footer', 'dbem'), 'dbem_event_list_item_format_footer', __('This content will appear just below your code for the default event list format. Default is blank', 'dbem'));
    em_options_input_text(__('No events message', 'dbem'), 'dbem_no_events_message', __('The message displayed when no events are available.', 'dbem'));
    em_options_input_text(__('List events by date title', 'dbem'), 'dbem_list_date_title', __('If viewing a page for events on a specific date, this is the title that would show up. To insert date values, use <a href="http://www.php.net/manual/en/function.date.php">PHP time format characters</a>  with a <code>#</code> symbol before them, i.e. <code>#m</code>, <code>#M</code>, <code>#j</code>, etc.<br/>', 'dbem'));
    ?>
					 	<tr><td><strong><?php 
    echo sprintf(__('Single %s Page', 'dbem'), __('Event', 'dbem'));
    ?>
</strong></td></tr>
					 	<?php 
    if (EM_MS_GLOBAL) {
        em_options_input_text(__('Single event page title format', 'dbem'), 'dbem_event_page_title_format', __('The format of a single event page title.', 'dbem') . $events_placeholder_tip);
    }
    em_options_textarea(__('Default single event format', 'dbem'), 'dbem_single_event_format', __('The format of a single event page.', 'dbem') . $events_placeholder_tip);
    echo $save_button;
    ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->

				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('Search Form', 'dbem');
    ?>
 </span></h3>
				<div class="inside">
	            	<table class="form-table">
					    <?php 
    em_options_input_text(__('Search button text', 'dbem'), 'dbem_serach_form_submit');
    em_options_radio_binary(__('Show text search?', 'dbem'), 'dbem_search_form_text', '');
    em_options_input_text(__('Text search label', 'dbem'), 'dbem_search_form_text_label', __('Appears within the input box.', 'dbem'));
    em_options_radio_binary(__('Show date range?', 'dbem'), 'dbem_search_form_dates', '');
    em_options_radio_binary(__('Show categories?', 'dbem'), 'dbem_search_form_categories', '');
    em_options_input_text(__('Categories label', 'dbem'), 'dbem_search_form_categories_label', __('Appears as the first default search option.', 'dbem'));
    em_options_radio_binary(__('Show countries?', 'dbem'), 'dbem_search_form_countries', '');
    em_options_input_text(__('All countries text', 'dbem'), 'dbem_search_form_countries_label', __('Appears as the first default search option.', 'dbem'));
    em_options_radio_binary(__('Show regions?', 'dbem'), 'dbem_search_form_regions', '');
    em_options_input_text(__('All regions text', 'dbem'), 'dbem_search_form_regions_label', __('Appears as the first default search option.', 'dbem'));
    em_options_radio_binary(__('Show states?', 'dbem'), 'dbem_search_form_states', '');
    em_options_input_text(__('All states text', 'dbem'), 'dbem_search_form_states_label', __('Appears as the first default search option.', 'dbem'));
    em_options_radio_binary(__('Show towns/cities?', 'dbem'), 'dbem_search_form_towns', '');
    em_options_input_text(__('All towns/cities text', 'dbem'), 'dbem_search_form_towns_label', __('Appears as the first default search option.', 'dbem'));
    echo $save_button;
    ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->

				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('Date/Time', 'dbem');
    ?>
 </span></h3>
				<div class="inside">
					<p><?php 
    echo sprintf(__('Date and Time formats follow the <a href="%s">WordPress time formatting conventions</a>', 'dbem'), 'http://codex.wordpress.org/Formatting_Date_and_Time');
    ?>
</p>
					<table class="form-table">
	            		<?php 
    em_options_input_text(__('Date Format', 'dbem'), 'dbem_date_format', sprintf(__('For use with the %s placeholder'), '<code>#_EVENTDATES</code>'));
    em_options_input_text(__('Date Picker Format', 'dbem'), 'dbem_date_format_js', sprintf(__('Same as <em>Date Format</em>, but this is used for the datepickers used by Events Manager. This uses a slightly different format to the others on here, for a list of characters to use, visit the <a href="%s">jQuery formatDate reference</a>', 'dbem'), 'http://docs.jquery.com/UI/Datepicker/formatDate'));
    em_options_input_text(__('Date Separator', 'dbem'), 'dbem_dates_Separator', sprintf(__('For when start/end %s are present, this will seperate the two (include spaces here if necessary).', 'dbem'), __('dates', 'dbem')));
    em_options_input_text(__('Time Format', 'dbem'), 'dbem_time_format', sprintf(__('For use with the %s placeholder'), '<code>#_EVENTTIMES</code>'));
    em_options_input_text(__('Time Separator', 'dbem'), 'dbem_times_Separator', sprintf(__('For when start/end %s are present, this will seperate the two (include spaces here if necessary).', 'dbem'), __('times', 'dbem')));
    em_options_input_text(__('All Day Message', 'dbem'), 'dbem_event_all_day_message', sprintf(__('If an event lasts all day, this text will show if using the %s placeholder', 'dbem'), '<code>#_EVENTTIMES</code>'));
    em_options_radio_binary(__('Use 24h Format?', 'dbem'), 'dbem_time_24h', __('When creating events, would you like your times to be shown in 24 hour format?', 'dbem'));
    echo $save_button;
    ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				      
	           	<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('Calendar', 'dbem');
    ?>
</span></h3>
				<div class="inside">
	            	<table class="form-table">
	            		<?php 
    em_options_radio_binary(__('Link directly to event on day with single event?', 'dbem'), 'dbem_calendar_direct_links', __("If a calendar day has only one event, you can force a direct link to the event (recommended to avoid duplicate content).", 'dbem'));
    em_options_radio_binary(__('Show list on day with single event?', 'dbem'), 'dbem_display_calendar_day_single', __("By default, if a calendar day only has one event, it display a single event when clicking on the link of that calendar date. If you select Yes here, you will get always see a list of events.", 'dbem'));
    ?>
	            		<tr><td colspan="2"><strong><?php 
    _e('Small Calendar', 'dbem');
    ?>
</strong></td></tr>
						<?php 
    em_options_input_text(__('Event titles', 'dbem'), 'dbem_small_calendar_event_title_format', __('The format of the title, corresponding to the text that appears when hovering on an eventful calendar day.', 'dbem') . $events_placeholder_tip);
    em_options_input_text(__('Title separator', 'dbem'), 'dbem_small_calendar_event_title_separator', __('The separator appearing on the above title when more than one events are taking place on the same day.', 'dbem'));
    em_options_radio_binary(__('Abbreviated weekdays', 'dbem'), 'dbem_small_calendar_abbreviated_weekdays', __('The calendar headings uses abbreviated weekdays'));
    em_options_input_text(__('Initial lengths', 'dbem'), 'dbem_small_calendar_initials_length', __('Shorten the calendar headings containing the days of the week, use 0 for the full name.', 'dbem') . $events_placeholder_tip);
    ?>
	            		<tr><td colspan="2"><strong><?php 
    _e('Full Calendar', 'dbem');
    ?>
</strong></td></tr>
					    <?php 
    em_options_input_text(__('Event format', 'dbem'), 'dbem_full_calendar_event_format', __('The format of each event when displayed in the full calendar. Remember to include <code>li</code> tags before and after the event.', 'dbem') . $events_placeholder_tip);
    em_options_radio_binary(__('Abbreviated weekdays?', 'dbem'), 'dbem_full_calendar_abbreviated_weekdays', __('Use abbreviations, e.g. Friday = Fri. Useful for certain languages where abbreviations differ from full names.', 'dbem'));
    em_options_input_text(__('Initial lengths', 'dbem'), 'dbem_full_calendar_initials_length', __('Shorten the calendar headings containing the days of the week, use 0 for the full name.', 'dbem') . $events_placeholder_tip);
    ?>
		
					    <tr><td colspan="2"><strong><?php 
    echo __('Calendar Day Event List Settings', 'dbem');
    ?>
</strong></td></tr>			
						<tr valign="top" id='dbem_display_calendar_orderby_row'>
					   		<th scope="row"><?php 
    _e('Default event list ordering', 'dbem');
    ?>
</th>
					   		<td>   
								<select name="dbem_display_calendar_orderby" >
									<?php 
    $orderby_options = apply_filters('dbem_display_calendar_orderby_ddm', array('event_name,event_start_time' => __('Order by event name, then event start time', 'dbem'), 'event_start_time,event_name' => __('Order by event start time, then event name', 'dbem')));
    ?>
									<?php 
    foreach ($orderby_options as $key => $value) {
        ?>
   
					 				<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_display_calendar_orderby') ? "selected='selected'" : '';
        ?>
>
					 					<?php 
        echo $value;
        ?>
					 				</option>
									<?php 
    }
    ?>
								</select> 
								<select name="dbem_display_calendar_order" >
									<?php 
    $ascending = __('Ascending', 'dbem');
    $descending = __('Descending', 'dbem');
    $order_options = apply_filters('dbem_display_calendar_order_ddm', array('ASC' => __('All Ascending', 'dbem'), 'DESC,ASC' => "{$descending}, {$ascending}", 'DESC,DESC' => "{$descending}, {$descending}", 'DESC' => __('All Descending', 'dbem')));
    ?>
									<?php 
    foreach ($order_options as $key => $value) {
        ?>
   
					 				<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_display_calendar_order') ? "selected='selected'" : '';
        ?>
>
					 					<?php 
        echo $value;
        ?>
					 				</option>
									<?php 
    }
    ?>
								</select>
								<br/>
								<em><?php 
    _e('When Events Manager displays lists of events the default behaviour is ordering by start date in ascending order. To change this, modify the values above.', 'dbem');
    ?>
</em>
							</td>
					   	</tr>
					   	<?php 
    em_options_input_text(__('Calendar events/day limit', 'dbem'), 'dbem_display_calendar_events_limit', __('Limits the number of events on each calendar day. Leave blank for no limit.', 'dbem'));
    em_options_input_text(__('More Events message', 'dbem'), 'dbem_display_calendar_events_limit_msg', __('Text with link to calendar day page with all events for that day if there are more events than the limit above, leave blank for no link as the day number is also a link.', 'dbem'));
    ?>
					    <tr><td><strong><?php 
    echo sprintf(__('iCal Feed Settings', 'dbem'), __('Event', 'dbem'));
    ?>
</strong></td></tr>
					    <?php 
    em_options_input_text(__('iCal Title', 'dbem'), 'dbem_ical_description_format', __('The title that will appear in the calendar.', 'dbem') . $events_placeholder_tip);
    em_options_input_text(__('iCal Limit', 'dbem'), 'dbem_ical_limit', __('Limits the number of future events shown (0 = unlimited).', 'dbem'));
    echo $save_button;
    ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				
				<?php 
    if (get_option('dbem_locations_enabled')) {
        ?>
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        _e('Locations', 'dbem');
        ?>
 </span></h3>
				<div class="inside">
	            	<table class="form-table">
					 	<tr><td><strong><?php 
        echo sprintf(__('%s Page', 'dbem'), __('Locations', 'dbem'));
        ?>
</strong></td></tr>
						<?php 
        em_options_textarea(sprintf(__('%s list header format', 'dbem'), __('Locations', 'dbem')), 'dbem_location_list_item_format_header', sprintf(__('This content will appear just above your code for the %s list format below. Default is blank', 'dbem'), __('locations', 'dbem')));
        em_options_textarea(sprintf(__('%s list item format', 'dbem'), __('Locations', 'dbem')), 'dbem_location_list_item_format', sprintf(__('The format of a single %s in a list.', 'dbem'), __('locations', 'dbem')) . $locations_placeholder_tip);
        em_options_textarea(sprintf(__('%s list footer format', 'dbem'), __('Locations', 'dbem')), 'dbem_location_list_item_format_footer', sprintf(__('This content will appear just below your code for the %s list format above. Default is blank', 'dbem'), __('locations', 'dbem')));
        em_options_input_text(sprintf(__('No %s message', 'dbem'), __('Locations', 'dbem')), 'dbem_no_locations_message', sprintf(__('The message displayed when no %s are available.', 'dbem'), __('locations', 'dbem')));
        ?>
					 	<tr><td><strong><?php 
        echo sprintf(__('Single %s Page', 'dbem'), __('Location', 'dbem'));
        ?>
</strong></td></tr>
					 	<?php 
        em_options_input_text(sprintf(__('Single %s title format', 'dbem'), __('location', 'dbem')), 'dbem_location_page_title_format', __('The format of a single location page title.', 'dbem') . $locations_placeholder_tip);
        em_options_textarea(sprintf(__('Single %s page format', 'dbem'), __('location', 'dbem')), 'dbem_single_location_format', __('The format of a single location page.', 'dbem') . $locations_placeholder_tip);
        ?>
					 	<tr><td><strong><?php 
        echo sprintf(__('%s List Formats', 'dbem'), __('Event', 'dbem'));
        ?>
</strong></td></tr>
					 	<?php 
        em_options_input_text(__('Default event list format header', 'dbem'), 'dbem_location_event_list_item_header_format', __('This content will appear just above your code for the default event list format. Default is blank', 'dbem'));
        em_options_textarea(sprintf(__('Default %s list format', 'dbem'), __('events', 'dbem')), 'dbem_location_event_list_item_format', sprintf(__('The format of the events the list inserted in the location page through the %s element.', 'dbem') . $locations_placeholder_tip, '<code>#_LOCATIONNEXTEVENTS</code>, <code>#_LOCATIONPASTEVENTS</code>, <code>#_LOCATIONALLEVENTS</code>'));
        em_options_input_text(__('Default event list format footer', 'dbem'), 'dbem_location_event_list_item_footer_format', __('This content will appear just below your code for the default event list format. Default is blank', 'dbem'));
        em_options_textarea(sprintf(__('No %s message', 'dbem'), __('events', 'dbem')), 'dbem_location_no_events_message', sprintf(__('The message to be displayed in the list generated by %s when no events are available.', 'dbem'), '<code>#_LOCATIONNEXTEVENTS</code>, <code>#_LOCATIONPASTEVENTS</code>, <code>#_LOCATIONALLEVENTS</code>'));
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				<?php 
    }
    ?>
				
				<?php 
    if (get_option('dbem_categories_enabled') && !(EM_MS_GLOBAL && !is_main_site())) {
        ?>
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        _e('Event Categories', 'dbem');
        ?>
 </span></h3>
				<div class="inside">
	            	<table class="form-table">
					 	<tr><td><strong><?php 
        echo sprintf(__('%s Page', 'dbem'), __('Categories', 'dbem'));
        ?>
</strong></td></tr>
						<?php 
        em_options_textarea(sprintf(__('%s list header format', 'dbem'), __('Categories', 'dbem')), 'dbem_categories_list_item_format_header', sprintf(__('This content will appear just above your code for the %s list format below. Default is blank', 'dbem'), __('categories', 'dbem')));
        em_options_textarea(sprintf(__('%s list item format', 'dbem'), __('Categories', 'dbem')), 'dbem_categories_list_item_format', sprintf(__('The format of a single %s in a list.', 'dbem'), __('categories', 'dbem')) . $categories_placeholder_tip);
        em_options_textarea(sprintf(__('%s list footer format', 'dbem'), __('Categories', 'dbem')), 'dbem_categories_list_item_format_footer', sprintf(__('This content will appear just below your code for the %s list format above. Default is blank', 'dbem'), __('categories', 'dbem')));
        em_options_input_text(sprintf(__('No %s message', 'dbem'), __('Categories', 'dbem')), 'dbem_no_categories_message', sprintf(__('The message displayed when no %s are available.', 'dbem'), __('categories', 'dbem')));
        ?>
					 	<tr><td><strong><?php 
        echo sprintf(__('Single %s Page', 'dbem'), __('Category', 'dbem'));
        ?>
</strong></td></tr>
					 	<?php 
        em_options_input_text(sprintf(__('Single %s title format', 'dbem'), __('category', 'dbem')), 'dbem_category_page_title_format', __('The format of a single category page title.', 'dbem') . $categories_placeholder_tip);
        em_options_textarea(sprintf(__('Single %s page format', 'dbem'), __('category', 'dbem')), 'dbem_category_page_format', __('The format of a single category page.', 'dbem') . $categories_placeholder_tip);
        ?>
					 	<tr><td><strong><?php 
        echo sprintf(__('%s List Formats', 'dbem'), __('Event', 'dbem'));
        ?>
</strong></td></tr>
					 	<?php 
        em_options_input_text(__('Default event list format header', 'dbem'), 'dbem_category_event_list_item_header_format', __('This content will appear just above your code for the default event list format. Default is blank', 'dbem'));
        em_options_textarea(sprintf(__('Default %s list format', 'dbem'), __('events', 'dbem')), 'dbem_category_event_list_item_format', sprintf(__('The format of the events the list inserted in the category page through the %s element.', 'dbem') . $categories_placeholder_tip, '<code>#_CATEGORYPASTEVENTS</code>, <code>#_CATEGORYNEXTEVENTS</code>, <code>#_CATEGORYALLEVENTS</code>'));
        em_options_input_text(__('Default event list format footer', 'dbem'), 'dbem_category_event_list_item_footer_format', __('This content will appear just below your code for the default event list format. Default is blank', 'dbem'));
        em_options_textarea(sprintf(__('No %s message', 'dbem'), __('events', 'dbem')), 'dbem_category_no_events_message', sprintf(__('The message to be displayed in the list generated by %s when no events are available.', 'dbem'), '<code>#_CATEGORYPASTEVENTS</code>, <code>#_CATEGORYNEXTEVENTS</code>, <code>#_CATEGORYALLEVENTS</code>'));
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				<?php 
    }
    ?>
				
				<?php 
    if (get_option('dbem_tags_enabled')) {
        ?>
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        _e('Event Tags', 'dbem');
        ?>
 </span></h3>
				<div class="inside">
	            	<table class="form-table">
					 	<tr><td><strong><?php 
        echo sprintf(__('Single %s Page', 'dbem'), __('Tag', 'dbem'));
        ?>
</strong></td></tr>
					 	<?php 
        em_options_input_text(sprintf(__('Single %s title format', 'dbem'), __('tag', 'dbem')), 'dbem_tag_page_title_format', __('The format of a single tag page title.', 'dbem') . $categories_placeholder_tip);
        em_options_textarea(sprintf(__('Single %s page format', 'dbem'), __('tag', 'dbem')), 'dbem_tag_page_format', __('The format of a single tag page.', 'dbem') . $categories_placeholder_tip);
        ?>
					 	<tr><td><strong><?php 
        echo sprintf(__('%s List Formats', 'dbem'), __('Event', 'dbem'));
        ?>
</strong></td></tr>
					 	<?php 
        em_options_input_text(__('Default event list format header', 'dbem'), 'dbem_tag_event_list_item_header_format', __('This content will appear just above your code for the default event list format. Default is blank', 'dbem'));
        em_options_textarea(sprintf(__('Default %s list format', 'dbem'), __('events', 'dbem')), 'dbem_tag_event_list_item_format', __('The format of the events the list inserted in the tag page through the <code>#_TAGNEXTEVENTS</code>, <code>#_TAGNEXTEVENTS</code> and <code>#_TAGALLEVENTS</code> element.', 'dbem') . $categories_placeholder_tip);
        em_options_input_text(__('Default event list format footer', 'dbem'), 'dbem_tag_event_list_item_footer_format', __('This content will appear just below your code for the default event list format. Default is blank', 'dbem'));
        em_options_textarea(sprintf(__('No %s message', 'dbem'), __('events', 'dbem')), 'dbem_tag_no_events_message', __('The message to be displayed in the list generated by <code>#_TAGNEXTEVENTS</code>, <code>#_TAGNEXTEVENTS</code> and <code>#_TAGALLEVENTS</code> when no events are available.', 'dbem'));
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				<?php 
    }
    ?>
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('RSS', 'dbem');
    ?>
 </span></h3>
				<div class="inside">
	            	<table class="form-table">
						<?php 
    em_options_input_text(__('RSS main title', 'dbem'), 'dbem_rss_main_title', __('The main title of your RSS events feed.', 'dbem') . $events_placeholder_tip);
    em_options_input_text(__('RSS main description', 'dbem'), 'dbem_rss_main_description', __('The main description of your RSS events feed.', 'dbem'));
    em_options_input_text(__('RSS title format', 'dbem'), 'dbem_rss_title_format', __('The format of the title of each item in the events RSS feed.', 'dbem') . $events_placeholder_tip);
    em_options_input_text(__('RSS description format', 'dbem'), 'dbem_rss_description_format', __('The format of the description of each item in the events RSS feed.', 'dbem') . $events_placeholder_tip);
    echo $save_button;
    ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('Maps', 'dbem');
    ?>
 </span></h3>
				<div class="inside">
					<p><?php 
    echo sprintf(__('You can use Google Maps to show where your events are located. For more information on using maps, <a href="%s">see our documentation</a>.', 'dbem'), 'http://wp-events-plugin.com/documentation/google-maps/');
    ?>
					<table class='form-table'> 
						<?php 
    $gmap_is_active = get_option('dbem_gmap_is_active');
    ?>
						<tr valign="top">
							<th scope="row"><?php 
    _e('Enable Google Maps integration?', 'dbem');
    ?>
</th>
							<td>
								<?php 
    _e('Yes');
    ?>
 <input id="dbem_gmap_is_active_yes" name="dbem_gmap_is_active" type="radio" value="1" <?php 
    echo $gmap_is_active ? "checked='checked'" : '';
    ?>
 />
								<?php 
    _e('No');
    ?>
 <input name="dbem_gmap_is_active" type="radio" value="0" <?php 
    echo $gmap_is_active ? '' : "checked='checked'";
    ?>
 /><br />
								<em><?php 
    _e('Check this option to enable Goggle Map integration.', 'dbem');
    ?>
</em>
							</td>
						</tr>
						<tr><td colspan="2">
							<strong><?php 
    _e('Global Map Format', 'dbem');
    ?>
</strong>
							<p><?php 
    echo sprintf(__('If you use the %s <a href="%s">shortcode</a>, you can display a map of all your locations and events, the settings below will be used.', 'dbem'), '<code>[locations_map]</code>', 'http://wp-events-plugin.com/documentation/shortcodes/');
    ?>
</p>
						</td></tr>
						<?php 
    em_options_textarea(__('Location balloon format', 'dbem'), 'dbem_map_text_format', __('The format of of the text appearing in the balloon describing the location.', 'dbem') . ' ' . __('Event.', 'dbem') . $locations_placeholder_tip);
    ?>
						<tr><td colspan="2">
							<strong><?php 
    _e('Single Location/Event Map Format', 'dbem');
    ?>
</strong>
							<p><?php 
    echo sprintf(_e('If you use the <code>#_LOCATIONMAP</code> <a href="%s">placeholder</a> when displaying individual event and location information, the settings below will be used.', 'dbem'), '<code>[locations_map]</code>', 'http://wp-events-plugin.com/documentation/placeholders/');
    ?>
</p>
						</td></tr>
						<?php 
    em_options_textarea(__('Location balloon format', 'dbem'), 'dbem_location_baloon_format', __('The format of of the text appearing in the balloon describing the location.', 'dbem') . $events_placeholder_tip);
    echo $save_button;
    ?>
 
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				
				<?php 
    do_action('em_options_page_footer_formats');
    ?>
				
			</div> <!-- .em-menu-formats -->
			
			<?php 
    if (get_option('dbem_rsvp_enabled')) {
        ?>
			<!-- BOOKING OPTIONS -->
		  	<div class="em-menu-bookings em-menu-group" style="display:none;">	
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        echo sprintf(__('%s Options', 'dbem'), __('General', 'dbem'));
        ?>
 </span></h3>
				<div class="inside">
					<table class='form-table'> 
						<?php 
        em_options_radio_binary(__('Allow guest bookings?', 'dbem'), 'dbem_bookings_anonymous', __('If enabled, guest visitors can supply an email address and a user account will automatically be created for them along with their booking. They will be also be able to log back in with that newly created account.', 'dbem'));
        em_options_radio_binary(__('Approval Required?', 'dbem'), 'dbem_bookings_approval', __('Bookings will not be confirmed until the event administrator approves it.', 'dbem'));
        em_options_radio_binary(__('Reserved unconfirmed spaces?', 'dbem'), 'dbem_bookings_approval_reserved', __('By default, event spaces become unavailable once there are enough CONFIRMED bookings. To reserve spaces even if unnapproved, choose yes.', 'dbem'));
        em_options_radio_binary(__('Can users cancel their booking?', 'dbem'), 'dbem_bookings_user_cancellation', __('If enabled, users can cancel their bookings themselves from their bookings page.', 'dbem'));
        em_options_radio_binary(__('Allow overbooking when approving?', 'dbem'), 'dbem_bookings_approval_overbooking', __('If you get a lot of pending bookings and you decide to allow more bookings than spaces allow, setting this to yes will allow you to override the event space limit when manually approving.', 'dbem'));
        em_options_radio_binary(__('Allow double bookings?', 'dbem'), 'dbem_bookings_double', __('If enabled, users can book an event more than once.', 'dbem'));
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        echo sprintf(__('%s Options', 'dbem'), __('Pricing', 'dbem'));
        ?>
 </span></h3>
				<div class="inside">
					<table class='form-table'>
						<?php 
        /* Tax & Currency */
        em_options_select(__('Currency', 'dbem'), 'dbem_bookings_currency', em_get_currencies()->names, __('Choose your currency for displaying event pricing.', 'dbem'));
        em_options_input_text(__('Thousands Separator', 'dbem'), 'dbem_bookings_currency_thousands_sep', '<code>' . get_option('dbem_bookings_currency_thousands_sep') . " = " . em_get_currency_symbol() . '100<strong>' . get_option('dbem_bookings_currency_thousands_sep') . '</strong>000<strong>' . get_option('dbem_bookings_currency_decimal_point') . '</strong>00</code>');
        em_options_input_text(__('Decimal Point', 'dbem'), 'dbem_bookings_currency_decimal_point', '<code>' . get_option('dbem_bookings_currency_decimal_point') . " = " . em_get_currency_symbol() . '100<strong>' . get_option('dbem_bookings_currency_decimal_point') . '</strong>00</code>');
        em_options_input_text(__('Currency Format', 'dbem'), 'dbem_bookings_currency_format', __('Choose how prices are displayed. <code>@</code> will be replaced by the currency symbol, and <code>#</code> will be replaced by the number.', 'dbem') . ' <code>' . get_option('dbem_bookings_currency_format') . " = " . em_get_currency_formatted('10000000') . '</code>');
        em_options_input_text(__('Tax Rate', 'dbem'), 'dbem_bookings_tax', __('Add a tax rate to your ticket prices (entering 10 will add 10% to the ticket price).', 'dbem'));
        em_options_radio_binary(__('Add tax to ticket price?', 'dbem'), 'dbem_bookings_tax_auto_add', __('When displaying ticket prices and booking totals, include the tax automatically?', 'dbem'));
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox --> 
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        _e('Customize Feedback Messages', 'dbem');
        ?>
 </span></h3>
				<div class="inside">
					<p><?php 
        _e('Below you will find texts that will be displayed to users in various areas during the bookings process, particularly on booking forms.', 'dbem');
        ?>
</p>
					<table class='form-table'>
						<tr><td colspan='2'><h4><?php 
        _e('My Bookings messages', 'dbem');
        ?>
</h4></td></tr>
						<?php 
        em_options_input_text(__('Booking Cancelled', 'dbem'), 'dbem_booking_feedback_cancelled', __('When a user cancels their booking, this message will be displayed confirming the cancellation.', 'dbem'));
        em_options_input_text(__('Booking Cancellation Warning', 'dbem'), 'dbem_booking_warning_cancel', __('When a user chooses to cancel a booking, this warning is displayed for them to confirm.', 'dbem'));
        ?>
						<tr><td colspan='2'><h4><?php 
        _e('Booking form texts/messages', 'dbem');
        ?>
</h4></td></tr>
						<?php 
        em_options_input_text(__('Bookings disabled', 'dbem'), 'dbem_bookings_form_msg_disabled', __('An event with no bookings.', 'dbem'));
        em_options_input_text(__('Bookings closed', 'dbem'), 'dbem_bookings_form_msg_closed', __('Bookings have closed (e.g. event has started).', 'dbem'));
        em_options_input_text(__('Fully booked', 'dbem'), 'dbem_bookings_form_msg_full', __('Event is fully booked.', 'dbem'));
        em_options_input_text(__('Already attending', 'dbem'), 'dbem_bookings_form_msg_attending', __('If already attending and double bookings are disabled, this message will be displayed, followed by a link to the users booking page.', 'dbem'));
        em_options_input_text(__('Manage bookings link text', 'dbem'), 'dbem_bookings_form_msg_bookings_link', __('Link text used for link to user bookings.', 'dbem'));
        ?>
						<tr><td colspan='2'><h4><?php 
        _e('Booking form feedback messages', 'dbem');
        ?>
</h4></td></tr>
						<tr><td colspan='2'><?php 
        _e('When a booking is made by a user, a feedback message is shown depending on the result, which can be customized below.', 'dbem');
        ?>
</td></tr>
						<?php 
        em_options_input_text(__('Successful booking', 'dbem'), 'dbem_booking_feedback', __('When a booking is registered and confirmed.', 'dbem'));
        em_options_input_text(__('Successful pending booking', 'dbem'), 'dbem_booking_feedback_pending', __('When a booking is registered but pending.', 'dbem'));
        em_options_input_text(__('Not enough spaces', 'dbem'), 'dbem_booking_feedback_full', __('When a booking cannot be made due to lack of spaces.', 'dbem'));
        em_options_input_text(__('Errors', 'dbem'), 'dbem_booking_feedback_error', __('When a booking cannot be made due to an error when filling the form. Below this, there will be a dynamic list of errors.', 'dbem'));
        em_options_input_text(__('Email Exists', 'dbem'), 'dbem_booking_feedback_email_exists', __('When a guest tries to book using an email registered with a user account.', 'dbem'));
        em_options_input_text(__('User must log in', 'dbem'), 'dbem_booking_feedback_log_in', __('When a user must log in before making a booking.', 'dbem'));
        em_options_input_text(__('Error mailing user', 'dbem'), 'dbem_booking_feedback_nomail', __('If a booking is made and an email cannot be sent, this is added to the success message.', 'dbem'));
        em_options_input_text(__('Already booked', 'dbem'), 'dbem_booking_feedback_already_booked', __('If the user made a previous booking and cannot double-book.', 'dbem'));
        em_options_input_text(__('No spaces booked', 'dbem'), 'dbem_booking_feedback_min_space', __('If the user tries to make a booking without requesting any spaces.', 'dbem'));
        $notice_full = __('Sold Out', 'dbem');
        ?>
						<tr><td colspan='2'><h4><?php 
        _e('Booking button feedback messages', 'dbem');
        ?>
</h4></td></tr>
						<tr><td colspan='2'><?php 
        echo sprintf(__('When the %s placeholder, the below texts will be used.', 'dbem'), '<code>#_BOOKINGBUTTON</code>');
        ?>
</td></tr>
						<?php 
        em_options_input_text(__('User can book', 'dbem'), 'dbem_booking_button_msg_book', '');
        em_options_input_text(__('Booking in progress', 'dbem'), 'dbem_booking_button_msg_booking', '');
        em_options_input_text(__('Booking complete', 'dbem'), 'dbem_booking_button_msg_booked', '');
        em_options_input_text(__('Booking error', 'dbem'), 'dbem_booking_button_msg_error', '');
        em_options_input_text(__('Event fully booked', 'dbem'), 'dbem_booking_button_msg_full', '');
        em_options_input_text(__('Cancel', 'dbem'), 'dbem_booking_button_msg_cancel', '');
        em_options_input_text(__('Cancelation in progress', 'dbem'), 'dbem_booking_button_msg_canceling', '');
        em_options_input_text(__('Cancelation complete', 'dbem'), 'dbem_booking_button_msg_cancelled', '');
        em_options_input_text(__('Cancelation error', 'dbem'), 'dbem_booking_button_msg_cancel_error', '');
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox --> 
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        echo sprintf(__('%s Options', 'dbem'), __('Booking Form', 'dbem'));
        ?>
 </span></h3>
				<div class="inside">
					<table class='form-table'>
						<?php 
        em_options_radio_binary(__('Display login form?', 'dbem'), 'dbem_bookings_login_form', __('Choose whether or not to display a login form in the booking form area to remind your members to log in before booking.', 'dbem'));
        em_options_input_text(__('Submit button text', 'dbem'), 'dbem_bookings_submit_button', sprintf(__('The text used by the submit button. To use an image instead, enter the full url starting with %s or %s.', 'dbem'), '<code>http://</code>', '<code>https://</code>'));
        do_action('em_options_booking_form_options');
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox --> 
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        echo sprintf(__('%s Options', 'dbem'), __('Ticket', 'dbem'));
        ?>
 </span></h3>
				<div class="inside">
					<table class='form-table'>
						<?php 
        em_options_radio_binary(__('Single ticket mode?', 'dbem'), 'dbem_bookings_tickets_single', __('In single ticket mode, users can only create one ticket per booking (and will not see options to add more tickets).', 'dbem'));
        em_options_radio_binary(__('Show ticket table in single ticket mode?', 'dbem'), 'dbem_bookings_tickets_single_form', __('If you prefer a ticket table like with multiple tickets, even for single ticket events, enable this.', 'dbem'));
        em_options_radio_binary(__('Show unavailable tickets?', 'dbem'), 'dbem_bookings_tickets_show_unavailable', __('You can choose whether or not to show unavailable tickets to visitors.', 'dbem'));
        em_options_radio_binary(__('Show multiple tickets if logged out?', 'dbem'), 'dbem_bookings_tickets_show_loggedout', __('If logged out, a user will be asked to register in order to book. However, we can show available tickets if you have more than one ticket.', 'dbem'));
        $ticket_orders = array('ticket_price DESC, ticket_name ASC' => __('Ticket Price (Descending)', 'dbem'), 'ticket_price ASC, ticket_name ASC' => __('Ticket Price (Ascending)', 'dbem'), 'ticket_name ASC, ticket_price DESC' => __('Ticket Name (Ascending)', 'dbem'), 'ticket_name DESC, ticket_price DESC' => __('Ticket Name (Descending)', 'dbem'));
        em_options_select(__('Order Tickets By', 'dbem'), 'dbem_bookings_tickets_orderby', $ticket_orders, __('Choose which order your tickets appear.', 'dbem'));
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox --> 
					
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        _e('No-User Booking Mode', 'dbem');
        ?>
 </span></h3>
				<div class="inside">
					<table class='form-table'>
						<tr><td colspan='2'>
							<p><?php 
        _e('By default, when a booking is made by a user, this booking is tied to a user account, if the user is not registered nor logged in and guest bookings are enabled, an account will be created for them.', 'dbem');
        ?>
</p>
							<p><?php 
        _e('The option below allows you to disable user accounts and assign all bookings to a parent user, yet you will still see the supplied booking personal information for each booking. When this mode is enabled, extra booking information about the person is stored alongside the booking record rather than as a WordPress user.', 'dbem');
        ?>
</p>
							<p><?php 
        _e('<strong>Warning : </strong> Various features afforded to users with an account will not be available, e.g. viewing bookings. Once you enable this and select a user, modifying these values will prevent older non-user bookings from displaying the correct information.', 'dbem');
        ?>
</p>
						</td></tr>
						<?php 
        em_options_radio_binary(__('Enable No-User Booking Mode?', 'dbem'), 'dbem_bookings_registration_disable', __('This disables user registrations for bookings.', 'dbem'));
        $current_user = array();
        if (get_option('dbem_bookings_registration_user')) {
            $user = get_user_by('id', get_option('dbem_bookings_registration_user'));
            $current_user[$user->ID] = $user->display_name;
        }
        em_options_select(__('Assign bookings to', 'dbem'), 'dbem_bookings_registration_user', em_get_wp_users(array('role' => 'subscriber'), $current_user), __('Choose a parent user to assign bookings to. People making their booking will be unaware of this and will never have access to those user details. This should be a subscriber user you do not use to log in with yourself.', 'dbem'));
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				
				<?php 
        do_action('em_options_page_footer_bookings');
        ?>
				
			</div> <!-- .em-menu-bookings -->
			<?php 
    }
    ?>
			
			<!-- EMAIL OPTIONS -->
		  	<div class="em-menu-emails em-menu-group" style="display:none;">
				
				<?php 
    if (!is_multisite()) {
        em_admin_option_box_email();
    }
    ?>
		  	
		  		<?php 
    if (get_option('dbem_rsvp_enabled')) {
        ?>
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle', 'dbem');
        ?>
"><br /></div><h3><span><?php 
        _e('Booking Email Templates', 'dbem');
        ?>
 </span></h3>
				<div class="inside">
					<table class='form-table'>
						<?php 
        $email_subject_tip = __('You can disable this email by leaving the subject blank.', 'dbem');
        em_options_input_text(__('Email events admin?', 'dbem'), 'dbem_bookings_notify_admin', __("If you would like every event booking confirmation email sent to an administrator write their email here (leave blank to not send an email).", 'dbem') . ' ' . __('For multiple emails, seperate by commas (e.g. email1@test.com,email2@test.com,etc.)', 'dbem'));
        em_options_radio_binary(__('Email event owner?', 'dbem'), 'dbem_bookings_contact_email', __('Check this option if you want the event contact to receive an email when someone books places. An email will be sent when a booking is first made (regardless if confirmed or pending)', 'dbem'));
        em_options_radio_binary(__('Disable new registration email?', 'dbem'), 'dbem_email_disable_registration', __('Check this option if you want to prevent the WordPress registration email from going out when a user anonymously books an event.', 'dbem'));
        ?>
						<tr><td colspan='2'><h4><?php 
        _e('Contact person booking confirmed', 'dbem');
        ?>
</h4></td></tr>
						<tr><td colspan='2'><?php 
        echo __('An email will be sent to the event contact when a booking is first made.', 'dbem') . $bookings_placeholder_tip;
        ?>
</td></tr>
						<?php 
        em_options_input_text(__('Contact person email subject', 'dbem'), 'dbem_bookings_contact_email_subject', $email_subject_tip);
        em_options_textarea(__('Contact person email', 'dbem'), 'dbem_bookings_contact_email_body', '');
        ?>
						<tr><td colspan='2'><h4><?php 
        _e('Contact person booking cancelled', 'dbem');
        ?>
</h4></td></tr>
						<tr><td colspan='2'><?php 
        echo __('An email will be sent to the event contact if someone cancels their booking.', 'dbem') . $bookings_placeholder_tip;
        ?>
</td></tr>
						<?php 
        em_options_input_text(__('Contact person cancellation subject', 'dbem'), 'dbem_contactperson_email_cancelled_subject', $email_subject_tip);
        em_options_textarea(__('Contact person cancellation email', 'dbem'), 'dbem_contactperson_email_cancelled_body', '');
        ?>
						<tr><td colspan='2'><h4><?php 
        _e('Confirmed booking email', 'dbem');
        ?>
</h4></td></tr>
						<tr><td colspan='2'><?php 
        echo __('This is sent when a person\'s booking is confirmed. This will be sent automatically if approvals are required and the booking is approved. If approvals are disabled, this is sent out when a user first submits their booking.', 'dbem') . $bookings_placeholder_tip;
        ?>
</td></tr>
						<?php 
        em_options_input_text(__('Booking confirmed email subject', 'dbem'), 'dbem_bookings_email_confirmed_subject', $email_subject_tip);
        em_options_textarea(__('Booking confirmed email', 'dbem'), 'dbem_bookings_email_confirmed_body', '');
        ?>
						<tr><td colspan='2'><h4><?php 
        _e('Pending booking email', 'dbem');
        ?>
</h4></td></tr>
						<tr><td colspan='2'><?php 
        echo __('This will be sent to the person when they first submit their booking. Not relevant if bookings don\'t require approval.', 'dbem') . $bookings_placeholder_tip;
        ?>
</td></tr>
						<?php 
        em_options_input_text(__('Booking pending email subject', 'dbem'), 'dbem_bookings_email_pending_subject', $email_subject_tip);
        em_options_textarea(__('Booking pending email', 'dbem'), 'dbem_bookings_email_pending_body', '');
        ?>
						<tr><td colspan='2'><h4><?php 
        _e('Rejected booking email', 'dbem');
        ?>
</h4></td></tr>
						<tr><td colspan='2'><?php 
        echo __('This will be sent automatically when a booking is rejected. Not relevant if bookings don\'t require approval.', 'dbem') . $bookings_placeholder_tip;
        ?>
</td></tr>
						<?php 
        em_options_input_text(__('Booking rejected email subject', 'dbem'), 'dbem_bookings_email_rejected_subject', $email_subject_tip);
        em_options_textarea(__('Booking rejected email', 'dbem'), 'dbem_bookings_email_rejected_body', '');
        ?>
						<tr><td colspan='2'><h4><?php 
        _e('Booking cancelled', 'dbem');
        ?>
</h4></td></tr>
						<tr><td colspan='2'><?php 
        echo __('This will be sent when a user cancels their booking.', 'dbem') . $bookings_placeholder_tip;
        ?>
</td></tr>
						<?php 
        em_options_input_text(__('Booking cancelled email subject', 'dbem'), 'dbem_bookings_email_cancelled_subject', $email_subject_tip);
        em_options_textarea(__('Booking cancelled email', 'dbem'), 'dbem_bookings_email_cancelled_body', '');
        ?>
						<?php 
        echo $save_button;
        ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				<?php 
    }
    ?>
				
				<div  class="postbox " >
				<div class="handlediv" title="<?php 
    __('Click to toggle', 'dbem');
    ?>
"><br /></div><h3><span><?php 
    _e('Event Submission Templates', 'dbem');
    ?>
 </span></h3>
				<div class="inside">
					<table class='form-table'>
						<?php 
    em_options_input_text(__('Administrator Email', 'dbem'), 'dbem_event_submitted_email_admin', __('Event submission notifications will be sent to emails added here.', 'dbem') . ' ' . __('If left blank, no emails will be sent. Seperate emails with commas for more than one email.', 'dbem'));
    ?>
						<tr><td colspan='2'><strong><?php 
    _e('Event Submitted', 'dbem');
    ?>
</strong></td></tr>
						<tr><td colspan='2'><?php 
    echo __('An email will be sent to your administrator emails when an event is submitted and pending approval.', 'dbem') . $bookings_placeholder_tip;
    ?>
</td></tr>
						<?php 
    em_options_input_text(__('Event submitted subject', 'dbem'), 'dbem_event_submitted_email_subject', __('If left blank, this email will not be sent.', 'dbem'));
    em_options_textarea(__('Event submitted email', 'dbem'), 'dbem_event_submitted_email_body', '');
    ?>
						<tr><td colspan='2'><strong><?php 
    _e('Event Re-Submitted', 'dbem');
    ?>
</strong></td></tr>
						<tr><td colspan='2'><?php 
    echo __('When a user modifies a previously published event, it will be put back into pending review status and will not be publisehd until you re-approve it.', 'dbem') . $bookings_placeholder_tip;
    ?>
</td></tr>
						<?php 
    em_options_input_text(__('Event resubmitted subject', 'dbem'), 'dbem_event_resubmitted_email_subject', __('If left blank, this email will not be sent.', 'dbem'));
    em_options_textarea(__('Event resubmitted email', 'dbem'), 'dbem_event_resubmitted_email_body', '');
    ?>
						<tr><td colspan='2'><strong><?php 
    _e('Event Published', 'dbem');
    ?>
</strong></td></tr>
						<tr><td colspan='2'><?php 
    echo __('An email will be sent to an administrator of your choice when an event is published by users who are not administrators.', 'dbem') . $bookings_placeholder_tip;
    ?>
</td></tr>
						<?php 
    em_options_input_text(__('Event published subject', 'dbem'), 'dbem_event_published_email_subject', __('If left blank, this email will not be sent.', 'dbem'));
    em_options_textarea(__('Event published email', 'dbem'), 'dbem_event_published_email_body', '');
    ?>
						<tr><td colspan='2'><strong><?php 
    _e('Event Approved', 'dbem');
    ?>
</strong></td></tr>
						<tr><td colspan='2'><?php 
    echo __('An email will be sent to the event owner when their event is approved. Users requiring event approval do not have the <code>publish_events</code> capability.', 'dbem') . $bookings_placeholder_tip;
    ?>
</td></tr>
						<?php 
    em_options_input_text(__('Event approved subject', 'dbem'), 'dbem_event_approved_email_subject', __('If left blank, this email will not be sent.', 'dbem'));
    em_options_textarea(__('Event approved email', 'dbem'), 'dbem_event_approved_email_body', '');
    ?>
						<tr><td colspan='2'><?php 
    echo __('When a user modifies a previously published event, it will be put back into pending review status and will not be publisehd until you re-approve it.', 'dbem') . $bookings_placeholder_tip;
    ?>
</td></tr>
						<?php 
    em_options_input_text(__('Event reapproved subject', 'dbem'), 'dbem_event_reapproved_email_subject', __('If left blank, this email will not be sent.', 'dbem'));
    em_options_textarea(__('Event reapproved email', 'dbem'), 'dbem_event_reapproved_email_body', '');
    ?>
						<?php 
    echo $save_button;
    ?>
					</table>
				</div> <!-- . inside -->
				</div> <!-- .postbox -->
				
				<?php 
    do_action('em_options_page_footer_emails');
    ?>
				
			</div><!-- .em-group-emails --> 
			<?php 
    /*
    <div  class="postbox " >
    <div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Debug Modes', 'dbem' ); ?> </span></h3>
    <div class="inside">
    	<table class='form-table'>
    		<?php
    		em_options_radio_binary ( __( 'EM Debug Mode?', 'dbem' ), 'dbem_debug', __( 'Setting this to yes will display different content to admins for event pages and emails so you can see all the available placeholders and their values.', 'dbem' ) );
    		em_options_radio_binary ( __( 'WP Debug Mode?', 'dbem' ), 'dbem_wp_debug', __( 'This will turn WP_DEBUG mode on. Useful if you want to troubleshoot php errors without looking at your logs.', 'dbem' ) );
    		?>
    	</table>
    </div> <!-- . inside -->
    </div> <!-- .postbox -->
    */
    ?>

			<p class="submit">
				<input type="submit" id="dbem_options_submit" class="button-primary" name="Submit" value="<?php 
    _e('Save Changes');
    ?>
" />
				<input type="hidden" name="em-submitted" value="1" />
				<input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('events-manager-options');
    ?>
" />
			</p>  
			
			</div> <!-- .metabox-sortables -->
			</div> <!-- .postbox-container -->
			
			</div> <!-- .metabox-holder -->	
		</form>
	</div>
	<?php 
}
Exemplo n.º 15
0
 /**
  * Gets the total price for this ticket.
  * @return float
  */
 function get_price($format = false, $add_tax = 'x')
 {
     $price = $this->ticket_price;
     if (is_numeric(get_option('dbem_bookings_tax')) && get_option('dbem_bookings_tax') > 0) {
         //tax could be added here
         if ($add_tax === true || $add_tax !== false && get_option('dbem_bookings_tax_auto_add')) {
             $price = round($price * (1 + get_option('dbem_bookings_tax') / 100), 2);
         }
     }
     $price = apply_filters('em_ticket_get_price', $price, $this);
     if ($format) {
         return em_get_currency_formatted($price);
     }
     return $price;
 }
Exemplo n.º 16
0
 /**
  * Will output a event in the format passed in $format by replacing placeholders within the format.
  * @param string $format
  * @param string $target
  * @return string
  */
 function output($format, $target = "html")
 {
     $event_string = $format;
     //Time place holder that doesn't show if empty.
     //TODO add filter here too
     preg_match_all('/#@?_\\{[^}]+\\}/', $format, $results);
     foreach ($results[0] as $result) {
         if (substr($result, 0, 3) == "#@_") {
             $date = 'end_date';
             $offset = 4;
         } else {
             $date = 'start_date';
             $offset = 3;
         }
         if ($date == 'end_date' && $this->event_end_date == $this->event_start_date) {
             $replace = __(apply_filters('em_event_output_placeholder', '', $this, $result, $target));
         } else {
             $replace = __(apply_filters('em_event_output_placeholder', mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $this->{$date}), $this, $result, $target));
         }
         $event_string = str_replace($result, $replace, $event_string);
     }
     //This is for the custom attributes
     preg_match_all('/#_ATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $event_string, $results);
     $attributes = em_get_attributes();
     foreach ($results[0] as $resultKey => $result) {
         //Strip string of placeholder and just leave the reference
         $attRef = substr(substr($result, 0, strpos($result, '}')), 6);
         $attString = '';
         if (is_array($this->event_attributes) && array_key_exists($attRef, $this->event_attributes)) {
             $attString = $this->event_attributes[$attRef];
         } elseif (!empty($results[3][$resultKey])) {
             //Check to see if we have a second set of braces;
             $attString = $results[3][$resultKey];
         } elseif (!empty($attributes['values'][$attRef][0])) {
             $attString = $attributes['values'][$attRef][0];
         }
         $attString = apply_filters('em_event_output_placeholder', $attString, $this, $result, $target);
         $event_string = str_replace($result, $attString, $event_string);
     }
     //First let's do some conditional placeholder removals
     for ($i = 0; $i < EM_CONDITIONAL_RECURSIONS; $i++) {
         //you can add nested recursions by modifying this setting in your wp_options table
         preg_match_all('/\\{([a-zA-Z0-9_\\-]+)\\}(.+?)\\{\\/\\1\\}/s', $event_string, $conditionals);
         if (count($conditionals[0]) > 0) {
             //Check if the language we want exists, if not we take the first language there
             foreach ($conditionals[1] as $key => $condition) {
                 $show_condition = false;
                 if ($condition == 'has_bookings') {
                     //check if there's a booking, if not, remove this section of code.
                     $show_condition = $this->event_rsvp && get_option('dbem_rsvp_enabled');
                 } elseif ($condition == 'no_bookings') {
                     //check if there's a booking, if not, remove this section of code.
                     $show_condition = !$this->event_rsvp && get_option('dbem_rsvp_enabled');
                 } elseif ($condition == 'no_location') {
                     //does this event have a valid location?
                     $show_condition = empty($this->location_id) || !$this->get_location()->location_status;
                 } elseif ($condition == 'has_location') {
                     //does this event have a valid location?
                     $show_condition = !empty($this->location_id) && $this->get_location()->location_status;
                 } elseif ($condition == 'has_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() != '';
                 } elseif ($condition == 'no_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() == '';
                 } elseif ($condition == 'has_time') {
                     //are the booking times different and not an all-day event
                     $show_condition = $this->event_start_time != $this->event_end_time && !$this->event_all_day;
                 } elseif ($condition == 'no_time') {
                     //are the booking times exactly the same and it's not an all-day event.
                     $show_condition = $this->event_start_time == $this->event_end_time && !$this->event_all_day;
                 } elseif ($condition == 'all_day') {
                     //is it an all day event
                     $show_condition = !empty($this->event_all_day);
                 } elseif ($condition == 'logged_in') {
                     //user is logged in
                     $show_condition = is_user_logged_in();
                 } elseif ($condition == 'not_logged_in') {
                     //not logged in
                     $show_condition = !is_user_logged_in();
                 } elseif ($condition == 'has_spaces') {
                     //there are still empty spaces
                     $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() > 0;
                 } elseif ($condition == 'fully_booked') {
                     //event is fully booked
                     $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() <= 0;
                 } elseif ($condition == 'bookings_open') {
                     //bookings are still open
                     $show_condition = $this->event_rsvp && $this->get_bookings()->is_open();
                 } elseif ($condition == 'bookings_closed') {
                     //bookings are still closed
                     $show_condition = $this->event_rsvp && !$this->get_bookings()->is_open();
                 } elseif ($condition == 'is_free' || $condition == 'is_free_now') {
                     //is it a free day event, if _now then free right now
                     $show_condition = !$this->event_rsvp || $this->is_free($condition == 'is_free_now');
                 } elseif ($condition == 'not_free' || $condition == 'not_free_now') {
                     //is it a paid event, if _now then paid right now
                     $show_condition = $this->event_rsvp && !$this->is_free($condition == 'not_free_now');
                 } elseif ($condition == 'is_long') {
                     //is it an all day event
                     $show_condition = $this->event_start_date != $this->event_end_date;
                 } elseif ($condition == 'not_long') {
                     //is it an all day event
                     $show_condition = $this->event_start_date == $this->event_end_date;
                 } elseif ($condition == 'is_past') {
                     //if event is past
                     if (get_option('dbem_events_current_are_past')) {
                         $show_condition = $this->start <= current_time('timestamp');
                     } else {
                         $show_condition = $this->end <= current_time('timestamp');
                     }
                 } elseif ($condition == 'is_future') {
                     //if event is upcoming
                     $show_condition = $this->start > current_time('timestamp');
                 } elseif ($condition == 'is_current') {
                     //if event is upcoming
                     $ts = current_time('timestamp');
                     $show_condition = $this->start <= $ts && $this->end >= $ts;
                 } elseif ($condition == 'is_recurrence') {
                     //if event is a recurrence
                     $show_condition = $this->is_recurrence();
                 } elseif ($condition == 'not_recurrence') {
                     //if event is not a recurrence
                     $show_condition = !$this->is_recurrence();
                 } elseif ($condition == 'is_private') {
                     //if event is a recurrence
                     $show_condition = $this->event_private == 1;
                 } elseif ($condition == 'not_private') {
                     //if event is not a recurrence
                     $show_condition = $this->event_private == 0;
                 } elseif (preg_match('/^has_category_([a-zA-Z0-9_\\-]+)$/', $condition, $category_match)) {
                     //event is in this category
                     $show_condition = has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
                 } elseif (preg_match('/^no_category_([a-zA-Z0-9_\\-]+)$/', $condition, $category_match)) {
                     //event is NOT in this category
                     $show_condition = !has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
                 } elseif (preg_match('/^has_tag_([a-zA-Z0-9_\\-]+)$/', $condition, $tag_match)) {
                     //event has this tag
                     $show_condition = has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
                 } elseif (preg_match('/^no_tag_([a-zA-Z0-9_\\-]+)$/', $condition, $tag_match)) {
                     //event doesn't have this tag
                     $show_condition = !has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
                 }
                 //other potential ones - has_attribute_... no_attribute_... has_categories_...
                 $show_condition = apply_filters('em_event_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this);
                 if ($show_condition) {
                     //calculate lengths to delete placeholders
                     $placeholder_length = strlen($condition) + 2;
                     $replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key]) - ($placeholder_length * 2 + 1));
                 } else {
                     $replacement = '';
                 }
                 $event_string = str_replace($conditionals[0][$key], apply_filters('em_event_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $event_string);
             }
         }
     }
     //Now let's check out the placeholders.
     preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $event_string, $placeholders);
     $replaces = array();
     foreach ($placeholders[1] as $key => $result) {
         $match = true;
         $replace = '';
         $full_result = $placeholders[0][$key];
         switch ($result) {
             //Event Details
             case '#_EVENTID':
                 $replace = $this->event_id;
                 break;
             case '#_EVENTPOSTID':
                 $replace = $this->post_id;
                 break;
             case '#_NAME':
                 //depreciated
             //depreciated
             case '#_EVENTNAME':
                 $replace = $this->event_name;
                 break;
             case '#_NOTES':
                 //depreciated
             //depreciated
             case '#_EXCERPT':
                 //depreciated
             //depreciated
             case '#_EVENTNOTES':
             case '#_EVENTEXCERPT':
                 $replace = $this->post_content;
                 if ($result == "#_EXCERPT" || $result == "#_EVENTEXCERPT") {
                     if (!empty($this->post_excerpt)) {
                         $replace = $this->post_excerpt;
                     } else {
                         $excerpt_length = 55;
                         $excerpt_more = apply_filters('em_excerpt_more', ' ' . '[...]');
                         if (!empty($placeholders[3][$key])) {
                             $trim = true;
                             $ph_args = explode(',', $placeholders[3][$key]);
                             if (is_numeric($ph_args[0])) {
                                 $excerpt_length = $ph_args[0];
                             }
                             if (!empty($ph_args[1])) {
                                 $excerpt_more = $ph_args[1];
                             }
                         }
                         if (preg_match('/<!--more(.*?)?-->/', $replace, $matches)) {
                             $content = explode($matches[0], $replace, 2);
                             $replace = force_balance_tags($content[0]);
                         }
                         if (!empty($trim)) {
                             //shorten content by supplied number - copied from wp_trim_excerpt
                             $replace = strip_shortcodes($replace);
                             $replace = str_replace(']]>', ']]&gt;', $replace);
                             $replace = wp_trim_words($replace, $excerpt_length, $excerpt_more);
                         }
                     }
                 }
                 break;
             case '#_EVENTIMAGEURL':
             case '#_EVENTIMAGE':
                 if ($this->get_image_url() != '') {
                     if ($result == '#_EVENTIMAGEURL') {
                         $replace = esc_url($this->image_url);
                     } else {
                         if (empty($placeholders[3][$key])) {
                             $replace = "<img src='" . esc_url($this->image_url) . "' alt='" . esc_attr($this->event_name) . "'/>";
                         } else {
                             $image_size = explode(',', $placeholders[3][$key]);
                             $image_url = $this->image_url;
                             if (self::array_is_numeric($image_size) && count($image_size) > 1) {
                                 //get a thumbnail
                                 if (get_option('dbem_disable_thumbnails')) {
                                     $image_attr = '';
                                     $image_args = array();
                                     if (empty($image_size[1]) && !empty($image_size[0])) {
                                         $image_attr = 'width="' . $image_size[0] . '"';
                                         $image_args['w'] = $image_size[0];
                                     } elseif (empty($image_size[0]) && !empty($image_size[1])) {
                                         $image_attr = 'height="' . $image_size[1] . '"';
                                         $image_args['h'] = $image_size[1];
                                     } elseif (!empty($image_size[0]) && !empty($image_size[1])) {
                                         $image_attr = 'width="' . $image_size[0] . '" height="' . $image_size[1] . '"';
                                         $image_args = array('w' => $image_size[0], 'h' => $image_size[1]);
                                     }
                                     $replace = "<img src='" . esc_url(em_add_get_params($image_url, $image_args)) . "' alt='" . esc_attr($this->event_name) . "' {$image_attr} />";
                                 } else {
                                     if (EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id) {
                                         switch_to_blog($this->blog_id);
                                         $switch_back = true;
                                     }
                                     $replace = get_the_post_thumbnail($this->ID, $image_size);
                                     if (!empty($switch_back)) {
                                         restore_current_blog();
                                     }
                                 }
                             } else {
                                 $replace = "<img src='" . esc_url($image_url) . "' alt='" . esc_attr($this->event_name) . "'/>";
                             }
                         }
                     }
                 }
                 break;
                 //Times & Dates
             //Times & Dates
             case '#_24HSTARTTIME':
             case '#_24HENDTIME':
                 $time = $result == '#_24HSTARTTIME' ? $this->event_start_time : $this->event_end_time;
                 $replace = substr($time, 0, 5);
                 break;
             case '#_12HSTARTTIME':
             case '#_12HENDTIME':
                 $time = $result == '#_12HSTARTTIME' ? $this->event_start_time : $this->event_end_time;
                 $replace = date('g:i A', strtotime($time));
                 break;
             case '#_EVENTTIMES':
                 //get format of time to show
                 if (!$this->event_all_day) {
                     $time_format = get_option('dbem_time_format') ? get_option('dbem_time_format') : get_option('time_format');
                     if ($this->event_start_time != $this->event_end_time) {
                         $replace = date_i18n($time_format, $this->start) . get_option('dbem_times_separator') . date_i18n($time_format, $this->end);
                     } else {
                         $replace = date_i18n($time_format, $this->start);
                     }
                 } else {
                     $replace = get_option('dbem_event_all_day_message');
                 }
                 break;
             case '#_EVENTDATES':
                 //get format of time to show
                 $date_format = get_option('dbem_date_format') ? get_option('dbem_date_format') : get_option('date_format');
                 if ($this->event_start_date != $this->event_end_date) {
                     $replace = date_i18n($date_format, $this->start) . get_option('dbem_dates_separator') . date_i18n($date_format, $this->end);
                 } else {
                     $replace = date_i18n($date_format, $this->start);
                 }
                 break;
                 //Links
             //Links
             case '#_EVENTPAGEURL':
                 //Depreciated
             //Depreciated
             case '#_LINKEDNAME':
                 //Depreciated
             //Depreciated
             case '#_EVENTURL':
                 //Just the URL
             //Just the URL
             case '#_EVENTLINK':
                 //HTML Link
                 $event_link = esc_url($this->get_permalink());
                 if ($result == '#_LINKEDNAME' || $result == '#_EVENTLINK') {
                     $replace = '<a href="' . $event_link . '" title="' . esc_attr($this->event_name) . '">' . esc_attr($this->event_name) . '</a>';
                 } else {
                     $replace = $event_link;
                 }
                 break;
             case '#_EDITEVENTURL':
             case '#_EDITEVENTLINK':
                 if ($this->can_manage('edit_events', 'edit_others_events')) {
                     $link = esc_url($this->get_edit_url());
                     if ($result == '#_EDITEVENTLINK') {
                         $replace = '<a href="' . $link . '">' . esc_html(sprintf(__('Edit Event', 'dbem'))) . '</a>';
                     } else {
                         $replace = $link;
                     }
                 }
                 break;
                 //Bookings
             //Bookings
             case '#_ADDBOOKINGFORM':
                 //Depreciated
             //Depreciated
             case '#_REMOVEBOOKINGFORM':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGFORM':
                 if (get_option('dbem_rsvp_enabled')) {
                     if (!defined('EM_XSS_BOOKINGFORM_FILTER') && locate_template('plugins/events-manager/placeholders/bookingform.php')) {
                         //xss fix for old overriden booking forms
                         add_filter('em_booking_form_action_url', 'esc_url');
                         define('EM_XSS_BOOKINGFORM_FILTER', true);
                     }
                     ob_start();
                     $template = em_locate_template('placeholders/bookingform.php', true, array('EM_Event' => $this));
                     EM_Bookings::enqueue_js();
                     $replace = ob_get_clean();
                 }
                 break;
             case '#_BOOKINGBUTTON':
                 if (get_option('dbem_rsvp_enabled') && $this->event_rsvp) {
                     ob_start();
                     $template = em_locate_template('placeholders/bookingbutton.php', true, array('EM_Event' => $this));
                     $replace = ob_get_clean();
                 }
                 break;
             case '#_EVENTPRICERANGEALL':
                 $show_all_ticket_prices = true;
                 //continues below
             //continues below
             case '#_EVENTPRICERANGE':
                 //get the range of prices
                 $min = false;
                 $max = 0;
                 if ($this->get_bookings()->is_open() || !empty($show_all_ticket_prices)) {
                     foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                         /* @var $EM_Ticket EM_Ticket */
                         if ($EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable') || !empty($show_all_ticket_prices)) {
                             if ($EM_Ticket->get_price() > $max) {
                                 $max = $EM_Ticket->get_price();
                             }
                             if ($EM_Ticket->get_price() < $min || $min === false) {
                                 $min = $EM_Ticket->get_price();
                             }
                         }
                     }
                 }
                 if ($min === false) {
                     $min = 0;
                 }
                 if ($min != $max) {
                     $replace = em_get_currency_formatted($min) . ' - ' . em_get_currency_formatted($max);
                 } else {
                     $replace = em_get_currency_formatted($min);
                 }
                 break;
             case '#_EVENTPRICEMIN':
                 //get the range of prices
                 $min = false;
                 foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                     /* @var $EM_Ticket EM_Ticket */
                     if ($EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable')) {
                         if ($EM_Ticket->get_price() < $min || $min === false) {
                             $min = $EM_Ticket->get_price();
                         }
                     }
                 }
                 if ($min === false) {
                     $min = 0;
                 }
                 $replace = em_get_currency_formatted($min);
                 break;
             case '#_EVENTPRICEMAX':
                 //get the range of prices
                 $max = 0;
                 foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                     /* @var $EM_Ticket EM_Ticket */
                     if ($EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable')) {
                         if ($EM_Ticket->get_price() > $max) {
                             $max = $EM_Ticket->get_price();
                         }
                     }
                 }
                 $replace = em_get_currency_formatted($max);
                 break;
             case '#_AVAILABLESEATS':
                 //Depreciated
             //Depreciated
             case '#_AVAILABLESPACES':
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_available_spaces();
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_BOOKEDSEATS':
                 //Depreciated
             //Depreciated
             case '#_BOOKEDSPACES':
                 //This placeholder is actually a little misleading, as it'll consider reserved (i.e. pending) bookings as 'booked'
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_booked_spaces();
                     if (get_option('dbem_bookings_approval_reserved')) {
                         $replace += $this->get_bookings()->get_pending_spaces();
                     }
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_PENDINGSPACES':
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_pending_spaces();
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_SEATS':
                 //Depreciated
             //Depreciated
             case '#_SPACES':
                 $replace = $this->get_spaces();
                 break;
             case '#_BOOKINGSURL':
             case '#_BOOKINGSLINK':
                 if ($this->can_manage('manage_bookings', 'manage_others_bookings')) {
                     $bookings_link = esc_url($this->get_bookings_url());
                     if ($result == '#_BOOKINGSLINK') {
                         $replace = '<a href="' . $bookings_link . '" title="' . esc_attr($this->event_name) . '">' . esc_html($this->event_name) . '</a>';
                     } else {
                         $replace = $bookings_link;
                     }
                 }
                 break;
             case '#_BOOKINGSCUTOFF':
             case '#_BOOKINGSCUTOFFDATE':
             case '#_BOOKINGSCUTOFFTIME':
                 $replace = '';
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled') && !empty($this->rsvp_end)) {
                     $replace_format = get_option('dbem_date_format') . ' ' . get_option('dbem_time_format');
                     if ($result == '#_BOOKINGSCUTOFFDATE') {
                         $replace_format = get_option('dbem_date_format');
                     }
                     if ($result == '#_BOOKINGSCUTOFFTIME') {
                         $replace_format = get_option('dbem_time_format');
                     }
                     $replace = date($replace_format, $this->rsvp_end);
                 }
                 break;
                 //Contact Person
             //Contact Person
             case '#_CONTACTNAME':
             case '#_CONTACTPERSON':
                 //Depreciated (your call, I think name is better)
                 $replace = $this->get_contact()->display_name;
                 break;
             case '#_CONTACTUSERNAME':
                 $replace = $this->get_contact()->user_login;
                 break;
             case '#_CONTACTEMAIL':
             case '#_CONTACTMAIL':
                 //Depreciated
                 $replace = $this->get_contact()->user_email;
                 break;
             case '#_CONTACTURL':
                 $replace = $this->get_contact()->user_url;
                 break;
             case '#_CONTACTID':
                 $replace = $this->get_contact()->ID;
                 break;
             case '#_CONTACTPHONE':
                 $replace = $this->get_contact()->phone != '' ? $this->get_contact()->phone : __('N/A', 'dbem');
                 break;
             case '#_CONTACTAVATAR':
                 $replace = get_avatar($this->get_contact()->ID, $size = '50');
                 break;
             case '#_CONTACTPROFILELINK':
             case '#_CONTACTPROFILEURL':
                 if (function_exists('bp_core_get_user_domain')) {
                     $replace = bp_core_get_user_domain($this->get_contact()->ID);
                     if ($result == '#_CONTACTPROFILELINK') {
                         $replace = '<a href="' . esc_url($replace) . '">' . __('Profile', 'dbem') . '</a>';
                     }
                 }
                 break;
             case '#_CONTACTMETA':
                 if (!empty($placeholders[3][$key])) {
                     $replace = get_user_meta($this->event_owner, $placeholders[3][$key], true);
                 }
                 break;
             case '#_ATTENDEES':
                 ob_start();
                 $template = em_locate_template('placeholders/attendees.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_ATTENDEESLIST':
                 ob_start();
                 $template = em_locate_template('placeholders/attendeeslist.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_ATTENDEESPENDINGLIST':
                 ob_start();
                 $template = em_locate_template('placeholders/attendeespendinglist.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
                 //Categories and Tags
             //Categories and Tags
             case '#_EVENTCATEGORIESIMAGES':
                 ob_start();
                 $template = em_locate_template('placeholders/eventcategoriesimages.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_EVENTTAGS':
                 ob_start();
                 $template = em_locate_template('placeholders/eventtags.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_CATEGORIES':
                 //depreciated
             //depreciated
             case '#_EVENTCATEGORIES':
                 ob_start();
                 $template = em_locate_template('placeholders/categories.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
                 //Ical Stuff
             //Ical Stuff
             case '#_EVENTICALURL':
             case '#_EVENTICALLINK':
                 $replace = $this->get_ical_url();
                 if ($result == '#_EVENTICALLINK') {
                     $replace = '<a href="' . esc_url($replace) . '">iCal</a>';
                 }
                 break;
             case '#_EVENTGCALURL':
             case '#_EVENTGCALLINK':
                 //get dates in UTC/GMT time
                 if ($this->event_all_day && $this->event_start_date == $this->event_end_date) {
                     $dateStart = get_gmt_from_date(date('Y-m-d H:i:s', $this->start), 'Ymd');
                     $dateEnd = get_gmt_from_date(date('Y-m-d H:i:s', $this->start + 60 * 60 * 24), 'Ymd');
                 } else {
                     $dateStart = get_gmt_from_date(date('Y-m-d H:i:s', $this->start), 'Ymd\\THis\\Z');
                     $dateEnd = get_gmt_from_date(date('Y-m-d H:i:s', $this->end), 'Ymd\\THis\\Z');
                 }
                 //build url
                 $gcal_url = 'http://www.google.com/calendar/event?action=TEMPLATE&text=event_name&dates=start_date/end_date&details=post_content&location=location_name&trp=false&sprop=event_url&sprop=name:blog_name';
                 $gcal_url = str_replace('event_name', urlencode($this->event_name), $gcal_url);
                 $gcal_url = str_replace('start_date', urlencode($dateStart), $gcal_url);
                 $gcal_url = str_replace('end_date', urlencode($dateEnd), $gcal_url);
                 $gcal_url = str_replace('location_name', urlencode($this->output('#_LOCATION')), $gcal_url);
                 $gcal_url = str_replace('blog_name', urlencode(get_bloginfo()), $gcal_url);
                 $gcal_url = str_replace('event_url', urlencode($this->get_permalink()), $gcal_url);
                 //calculate URL length so we know how much we can work with to make a description.
                 if (!empty($this->post_excerpt)) {
                     $gcal_url_description = $this->post_excerpt;
                 } else {
                     $matches = explode('<!--more', $this->post_content);
                     $gcal_url_description = wp_kses_data($matches[0]);
                 }
                 $gcal_url_length = strlen($gcal_url) - 9;
                 if (strlen($gcal_url_description) + $gcal_url_length > 1350) {
                     $gcal_url_description = substr($gcal_url_description, 0, 1380 - $gcal_url_length - 3) . '...';
                 }
                 $gcal_url = str_replace('post_content', urlencode($gcal_url_description), $gcal_url);
                 //get the final url
                 $replace = $gcal_url;
                 if ($result == '#_EVENTGCALLINK') {
                     $img_url = 'www.google.com/calendar/images/ext/gc_button2.gif';
                     $img_url = is_ssl() ? 'https://' . $img_url : 'http://' . $img_url;
                     $replace = '<a href="' . esc_url($replace) . '" target="_blank"><img src="' . esc_url($img_url) . '" alt="0" border="0"></a>';
                 }
                 break;
             default:
                 $replace = $full_result;
                 break;
         }
         $replaces[$full_result] = apply_filters('em_event_output_placeholder', $replace, $this, $full_result, $target);
     }
     //sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
     krsort($replaces);
     foreach ($replaces as $full_result => $replacement) {
         if (!in_array($full_result, array('#_NOTES', '#_EVENTNOTES'))) {
             $event_string = str_replace($full_result, $replacement, $event_string);
         } else {
             $new_placeholder = str_replace('#_', '__#', $full_result);
             //this will avoid repeated filters when locations/categories are parsed
             $event_string = str_replace($full_result, $new_placeholder, $event_string);
             $desc_replace[$new_placeholder] = $replacement;
         }
     }
     //Time placeholders
     foreach ($placeholders[1] as $result) {
         // matches all PHP START date and time placeholders
         if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
             $replace = date_i18n(ltrim($result, "#"), $this->start);
             $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
             $event_string = str_replace($result, $replace, $event_string);
         }
         // matches all PHP END time placeholders for endtime
         if (preg_match('/^#@[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
             $replace = date_i18n(ltrim($result, "#@"), $this->end);
             $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
             $event_string = str_replace($result, $replace, $event_string);
         }
     }
     //Now do dependent objects
     if (!empty($this->location_id) && $this->get_location()->location_status) {
         $event_string = $this->get_location()->output($event_string, $target);
     } else {
         $EM_Location = new EM_Location();
         $event_string = $EM_Location->output($event_string, $target);
     }
     //for backwards compat and easy use, take over the individual category placeholders with the frirst cat in th elist.
     $EM_Categories = $this->get_categories();
     if (count($EM_Categories->categories) > 0) {
         $EM_Category = $EM_Categories->get_first();
     }
     if (empty($EM_Category)) {
         $EM_Category = new EM_Category();
     }
     $event_string = $EM_Category->output($event_string, $target);
     //Finally, do the event notes, so that previous placeholders don't get replaced within the content, which may use shortcodes
     if (!empty($desc_replace)) {
         foreach ($desc_replace as $full_result => $replacement) {
             $event_string = str_replace($full_result, $replacement, $event_string);
         }
     }
     //do some specific formatting
     //TODO apply this sort of formatting to any output() function
     if ($target == 'ical') {
         //strip html and escape characters
         $event_string = str_replace('\\', '\\\\', strip_tags($event_string));
         $event_string = str_replace(';', '\\;', $event_string);
         $event_string = str_replace(',', '\\,', $event_string);
         //remove and define line breaks in ical format
         $event_string = str_replace('\\\\n', '\\n', $event_string);
         $event_string = str_replace("\r\n", '\\n', $event_string);
         $event_string = str_replace("\n", '\\n', $event_string);
     }
     return apply_filters('em_event_output', $event_string, $this, $format, $target);
 }
Exemplo n.º 17
0
 /**
  * Puts the coupon into a text representation in terms of discount
  */
 function get_discount_text()
 {
     $text = "";
     switch ($this->coupon_type) {
         case '%':
             //discount by percent
             $text = sprintf(__('%s Off', 'em-pro'), number_format($this->coupon_discount, 0) . '%');
             break;
         case '#':
             //discount by price
             $text = sprintf(__('%s Off', 'em-pro'), em_get_currency_formatted($this->coupon_discount));
             break;
     }
     return apply_filters('em_coupon_get_discount_text', $text, $this);
 }