public function categories($params)
 {
     $results = array();
     $results[] = array('name' => 'All', 'category_id' => ALL_CATEGORY_ID, 'allowed' => true);
     $categories = EM_Categories::get(array('offset' => $params['offset'], 'limit' => $params['limit']));
     foreach ($categories as $category) {
         $results[] = array('name' => $category->name, 'category_id' => $category->id, 'allowed' => true);
     }
     return $this->add_paging_info($results, $params);
 }
Пример #2
0
<?php

/*
 * This file is called by templates/forms/location-editor.php to display fields for uploading images on your event form on your website. This does not affect the admin featured image section.
* You can override this file by copying it to /wp-content/themes/yourtheme/plugins/events-manager/forms/event/ and editing it there.
*/
global $EM_Event;
/* @var $EM_Event EM_Event */
$categories = EM_Categories::get(array('orderby' => 'name', 'hide_empty' => 0));
if (count($categories) > 0) {
    ?>
<div class="event-categories">
	<!-- START Categories -->
	<label for="event_categories[]"><?php 
    _e('Category:', 'dbem');
    ?>
</label>
	<select name="event_categories[]" multiple size="10">
	<?php 
    $selected = $EM_Event->get_categories()->get_ids();
    $walker = new EM_Walker_CategoryMultiselect();
    $args_em = array('hide_empty' => 0, 'name' => 'event_categories[]', 'hierarchical' => true, 'id' => EM_TAXONOMY_CATEGORY, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $selected, 'walker' => $walker);
    echo walk_category_dropdown_tree($categories, 0, $args_em);
    ?>
</select>
	<!-- END Categories -->
</div>
<?php 
}
Пример #3
0
    function meta_box_ms_categories()
    {
        global $EM_Event;
        $categories = EM_Categories::get(array('orderby' => 'category_name', 'hide_empty' => false));
        ?>
		<?php 
        if (count($categories) > 0) {
            ?>
			<p>
				<?php 
            foreach ($categories as $EM_Category) {
                ?>
				<label><input type="checkbox" name="event_categories[]" value="<?php 
                echo $EM_Category->id;
                ?>
" <?php 
                if ($EM_Event->get_categories()->has($EM_Category->id)) {
                    echo 'checked="checked"';
                }
                ?>
 /> <?php 
                echo $EM_Category->name;
                ?>
</label><br />			
				<?php 
            }
            ?>
			</p>
		<?php 
        } else {
            ?>
			<p><?php 
            sprintf(__('No categories available, <a href="%s">create one here first</a>', 'dbem'), get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager-categories');
            ?>
</p>
		<?php 
        }
        ?>
		<!-- END Categories -->
		<?php 
    }
Пример #4
0
function em_admin_options_page()
{
    //TODO place all options into an array
    $events_placeholders = '<a href="admin.php?page=events-manager-help#event-placeholders">' . __('Event Related Placeholders', 'dbem') . '</a>';
    $locations_placeholders = '<a href="admin.php?page=events-manager-help#location-placeholders">' . __('Location Related Placeholders', 'dbem') . '</a>';
    $bookings_placeholders = '<a href="admin.php?page=events-manager-help#booking-placeholders">' . __('Booking 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);
    $bookings_placeholder_tip = " " . sprintf(__('This accepts %s, %s and %s placeholders.', 'dbem'), $bookings_placeholders, $events_placeholders, $locations_placeholders);
    $save_button = '<tr><th>&nbsp;</th><td><p class="submit" style="margin:0px; padding:0px; text-align:right;"><input type="submit" id="dbem_options_submit" name="Submit" value="' . __('Save Changes') . ' (' . __('All', 'dbem') . ')" /></p></ts></td></tr>';
    ?>
	
	<script type="text/javascript" charset="utf-8">
		jQuery(document).ready(function($){
			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;">'+close_text+'</a>');
			$('#icon-options-general').after(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);
				} 
			});
			//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');
			
		});
	</script>
	<div class="wrap">
		<div id='icon-options-general' class='icon32'><br />
		</div>		
		<h2><?php 
    _e('Event Manager Options', 'dbem');
    ?>
</h2>
		
		<form id="dbem_options_form" method="post" action="">          

			<div class="metabox-holder">         
			<!-- // TODO Move style in css -->
			<div class='postbox-container' style='width: 99.5%'>
			<div id="" class="meta-box-sortables" >
		  
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('General options', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
	            <table class="form-table">
					<?php 
    em_options_radio_binary(__('Use dropdown for locations?'), '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(__('Use recurrence?'), 'dbem_recurrence_enabled', __('Select yes to enable the recurrence features feature', 'dbem'));
    em_options_radio_binary(__('Use RSVP?'), 'dbem_rsvp_enabled', __('Select yes to enable the RSVP feature', 'dbem'));
    em_options_radio_binary(__('Use categories?'), 'dbem_categories_enabled', __('Select yes to enable the category features', 'dbem'));
    em_options_radio_binary(__('Use attributes?'), 'dbem_attributes_enabled', __('Select yes to enable the attributes feature', 'dbem'));
    /*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;
    }
    em_options_select(__('Default Category'), 'dbem_default_category', $category_options, __('This option allows you to select the default category when adding an event.', 'dbem') . " " . __('(not applicable with event ownership on presently, coming soon!)', 'dbem'));
    /*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->id] = $EM_Location->name;
    }
    em_options_select(__('Default Location'), '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'));
    em_options_textarea(__('Custom Placeholders', 'dbem'), 'dbem_placeholders_custom', sprintf(__("You can add custom placeholders 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'), 'wp-events-plugin.com/documentation/the-em-templates-syntax/'));
    echo $save_button;
    ?>
				</table>
				    
			</div> <!-- . inside --> 
			</div> <!-- .postbox --> 
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Events page', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
                 <table class="form-table">         
				 	<?php 
    //Wordpress Pages
    global $em_disable_filter;
    //Using a flag here instead
    $em_disable_filter = true;
    $get_pages = get_pages();
    $events_page_options = array();
    $events_page_options[0] = __('[No Events Page]');
    //TODO Add the hierarchy style ddm, like when choosing page parents
    foreach ($get_pages as $page) {
        $events_page_options[$page->ID] = $page->post_title;
    }
    em_options_select(__('Events page'), 'dbem_events_page', $events_page_options, __('This option allows you to select which page to use as an events page', 'dbem'));
    $em_disable_filter = false;
    //Rest
    em_options_radio_binary(__('Show events page in lists?', 'dbem'), 'dbem_list_events_page', __('Check this option if you want the events page to appear together with other pages in pages lists.', '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'));
    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'));
    ?>
					<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('start_date,start_time,name' => __('Order by start date, start time, then event name', 'dbem'), 'name,start_date,start_time' => __('Order by name, start date, then start time', 'dbem'), 'name,end_date,end_time' => __('Order by name, end date, then end time', 'dbem'), 'end_date,end_time,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 range limit', 'dbem');
    ?>
</th>
							<td>
								<select name="dbem_events_page_time_limit" >
									<?php 
    $limit_options = apply_filters('em_settings_events_page_time_limit_ddm', array('0' => __('no limit', 'dbem'), '1' => __('This month', 'dbem'), '2' => __('Next two months', 'dbem'), '3' => __('Next three months', 'dbem'), '6' => __('Next six months', 'dbem'), '12' => __('Next twelve months', 'dbem')));
    ?>
									<?php 
    foreach ($limit_options as $key => $value) {
        ?>
   
									<option value='<?php 
        echo $key;
        ?>
' <?php 
        echo $key == get_option('dbem_events_page_time_limit') ? "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 no time limit is applied.', 'dbem');
    ?>
</em>
							</td>
					</tr>					
					<?php 
    echo $save_button;
    ?>
				
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Events format', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
            	<table class="form-table">
				 	<?php 
    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(__('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);
    em_options_input_text(__('Events page title', 'dbem'), 'dbem_events_page_title', __('The title on the multiple events page.', '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'));
    echo $save_button;
    ?>
				</table> 	
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			      
           	<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Calendar format', 'dbem');
    ?>
</span></h3>
			<div class="inside">
            	<table class="form-table">   
					<?php 
    em_options_input_text(__('Small calendar title', '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(__('Small calendar 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_input_text(__('Full calendar events 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(__('Show long events on calendar pages?', 'dbem'), 'dbem_full_calendar_long_events', __("If you are showing a calendar on the events page (see Events format section on this page), you have the option of showing events that span over days on each day it occurs.", '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'));
    echo $save_button;
    ?>
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Locations format', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
            	<table class="form-table">
					<?php 
    em_options_input_text(__('Single location page title format', 'dbem'), 'dbem_location_page_title_format', __('The format of a single location page title.', 'dbem') . $locations_placeholder_tip);
    em_options_textarea(__('Default single location page format', 'dbem'), 'dbem_single_location_format', __('The format of a single location page.', 'dbem') . $locations_placeholder_tip);
    em_options_textarea(__('Default location balloon format', 'dbem'), 'dbem_location_baloon_format', __('The format of of the text appearing in the baloon describing the location in the map.', 'dbem') . $locations_placeholder_tip);
    em_options_textarea(__('Default location event list format', 'dbem'), 'dbem_location_event_list_item_format', __('The format of the events the list inserted in the location page through the <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> element.', 'dbem') . $locations_placeholder_tip);
    em_options_textarea(__('Default no events message', 'dbem'), 'dbem_location_no_events_message', __('The message to be displayed in the list generated by <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> when no events are available.', 'dbem'));
    echo $save_button;
    ?>
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('RSS feed format', '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');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Maps and geotagging', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
				<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>
					<?php 
    em_options_textarea(__('Map text format', 'dbem'), 'dbem_map_text_format', __('The text format inside the map balloons.', 'dbem') . $events_placeholder_tip);
    echo $save_button;
    ?>
 
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('RSVP and bookings', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
				<table class='form-table'>
					<?php 
    em_options_select(__('Default contact person', 'dbem'), 'dbem_default_contact_person', em_get_wp_users(), __('Select the default contact person. This user will be employed whenever a contact person is not explicitly specified for an event', '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_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'));
    em_options_radio_binary(__('Email contact person?', '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'));
    ?>
					<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', '');
    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', '');
    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', '');
    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', '');
    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', __("The subject of the email sent to the person making a booking that is awaiting administrator approval. Not relevant if bookings don't require approval.", 'dbem') . $bookings_placeholder_tip);
    em_options_textarea(__('Booking rejected email', 'dbem'), 'dbem_bookings_email_rejected_body', __('The body of the email which will be sent to the person if the booking is rejected. Not relevant if bookings don\'t require approval.', 'dbem') . $bookings_placeholder_tip);
    echo $save_button;
    ?>
					<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', '');
    em_options_textarea(__('Booking cancelled email', 'dbem'), 'dbem_bookings_email_cancelled_body', '');
    ?>
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
						
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Email Settings', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
				<table class='form-table'>
					<?php 
    em_options_input_text(__('Notification sender name', 'dbem'), 'dbem_mail_sender_name', __("Insert the display name of the notification sender.", 'dbem'));
    em_options_input_text(__('Notification sender address', 'dbem'), 'dbem_mail_sender_address', __("Insert the address of the notification sender.", 'dbem'));
    em_options_input_text('Mail sending port', 'dbem_rsvp_mail_port', __("The port through which you e-mail notifications will be sent. Make sure the firewall doesn't block this port", 'dbem'));
    em_options_select(__('Mail sending method', 'dbem'), 'dbem_rsvp_mail_send_method', array('smtp' => 'SMTP', 'mail' => __('PHP mail function', 'dbem'), 'sendmail' => 'Sendmail', 'qmail' => 'Qmail', 'wp_mail' => 'WP Mail'), __('Select the method to send email notification.', 'dbem'));
    em_options_radio_binary(__('Use SMTP authentication?', 'dbem'), 'dbem_rsvp_mail_SMTPAuth', __('SMTP authentication is often needed. If you use GMail, make sure to set this parameter to Yes', 'dbem'));
    em_options_input_text('SMTP host', 'dbem_smtp_host', __("The SMTP host. Usually it corresponds to 'localhost'. If you use GMail, set this value to 'ssl://smtp.gmail.com:465'.", 'dbem'));
    em_options_input_text(__('SMTP username', 'dbem'), 'dbem_smtp_username', __("Insert the username to be used to access your SMTP server.", 'dbem'));
    em_options_input_password(__('SMTP password', 'dbem'), "dbem_smtp_password", __("Insert the password to be used to access your SMTP server", 'dbem'));
    echo $save_button;
    ?>
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Images size', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
				<table class='form-table'>
					<?php 
    em_options_input_text(__('Maximum width (px)', 'dbem'), 'dbem_image_max_width', __('The maximum allowed width for images uploades', 'dbem'));
    em_options_input_text(__('Maximum height (px)', 'dbem'), 'dbem_image_max_height', __("The maximum allowed height for images uploaded, in pixels", 'dbem'));
    em_options_input_text(__('Maximum size (bytes)', 'dbem'), 'dbem_image_max_size', __("The maximum allowed size for images uploaded, in pixels", 'dbem'));
    echo $save_button;
    ?>
				</table> 
			</div> <!-- . inside -->
			</div> <!-- .postbox -->

		<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Management Permission Options', 'dbem');
    ?>
 (Beta)</span></h3>
			<div class="inside">
	            <table class="form-table">
	            	<tr><td colspan="2">
	            		<strong><?php 
    _e('Warning: Changing these values may result in exposing previously hidden information to all users.');
    ?>
</strong><br />
	            		<em><?php 
    _e('Note that currently "users" are considered as wordpress contributor users upwards, as they can create and manage events (we\'re working on that). Wordpress administrators can control all events/locations/categories/etc. on Events Manager.', 'dbem');
    ?>
</em>
	            	</td></tr>
					<tr><th colspan="2"><strong><?php 
    _e('Event Permissions', 'dbem');
    ?>
</strong></th></tr>
					<?php 
    $location_privacy_options = array('0' => __('Every user can create and manage their own events. Users can\'t view or modify each others\' events and booking data', 'dbem'), '1' => __('Every user can create/edit/delete any event on this site. (not recommended)', 'dbem'));
    em_options_radio('dbem_permissions_events', $location_privacy_options);
    ?>
					<tr><th colspan="2"><strong><?php 
    _e('Location Permissions', 'dbem');
    ?>
</strong></th></tr>
					<?php 
    $location_privacy_options = array('0' => __('Every user can create and manage their own location.', 'dbem') . " " . __('In future releases of Events Manager, sharing locations with more than one user will be possible in this option, as well as connecting different user defined locations to prevent duplicate listings.', 'dbem'), '1' => __('Only event administrators can create and edit locations. User must choose from these available locations.', 'dbem'), '2' => __('Everyone can create/edit/delete all locations on this site. (not recommended)', 'dbem'));
    em_options_radio('dbem_permissions_locations', $location_privacy_options);
    ?>
					<tr><th colspan="2"><strong><?php 
    _e('Category Permissions', 'dbem');
    ?>
</strong></th></tr>
					<?php 
    $category_privacy_options = array('0' => __('Every user can create and manage their own category.', 'dbem'), '1' => __('Only event administrators can create and edit categories. User must choose from these available categories.', 'dbem'), '2' => __('Everyone can create/edit/delete all categories on the system. (not recommended)', 'dbem'));
    em_options_radio('dbem_permissions_categories', $category_privacy_options);
    ?>
				</table>
				    
			</div> <!-- . inside --> 
			</div> <!-- .postbox -->    
            
			<p class="submit">
				<input type="submit" id="dbem_options_submit" name="Submit" value="<?php 
    _e('Save Changes');
    ?>
" />
				<input type="hidden" name="em-submitted" value="1" />
			</p>  
			
			</div> <!-- .metabox-sortables -->
			</div> <!-- .postbox-container -->
			
			</div> <!-- .metabox-holder -->	
		</form>
	</div>
	<?php 
}
Пример #5
0
function em_categories_table_layout($message = "")
{
    $categories = EM_Categories::get();
    $destination = get_bloginfo('url') . "/wp-admin/admin.php";
    ?>
	<div class='wrap nosubsub'>
		<div id='icon-edit' class='icon32'>
			<br/>
		</div>
  		<h2><?php 
    echo __('Categories', 'dbem');
    ?>
</h2>
	 		
		<?php 
    if ($message != "") {
        ?>
			<div id='message' class='updated fade below-h2' style='background-color: rgb(255, 251, 204);'>
				<p><?php 
        echo $message;
        ?>
</p>
			</div>
		<?php 
    }
    ?>
		
		<div id='col-container'>
			<!-- begin col-right -->   
			<div id='col-right'>
			 	<div class='col-wrap'>       
				 	 <form id='bookings-filter' method='post' action='<?php 
    echo get_bloginfo('wpurl');
    ?>
/wp-admin/admin.php?page=events-manager-categories'>
						<input type='hidden' name='action' value='delete'/>
						<?php 
    if (count($categories) > 0) {
        ?>
							<table class='widefat'>
								<thead>
									<tr>
										<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
										<th><?php 
        echo __('ID', 'dbem');
        ?>
</th>
										<th><?php 
        echo __('Name', 'dbem');
        ?>
</th>
									</tr> 
								</thead>
								<tfoot>
									<tr>
										<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
										<th><?php 
        echo __('ID', 'dbem');
        ?>
</th>
										<th><?php 
        echo __('Name', 'dbem');
        ?>
</th>
									</tr>             
								</tfoot>
								<tbody>
									<?php 
        foreach ($categories as $EM_Category) {
            ?>
									<tr>
										<td><input type='checkbox' class ='row-selector' value='<?php 
            echo $EM_Category->id;
            ?>
' name='categories[]'/></td>
										<td><a href='<?php 
            echo get_bloginfo('wpurl');
            ?>
/wp-admin/admin.php?page=events-manager-categories&amp;action=edit&amp;category_id=<?php 
            echo $EM_Category->id;
            ?>
'><?php 
            echo htmlspecialchars($EM_Category->id, ENT_QUOTES);
            ?>
</a></td>
										<td><a href='<?php 
            echo get_bloginfo('wpurl');
            ?>
/wp-admin/admin.php?page=events-manager-categories&amp;action=edit&amp;category_id=<?php 
            echo $EM_Category->id;
            ?>
'><?php 
            echo htmlspecialchars($EM_Category->name, ENT_QUOTES);
            ?>
</a></td>
									</tr>
									<?php 
        }
        ?>
								</tbody>
	
							</table>
	
							<div class='tablenav'>
								<div class='alignleft actions'>
							 	<input class='button-secondary action' type='submit' name='doaction2' value='Delete'/>
								<br class='clear'/> 
								</div>
								<br class='clear'/>
							</div>
						<?php 
    } else {
        ?>
							<p><?php 
        echo __('No categories have been inserted yet!', 'dbem');
        ?>
</p>
						<?php 
    }
    ?>
					</form>
				</div>
			</div>
			<!-- end col-right -->     
			
			<!-- begin col-left -->
			<div id='col-left'>
		  		<div class='col-wrap'>
					<div class='form-wrap'> 
						<div id='ajax-response'>
					  		<h3><?php 
    echo __('Add category', 'dbem');
    ?>
</h3>
							<form name='add' id='add' method='post' action='admin.php?page=events-manager-categories' class='add:the-list: validate'>
								<input type='hidden' name='action' value='save' />
								<div class='form-field form-required'>
									<label for='category_name'><?php 
    echo __('Category name', 'dbem');
    ?>
</label>
									<input id='category-name' name='category_name' id='category_name' type='text' size='40' />
									<p><?php 
    echo __('The name of the category', 'dbem');
    ?>
</p>
								</div>
								<p class='submit'><input type='submit' class='button' name='submit' value='<?php 
    echo __('Add category', 'dbem');
    ?>
' /></p>
							</form>
					  	</div>
					</div> 
				</div>    
			</div> 
			<!-- end col-left --> 		
		</div> 
  	</div>
  	<?php 
}
Пример #6
0
function em_get_categories_shortcode($args, $format = '')
{
    $args = (array) $args;
    $args['format'] = $format != '' || empty($args['format']) ? $format : $args['format'];
    $args['format'] = html_entity_decode($args['format']);
    //shorcode doesn't accept html
    $args['orderby'] = !empty($args['orderby']) ? $args['orderby'] : get_option('dbem_categories_default_orderby');
    $args['order'] = !empty($args['order']) ? $args['order'] : get_option('dbem_categories_default_order');
    return EM_Categories::output($args);
}
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 
}
Пример #8
0
/**
 * Handles AJAX Searching and Pagination for events, locations, tags and categories
 */
function em_ajax_search_and_pagination()
{
    $args = array('owner' => false, 'pagination' => 1, 'ajax' => true);
    if (empty($args['scope'])) {
        $args['scope'] = get_option('dbem_events_page_scope');
    }
    echo '<div class="em-search-ajax">';
    ob_start();
    if ($_REQUEST['action'] == 'search_events') {
        $args = EM_Events::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_events_default_limit');
        em_locate_template('templates/events-list.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    } elseif ($_REQUEST['action'] == 'search_events_grouped' && defined('DOING_AJAX')) {
        $args = EM_Events::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_events_default_limit');
        em_locate_template('templates/events-list-grouped.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    } elseif ($_REQUEST['action'] == 'search_locations' && defined('DOING_AJAX')) {
        $args = EM_Locations::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_locations_default_limit');
        em_locate_template('templates/locations-list.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    } elseif ($_REQUEST['action'] == 'search_tags' && defined('DOING_AJAX')) {
        $args = EM_Tags::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_tags_default_limit');
        em_locate_template('templates/tags-list.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    } elseif ($_REQUEST['action'] == 'search_cats' && defined('DOING_AJAX')) {
        $args = EM_Categories::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_categories_default_limit');
        em_locate_template('templates/categories-list.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    }
    echo '</div>';
    echo apply_filters('em_ajax_' . $_REQUEST['action'], ob_get_clean(), $args);
    exit;
}
Пример #9
0
					<textarea name="content" rows="10" style="width:100%"><?php 
echo $EM_Event->notes;
?>
</textarea>
					<br />
					<?php 
_e('Details about the event.', 'dbem');
_e('HTML Allowed.', 'dbem');
?>
				</div>
				<div>
				<?php 
if (get_option('dbem_categories_enabled')) {
    ?>
					<?php 
    $categories = EM_Categories::get(array('orderby' => 'category_name'));
    ?>
					<?php 
    if (count($categories) > 0) {
        ?>
						<!-- START Categories -->
						<label for="event_categories[]"><?php 
        _e('Category:', 'dbem');
        ?>
</label>
						<select name="event_categories[]" multiple size="10">
							<?php 
        foreach ($categories as $EM_Category) {
            $selected = $EM_Event->get_categories()->has($EM_Category->id) ? "selected='selected'" : '';
            ?>
								<option value="<?php 
Пример #10
0
/**
 * Performs actions on init. This works for both ajax and normal requests, the return results depends if an em_ajax flag is passed via POST or GET.
 */
function em_init_actions()
{
    global $wpdb, $EM_Notices, $EM_Event;
    //NOTE - No EM objects are globalized at this point, as we're hitting early init mode.
    //TODO Clean this up.... use a uniformed way of calling EM Ajax actions
    if (!empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action'])) {
        if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
            if (isset($_REQUEST['id'])) {
                $EM_Location = new EM_Location($_REQUEST['id']);
                $location_array = $EM_Location->to_array();
                $location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
                echo EM_Object::json_encode($location_array);
            }
            die;
        }
        if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'delete_ticket') {
            if (isset($_REQUEST['id'])) {
                $EM_Ticket = new EM_Ticket($_REQUEST['id']);
                $result = $EM_Ticket->delete();
                if ($result) {
                    $result = array('result' => true);
                } else {
                    $result = array('result' => false, 'error' => $EM_Ticket->feedback_message);
                }
            } else {
                $result = array('result' => false, 'error' => __('No ticket id provided', 'dbem'));
            }
            echo EM_Object::json_encode($result);
            die;
        }
        if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
            $EM_Locations = EM_Locations::get($_REQUEST);
            $json_locations = array();
            foreach ($EM_Locations as $location_key => $EM_Location) {
                $json_locations[$location_key] = $EM_Location->to_array();
                $json_locations[$location_key]['location_balloon'] = $EM_Location->output(get_option('dbem_map_text_format'));
            }
            echo EM_Object::json_encode($json_locations);
            die;
        }
        if (isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
            //FIXME if long events enabled originally, this won't show up on ajax call
            echo EM_Calendar::output($_REQUEST);
            die;
        }
    }
    //Event Actions
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 5) == 'event') {
        //Load the event object, with saved event if requested
        if (!empty($_REQUEST['event_id'])) {
            $EM_Event = new EM_Event($_REQUEST['event_id']);
        } else {
            $EM_Event = new EM_Event();
        }
        if ($_REQUEST['action'] == 'event_save' && current_user_can('edit_events')) {
            //Check Nonces
            if (is_admin()) {
                if (!wp_verify_nonce($_REQUEST['_wpnonce'] && 'event_save')) {
                    check_admin_referer('trigger_error');
                }
            } else {
                if (!wp_verify_nonce($_REQUEST['_wpnonce'] && 'event_save')) {
                    exit('Trying to perform an illegal action.');
                }
            }
            //Grab and validate submitted data
            if ($EM_Event->get_post() && $EM_Event->save()) {
                //EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
                $EM_Notices->add_confirm($EM_Event->feedback_message);
                if (is_admin()) {
                    $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
                    $scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
                    //wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager&pno='.$page.'&scope='.$scope.'&message='.urlencode($EM_Event->feedback_message));
                } else {
                    $redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
                    wp_redirect($redirect);
                }
                $events_result = true;
            } else {
                $EM_Notices->add_error($EM_Event->get_errors());
                $events_result = false;
            }
        }
        if ($_REQUEST['action'] == 'event_duplicate') {
            global $EZSQL_ERROR;
            $EM_Event = $EM_Event->duplicate();
            if ($EM_Event === false) {
                $EM_Notices->add_error($EM_Event->errors, true);
            } else {
                if ($EM_Event->id == $_REQUEST['event_id']) {
                    $EM_Notices->add_confirm($EM_Event->feedback_message . " " . sprintf(__('You are now viewing the duplicated %s.', 'dbem'), __('event', 'dbem')), true);
                } else {
                    $EM_Notices->add_confirm($EM_Event->feedback_message, true);
                }
            }
        }
        if ($_REQUEST['action'] == 'event_delete') {
            //DELETE action
            $selectedEvents = !empty($_REQUEST['events']) ? $_REQUEST['events'] : '';
            if (EM_Object::array_is_numeric($selectedEvents)) {
                $events_result = EM_Events::delete($selectedEvents);
            } elseif (is_object($EM_Event)) {
                $events_result = $EM_Event->delete();
            }
            $plural = count($selectedEvents) > 1 ? __('Events', 'dbem') : __('Event', 'dbem');
            if ($events_result) {
                $message = is_object($EM_Event) ? $EM_Event->feedback_message : sprintf(__('%s successfully deleted.', 'dbem'), $plural);
                $EM_Notices->add_confirm($message);
            } else {
                $message = is_object($EM_Event) ? $EM_Event->errors : sprintf(__('%s could not be deleted.', 'dbem'), $plural);
                $EM_Notices->add_confirm($message);
            }
        } elseif ($_REQUEST['action'] == 'event_approve') {
            //Approve Action
            $events_result = $EM_Event->approve();
            if ($events_result) {
                $EM_Notices->add_confirm($EM_Event->feedback_message);
            } else {
                $EM_Notices->add_error($EM_Event->errors);
            }
        }
        //AJAX Exit
        if (isset($events_result) && !empty($_REQUEST['em_ajax'])) {
            if ($events_result) {
                $return = array('result' => true, 'message' => $EM_Event->feedback_message);
            } else {
                $return = array('result' => false, 'message' => $EM_Event->feedback_message, 'errors' => $EM_Event->errors);
            }
        }
    }
    //Location Actions
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 8) == 'location') {
        global $EM_Location, $EM_Notices;
        //Load the location object, with saved event if requested
        if (!empty($_REQUEST['location_id'])) {
            $EM_Location = new EM_Location($_REQUEST['location_id']);
        } else {
            $EM_Location = new EM_Location();
        }
        if ($_REQUEST['action'] == 'location_save' && current_user_can('edit_locations')) {
            //Check Nonces
            em_verify_nonce('location_save');
            //Grab and validate submitted data
            if ($EM_Location->get_post() && $EM_Location->save()) {
                //EM_location gets the location if submitted via POST and validates it (safer than to depend on JS)
                $EM_Notices->add_confirm($EM_Location->feedback_message);
                $result = true;
            } else {
                $EM_Notices->add_error($EM_Location->get_errors());
                $result = false;
            }
        } elseif (!empty($_REQUEST['action']) && $_REQUEST['action'] == "location_delete") {
            //delete location
            //get object or objects
            if (!empty($_REQUEST['locations']) || !empty($_REQUEST['location_id'])) {
                $args = !empty($_REQUEST['locations']) ? $_REQUEST['locations'] : $_REQUEST['location_id'];
                $locations = EM_Locations::get($args);
                foreach ($locations as $location) {
                    if (!$location->delete()) {
                        $EM_Notices->add_error($location->get_errors());
                        $errors = true;
                    }
                }
                if (empty($errors)) {
                    $result = true;
                    $location_term = count($locations) > 1 ? __('Locations', 'dbem') : __('Location', 'dbem');
                    $EM_Notices->add_confirm(sprintf(__('%s successfully deleted', 'dbem'), $location_term));
                } else {
                    $result = false;
                }
            }
        }
        if (isset($result) && $result && !empty($_REQUEST['em_ajax'])) {
            $return = array('result' => true, 'message' => $EM_Location->feedback_message);
            echo EM_Object::json_encode($return);
            die;
        } elseif (isset($result) && !$result && !empty($_REQUEST['em_ajax'])) {
            $return = array('result' => false, 'message' => $EM_Location->feedback_message, 'errors' => $EM_Notices->get_errors());
            echo EM_Object::json_encode($return);
            die;
        }
    }
    //Category Actions
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 8) == 'category') {
        global $EM_Category, $EM_Notices;
        //Load the category object, with saved event if requested
        if (!empty($_REQUEST['category_id'])) {
            $EM_Category = new EM_Category($_REQUEST['category_id']);
        } else {
            $EM_Category = new EM_Category();
        }
        if ($_REQUEST['action'] == 'category_save' && current_user_can('edit_categories')) {
            //Check Nonces
            em_verify_nonce('category_save');
            //Grab and validate submitted data
            if ($EM_Category->get_post() && $EM_Category->save()) {
                //EM_Category gets the category if submitted via POST and validates it (safer than to depend on JS)
                $EM_Notices->add_confirm($EM_Category->feedback_message);
                $result = true;
            } else {
                $EM_Notices->add_error($EM_Category->get_errors());
                $result = false;
            }
        } elseif (!empty($_REQUEST['action']) && $_REQUEST['action'] == "category_delete") {
            //delete category
            //get object or objects
            if (!empty($_REQUEST['categories']) || !empty($_REQUEST['category_id'])) {
                $args = !empty($_REQUEST['categories']) ? $_REQUEST['categories'] : $_REQUEST['category_id'];
                $categories = EM_Categories::get($args);
                foreach ($categories as $category) {
                    if (!$category->delete()) {
                        $EM_Notices->add_error($category->get_errors());
                        $errors = true;
                    }
                }
                if (empty($errors)) {
                    $result = true;
                    $category_term = count($categories) > 1 ? __('EM_Categories', 'dbem') : __('Category', 'dbem');
                    $EM_Notices->add_confirm(sprintf(__('%s successfully deleted', 'dbem'), $category_term));
                } else {
                    $result = false;
                }
            }
        }
        if (isset($result) && $result && !empty($_REQUEST['em_ajax'])) {
            $return = array('result' => true, 'message' => $EM_Category->feedback_message);
            echo EM_Object::json_encode($return);
            die;
        } elseif (isset($result) && !$result && !empty($_REQUEST['em_ajax'])) {
            $return = array('result' => false, 'message' => $EM_Category->feedback_message, 'errors' => $EM_Notices->get_errors());
            echo EM_Object::json_encode($return);
            die;
        }
    }
    //Booking Actions
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 7) == 'booking' && (is_user_logged_in() || $_REQUEST['action'] == 'booking_add' && get_option('dbem_bookings_anonymous'))) {
        global $EM_Event, $EM_Booking, $EM_Person;
        //Load the event object, with saved event if requested
        $EM_Event = !empty($_REQUEST['event_id']) ? new EM_Event($_REQUEST['event_id']) : new EM_Event();
        //Load the booking object, with saved booking if requested
        $EM_Booking = !empty($_REQUEST['booking_id']) ? new EM_Booking($_REQUEST['booking_id']) : new EM_Booking();
        $allowed_actions = array('bookings_approve' => 'approve', 'bookings_reject' => 'reject', 'bookings_unapprove' => 'unapprove', 'bookings_delete' => 'delete');
        $result = false;
        if ($_REQUEST['action'] == 'booking_add') {
            //ADD/EDIT Booking
            em_verify_nonce('booking_add');
            do_action('em_booking_add', $EM_Event, $EM_Booking);
            if ($EM_Booking->get_post()) {
                //Does this user need to be registered first?
                $registration = true;
                //TODO do some ticket validation before registering the user
                if ($_REQUEST['register_user'] && get_option('dbem_bookings_anonymous')) {
                    //find random username - less options for user, less things go wrong
                    $username_root = explode('@', $_REQUEST['user_email']);
                    $username_rand = $username_root[0] . rand(1, 1000);
                    while (username_exists($username_root[0] . rand(1, 1000))) {
                        $username_rand = $username_root[0] . rand(1, 1000);
                    }
                    $id = em_register_new_user($username_rand, $_REQUEST['user_email'], $_REQUEST['user_name'], $_REQUEST['user_phone']);
                    if (is_numeric($id)) {
                        $EM_Person = new EM_Person($id);
                        $EM_Booking->person_id = $id;
                        $EM_Notices->add_confirm(__('A new user account has been created for you. Please check your email for access details.', 'dbem'));
                    } else {
                        $registration = false;
                        if (is_object($id) && get_class($id) == 'WP_Error') {
                            /* @var $id WP_Error */
                            if ($id->get_error_code() == 'email_exists') {
                                $EM_Notices->add_error(__('This email already exists in our system, please log in to register to proceed with your booking.', 'dbem'));
                            } else {
                                $EM_Notices->add_error($id->get_error_messages());
                            }
                        } else {
                            $EM_Notices->add_error(__('There was a problem creating a user account, please contact a website administrator.', 'dbem'));
                        }
                    }
                }
                if ($EM_Event->get_bookings()->add($EM_Booking) && $registration) {
                    $result = true;
                    $EM_Notices->add_confirm($EM_Event->get_bookings()->feedback_message);
                } else {
                    ob_start();
                    echo "<pre>";
                    print_r($id);
                    echo "</pre>";
                    $EM_Booking->feedback_message = ob_get_clean();
                    $EM_Notices->add_error($EM_Event->get_bookings()->get_errors());
                }
            } else {
                $result = false;
                $EM_Notices->add_error($EM_Booking->get_errors());
            }
        } elseif ($_REQUEST['action'] == 'booking_add_one' && is_object($EM_Event) && is_user_logged_in()) {
            //ADD/EDIT Booking
            em_verify_nonce('booking_add_one');
            $EM_Booking = new EM_Booking(array('person_id' => get_current_user_id(), 'event_id' => $EM_Event->id));
            //new booking
            //get first ticket in this event and book one place there.
            $EM_Ticket = $EM_Event->get_bookings()->get_tickets()->get_first();
            $EM_Ticket_Booking = new EM_Ticket_Booking(array('ticket_id' => $EM_Ticket->id, 'ticket_booking_spaces' => 1));
            $EM_Booking->get_tickets_bookings();
            $EM_Booking->tickets_bookings->tickets_bookings[] = $EM_Ticket_Booking;
            //Now save booking
            if ($EM_Event->get_bookings()->add($EM_Booking)) {
                $EM_Booking = $booking;
                $result = true;
                $EM_Notices->add_confirm($EM_Event->get_bookings()->feedback_message);
            } else {
                $EM_Notices->add_error($EM_Event->get_bookings()->get_errors());
            }
        } elseif ($_REQUEST['action'] == 'booking_cancel') {
            //Cancel Booking
            em_verify_nonce('booking_cancel');
            if ($EM_Booking->can_manage() || $EM_Booking->person->ID == get_current_user_id()) {
                if ($EM_Booking->cancel()) {
                    $result = true;
                    if (!defined('DOING_AJAX')) {
                        if ($EM_Booking->person->ID == get_current_user_id()) {
                            $EM_Notices->add_confirm(sprintf(__('Booking %s', 'dbem'), __('Cancelled', 'dbem')), true);
                        } else {
                            $EM_Notices->add_confirm($EM_Booking->feedback_message, true);
                        }
                        wp_redirect($_SERVER['HTTP_REFERER']);
                        exit;
                    }
                } else {
                    $EM_Notices->add_error($EM_Booking->get_errors());
                }
            } else {
                $EM_Notices->add_error(__('You must log in to cancel your booking.', 'dbem'));
            }
        } elseif (array_key_exists($_REQUEST['action'], $allowed_actions) && $EM_Event->can_manage('manage_bookings', 'manage_others_bookings')) {
            //Event Admin only actions
            $action = $allowed_actions[$_REQUEST['action']];
            //Just do it here, since we may be deleting bookings of different events.
            if (!empty($_REQUEST['bookings']) && EM_Object::array_is_numeric($_REQUEST['bookings'])) {
                $results = array();
                foreach ($_REQUEST['bookings'] as $booking_id) {
                    $EM_Booking = new EM_Booking($booking_id);
                    $result = $EM_Booking->{$action}();
                    $results[] = $result;
                    if (!in_array(false, $results) && !$result) {
                        $feedback = $EM_Booking->feedback_message;
                    }
                }
                $result = !in_array(false, $results);
            } elseif (is_object($EM_Booking)) {
                $result = $EM_Booking->{$action}();
                $feedback = $EM_Booking->feedback_message;
            }
            //FIXME not adhereing to object's feedback or error message, like other bits in this file.
            //TODO multiple deletion won't work in ajax
            if (isset($result) && !empty($_REQUEST['em_ajax'])) {
                if ($result) {
                    echo $feedback;
                } else {
                    echo '<span style="color:red">' . $feedback . '</span>';
                }
                die;
            }
        }
        if ($result && defined('DOING_AJAX')) {
            $return = array('result' => true, 'message' => $EM_Booking->feedback_message);
            echo EM_Object::json_encode($return);
            die;
        } elseif (!$result && defined('DOING_AJAX')) {
            $return = array('result' => false, 'message' => $EM_Booking->feedback_message, 'errors' => $EM_Notices->get_errors());
            echo EM_Object::json_encode($return);
            die;
        }
    } elseif (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'booking_add' && !is_user_logged_in() && !get_option('dbem_bookings_anonymous')) {
        $EM_Notices->add_error(__('You must log in before you make a booking.', 'dbem'));
        if (!$result && defined('DOING_AJAX')) {
            $return = array('result' => false, 'message' => $EM_Booking->feedback_message, 'errors' => $EM_Notices->get_errors());
            echo EM_Object::json_encode($return);
        }
        die;
    }
    //AJAX call for searches
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 6) == 'search') {
        if ($_REQUEST['action'] == 'search_states' && wp_verify_nonce($_REQUEST['_wpnonce'], 'search_states')) {
            if (!empty($_REQUEST['country'])) {
                $results = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT location_state AS value, location_country AS country, CONCAT(location_state, ', ', location_country) AS label FROM " . EM_LOCATIONS_TABLE . " WHERE location_state IS NOT NULL AND location_state != '' AND location_country=%s", $_REQUEST['country']));
            } elseif (!empty($_REQUEST['region'])) {
                $results = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT location_state AS value, location_country AS country, CONCAT(location_state, ', ', location_country) AS label FROM " . EM_LOCATIONS_TABLE . " WHERE location_state IS NOT NULL AND location_state != '' AND location_region=%s", $_REQUEST['region']));
            } else {
                $results = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT location_state AS value, location_country AS country, CONCAT(location_state, ', ', location_country) AS label FROM " . EM_LOCATIONS_TABLE, $_REQUEST['country'] . "WHERE  location_state IS NOT NULL AND location_state != ''"));
            }
            if ($_REQUEST['return_html']) {
                //quick shortcut for quick html form manipulation
                ob_start();
                ?>
				<option value=''><?php 
                _e('All States', 'dbem');
                ?>
</option>
				<?php 
                foreach ($results as $result) {
                    echo "<option>{$result->value}</option>";
                }
                $return = ob_get_clean();
                echo apply_filters('em_ajax_search_states', $return);
                exit;
            } else {
                echo EM_Object::json_encode($results);
                exit;
            }
        }
        if ($_REQUEST['action'] == 'search_regions' && wp_verify_nonce($_REQUEST['_wpnonce'], 'search_regions')) {
            if (!empty($_REQUEST['country'])) {
                $results = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT location_region AS value, location_country AS country, CONCAT(location_region, ', ', location_country) AS label FROM " . EM_LOCATIONS_TABLE . " WHERE location_region IS NOT NULL AND location_region != '' AND location_country=%s", $_REQUEST['country']));
            } else {
                $results = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT location_region AS value, location_country AS country, CONCAT(location_region, ', ', location_country) AS label FROM " . EM_LOCATIONS_TABLE . " WHERE location_region IS NOT NULL AND location_region != ''", $_REQUEST['country']));
            }
            if ($_REQUEST['return_html']) {
                //quick shortcut for quick html form manipulation
                ob_start();
                ?>
				<option value=''><?php 
                _e('All Regions', 'dbem');
                ?>
</option>
				<?php 
                foreach ($results as $result) {
                    echo "<option>{$result->value}</option>";
                }
                $return = ob_get_clean();
                echo apply_filters('em_ajax_search_regions', $return);
                exit;
            } else {
                echo EM_Object::json_encode($results);
                exit;
            }
        } elseif ($_REQUEST['action'] == 'search_events' && wp_verify_nonce($_POST['_wpnonce'], 'search_events') && get_option('dbem_events_page_search')) {
            $args = EM_Events::get_post_search();
            ob_start();
            em_locate_template('templates/events-list.php', true, array('args' => $args));
            //if successful, this template overrides the settings and defaults, including search
            echo apply_filters('em_ajax_search_events', ob_get_clean(), $args);
            exit;
        }
    }
    //EM Ajax requests require this flag.
    if (is_admin() && is_user_logged_in()) {
        //Admin operations
        //Specific Oject Ajax
        if (!empty($_REQUEST['em_obj'])) {
            switch ($_REQUEST['em_obj']) {
                case 'em_bookings_events_table':
                case 'em_bookings_pending_table':
                case 'em_bookings_confirmed_table':
                    call_user_func($_REQUEST['em_obj']);
                    break;
            }
            die;
        }
    }
}
 /**
  * get a list of event categories, keyed by category name => category
  * @return array
  */
 public static function getEventCategories()
 {
     $cats = EM_Categories::get();
     $eventCats = array();
     foreach ($cats as $cat) {
         $eventCats[$cat->name] = $cat;
     }
     return $eventCats;
 }
Пример #12
0
/**
 * Generates Event Admin page, for adding and updating a single (or recurring) event.
 * @param $title
 * @return null
 */
function em_admin_event_page()
{
    global $EM_Event, $current_user, $EM_Notices, $localised_date_formats;
    //$EM_Event->get_bookings()->get_tickets()->get_ticket_bookings(); print_r($EM_Event);die();
    //check that user can access this page
    if (is_object($EM_Event) && !$EM_Event->can_manage('edit_events', 'edit_others_events')) {
        ?>
		<div class="wrap"><h2><?php 
        _e('Unauthorized Access', 'dbem');
        ?>
</h2><p><?php 
        echo sprintf(__('You do not have the rights to manage this %s.', 'dbem'), __('Event', 'dbem'));
        ?>
</p></div>
		<?php 
        return false;
    } elseif (!is_object($EM_Event)) {
        $EM_Event = new EM_Event();
    }
    if (is_object($EM_Event) && $EM_Event->id > 0) {
        if ($EM_Event->is_recurring()) {
            $title = __("Reschedule", 'dbem') . " '{$EM_Event->name}'";
        } else {
            $title = __("Edit Event", 'dbem') . " '" . $EM_Event->name . "'";
        }
    } else {
        $EM_Event = is_object($EM_Event) && get_class($EM_Event) == 'EM_Event' ? $EM_Event : new EM_Event();
        $title = __("Insert New Event", 'dbem');
        //Give a default location & category
        $default_cat = get_option('dbem_default_category');
        $default_loc = get_option('dbem_default_location');
        if (is_numeric($default_cat) && $default_cat > 0) {
            $EM_Category = new EM_Category($default_cat);
            $EM_Event->get_categories()->categories[] = $EM_Category;
        }
        if (is_numeric($default_loc) && $default_loc > 0 && (empty($EM_Event->location->id) && empty($EM_Event->location->name) && empty($EM_Event->location->address) && empty($EM_Event->location->town))) {
            $EM_Event->location_id = $default_loc;
            $EM_Event->location = new EM_Location($default_loc);
        }
    }
    $use_select_for_locations = get_option('dbem_use_select_for_locations');
    // change prefix according to event/recurrence
    $pref = "event_";
    $locale_code = substr(get_locale(), 0, 2);
    $localised_date_format = $localised_date_formats[$locale_code];
    //FIXME time useage is very flimsy imho
    $hours_locale_regexp = "H:i";
    // Setting 12 hours format for those countries using it
    if (preg_match("/en|sk|zh|us|uk/", $locale_code)) {
        $hours_locale_regexp = "h:iA";
    }
    $days_names = array(1 => __('Mon'), 2 => __('Tue'), 3 => __('Wed'), 4 => __('Thu'), 5 => __('Fri'), 6 => __('Sat'), 0 => __('Sun'));
    $required = "<i>*</i>";
    ?>
	<?php 
    echo $EM_Notices;
    ?>

	<form id="event-form" method="post" action=""  enctype='multipart/form-data'>
		<div class="wrap">
			<div id="icon-events" class="icon32"><br /></div>
			<h2><?php 
    echo $title;
    ?>
</h2>
			<?php 
    if (count($EM_Event->warnings) > 0) {
        ?>
				<?php 
        foreach ($EM_Event->warnings as $warning) {
            ?>
				<p class="warning"><?php 
            echo $warning;
            ?>
</p>
				<?php 
        }
        ?>
			<?php 
    }
    ?>
             
			<div id="poststuff" class="metabox-holder has-right-sidebar">
				<!-- SIDEBAR -->
				<div id="side-info-column" class='inner-sidebar'>
					<div id='side-sortables'>
						<?php 
    do_action('em_admin_event_form_side_header');
    ?>
       
						<?php 
    if (get_option('dbem_recurrence_enabled') && ($EM_Event->is_recurrence() || $EM_Event->is_recurring() || $EM_Event->id == '')) {
        ?>
							<!-- START recurrence postbox -->
							<div class="postbox ">
								<div class="handlediv" title="Fare clic per cambiare."><br />
								</div>
								<h3 class='hndle'><span>
									<?php 
        _e("Recurrence", 'dbem');
        ?>
									</span></h3>
									<div class="inside">
									<?php 
        //TODO add js warning if rescheduling, since all bookings are deleted
        ?>
									<?php 
        if (!$EM_Event->id || $EM_Event->is_recurring()) {
            ?>
										<p>
											<input id="event-recurrence" type="checkbox" name="repeated_event" value="1" <?php 
            echo $EM_Event->is_recurring() ? 'checked="checked"' : '';
            ?>
 />
											<?php 
            _e('Repeated event', 'dbem');
            ?>
										</p>
										<div id="event_recurrence_pattern">
											<p>
												Frequency:
												<select id="recurrence-frequency" name="recurrence_freq">
													<?php 
            $freq_options = array("daily" => __('Daily', 'dbem'), "weekly" => __('Weekly', 'dbem'), "monthly" => __('Monthly', 'dbem'));
            em_option_items($freq_options, $EM_Event->freq);
            ?>
												</select>
											</p>
											<p>
												<?php 
            _e('Every', 'dbem');
            ?>
												<input id="recurrence-interval" name='recurrence_interval' size='2' value='<?php 
            echo $EM_Event->interval;
            ?>
' />
												<span class='interval-desc' id="interval-daily-singular">
												<?php 
            _e('day', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-daily-plural">
												<?php 
            _e('days', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-weekly-singular">
												<?php 
            _e('week', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-weekly-plural">
												<?php 
            _e('weeks', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-monthly-singular">
												<?php 
            _e('month', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-monthly-plural">
												<?php 
            _e('months', 'dbem');
            ?>
												</span> 
											</p>
											<p class="alternate-selector" id="weekly-selector">
												<?php 
            $saved_bydays = $EM_Event->is_recurring() ? explode(",", $EM_Event->byday) : array();
            em_checkbox_items('recurrence_bydays[]', $days_names, $saved_bydays);
            ?>
											</p>
											<p class="alternate-selector" id="monthly-selector">
												<?php 
            _e('Every', 'dbem');
            ?>
												<select id="monthly-modifier" name="recurrence_byweekno">
													<?php 
            $weekno_options = array("1" => __('first', 'dbem'), '2' => __('second', 'dbem'), '3' => __('third', 'dbem'), '4' => __('fourth', 'dbem'), '-1' => __('last', 'dbem'));
            em_option_items($weekno_options, $EM_Event->byweekno);
            ?>
												</select>
												<select id="recurrence-weekday" name="recurrence_byday">
													<?php 
            em_option_items($days_names, $EM_Event->byday);
            ?>
												</select>
												&nbsp;
											</p>
										</div>
										<p id="recurrence-tip">
											<?php 
            _e('Check if your event happens more than once according to a regular pattern', 'dbem');
            ?>
										</p>
									<?php 
        } elseif ($EM_Event->is_recurrence()) {
            ?>
											<p>
												<?php 
            echo $EM_Event->get_recurrence_description();
            ?>
												<br />
												<a href="<?php 
            bloginfo('wpurl');
            ?>
/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php 
            echo $EM_Event->recurrence_id;
            ?>
">
												<?php 
            _e('Reschedule', 'dbem');
            ?>
												</a>
												<input type="hidden" name="recurrence_id" value="<?php 
            echo $EM_Event->recurrence_id;
            ?>
" />
											</p>
									<?php 
        } else {
            ?>
										<p><?php 
            _e('This is\'t a recurrent event', 'dbem');
            ?>
</p>
									<?php 
        }
        ?>
								</div>
							</div> 
							<!-- END recurrence postbox -->   
						<?php 
    }
    ?>
   
						   
						<?php 
    if (current_user_can('edit_others_events')) {
        ?>
						<div class="postbox ">
							<div class="handlediv" title="Fare clic per cambiare."><br />
							</div>
							<h3 class='hndle'><span><?php 
        _e('Event Owner/Contact Person', 'dbem');
        ?>
</span></h3>
							<div class="inside">
								<?php 
        wp_dropdown_users(array('name' => 'event_owner', 'show_option_none' => __("Select...", 'dbem'), 'selected' => $EM_Event->owner));
        ?>
							</div>
						</div>
						<?php 
    } else {
        ?>
						<input type="hidden" name="event_owner" value="<?php 
        get_current_user_id();
        ?>
" />
						<?php 
    }
    ?>
 
						   
						<?php 
    if (empty($EM_Event->id)) {
        ?>
							<?php 
        $user_groups = array();
        if (function_exists('groups_get_user_groups')) {
            $group_data = groups_get_user_groups(get_current_user_id());
            foreach ($group_data['groups'] as $group_id) {
                if (groups_is_user_admin(get_current_user_id(), $group_id)) {
                    $user_groups[] = groups_get_group(array('group_id' => $group_id));
                }
            }
        }
        ?>
							<?php 
        if (count($user_groups) > 0) {
            ?>
							<!-- START RSVP -->
							<div class="postbox " id='group-data'>
								<div class="handlediv" title="Fare clic per cambiare."><br />
								</div>
								<h3 class='hndle'><span><?php 
            _e('Group Ownership', 'dbem');
            ?>
</span></h3>
								<div class="inside">
									<p>
										<select name="group_id">
											<option value="<?php 
            echo $BP_Group->id;
            ?>
">Not a Group Event</option>
										<?php 
            foreach ($user_groups as $BP_Group) {
                ?>
											<option value="<?php 
                echo $BP_Group->id;
                ?>
"><?php 
                echo $BP_Group->name;
                ?>
</option>
											<?php 
            }
            ?>
										</select>
										<br />
										<em><?php 
            _e('Select a group you admin to attach this event to it. Note that all other admins of that group can modify the booking, and you will not be able to unattach the event without deleting it.', 'dbem');
            ?>
</em>
									</p>
								</div>
							</div>
							<?php 
        }
        ?>
						<?php 
    }
    ?>
						
						<?php 
    if (get_option('dbem_rsvp_enabled')) {
        ?>
							<!-- START RSVP -->
							<div class="postbox " id='rsvp-data'>
								<div class="handlediv" title="Fare clic per cambiare."><br />
								</div>
								<h3 class='hndle'><span><?php 
        _e('Bookings Stats', 'dbem');
        ?>
</span></h3>
								<div class="inside">
									<div>
										<!-- START RSVP Stats -->
										<?php 
        $available_spaces = $EM_Event->get_bookings()->get_available_spaces();
        $booked_spaces = $EM_Event->get_bookings()->get_booked_spaces();
        if (count($EM_Event->get_bookings()->bookings) > 0) {
            ?>
													<div class='wrap'>
														<p><strong><?php 
            echo __('Available Spaces', 'dbem') . ': ' . $EM_Event->get_bookings()->get_available_spaces();
            ?>
</strong></p>
														<p><strong><?php 
            echo __('Confirmed Spaces', 'dbem') . ': ' . $EM_Event->get_bookings()->get_booked_spaces();
            ?>
</strong></p>
														<p><strong><?php 
            echo __('Pending Spaces', 'dbem') . ': ' . $EM_Event->get_bookings()->get_pending_spaces();
            ?>
</strong></p>
												 	</div>
													 		
											 	    <br class='clear'/>
											 	    
											 	 	<div id='major-publishing-actions'>  
														<div id='publishing-action'> 
															<a id='printable' href='<?php 
            echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&event_id=" . $EM_Event->id;
            ?>
'><?php 
            _e('manage bookings', 'dbem');
            ?>
</a><br />
															<a target='_blank' href='<?php 
            echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=bookings_report&event_id=" . $EM_Event->id;
            ?>
'><?php 
            _e('printable view', 'dbem');
            ?>
</a>
															<a href='<?php 
            echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=export_csv&event_id=" . $EM_Event->id;
            ?>
'><?php 
            _e('export csv', 'dbem');
            ?>
</a>
															<br class='clear'/>             
												        </div>
														<br class='clear'/>    
													</div>
													<?php 
        } else {
            ?>
													<p><em><?php 
            _e('No responses yet!');
            ?>
</em></p>
													<?php 
        }
        ?>
										<!-- END RSVP Stats -->
									</div>
								</div>
							</div>
							<!-- END RSVP -->
						<?php 
    }
    ?>
  
						<?php 
    if (get_option('dbem_categories_enabled')) {
        ?>
							<!-- START Categories -->
							<div class="postbox ">
								<div class="handlediv" title="Fare clic per cambiare."><br />
								</div>
								<h3 class='hndle'><span>
									<?php 
        _e('Category', 'dbem');
        ?>
									</span></h3>
								<div class="inside">
									<?php 
        $categories = EM_Categories::get(array('orderby' => 'category_name'));
        ?>
									<?php 
        if (count($categories) > 0) {
            ?>
										<p>
											<?php 
            foreach ($categories as $EM_Category) {
                ?>
											<label><input type="checkbox" name="event_categories[]" value="<?php 
                echo $EM_Category->id;
                ?>
" <?php 
                if ($EM_Event->get_categories()->has($EM_Category->id)) {
                    echo 'checked="checked"';
                }
                ?>
 /> <?php 
                echo $EM_Category->name;
                ?>
</label><br />			
											<?php 
            }
            ?>
										</p>
									<?php 
        } else {
            ?>
										<p><?php 
            sprintf(__('No categories available, <a href="%s">create one here first</a>', 'dbem'), get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager-categories');
            ?>
</p>
									<?php 
        }
        ?>
								</div>
							</div> 
							<!-- END Categories -->
						<?php 
    }
    ?>
						<?php 
    do_action('em_admin_event_form_side_footer');
    ?>
					</div>
				</div>
				<!-- END OF SIDEBAR -->
				<div id="post-body">
					<div id="post-body-content">
						<?php 
    do_action('em_admin_event_form_header');
    ?>
						<div id="event_name" class="stuffbox">
							<h3>
								<?php 
    _e('Name', 'dbem');
    ?>
							</h3>
							<div class="inside">
								<input type="text" name="event_name" id="event-name" value="<?php 
    echo htmlspecialchars($EM_Event->name, ENT_QUOTES);
    ?>
" /><?php 
    echo $required;
    ?>
								<br />
								<?php 
    _e('The event name. Example: Birthday party', 'dbem');
    ?>
								<?php 
    $slug_link = __('View Slug', 'dbem');
    ?>
								<a href="#" id="event-slug-trigger"><?php 
    echo $slug_link;
    ?>
</a>
								<script type="text/javascript">
									jQuery(document).ready(function($){
										$('#event-slug-trigger').click(function(){
											if( $(this).text() == '<?php 
    echo $slug_link;
    ?>
'){
												$('.event-slug').show(); 
												 $(this).text('<?php 
    _e('Hide Slug', 'dbem');
    ?>
');
											}else{ 
												$('.event-slug').hide(); 
												 $(this).text('<?php 
    echo $slug_link;
    ?>
'); 
											}
										});
									});
								</script>
								<p class='event-slug' style="display:none">
									<?php 
    _e('Event Slug', 'dbem');
    ?>
: <input type="text" name="event_slug" id="event-slug" value="<?php 
    echo $EM_Event->slug;
    ?>
" />
									<br />
									<?php 
    _e('The event slug. If the event slug already exists, a random number will be appended to the end.', 'dbem');
    ?>
								</p>
							</div>
						</div>
						<div id="event_start_date" class="stuffbox">
							<h3 id='event-date-title'><?php 
    _e('Event date', 'dbem');
    ?>
</h3>
							<h3 id='recurrence-dates-title'><?php 
    _e('Recurrence dates', 'dbem');
    ?>
</h3>
							<div class="inside">
								<input id="em-date-start-loc" type="text" />
								<input id="em-date-start" type="hidden" name="event_start_date" value="<?php 
    echo $EM_Event->start_date;
    ?>
" />
								<input id="em-date-end-loc" type="text" />
								<input id="em-date-end" type="hidden" name="event_end_date" value="<?php 
    echo $EM_Event->end_date;
    ?>
" />
								<br />
								<span id='event-date-explanation'>
								<?php 
    _e('The event date.', 'dbem');
    /* Marcus Begin Edit */
    echo " ";
    _e('When not reoccurring, this event spans between the beginning and end date.', 'dbem');
    /* Marcus End Edit */
    ?>
								</span>
								<span id='recurrence-dates-explanation'>
									<?php 
    _e('The recurrence beginning and end date.', 'dbem');
    ?>
								</span>
							</div>
						</div>
						<div id="event_end_day" class="stuffbox">
							<h3>
								<?php 
    _e('Event time', 'dbem');
    ?>
							</h3>
							<div class="inside">
								<input id="start-time" type="text" size="8" maxlength="8" name="event_start_time" value="<?php 
    echo date($hours_locale_regexp, strtotime($EM_Event->start_time));
    ?>
" />
								-
								<input id="end-time" type="text" size="8" maxlength="8" name="event_end_time" value="<?php 
    echo date($hours_locale_regexp, strtotime($EM_Event->end_time));
    ?>
" />
								<br />
								<?php 
    _e('The time of the event beginning and end', 'dbem');
    ?>
. 
							</div>
						</div>
						<div id="location_coordinates" class="stuffbox" style='display: none;'>
							<h3>
								<?php 
    _e('Coordinates', 'dbem');
    ?>
							</h3>
							<div class="inside">
								<input id='location-latitude' name='location_latitude' type='text' value='<?php 
    echo $EM_Event->get_location()->latitude;
    ?>
' size='15' />
								-
								<input id='location-longitude' name='location_longitude' type='text' value='<?php 
    echo $EM_Event->get_location()->longitude;
    ?>
' size='15' />
							</div>
						</div>
						<div id="location_info" class="stuffbox">
							<h3>
								<?php 
    _e('Location', 'dbem');
    ?>
							</h3>
							<div class="inside">
								<table id="dbem-location-data">     
									<tr>
										<td style="padding-right:20px; width:100%;">
											<table>
												<?php 
    if ($use_select_for_locations) {
        ?>
 
												<tr>
													<th><?php 
        _e('Location:', 'dbem');
        ?>
</th>
													<td> 
														<select name="location_id" id='location-select-id' size="1">  
															<?php 
        $locations = EM_Locations::get();
        foreach ($locations as $location) {
            $selected = "";
            if ($EM_Event->get_location()->id == $location->id) {
                $selected = "selected='selected' ";
            }
            ?>
          
														    	<option value="<?php 
            echo $location->id;
            ?>
" title="<?php 
            echo "{$location->latitude},{$location->longitude}";
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo $location->name;
            ?>
</option>
														    	<?php 
        }
        ?>
														</select>
														<p><?php 
        _e('The name of the location where the event takes place. You can use the name of a venue, a square, etc', 'dbem');
        ?>
</p>
													</td>
												</tr>
												<?php 
    } else {
        ?>
												<tr>
													<th><?php 
        _e('Name:');
        ?>
</th>
													<td>
														<input id='location-id' name='location_id' type='hidden' value='<?php 
        echo $EM_Event->get_location()->id;
        ?>
' size='15' />
														<input id="location-name" type="text" name="location_name" value="<?php 
        echo htmlspecialchars($EM_Event->location->name, ENT_QUOTES);
        ?>
" /><?php 
        echo $required;
        ?>
													
					                            		<p><em><?php 
        _e('Create a location or start typing to search a previously created location.', 'dbem');
        ?>
</em></p>
					                            	</td>
										 		</tr>
												<tr>
													<th><?php 
        _e('Address:');
        ?>
&nbsp;</th>
													<td>
														<input id="location-address" type="text" name="location_address" value="<?php 
        echo htmlspecialchars($EM_Event->location->address, ENT_QUOTES);
        ?>
" /><?php 
        echo $required;
        ?>
													</td>
												</tr>
												<tr>
													<th><?php 
        _e('City/Town:');
        ?>
&nbsp;</th>
													<td>
														<input id="location-town" type="text" name="location_town" value="<?php 
        echo htmlspecialchars($EM_Event->location->town, ENT_QUOTES);
        ?>
" /><?php 
        echo $required;
        ?>
														<input id="location-town-wpnonce" type="hidden" value="<?php 
        echo wp_create_nonce('search_town');
        ?>
" />
													</td>
												</tr>
												<tr>
													<th><?php 
        _e('State/County:');
        ?>
&nbsp;</th>
													<td>
														<input id="location-state" type="text" name="location_state" value="<?php 
        echo htmlspecialchars($EM_Event->location->state, ENT_QUOTES);
        ?>
" />
														<input id="location-state-wpnonce" type="hidden" value="<?php 
        echo wp_create_nonce('search_states');
        ?>
" />
													</td>
												</tr>
												<tr>
													<th><?php 
        _e('Postcode:');
        ?>
&nbsp;</th>
													<td>
														<input id="location-postcode" type="text" name="location_postcode" value="<?php 
        echo htmlspecialchars($EM_Event->location->postcode, ENT_QUOTES);
        ?>
" />
													</td>
												</tr>
												<tr>
													<th><?php 
        _e('Region:');
        ?>
&nbsp;</th>
													<td>
														<input id="location-region" type="text" name="location_region" value="<?php 
        echo htmlspecialchars($EM_Event->location->region, ENT_QUOTES);
        ?>
" />
														<input id="location-region-wpnonce" type="hidden" value="<?php 
        echo wp_create_nonce('search_regions');
        ?>
" />
													</td>
												</tr>
												<tr>
													<th><?php 
        _e('Country:');
        ?>
&nbsp;</th>
													<td>
														<select id="location-country" name="location_country">
															<option value="0" <?php 
        echo $EM_Event->location->country == '' && $EM_Event->location->id == '' && get_option('dbem_location_default_country') == '' ? 'selected="selected"' : '';
        ?>
><?php 
        _e('none selected', 'dbem');
        ?>
</option>
															<?php 
        foreach (em_get_countries() as $country_key => $country_name) {
            ?>
															<option value="<?php 
            echo $country_key;
            ?>
" <?php 
            echo $EM_Event->location->country == $country_key || $EM_Event->location->country == '' && $EM_Event->location->id == '' && get_option('dbem_location_default_country') == $country_key ? 'selected="selected"' : '';
            ?>
><?php 
            echo $country_name;
            ?>
</option>
															<?php 
        }
        ?>
														</select><?php 
        echo $required;
        ?>
														<!-- <p><em><?php 
        _e('Filling this in first will allow you to quickly find previously filled states and regions for the country.', 'dbem');
        ?>
</em></p> -->
													</td>
												</tr>
												<?php 
    }
    ?>
											</table>
										</td>
										<?php 
    if (get_option('dbem_gmap_is_active')) {
        ?>
										<td width="400">
											<div id='em-map-404' style='width: 400px; vertical-align:middle; text-align: center;'>
												<p><em><?php 
        _e('Location not found', 'dbem');
        ?>
</em></p>
											</div>
											<div id='em-map' style='width: 400px; height: 300px; display: none;'></div>
										</td>
										<?php 
    }
    ?>
									</tr>
							</table>
						</div>
					</div>
					<div id="event_notes" class="stuffbox">
						<h3>
							<?php 
    _e('Details', 'dbem');
    ?>
						</h3>
						<div class="inside">
							<div id="<?php 
    echo user_can_richedit() ? 'postdivrich' : 'postdiv';
    ?>
" class="postarea">
								<?php 
    the_editor($EM_Event->notes);
    ?>
							</div>
							<br />
							<?php 
    _e('Details about the event', 'dbem');
    ?>
						</div>
					</div>
									
					<div id="event-image" class="stuffbox">
						<h3>
							<?php 
    _e('Event image', 'dbem');
    ?>
						</h3>
						<div class="inside" style="padding:10px;">
								<?php 
    if ($EM_Event->get_image_url() != '') {
        ?>
 
									<img src='<?php 
        echo $EM_Event->image_url;
        ?>
' alt='<?php 
        echo $EM_Event->name;
        ?>
'/>
								<?php 
    } else {
        ?>
 
									<?php 
        _e('No image uploaded for this event yet', 'dbem');
        ?>
								<?php 
    }
    ?>
								<br /><br />
								<label for='event_image'><?php 
    _e('Upload/change picture', 'dbem');
    ?>
</label> <input id='event-image' name='event_image' id='event_image' type='file' size='40' />
						</div>
					</div>
					
					<?php 
    if (get_option('dbem_rsvp_enabled')) {
        ?>
					<div id="event-bookings" class="stuffbox">
						<h3><span><?php 
        _e('Bookings/Registration', 'dbem');
        ?>
</span></h3>
						<div class="inside">
							<div class="wrap">
								<div id="event-rsvp-box">
									<input id="event-rsvp" name='event_rsvp' value='1' type='checkbox' <?php 
        echo $EM_Event->rsvp ? 'checked="checked"' : '';
        ?>
 />
									&nbsp;&nbsp;
									<?php 
        _e('Enable registration for this event', 'dbem');
        ?>
								</div>
								<div id="event-tickets" style="<?php 
        echo $EM_Event->rsvp ? '' : 'display:none;';
        ?>
">
									<?php 
        //get tickets here and if there are none, create a blank ticket
        $EM_Tickets = $EM_Event->get_bookings()->get_tickets();
        if (count($EM_Tickets->tickets) == 0) {
            $EM_Tickets->tickets[] = new EM_Ticket();
            $delete_temp_ticket = true;
        }
        if (get_option('dbem_bookings_tickets_single')) {
            $EM_Ticket = $EM_Tickets->get_first();
            include em_locate_template('forms/ticket-form.php');
        } else {
            ?>
		
										<p><strong><?php 
            _e('Tickets', 'dbem');
            ?>
</strong></p>
										<p><em><?php 
            _e('You have single or multiple tickets, where certain tickets become availalble under certain conditions, e.g. early bookings, group discounts, maximum bookings per ticket, etc.', 'dbem');
            ?>
</em></p>					
										<table class="form-table">
											<thead>
												<tr valign="top">
													<th class="ticket-status">&nbsp;</th>
													<th><?php 
            _e('Ticket Name', 'dbem');
            ?>
</th>
													<th><?php 
            _e('Price', 'dbem');
            ?>
</th>
													<th><?php 
            _e('Min/Max', 'dbem');
            ?>
</th>
													<th><?php 
            _e('Start/End', 'dbem');
            ?>
</th>
													<th><?php 
            _e('Avail. Spaces', 'dbem');
            ?>
</th>
													<th><?php 
            _e('Booked Spaces', 'dbem');
            ?>
</th>
													<th>&nbsp;</th>
												</tr>
											</thead>    
											<tfoot>
												<tr valign="top">
													<td colspan="6">
														<a href="#" id="em-tickets-add" rel="#em-tickets-form"><?php 
            _e('Add new ticket', 'dbem');
            ?>
</a>
													</td>
												</tr>
											</tfoot>
											<tbody id="em-tickets-body">
												<?php 
            $count = 1;
            foreach ($EM_Tickets->tickets as $EM_Ticket) {
                ?>
														<tr valign="top" id="em-tickets-row-<?php 
                echo $count;
                ?>
" class="em-tickets-row">
															<td class="ticket-status"><span class="<?php 
                echo $EM_Ticket->is_available() ? 'ticket_on' : 'ticket_off';
                ?>
"></span></td>													
															<td class="ticket-name"><span class="ticket_name"><?php 
                echo $EM_Ticket->name;
                ?>
</span><br /><span class="ticket_description"></span></td>
															<td class="ticket-price">
																<span class="ticket_price"><?php 
                echo $EM_Ticket->price ? $EM_Ticket->price : __('Free', 'dbem');
                ?>
</span>
															</td>
															<td class="ticket-limit">
																<span class="ticket_min">
																	<?php 
                echo !empty($EM_Ticket->min) ? $EM_Ticket->min : '-';
                ?>
																</span> / 
																<span class="ticket_max"><?php 
                echo !empty($EM_Ticket->max) ? $EM_Ticket->max : '-';
                ?>
</span>
															</td>
															<td class="ticket-time">
																<span class="ticket_start"><?php 
                echo !empty($EM_Ticket->start) ? date($localised_date_format, $EM_Ticket->start_timestamp) : '';
                ?>
</span> -
																<span class="ticket_end"><?php 
                echo !empty($EM_Ticket->end) ? date($localised_date_format, $EM_Ticket->end_timestamp) : '';
                ?>
</span>
															</td>
															<td class="ticket-qty">
																<span class="ticket_available_spaces"><?php 
                echo $EM_Ticket->get_available_spaces();
                ?>
</span>/
																<span class="ticket_spaces">
																	<?php 
                if ($EM_Ticket->get_spaces()) {
                    echo $EM_Ticket->get_spaces();
                    echo $EM_Ticket->spaces_limit ? '' : '*';
                } else {
                    echo '-';
                }
                ?>
																</span>
															</td>
															<td class="ticket-booked-spaces">
																<span class="ticket_booked_spaces"><?php 
                echo $EM_Ticket->get_booked_spaces();
                ?>
</span>
															</td>
															<td class="ticket-actions">
																<a href="#" class="ticket-actions-edit"><?php 
                _e('Edit', 'dbem');
                ?>
</a> 
																<?php 
                if (count($EM_Ticket->get_bookings()->bookings) == 0) {
                    ?>
																| <a href="<?php 
                    bloginfo('wpurl');
                    ?>
/wp-load.php" class="ticket-actions-delete"><?php 
                    _e('Delete', 'dbem');
                    ?>
</a>
																<?php 
                } else {
                    ?>
																| <a href="<?php 
                    bloginfo('wpurl');
                    ?>
/wp-admin/admin.php?page=events-manager-bookings&ticket_id=<?php 
                    echo $EM_Ticket->id;
                    ?>
"><?php 
                    _e('View Bookings', 'dbem');
                    ?>
</a>
																<?php 
                }
                ?>
																<input type="hidden" class="ticket_id" name="em_tickets[<?php 
                echo $count;
                ?>
][ticket_id]" value="<?php 
                echo $EM_Ticket->id;
                ?>
" />
																<input type="hidden" class="ticket_name" name="em_tickets[<?php 
                echo $count;
                ?>
][ticket_name]" value="<?php 
                echo $EM_Ticket->name;
                ?>
" />
																<input type="hidden" name="em_tickets[<?php 
                echo $count;
                ?>
][ticket_description]" value="<?php 
                echo $EM_Ticket->description;
                ?>
" />
																<input type="hidden" class="ticket_price" name="em_tickets[<?php 
                echo $count;
                ?>
][ticket_price]" value="<?php 
                echo $EM_Ticket->price;
                ?>
" />
																<input type="hidden" class="ticket_spaces" name="em_tickets[<?php 
                echo $count;
                ?>
][ticket_spaces]" value="<?php 
                echo $EM_Ticket->spaces;
                ?>
" />
																<input type="hidden" class="ticket_start" name="em_tickets[<?php 
                echo $count;
                ?>
][ticket_start]" value="<?php 
                echo !empty($EM_Ticket->start) ? date("Y-m-d H:i", $EM_Ticket->start_timestamp) : '';
                ?>
" />
																<input type="hidden" class="ticket_end" name="em_tickets[<?php 
                echo $count;
                ?>
][ticket_end]" value="<?php 
                echo !empty($EM_Ticket->end) ? date("Y-m-d H:i", $EM_Ticket->end_timestamp) : '';
                ?>
" />
																<input type="hidden" class="ticket_min" name="em_tickets[<?php 
                echo $count;
                ?>
][ticket_min]" value="<?php 
                echo $EM_Ticket->min;
                ?>
" />
																<input type="hidden" class="ticket_max" name="em_tickets[<?php 
                echo $count;
                ?>
][ticket_max]" value="<?php 
                echo $EM_Ticket->max;
                ?>
" />
															</td>
														</tr>
														<?php 
                $count++;
            }
            if (!empty($delete_temp_ticket)) {
                array_pop($EM_Tickets->tickets);
            }
            ?>
											</tbody>
										</table>
										<?php 
        }
        ?>
								</div>
							</div>
						</div>
					</div>
					<?php 
    }
    ?>
					
					<?php 
    if (get_option('dbem_attributes_enabled')) {
        ?>
						<div id="event-attributes" class="stuffbox">
							<h3>
								<?php 
        _e('Attributes', 'dbem');
        ?>
							</h3>
							<div class="inside">
								<?php 
        $attributes = em_get_attributes();
        $has_depreciated = false;
        ?>
								<div class="wrap">
									<?php 
        if (!empty($attributes['names']) && count($attributes['names']) > 0) {
            ?>
										<table class="form-table">
											<thead>
												<tr valign="top">
													<td><strong>Attribute Name</strong></td>
													<td><strong>Value</strong></td>
												</tr>
											</thead> 
											<tbody id="mtm_body">
												<?php 
            $count = 1;
            foreach ($attributes['names'] as $name) {
                ?>
													<tr valign="top" id="em_attribute_<?php 
                echo $count;
                ?>
">
														<td scope="row"><?php 
                echo $name;
                ?>
</td>
														<td>
															<?php 
                if (count($attributes['values'][$name]) > 0) {
                    ?>
															<select name="em_attributes[<?php 
                    echo $name;
                    ?>
]">
																<option><?php 
                    echo __('No Value', 'dbem');
                    ?>
</option>
																<?php 
                    foreach ($attributes['values'][$name] as $attribute_val) {
                        ?>
																	<?php 
                        if (array_key_exists($name, $EM_Event->attributes) && $EM_Event->attributes[$name] == $attribute_val) {
                            ?>
																		<option selected="selected"><?php 
                            echo $attribute_val;
                            ?>
</option>
																	<?php 
                        } else {
                            ?>
																		<option><?php 
                            echo $attribute_val;
                            ?>
</option>
																	<?php 
                        }
                        ?>
																<?php 
                    }
                    ?>
															</select>
															<?php 
                } else {
                    ?>
															<input type="text" name="em_attributes[<?php 
                    echo $name;
                    ?>
]" value="<?php 
                    echo array_key_exists($name, $EM_Event->attributes) ? htmlspecialchars($EM_Event->attributes[$name], ENT_QUOTES) : '';
                    ?>
" />
															<?php 
                }
                ?>
														</td>
													</tr>
													<?php 
                $count++;
            }
            if ($count == 1) {
                ?>
													<tr><td colspan="2"><?php 
                echo sprintf(__("You don't have any custom attributes defined in any of your Events Manager template settings. Please add them the <a href='%s'>settings page</a>", 'dbem'), get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-options");
                ?>
</td></tr>
													<?php 
            }
            ?>
											</tbody>
										</table>
										<?php 
            if (count(array_diff(array_keys($EM_Event->attributes), $attributes['names'])) > 0) {
                ?>
										<p><strong><?php 
                _e('Depreciated Attributes');
                ?>
</strong></p>
										<p><em><?php 
                _e("If you see any attributes under here, that means they're not used in Events Manager anymore. To add them, you need to add the custom attribute again to a formatting option in the settings page. To remove any of these depreciated attributes, give it a blank value and save.");
                ?>
</em></p>
										<table class="form-table">
											<thead>
												<tr valign="top">
													<td><strong>Attribute Name</strong></td>
													<td><strong>Value</strong></td>
												</tr>
											</thead> 
											<tbody id="mtm_body">
												<?php 
                if (is_array($EM_Event->attributes) and count($EM_Event->attributes) > 0) {
                    foreach ($EM_Event->attributes as $name => $value) {
                        if (!in_array($name, $attributes['names'])) {
                            ?>
															<tr valign="top" id="em_attribute_<?php 
                            echo $count;
                            ?>
">
																<td scope="row"><?php 
                            echo $name;
                            ?>
</td>
																<td>
																	<input type="text" name="em_attributes[<?php 
                            echo $name;
                            ?>
]" value="<?php 
                            echo htmlspecialchars($value, ENT_QUOTES);
                            ?>
" />
																</td>
															</tr>
															<?php 
                            $count++;
                        }
                    }
                }
                ?>
											</tbody>
										</table>
										<?php 
            }
            ?>
									<?php 
        } else {
            ?>
										<p>
										<?php 
            _e('In order to use attributes, you must define some in your templates, otherwise they\'ll never show. Go to Events > Settings to add attribute placeholders.', 'dbem');
            ?>
										</p> 
										<script>
											jQuery(document).ready(function($){ $('#event_attributes').addClass('closed'); });
										</script>
									<?php 
        }
        ?>
								</div>
							</div>
						</div>
						<?php 
    }
    ?>
						<?php 
    do_action('em_admin_event_form_footer');
    ?>
					</div>
					<p class="submit">
						<input type="submit" name="events_update" value="<?php 
    _e('Submit Event', 'dbem');
    ?>
 &raquo;" />
					</p>
					<input type="hidden" name="p" value="<?php 
    echo !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
    ?>
" /><a>
					<input type="hidden" name="scope" value="<?php 
    echo !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
    ?>
" /></a>
					<input type="hidden" name="event_id" value="<?php 
    echo $EM_Event->id;
    ?>
" />
					<input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('wpnonce_event_save');
    ?>
" />
					<input type="hidden" name="action" value="event_save" />
				</div>
			</div>
		</div>
	</form>
	<?php 
    em_locate_template('forms/tickets-form.php', true);
    //put here as it can't be in the add event form
    ?>
	<script type="text/javascript">
		jQuery(document).ready( function($) {
			<?php 
    if ($EM_Event->is_recurring()) {
        ?>
			//Recurrence Warnings
			$('#event_form').submit( function(event){
				confirmation = confirm('<?php 
        _e('Are you sure you want to reschedule this recurring event? If you do this, you will lose all booking information and the old recurring events will be deleted.', 'dbem');
        ?>
');
				if( confirmation == false ){
					event.preventDefault();
				}
			});
			<?php 
    }
    ?>
			<?php 
    if (get_option('dbem_rsvp_enabled')) {
        ?>
			//RSVP Warning
			$('#event-rsvp').click( function(event){
				if( !this.checked ){
					confirmation = confirm('<?php 
        _e('Are you sure you want to disable bookings? If you do this and save, you will lose all previous bookings. If you wish to prevent further bookings, reduce the number of spaces available to the amount of bookings you currently have', 'dbem');
        ?>
');
					if( confirmation == false ){
						event.preventDefault();
					}else{
						$('#event-tickets').hide();
						$("div#rsvp-data").hide();
					}
				}else{
					$('#event-tickets').fadeIn();
					$("div#rsvp-data").fadeIn();
				}
			});
			  
			if($('input#event-rsvp').attr("checked")) {
				$("div#rsvp-data").fadeIn();
			} else {
				$("div#rsvp-data").hide();
			}
			<?php 
    }
    ?>
		});		
	</script>
<?php 
}
Пример #13
0
/**
 * Generates Event Admin page, for adding and updating a single (or recurring) event.
 * @param $title
 * @return null
 */
function em_admin_event_page()
{
    global $EM_Event, $current_user;
    global $localised_date_formats;
    //check that user can access this page
    if (is_object($EM_Event) && !$EM_Event->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;
    }
    if (is_object($EM_Event) && $EM_Event->id > 0) {
        if ($EM_Event->is_recurring()) {
            $title = __("Reschedule", 'dbem') . " '{$EM_Event->name}'";
        } else {
            $title = __("Edit Event", 'dbem') . " '" . $EM_Event->name . "'";
        }
    } else {
        $EM_Event = is_object($EM_Event) && get_class($EM_Event) == 'EM_Event' ? $EM_Event : new EM_Event();
        $title = __("Insert New Event", 'dbem');
        //Give a default location & category
        $default_cat = get_option('dbem_default_category');
        $default_loc = get_option('dbem_default_location');
        if (is_numeric($default_cat) && $default_cat > 0) {
            $EM_Event->category_id = $default_cat;
            $EM_Event->category = new EM_Category($default_cat);
        }
        if (is_numeric($default_loc) && $default_loc > 0 && (empty($EM_Event->location->id) && empty($EM_Event->location->name) && empty($EM_Event->location->address) && empty($EM_Event->location->town))) {
            $EM_Event->location_id = $default_loc;
            $EM_Event->location = new EM_Location($default_loc);
        }
    }
    $use_select_for_locations = get_option('dbem_use_select_for_locations');
    // change prefix according to event/recurrence
    $pref = "event_";
    $locale_code = substr(get_locale(), 0, 2);
    $localised_date_format = $localised_date_formats[$locale_code];
    //FIXME time useage is very flimsy imho
    $hours_locale_regexp = "H:i";
    // Setting 12 hours format for those countries using it
    if (preg_match("/en|sk|zh|us|uk/", $locale_code)) {
        $hours_locale_regexp = "h:iA";
    }
    $days_names = array(1 => __('Mon'), 2 => __('Tue'), 3 => __('Wed'), 4 => __('Thu'), 5 => __('Fri'), 6 => __('Sat'), 0 => __('Sun'));
    ?>
	<?php 
    if (count($EM_Event->errors) > 0 || !empty($_GET['error'])) {
        ?>
	<div id='message' class='error '>
		<p>
			<?php 
        if (count($EM_Event->errors)) {
            ?>
			<strong><?php 
            echo __("Ach, there's a problem here:", "dbem");
            ?>
</strong><br /><br />
			<?php 
            echo implode('<br />', $EM_Event->errors);
            ?>
			<?php 
        } else {
            echo $_GET['error'];
        }
        ?>
		</p>
	</div>
	<?php 
    }
    ?>
	<?php 
    if (!empty($EM_Event->feedback_message) || !empty($_GET['message'])) {
        ?>
	<div id='message' class='updated fade'>
		<p><?php 
        echo !empty($EM_Event->feedback_message) ? $EM_Event->feedback_message : $_GET['message'];
        ?>
</p>
	</div>
	<?php 
    }
    ?>
	<form id="event-form" method="post" action="">
		<div class="wrap">
			<div id="icon-events" class="icon32"><br /></div>
			<h2><?php 
    echo $title;
    ?>
</h2>
			<?php 
    if ($EM_Event->is_recurrence() || $EM_Event->is_recurring()) {
        ?>
			<p id='recurrence_warning'>
				<?php 
        //TODO better warning system when changing a recurring event (e.g. when removing recurrences).
        if ($EM_Event->is_recurring()) {
            _e('WARNING: This is a recurring event.', 'dbem');
            echo "<br />";
            _e('Modifying these data all the events linked to this recurrence will be rescheduled', 'dbem');
            echo " ";
            _e('and all booking information will be deleted!', 'dbem');
        } elseif ($EM_Event->is_recurrence()) {
            //TODO Terminology confusing with methods, maybe worth changing?
            _e('WARNING: This is a recurrence.', 'dbem');
            echo "<br />";
            _e('If you change these data and save, this will become an independent event.', 'dbem');
        }
        ?>
			</p>
			<?php 
    }
    ?>
              
			<div id="poststuff" class="metabox-holder has-right-sidebar">
				<!-- SIDEBAR -->
				<div id="side-info-column" class='inner-sidebar'>
					<div id='side-sortables'>       
						<?php 
    if (get_option('dbem_recurrence_enabled')) {
        ?>
							<!-- START recurrence postbox -->
							<div class="postbox ">
								<div class="handlediv" title="Fare clic per cambiare."><br />
								</div>
								<h3 class='hndle'><span>
									<?php 
        _e("Recurrence", 'dbem');
        ?>
									</span></h3>
									<div class="inside">
									<?php 
        //TODO add js warning if rescheduling, since all bookings are deleted
        ?>
									<?php 
        if (!$EM_Event->id || $EM_Event->is_recurring()) {
            ?>
										<p>
											<input id="event-recurrence" type="checkbox" name="repeated_event" value="1" <?php 
            echo $EM_Event->is_recurring() ? 'checked="checked"' : '';
            ?>
 />
											<?php 
            _e('Repeated event', 'dbem');
            ?>
										</p>
										<div id="event_recurrence_pattern">
											<p>
												Frequency:
												<select id="recurrence-frequency" name="recurrence_freq">
													<?php 
            $freq_options = array("daily" => __('Daily', 'dbem'), "weekly" => __('Weekly', 'dbem'), "monthly" => __('Monthly', 'dbem'));
            em_option_items($freq_options, $EM_Event->freq);
            ?>
												</select>
											</p>
											<p>
												<?php 
            _e('Every', 'dbem');
            ?>
												<input id="recurrence-interval" name='recurrence_interval' size='2' value='<?php 
            echo $EM_Event->interval;
            ?>
' />
												<span class='interval-desc' id="interval-daily-singular">
												<?php 
            _e('day', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-daily-plural">
												<?php 
            _e('days', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-weekly-singular">
												<?php 
            _e('week', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-weekly-plural">
												<?php 
            _e('weeks', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-monthly-singular">
												<?php 
            _e('month', 'dbem');
            ?>
												</span> <span class='interval-desc' id="interval-monthly-plural">
												<?php 
            _e('months', 'dbem');
            ?>
												</span> 
											</p>
											<p class="alternate-selector" id="weekly-selector">
												<?php 
            $saved_bydays = $EM_Event->is_recurring() ? explode(",", $EM_Event->byday) : array();
            em_checkbox_items('recurrence_bydays[]', $days_names, $saved_bydays);
            ?>
											</p>
											<p class="alternate-selector" id="monthly-selector">
												<?php 
            _e('Every', 'dbem');
            ?>
												<select id="monthly-modifier" name="recurrence_byweekno">
													<?php 
            $weekno_options = array("1" => __('first', 'dbem'), '2' => __('second', 'dbem'), '3' => __('third', 'dbem'), '4' => __('fourth', 'dbem'), '-1' => __('last', 'dbem'));
            em_option_items($weekno_options, $EM_Event->byweekno);
            ?>
												</select>
												<select id="recurrence-weekday" name="recurrence_byday">
													<?php 
            em_option_items($days_names, $EM_Event->byday);
            ?>
												</select>
												&nbsp;
											</p>
										</div>
										<p id="recurrence-tip">
											<?php 
            _e('Check if your event happens more than once according to a regular pattern', 'dbem');
            ?>
										</p>
									<?php 
        } elseif ($EM_Event->is_recurrence()) {
            ?>
											<p>
												<?php 
            echo $EM_Event->get_recurrence_description();
            ?>
												<br />
												<a href="<?php 
            bloginfo('wpurl');
            ?>
/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php 
            echo $EM_Event->recurrence_id;
            ?>
">
												<?php 
            _e('Reschedule', 'dbem');
            ?>
												</a>
												<input type="hidden" name="recurrence_id" value="<?php 
            echo $EM_Event->recurrence_id;
            ?>
" />
											</p>
									<?php 
        } else {
            ?>
										<p><?php 
            _e('This is\'t a recurrent event', 'dbem');
            ?>
</p>
									<?php 
        }
        ?>
								</div>
							</div> 
							<!-- END recurrence postbox -->   
						<?php 
    }
    ?>
          
						<?php 
    if (get_option('dbem_rsvp_enabled')) {
        ?>
							<!-- START RSVP -->
							<?php 
        if (em_verify_admin()) {
            ?>
							<div class="postbox ">
								<div class="handlediv" title="Fare clic per cambiare."><br />
								</div>
								<h3 class='hndle'><span>
									<?php 
            _e('Contact Person', 'dbem');
            ?>
									</span></h3>
								<div class="inside">
									<p><?php 
            _e('Contact', 'dbem');
            ?>
										<?php 
            wp_dropdown_users(array('name' => 'event_contactperson_id', 'show_option_none' => __("Select...", 'dbem'), 'selected' => $EM_Event->contactperson_id));
            ?>
									</p>
								</div>
							</div>
							<?php 
        } else {
            ?>
							<input type="hidden" name="event_contactperson_id" value="<?php 
            get_current_user_id();
            ?>
" />
							<?php 
        }
        ?>
							<div class="postbox ">
								<div class="handlediv" title="Fare clic per cambiare."><br />
								</div>
								<h3 class='hndle'><span><?php 
        _e('RSVP', 'dbem');
        ?>
</span></h3>
								<div class="inside">
									<p>
										<input id="rsvp-checkbox" name='event_rsvp' value='1' type='checkbox' <?php 
        echo $EM_Event->rsvp ? 'checked="checked"' : '';
        ?>
 />
										<?php 
        _e('Enable registration for this event', 'dbem');
        ?>
									</p>
									<div id='rsvp-data'>
										<?php 
        if ($EM_Event->contactperson_id != NULL) {
            $selected = $EM_Event->contactperson_id;
        } else {
            $selected = '0';
        }
        ?>
										<p>
											<?php 
        _e('Spaces', 'dbem');
        ?>
 :
											<input id="seats-input" type="text" name="event_seats" size='5' value="<?php 
        echo $EM_Event->seats;
        ?>
" />
										</p>
										<!-- START RSVP Stats -->
										<?php 
        if ($EM_Event->rsvp) {
            $available_seats = $EM_Event->get_bookings()->get_available_seats();
            $booked_seats = $EM_Event->get_bookings()->get_booked_seats();
            if (count($EM_Event->get_bookings()->bookings) > 0) {
                ?>
													<div class='wrap'>
														<p><strong><?php 
                echo __('Available Spaces', 'dbem') . ': ' . $EM_Event->get_bookings()->get_available_seats();
                ?>
</strong></p>
														<p><strong><?php 
                echo __('Confirmed Spaces', 'dbem') . ': ' . $EM_Event->get_bookings()->get_booked_seats();
                ?>
</strong></p>
														<p><strong><?php 
                echo __('Pending Spaces', 'dbem') . ': ' . $EM_Event->get_bookings()->get_pending_seats();
                ?>
</strong></p>
												 	</div>
													 		
											 	    <br class='clear'/>
											 	    
											 	 	<div id='major-publishing-actions'>  
														<div id='publishing-action'> 
															<a id='printable' href='<?php 
                echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&event_id=" . $EM_Event->id;
                ?>
'><?php 
                _e('manage bookings', 'dbem');
                ?>
</a><br />
															<a target='_blank' href='<?php 
                echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=bookings_report&event_id=" . $EM_Event->id;
                ?>
'><?php 
                _e('printable view', 'dbem');
                ?>
</a>
															<a href='<?php 
                echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=export_csv&event_id=" . $EM_Event->id;
                ?>
'><?php 
                _e('export csv', 'dbem');
                ?>
</a>
															<br class='clear'/>             
												        </div>
														<br class='clear'/>    
													</div>
													<?php 
            } else {
                ?>
													<p><em><?php 
                _e('No responses yet!');
                ?>
</em></p>
													<?php 
            }
        }
        ?>
										<!-- END RSVP Stats -->
									</div>
								</div>
							</div>
							<!-- END RSVP -->
						<?php 
    }
    ?>
  
						<?php 
    if (get_option('dbem_categories_enabled')) {
        ?>
							<!-- START Categories -->
							<div class="postbox ">
								<div class="handlediv" title="Fare clic per cambiare."><br />
								</div>
								<h3 class='hndle'><span>
									<?php 
        _e('Category', 'dbem');
        ?>
									</span></h3>
								<div class="inside">
									<?php 
        $categories = EM_Categories::get(array('orderby' => 'category_name'));
        ?>
									<?php 
        if (count($categories) > 0) {
            ?>
										<p><?php 
            _e('Category:', 'dbem');
            ?>
											<select name="event_category_id">
												<option value="" <?php 
            echo $EM_Event->category_id == '' ? "selected='selected'" : '';
            ?>
><?php 
            _e('no category', 'dbem');
            ?>
</option>	
												<?php 
            foreach ($categories as $EM_Category) {
                $selected = $EM_Category->id == $EM_Event->category_id ? "selected='selected'" : '';
                ?>
													<option value="<?php 
                echo $EM_Category->id;
                ?>
" <?php 
                echo $selected;
                ?>
>
													<?php 
                echo $EM_Category->name;
                ?>
													</option>
													<?php 
            }
            ?>
											</select>
										</p>
									<?php 
        } else {
            ?>
										<p><?php 
            sprintf(__('No categories available, <a href="%s">create one here first</a>', 'dbem'), get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager-categories');
            ?>
</p>
									<?php 
        }
        ?>
								</div>
							</div> 
							<!-- END Categories -->
						<?php 
    }
    ?>
					</div>
				</div>
				<!-- END OF SIDEBAR -->
				<div id="post-body">
					<div id="post-body-content">
						<div id="event_name" class="stuffbox">
							<h3>
								<?php 
    _e('Name', 'dbem');
    ?>
							</h3>
							<div class="inside">
								<input type="text" name="event_name" id="event-name" value="<?php 
    echo htmlspecialchars($EM_Event->name, ENT_QUOTES);
    ?>
" />
								<br />
								<?php 
    _e('The event name. Example: Birthday party', 'dbem');
    ?>
							</div>
						</div>
						<div id="event_start_date" class="stuffbox">
							<h3 id='event-date-title'>
								<?php 
    _e('Event date', 'dbem');
    ?>
							</h3>
							<h3 id='recurrence-dates-title'>
								<?php 
    _e('Recurrence dates', 'dbem');
    ?>
							</h3>
							<div class="inside">
								<input id="localised-date" type="text" name="localised_event_date" style="display: none;" />
								<input id="date-to-submit" type="text" name="event_start_date" value="<?php 
    echo $EM_Event->start_date;
    ?>
" style="background: #FCFFAA" />
								<input id="localised-end-date" type="text" name="localised_event_end_date" style="display: none;" />
								<input id="end-date-to-submit" type="text" name="event_end_date" value="<?php 
    echo $EM_Event->end_date;
    ?>
" style="background: #FCFFAA" />
								<br />
								<span id='event-date-explanation'>
								<?php 
    _e('The event date.', 'dbem');
    /* Marcus Begin Edit */
    echo " ";
    _e('When not reoccurring, this event spans between the beginning and end date.', 'dbem');
    /* Marcus End Edit */
    ?>
								</span>
								<span id='recurrence-dates-explanation'>
									<?php 
    _e('The recurrence beginning and end date.', 'dbem');
    ?>
								</span>
							</div>
						</div>
						<div id="event_end_day" class="stuffbox">
							<h3>
								<?php 
    _e('Event time', 'dbem');
    ?>
							</h3>
							<div class="inside">
								<input id="start-time" type="text" size="8" maxlength="8" name="event_start_time" value="<?php 
    echo date($hours_locale_regexp, strtotime($EM_Event->start_time));
    ?>
" />
								-
								<input id="end-time" type="text" size="8" maxlength="8" name="event_end_time" value="<?php 
    echo date($hours_locale_regexp, strtotime($EM_Event->end_time));
    ?>
" />
								<br />
								<?php 
    _e('The time of the event beginning and end', 'dbem');
    ?>
. 
							</div>
						</div>
						<div id="location_coordinates" class="stuffbox" style='display: none;'>
							<h3>
								<?php 
    _e('Coordinates', 'dbem');
    ?>
							</h3>
							<div class="inside">
								<input id='location-latitude' name='location_latitude' type='text' value='<?php 
    echo $EM_Event->latitude;
    ?>
' size='15' />
								-
								<input id='location-longitude' name='location_longitude' type='text' value='<?php 
    echo $EM_Event->longitude;
    ?>
' size='15' />
							</div>
						</div>
						<div id="location_info" class="stuffbox">
							<h3>
								<?php 
    _e('Location', 'dbem');
    ?>
							</h3>
							<div class="inside">
								<table id="dbem-location-data">     
									<tr>
										<td style="padding-right:20px">
											<table>
												<?php 
    if ($use_select_for_locations) {
        ?>
 
												<tr>
													<th><?php 
        _e('Location:', 'dbem');
        ?>
</th>
													<td> 
														<select name="location-select-id" id='location-select-id' size="1">  
															<?php 
        $locations = EM_Locations::get();
        foreach ($locations as $location) {
            $selected = "";
            if (is_object($EM_Event->location)) {
                if ($EM_Event->location->id == $location->id) {
                    $selected = "selected='selected' ";
                }
            }
            ?>
          
														    	<option value="<?php 
            echo $location->id;
            ?>
" title="<?php 
            echo "{$location->latitude},{$location->longitude}";
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo $location->name;
            ?>
</option>
														    	<?php 
        }
        ?>
														</select>
														<p><?php 
        _e('The name of the location where the event takes place. You can use the name of a venue, a square, etc', 'dbem');
        ?>
</p>
													</td>
												</tr>
												<?php 
    } else {
        ?>
												<tr>
													<th><?php 
        _e('Name:');
        ?>
</th>
													<td>
														<input id="location-name" type="text" name="location_name" value="<?php 
        echo htmlspecialchars($EM_Event->location->name, ENT_QUOTES);
        ?>
" />													
					                            		<p><?php 
        _e('Select a location for your event', 'dbem');
        ?>
</p>
					                            	</td>
										 		</tr>
												<tr>
													<th><?php 
        _e('Address:');
        ?>
&nbsp;</th>
													<td>
														<input id="location-address" type="text" name="location_address" value="<?php 
        echo htmlspecialchars($EM_Event->location->address, ENT_QUOTES);
        ?>
" />
														<p><?php 
        _e('The address of the location where the event takes place. Example: 21, Dominick Street', 'dbem');
        ?>
</p>
													</td>
												</tr>
												<tr>
													<th><?php 
        _e('Town:');
        ?>
&nbsp;</th>
													<td>
														<input id="location-town" type="text" name="location_town" value="<?php 
        echo htmlspecialchars($EM_Event->location->town, ENT_QUOTES);
        ?>
" />
														<p><?php 
        _e('The town where the location is located. If you\'re using the Google Map integration and want to avoid geotagging ambiguities include the country in the town field. Example: Verona, Italy.', 'dbem');
        ?>
</p>
													</td>
												</tr>
												<?php 
    }
    ?>
											</table>
										</td>
										<?php 
    if (get_option('dbem_gmap_is_active')) {
        ?>
										<td width="400">
											<div id='em-map-404' style='width: 400px; vertical-align:middle; text-align: center;'>
												<p><em><?php 
        _e('Location not found', 'dbem');
        ?>
</em></p>
											</div>
											<div id='em-map' style='width: 400px; height: 300px; display: none;'></div>
										</td>
										<?php 
    }
    ?>
									</tr>
							</table>
						</div>
					</div>
					<div id="event_notes" class="postbox">
						<h3>
							<?php 
    _e('Details', 'dbem');
    ?>
						</h3>
						<div class="inside">
							<div id="<?php 
    echo user_can_richedit() ? 'postdivrich' : 'postdiv';
    ?>
" class="postarea">
								<?php 
    the_editor($EM_Event->notes);
    ?>
							</div>
							<br />
							<?php 
    _e('Details about the event', 'dbem');
    ?>
						</div>
					</div>
					
					<?php 
    if (get_option('dbem_attributes_enabled')) {
        ?>
						<div id="event_attributes" class="postbox">
							<h3>
								<?php 
        _e('Attributes', 'dbem');
        ?>
							</h3>
							<div class="inside">
								<?php 
        //We also get a list of attribute names and create a ddm list (since placeholders are fixed)
        $formats = get_option('dbem_event_list_item_format') . get_option('dbem_event_page_title_format') . get_option('dbem_full_calendar_event_format') . get_option('dbem_location_baloon_format') . get_option('dbem_location_event_list_item_format') . get_option('dbem_location_page_title_format') . get_option('dbem_map_text_format') . get_option('dbem_rss_description_format') . get_option('dbem_rss_title_format') . get_option('dbem_single_event_format') . get_option('dbem_single_location_format') . get_option('dbem_placeholders_custom');
        //We now have one long string of formats, get all the attribute placeholders
        preg_match_all('/#_ATT\\{.+?\\}(\\{.+?\\})?/', $formats, $placeholders);
        //Now grab all the unique attributes we can use in our event.
        $attributes = array();
        foreach ($placeholders[0] as $result) {
            $attribute = substr(substr($result, 0, strpos($result, '}')), 6);
            if (!in_array($attribute, $attributes)) {
                $attributes[] = $attribute;
            }
        }
        ?>
								<div class="wrap">
									<?php 
        if (count($attributes) > 0) {
            ?>
										<h2>Attributes</h2>
										<p>Add attributes here</p>
										<table class="form-table">
											<thead>
												<tr valign="top">
													<td><strong>Attribute Name</strong></td>
													<td><strong>Value</strong></td>
												</tr>
											</thead>    
											<tfoot>
												<tr valign="top">
													<td colspan="3"><a href="#" id="mtm_add_tag">Add new tag</a></td>
												</tr>
											</tfoot>
											<tbody id="mtm_body">
												<?php 
            $count = 1;
            if (is_array($EM_Event->attributes) and count($EM_Event->attributes) > 0) {
                foreach ($EM_Event->attributes as $name => $value) {
                    ?>
														<tr valign="top" id="mtm_<?php 
                    echo $count;
                    ?>
">
															<td scope="row">
																<select name="mtm_<?php 
                    echo $count;
                    ?>
_ref">
																	<?php 
                    if (!in_array($name, $attributes)) {
                        echo "<option value='{$name}'>{$name} (" . __('Not defined in templates', 'dbem') . ")</option>";
                    }
                    foreach ($attributes as $attribute) {
                        if ($attribute == $name) {
                            echo "<option selected='selected'>{$attribute}</option>";
                        } else {
                            echo "<option>{$attribute}</option>";
                        }
                    }
                    ?>
																</select>
																<a href="#" rel="<?php 
                    echo $count;
                    ?>
">Remove</a>
															</td>
															<td>
																<input type="text" name="mtm_<?php 
                    echo $count;
                    ?>
_name" value="<?php 
                    echo htmlspecialchars($value, ENT_QUOTES);
                    ?>
" />
															</td>
														</tr>
														<?php 
                    $count++;
                }
            } else {
                ?>
													<tr valign="top" id="mtm_<?php 
                echo $count;
                ?>
">
														<td scope="row">
															<select name="mtm_<?php 
                echo $count;
                ?>
_ref">
																<?php 
                foreach ($attributes as $attribute) {
                    echo "<option>{$attribute}</option>";
                }
                ?>
															</select>
															<a href="#" rel="<?php 
                echo $count;
                ?>
">Remove</a>
														</td>
														<td>
															<input type="text" name="mtm_<?php 
                echo $count;
                ?>
_name" />
														</td>
													</tr>
													<?php 
            }
            ?>
											</tbody>
										</table>
									<?php 
        } else {
            ?>
										<p>
										<?php 
            _e('In order to use attributes, you must define some in your templates, otherwise they\'ll never show. Go to Events > Settings to add attribute placeholders.', 'dbem');
            ?>
										</p> 
										<script>
											jQuery(document).ready(function($){ $('#event_attributes').addClass('closed'); });
										</script>
									<?php 
        }
        ?>
								</div>
							</div>
						</div>
						<?php 
    }
    ?>
					</div>
					<p class="submit">
						<input type="submit" name="events_update" value="<?php 
    _e('Submit Event', 'dbem');
    ?>
 &raquo;" />
					</p>
					<input type="hidden" name="p" value="<?php 
    echo !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
    ?>
" /><a>
					<input type="hidden" name="scope" value="<?php 
    echo !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
    ?>
" /></a>
					<input type="hidden" name="action" value="save" />
				</div>
			</div>
		</div>
	</form>
	<script type="text/javascript">
		jQuery(document).ready( function($) {
			<?php 
    if ($EM_Event->is_recurring()) {
        ?>
			//Recurrence Warnings
			$('#event_form').submit( function(event){
				confirmation = confirm('<?php 
        _e('Are you sure you want to reschedule this recurring event? If you do this, you will lose all booking information and the old recurring events will be deleted.', 'dbem');
        ?>
');
				if( confirmation == false ){
					event.preventDefault();
				}
			});
			<?php 
    }
    ?>
			<?php 
    if ($EM_Event->rsvp == 1) {
        ?>
			//RSVP Warning
			$('#rsvp-checkbox').click( function(event){
				if( !this.checked ){
					confirmation = confirm('<?php 
        _e('Are you sure you want to disable bookings? If you do this and save, you will lose all previous bookings. If you wish to prevent further bookings, reduce the number of seats available to the amount of bookings you currently have', 'dbem');
        ?>
');
					if( confirmation == false ){
						event.preventDefault();
					}
				}
			});
			<?php 
    }
    ?>
		});		
	</script>
<?php 
}
Пример #14
0
" onfocus="if(this.value=='<?php 
echo $s_default;
?>
')this.value=''" onblur="if(this.value=='')this.value='<?php 
echo $s_default;
?>
'" />
		<!-- END General Search -->
		<!-- START Category Search -->
		<select name="category">
			<option value=''><?php 
_e('All Categories', 'dbem');
?>
</option>
			<?php 
foreach (EM_Categories::get(array('orderby' => 'category_name')) as $EM_Category) {
    ?>
			 <option value="<?php 
    echo $EM_Category->id;
    ?>
" <?php 
    echo !empty($_POST['category']) && $_POST['category'] == $EM_Category->id ? 'selected="selected"' : '';
    ?>
><?php 
    echo $EM_Category->name;
    ?>
</option>
			<?php 
}
?>
		</select>
Пример #15
0
function em_get_categories_shortcode($args, $format = '')
{
    $args = (array) $args;
    $args['ajax'] = isset($args['ajax']) ? $args['ajax'] : !defined('EM_AJAX') || EM_AJAX;
    $args['format'] = $format != '' || empty($args['format']) ? $format : $args['format'];
    $args['format'] = html_entity_decode($args['format']);
    //shorcode doesn't accept html
    $args['orderby'] = !empty($args['orderby']) ? $args['orderby'] : get_option('dbem_categories_default_orderby');
    $args['order'] = !empty($args['order']) ? $args['order'] : get_option('dbem_categories_default_order');
    $args['limit'] = isset($args['limit']) ? $args['limit'] : get_option('dbem_categories_default_limit');
    $args['pagination'] = isset($args['pagination']) ? $args['pagination'] : 1;
    if (empty($args['format']) && empty($args['format_header']) && empty($args['format_footer'])) {
        ob_start();
        if (!empty($args['ajax'])) {
            echo '<div class="em-search-ajax">';
        }
        //open AJAX wrapper
        em_locate_template('templates/categories-list.php', true, array('args' => $args));
        if (!empty($args['ajax'])) {
            echo "</div>";
        }
        //close AJAX wrapper
        $return = ob_get_clean();
    } else {
        $args['ajax'] = false;
        $args['page'] = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
        $args['page'] = !empty($_GET['pno']) && is_numeric($_GET['pno']) ? $_GET['pno'] : $args['page'];
        $return = EM_Categories::output($args);
    }
    return $return;
}
Пример #16
0
function em_admin_options_page()
{
    global $wpdb;
    //TODO place all options into an array
    $events_placeholders = '<a href="admin.php?page=events-manager-help#event-placeholders">' . __('Event Related Placeholders', 'dbem') . '</a>';
    $locations_placeholders = '<a href="admin.php?page=events-manager-help#location-placeholders">' . __('Location Related Placeholders', 'dbem') . '</a>';
    $bookings_placeholders = '<a href="admin.php?page=events-manager-help#booking-placeholders">' . __('Booking Related Placeholders', 'dbem') . '</a>';
    $categories_placeholders = '<a href="admin.php?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);
    $save_button = '<tr><th>&nbsp;</th><td><p class="submit" style="margin:0px; padding:0px; text-align:right;"><input type="submit" id="dbem_options_submit" name="Submit" value="' . __('Save Changes') . ' (' . __('All', 'dbem') . ')" /></p></ts></td></tr>';
    //Do some multisite checking here for reuse
    $multisite_view = is_multisite() && is_super_admin() ? ' - (' . __('Only Network Admins see this', 'dbem') . ')' : '';
    ?>
	
	<script type="text/javascript" charset="utf-8">
		jQuery(document).ready(function($){
			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;">'+close_text+'</a>');
			$('#icon-options-general').after(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);
				} 
			});
			//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');
			$(".postbox").addClass('closed'); //Let's start off closing everything for now.			
		});
	</script>
	<div class="wrap">
		<div id='icon-options-general' class='icon32'><br />
		</div>		
		<h2><?php 
    _e('Event Manager Options', 'dbem');
    ?>
</h2>
		<?php 
    /*
     * START MIGRATION BIT
     */
    if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'bookings_migrate') {
        require_once dirname(__FILE__) . '/../em-install.php';
        em_migrate_bookings();
    } elseif (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'bookings_migrate_delete') {
        require_once dirname(__FILE__) . '/../em-install.php';
        em_migrate_bookings_delete();
    }
    ?>
		<?php 
    if ($wpdb->get_var("SHOW TABLES LIKE '" . EM_PEOPLE_TABLE . "'") == EM_PEOPLE_TABLE) {
        ?>
			<?php 
        if ($wpdb->get_var('SELECT COUNT(*) FROM ' . EM_TICKETS_BOOKINGS_TABLE) > 0) {
            ?>
				<div class='updated'>
					<p>
					It looks like you've already tried reimporting some bookings into the new version (or new bookings have been made since you installed). 
					If everything looks correct, you can 
					<a href="admin.php?page=events-manager-options&amp;_wpnonce=<?php 
            echo wp_create_nonce('bookings_migrate_delete');
            ?>
&amp;action=bookings_migrate_delete">delete the unused tables</a>, 
					or you can also safely try 
					<a href="admin.php?page=events-manager-options&amp;_wpnonce=<?php 
            echo wp_create_nonce('bookings_migrate');
            ?>
&amp;action=bookings_migrate">re-importing again</a>.
					</p>
				</div>
			<?php 
        } else {
            ?>
				<div class='updated'>
					<p>It looks like you've upgraded from Events Manager version 3.0, meaning your old bookings won't work until you re-import them. 
					Events Manager 3.0 kept booking user info in a simple database table, whereas now people that make bookings get a subscriber account so 
					they can access private booking information. You have to choice to 
					<a href="admin.php?page=events-manager-options&amp;_wpnonce=<?php 
            echo wp_create_nonce('bookings_migrate');
            ?>
&amp;action=bookings_migrate">import all your old bookings</a> 
					and create wordpress accounts for bookers, or you can also start afresh and 
					<a href="admin.php?page=events-manager-options&amp;_wpnonce=<?php 
            echo wp_create_nonce('bookings_migrate_delete');
            ?>
&amp;action=bookings_migrate_delete">delete the old bookings</a>.
					</p>
				</div>
			<?php 
        }
        ?>
		<?php 
    }
    ?>
		<?php 
    /*
     *  END MIGRATION BIT
     */
    ?>
		<form id="dbem_options_form" method="post" action="">          

			<div class="metabox-holder">         
			<!-- // TODO Move style in css -->
			<div class='postbox-container' style='width: 99.5%'>
			<div id="" class="meta-box-sortables" >
		  
			<?php 
    if (is_multisite() && is_super_admin()) {
        ?>
			<div  class="postbox " >
				<div class="handlediv" title="<?php 
        __('Click to toggle');
        ?>
"><br /></div><h3 class='hndle'><span><?php 
        _e('Multi Site Options', 'dbem');
        ?>
 <?php 
        echo $multisite_view;
        ?>
</span></h3>
				<div class="inside">
		            <table class="form-table">
						<?php 
        em_options_radio_binary(__('Enable global tables mode?'), 'dbem_ms_global_table', __('Setting this to yes will make all events save in the main site event tables (EM must also be activated). This allows you to share events across different blogs, such as showing events in your network whilst allowing users to display and manage their events within their own blog. Bear in mind that activating this will mean old events created on the sub-blogs will not be accessible anymore, and if you switch back they will be but new events created during global events mode will only remain on the main site.', 'dbem'));
        em_options_radio_binary(__('Display global events on main blog?'), 'dbem_ms_global_events', __('Displays events from all sites on the network by default. You can still restrict events by blog using shortcodes and template tags coupled with the <code>blog</code> attribute. Requires global tables to be turned on.', 'dbem'));
        em_options_radio_binary(__('Link sub-site events directly to sub-site?'), 'dbem_ms_global_events_links', __('When displaying global events on the main site you have the option of users viewing the event details on the main site or being directed to the sub-site.', 'dbem'));
        echo $save_button;
        ?>
					</table>
					    
				</div> <!-- . inside --> 
			</div> <!-- .postbox --> 
			<?php 
    }
    ?>
		  
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('General options', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
	            <table class="form-table">
					<?php 
    em_options_radio_binary(__('Use dropdown for locations?'), '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(__('Use recurrence?'), 'dbem_recurrence_enabled', __('Select yes to enable the recurrence features feature', 'dbem'));
    em_options_radio_binary(__('Enable bookings?'), 'dbem_rsvp_enabled', __('Select yes to allow bookings and tickets for events.', 'dbem'));
    em_options_radio_binary(__('Use categories?'), 'dbem_categories_enabled', __('Select yes to enable the category features', 'dbem'));
    em_options_radio_binary(__('Use event attributes?'), 'dbem_attributes_enabled', __('Select yes to enable the attributes feature', 'dbem'));
    /*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;
    }
    em_options_select(__('Default Category'), 'dbem_default_category', $category_options, __('This option allows you to select the default category when adding an event.', 'dbem') . " " . __('(not applicable with event ownership on presently, coming soon!)', 'dbem'));
    /*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->id] = $EM_Location->name;
    }
    em_options_select(__('Default Location'), '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_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'));
    em_options_textarea(__('Event Attributes', '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'), 'wp-events-plugin.com/documentation/event-attributes/'));
    echo $save_button;
    ?>
				</table>
				    
			</div> <!-- . inside --> 
			</div> <!-- .postbox --> 
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Events page', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
                 <table class="form-table">         
				 	<?php 
    //Wordpress Pages
    global $em_disable_filter;
    //Using a flag here instead
    $em_disable_filter = true;
    $get_pages = get_pages();
    $events_page_options = array();
    $events_page_options[0] = __('[No Events Page]');
    //TODO Add the hierarchy style ddm, like when choosing page parents
    foreach ($get_pages as $page) {
        $events_page_options[$page->ID] = $page->post_title;
    }
    em_options_select(__('Events page'), 'dbem_events_page', $events_page_options, __('This option allows you to select which page to use as an events page', 'dbem'));
    $em_disable_filter = false;
    //Rest
    em_options_radio_binary(__('Show events page in lists?', 'dbem'), 'dbem_list_events_page', __('Check this option if you want the events page to appear together with other pages in pages lists.', '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'));
    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'));
    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(__('Show events search?', 'dbem'), 'dbem_events_page_search', __("If set to yes, a search form will appear just above your list of events.", 'dbem'));
    ?>
					<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('start_date,start_time,name' => __('Order by start date, start time, then event name', 'dbem'), 'name,start_date,start_time' => __('Order by name, start date, then start time', 'dbem'), 'name,end_date,end_time' => __('Order by name, end date, then end time', 'dbem'), 'end_date,end_time,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 
    echo $save_button;
    ?>
				
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Events format', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
            	<table class="form-table">
				 	<tr><td><strong><?php 
    echo sprintf(__('%s Page', 'dbem'), __('Events', 'dbem'));
    ?>
</strong></td></tr>
					<?php 
    em_options_input_text(__('Events page title', 'dbem'), 'dbem_events_page_title', __('The title on the multiple events page.', 'dbem'));
    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 
    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');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Calendar format', 'dbem');
    ?>
</span></h3>
			<div class="inside">
            	<table class="form-table">
					<?php 
    em_options_input_text(__('Small calendar title', '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(__('Small calendar 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_input_text(__('Full calendar events 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(__('Show long events on calendar pages?', 'dbem'), 'dbem_full_calendar_long_events', __("If you are showing a calendar on the events page (see Events format section on this page), you have the option of showing events that span over days on each day it occurs.", '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'));
    echo $save_button;
    ?>
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Locations format', '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_input_text(sprintf(__('%s page title', 'dbem'), __('Locations', 'dbem')), 'dbem_locations_page_title', sprintf(__('The title on the multiple %s page.', 'dbem'), __('locations', 'dbem')));
    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);
    em_options_textarea(__('Default location balloon format', 'dbem'), 'dbem_location_baloon_format', __('The format of of the text appearing in the baloon describing the location a single location map.', 'dbem') . $locations_placeholder_tip);
    em_options_textarea(sprintf(__('Default %s list format', 'dbem'), __('events', 'dbem')), 'dbem_location_event_list_item_format', __('The format of the events the list inserted in the location page through the <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> element.', 'dbem') . $locations_placeholder_tip);
    em_options_textarea(sprintf(__('No %s message', 'dbem'), __('events', 'dbem')), 'dbem_location_no_events_message', __('The message to be displayed in the list generated by <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> when no events are available.', 'dbem'));
    echo $save_button;
    ?>
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Categories format', '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_input_text(sprintf(__('%s page title', 'dbem'), __('Categories', 'dbem')), 'dbem_categories_page_title', sprintf(__('The title on the multiple %s page.', 'dbem'), __('categories', 'dbem')));
    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);
    echo $save_button;
    ?>
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('RSS feed format', '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');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Maps and geotagging', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
				<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>
					<?php 
    em_options_textarea(__('Map text format', 'dbem'), 'dbem_map_text_format', __('The text format inside the map balloons.', 'dbem') . $events_placeholder_tip);
    echo $save_button;
    ?>
 
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Booking and Ticketing Options', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
				<table class='form-table'> 
					<?php 
    em_options_radio_binary(__('Approval Required?', 'dbem'), 'dbem_bookings_approval', __('Bookings will not be confirmed until the event administrator approves it.', 'dbem'));
    em_options_select(__('Currency', 'dbem'), 'dbem_bookings_currency', em_get_currencies()->names, __('Choose your currency for displaying event pricing.', 'dbem'));
    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 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(__('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(__('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'));
    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 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'));
    echo $save_button;
    ?>
 
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
    __('Click to toggle');
    ?>
"><br /></div><h3 class='hndle'><span><?php 
    _e('Booking Email Templates', 'dbem');
    ?>
 </span></h3>
			<div class="inside">
				<table class='form-table'>
					<?php 
    em_options_select(__('Default contact person', 'dbem'), 'dbem_default_contact_person', em_get_wp_users(), __('Select the default contact person. This user will be employed whenever a contact person is not explicitly specified for an event', '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'));
    em_options_radio_binary(__('Email contact person?', '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'));
    ?>
					<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', '');
    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', '');
    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', '');
    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', '');
    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', __("The subject of the email sent to the person making a booking that is awaiting administrator approval. Not relevant if bookings don't require approval.", 'dbem') . $bookings_placeholder_tip);
    em_options_textarea(__('Booking rejected email', 'dbem'), 'dbem_bookings_email_rejected_body', __('The body of the email which will be sent to the person if the booking is rejected. Not relevant if bookings don\'t require approval.', 'dbem') . $bookings_placeholder_tip);
    echo $save_button;
    ?>
					<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', '');
    em_options_textarea(__('Booking cancelled email', 'dbem'), 'dbem_bookings_email_cancelled_body', '');
    ?>
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<?php 
    if (!is_multisite() || is_multisite() && is_super_admin()) {
        ?>
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
        __('Click to toggle');
        ?>
"><br /></div><h3 class='hndle'><span><?php 
        _e('Email Settings', 'dbem');
        ?>
 <?php 
        echo $multisite_view;
        ?>
</span></h3>
			<div class="inside">
				<table class='form-table'>
					<?php 
        em_options_input_text(__('Notification sender name', 'dbem'), 'dbem_mail_sender_name', __("Insert the display name of the notification sender.", 'dbem'));
        em_options_input_text(__('Notification sender address', 'dbem'), 'dbem_mail_sender_address', __("Insert the address of the notification sender.", 'dbem'));
        em_options_input_text('Mail sending port', 'dbem_rsvp_mail_port', __("The port through which you e-mail notifications will be sent. Make sure the firewall doesn't block this port", 'dbem'));
        em_options_select(__('Mail sending method', 'dbem'), 'dbem_rsvp_mail_send_method', array('smtp' => 'SMTP', 'mail' => __('PHP mail function', 'dbem'), 'sendmail' => 'Sendmail', 'qmail' => 'Qmail', 'wp_mail' => 'WP Mail'), __('Select the method to send email notification.', 'dbem'));
        em_options_radio_binary(__('Use SMTP authentication?', 'dbem'), 'dbem_rsvp_mail_SMTPAuth', __('SMTP authentication is often needed. If you use GMail, make sure to set this parameter to Yes', 'dbem'));
        em_options_input_text('SMTP host', 'dbem_smtp_host', __("The SMTP host. Usually it corresponds to 'localhost'. If you use GMail, set this value to 'ssl://smtp.gmail.com:465'.", 'dbem'));
        em_options_input_text(__('SMTP username', 'dbem'), 'dbem_smtp_username', __("Insert the username to be used to access your SMTP server.", 'dbem'));
        em_options_input_password(__('SMTP password', 'dbem'), "dbem_smtp_password", __("Insert the password to be used to access your SMTP server", 'dbem'));
        echo $save_button;
        ?>
				</table>
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox " >
			<div class="handlediv" title="<?php 
        __('Click to toggle');
        ?>
"><br /></div><h3 class='hndle'><span><?php 
        _e('Images size', 'dbem');
        ?>
 <?php 
        echo $multisite_view;
        ?>
 </span></h3>
			<div class="inside">
				<table class='form-table'>
					<?php 
        em_options_input_text(__('Maximum width (px)', 'dbem'), 'dbem_image_max_width', __('The maximum allowed width for images uploades', 'dbem'));
        em_options_input_text(__('Maximum height (px)', 'dbem'), 'dbem_image_max_height', __("The maximum allowed height for images uploaded, in pixels", 'dbem'));
        em_options_input_text(__('Maximum size (bytes)', 'dbem'), 'dbem_image_max_size', __("The maximum allowed size for images uploaded, in pixels", 'dbem'));
        echo $save_button;
        ?>
				</table> 
			</div> <!-- . inside -->
			</div> <!-- .postbox -->
			
			<div  class="postbox" >
			<div class="handlediv" title="<?php 
        __('Click to toggle');
        ?>
"><br /></div><h3 class='hndle'><span><?php 
        _e('User Capabilities', 'dbem');
        ?>
 <?php 
        echo $multisite_view;
        ?>
</span></h3>
			<div class="inside">
	            <table class="form-table">
	            	<tr><td colspan="2">
	            		<strong><?php 
        _e('Warning: Changing these values may result in exposing previously hidden information to all users.');
        ?>
</strong><br />
	            	</td></tr>
					<?php 
        global $wp_roles;
        global $em_capabilities_array;
        ?>
	            	<tr><td colspan="2">
	            		<p><em><?php 
        _e('You can now give fine grained control with regards to what your users can do with events. Each user role can have perform different sets of actions.', 'dbem');
        ?>
</em></p>
			            <table class="em-caps-table" style="width:auto;" cellspacing="0" cellpadding="0">
							<thead>
								<tr>
									<td>&nbsp;</td>
									<?php 
        $odd = 0;
        $cap_docs = array('publish_events' => __('Users can publish events and skip any admin approval.', 'dbem'), 'edit_categories' => __('User can edit the global categories.', 'dbem'), 'delete_others_events' => __('User can delete other users events.', 'dbem'), 'delete_others_locations' => __('User can delete other users locations.', 'dbem'), 'edit_others_locations' => __('User can edit other users locations.', 'dbem'), 'manage_others_bookings' => __('User can manage other users individual bookings and event booking settings.', 'dbem'), 'edit_others_events' => __('User can edit other users events.', 'dbem'), 'delete_locations' => __('User can delete their own locations.', 'dbem'), 'delete_events' => __('User can delete their events.', 'dbem'), 'edit_locations' => __('User can edit their locations.', 'dbem'), 'manage_bookings' => __('User can use and manage bookings with their events.', 'dbem'), 'read_others_locations' => __('User can view other users locations, to make locations shared by all users allow all event user roles to view all locations.', 'dbem'), 'edit_recurrences' => __('User can create recurrent events.', 'dbem'), 'edit_events' => __('User can create and edit their events.', 'dbem'));
        foreach (array_keys($em_capabilities_array) as $capability) {
            ?>
<th class="<?php 
            echo $capability;
            ?>
 <?php 
            echo !is_int($odd / 2) ? 'odd' : '';
            ?>
">&nbsp;<a href="#" title="<?php 
            echo $cap_docs[$capability];
            ?>
">?</a></th><?php 
            $odd++;
        }
        ?>
								</tr>
							</thead>
							<tbody>
		            			<?php 
        foreach ($wp_roles->role_objects as $role) {
            ?>
			            		<tr>
			            			<td class="cap"><strong><?php 
            echo $role->name;
            ?>
</strong></td>
									<?php 
            $odd = 0;
            foreach (array_keys($em_capabilities_array) as $capability) {
                ?>
<td class="<?php 
                echo !is_int($odd / 2) ? 'odd' : '';
                ?>
"><input type="checkbox" name="em_capabilities[<?php 
                echo $role->name;
                ?>
][<?php 
                echo $capability;
                ?>
]" value="1" <?php 
                echo $role->has_cap($capability) ? 'checked="checked"' : '';
                ?>
 /></td><?php 
                $odd++;
            }
            ?>
			            		</tr>
					            <?php 
        }
        ?>
					        </tbody>
			            </table>
			        </td></tr>
			        <?php 
        echo $save_button;
        ?>
				</table>
			</div> <!-- . inside --> 
			</div> <!-- .postbox -->    
			<?php 
    }
    ?>

			<?php 
    /*
    <div  class="postbox " >
    <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><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 -->
    */
    ?>
			
			<?php 
    do_action('em_options_page_footer');
    ?>

			<p class="submit">
				<input type="submit" id="dbem_options_submit" name="Submit" value="<?php 
    _e('Save Changes');
    ?>
" />
				<input type="hidden" name="em-submitted" value="1" />
			</p>  
			
			</div> <!-- .metabox-sortables -->
			</div> <!-- .postbox-container -->
			
			</div> <!-- .metabox-holder -->	
		</form>
	</div>
	<?php 
}
Пример #17
0
function em_categories_table_layout($message = "")
{
    global $EM_Notices;
    $categories = EM_Categories::get();
    $destination = get_bloginfo('url') . "/wp-admin/admin.php";
    ?>
	<div class='wrap'>
		<div id='icon-edit' class='icon32'>
			<br/>
		</div>
  		<h2>
  			<?php 
    echo __('Categories', 'dbem');
    ?>
  			<a href="admin.php?page=events-manager-categories&action=add" class="button add-new-h2"><?php 
    _e('Add New');
    ?>
</a>
  		</h2>
	 		
		<?php 
    echo $EM_Notices;
    ?>

	 	 <form id='bookings-filter' method='post' action='<?php 
    echo get_bloginfo('wpurl');
    ?>
/wp-admin/admin.php?page=events-manager-categories'>
			<input type='hidden' name='action' value='category_delete'/>
			<input type='hidden' name='_wpnonce' value='<?php 
    echo wp_create_nonce('category_delete');
    ?>
'/>
			<?php 
    if (count($categories) > 0) {
        ?>
				<table class='widefat'>
					<thead>
						<tr>
							<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
							<th><?php 
        echo __('ID', 'dbem');
        ?>
</th>
							<th><?php 
        echo __('Name', 'dbem');
        ?>
</th>
						</tr> 
					</thead>
					<tfoot>
						<tr>
							<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
							<th><?php 
        echo __('ID', 'dbem');
        ?>
</th>
							<th><?php 
        echo __('Name', 'dbem');
        ?>
</th>
						</tr>             
					</tfoot>
					<tbody>
						<?php 
        foreach ($categories as $EM_Category) {
            ?>
						<tr>
							<td><input type='checkbox' class ='row-selector' value='<?php 
            echo $EM_Category->id;
            ?>
' name='categories[]'/></td>
							<td><a href='<?php 
            echo get_bloginfo('wpurl');
            ?>
/wp-admin/admin.php?page=events-manager-categories&amp;action=edit&amp;category_id=<?php 
            echo $EM_Category->id;
            ?>
'><?php 
            echo htmlspecialchars($EM_Category->id, ENT_QUOTES);
            ?>
</a></td>
							<td><a href='<?php 
            echo get_bloginfo('wpurl');
            ?>
/wp-admin/admin.php?page=events-manager-categories&amp;action=edit&amp;category_id=<?php 
            echo $EM_Category->id;
            ?>
'><?php 
            echo htmlspecialchars($EM_Category->name, ENT_QUOTES);
            ?>
</a></td>
						</tr>
						<?php 
        }
        ?>
					</tbody>

				</table>

				<div class='tablenav'>
					<div class='alignleft actions'>
				 	<input class='button-secondary action' type='submit' name='doaction2' value='Delete'/>
					<br class='clear'/> 
					</div>
					<br class='clear'/>
				</div>
			<?php 
    } else {
        ?>
				<p><?php 
        echo __('No categories have been inserted yet!', 'dbem');
        ?>
</p>
			<?php 
    }
    ?>
		</form>
  	</div>
  	<?php 
}
Пример #18
0
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><th>" . __('Default Category', 'dbem') . "</th><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')) {
Пример #19
0
    public static function meta_box_ms_categories()
    {
        global $EM_Event;
        EM_Object::ms_global_switch();
        $categories = EM_Categories::get(array('hide_empty' => false));
        ?>

		<?php 
        if (count($categories) > 0) {
            ?>

			<p class="ms-global-categories">
			 <?php 
            $selected = $EM_Event->get_categories()->get_ids();
            ?>

			 <?php 
            $walker = new EM_Walker_Category();
            ?>

			 <?php 
            $args_em = array('hide_empty' => 0, 'name' => 'event_categories[]', 'hierarchical' => true, 'id' => EM_TAXONOMY_CATEGORY, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $selected, 'walker' => $walker);
            ?>

			 <?php 
            echo walk_category_dropdown_tree($categories, 0, $args_em);
            ?>

			</p>
		<?php 
        } else {
            ?>

			<p><?php 
            sprintf(__('No categories available, <a href="%s">create one here first</a>', 'dbem'), get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager-categories');
            ?>
</p>
		<?php 
        }
        ?>

		<!-- END Categories -->
		<?php 
        EM_Object::ms_global_switch_back();
    }
<?php

/*
 * Default Categories List Template
 * This page displays a list of locations, called during the em_content() if this is an events list page.
 * You can override the default display settings pages by copying this file to yourthemefolder/plugins/events-manager/templates/ and modifying it however you need.
 * You can display locations (or whatever) however you wish, there are a few variables made available to you:
 * 
 * $args - the args passed onto EM_Locations::output()
 * 
 */
$args = apply_filters('em_content_categories_args', $args);
$categories = EM_Categories::get($args);
$args['limit'] = get_option('dbem_categories_default_limit');
$args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
if (count($categories) > 0) {
    echo EM_Categories::output($categories, $args);
} else {
    echo get_option('dbem_no_categories_message');
}
Пример #21
0
 /**
  * Saves events and replaces old ones. Returns true if sucecssful or false if not.
  * @return boolean
  */
 function save_events()
 {
     global $wpdb;
     $event_ids = $post_ids = array();
     if ($this->can_manage('edit_events', 'edit_others_events') && $this->is_published()) {
         do_action('em_event_save_events_pre', $this);
         //actions/filters only run if event is recurring
         //Make template event index, post, and meta (and we just change event dates)
         $event = $this->to_array(true);
         //event template - for index
         $event['event_attributes'] = serialize($event['event_attributes']);
         $post_fields = $wpdb->get_row('SELECT * FROM ' . $wpdb->posts . ' WHERE ID=' . $this->post_id, ARRAY_A);
         //post to copy
         $post_name = $post_fields['post_name'];
         //save post slug since we'll be using this
         $post_fields['post_type'] = 'event';
         //make sure we'll save events, not recurrence templates
         $meta_fields_map = $wpdb->get_results('SELECT meta_key,meta_value FROM ' . $wpdb->postmeta . ' WHERE post_id=' . $this->post_id, ARRAY_A);
         $meta_fields = array();
         //convert meta_fields into a cleaner array
         foreach ($meta_fields_map as $meta_data) {
             $meta_fields[$meta_data['meta_key']] = $meta_data['meta_value'];
         }
         //remove id and we have a event template to feed to wpdb insert
         unset($event['event_id']);
         unset($post_fields['ID']);
         //remove recurrence meta info we won't need in events
         foreach (array_keys($this->recurrence_fields) as $recurrence_field) {
             unset($event[$recurrence_field]);
             unset($meta_fields['_' . $recurrence_field]);
         }
         $event['event_date_created'] = current_time('mysql');
         //since the recurrences are recreated
         unset($event['event_date_modified']);
         //Set the recurrence ID
         $event['recurrence_id'] = $meta_fields['_recurrence_id'] = $this->event_id;
         $event['recurrence'] = $meta_fields['_recurrence'] = 0;
         //Let's start saving!
         $this->delete_events();
         //Delete old events beforehand, this will change soon
         $event_saves = array();
         $matching_days = $this->get_recurrence_days();
         //Get days where events recur
         if (count($matching_days) > 0) {
             //first save event post data
             $recurring_date_format = apply_filters('em_event_save_events_format', 'Y-m-d');
             foreach ($matching_days as $day) {
                 //rewrite post fields if needed
                 $post_fields['post_name'] = $event['event_slug'] = $meta_fields['_event_slug'] = apply_filters('em_event_save_events_slug', $post_name . '-' . date($recurring_date_format, $day), $post_fields, $day, $matching_days, $this);
                 //adjust certain meta information
                 $event['event_start_date'] = $meta_fields['_event_start_date'] = date("Y-m-d", $day);
                 $meta_fields['_start_ts'] = strtotime($event['event_start_date'] . ' ' . $event['event_start_time']);
                 if (is_numeric($event['recurrence_rsvp_days'])) {
                     $event_rsvp_days = $event['recurrence_rsvp_days'] >= 0 ? '+' . $event['recurrence_rsvp_days'] : $event['recurrence_rsvp_days'];
                     $event_rsvp_date = date('Y-m-d', strtotime($event_rsvp_days . ' days', $meta_fields['_start_ts']));
                     $event['event_rsvp_date'] = $meta_fields['_event_rsvp_date'] = $event_rsvp_date;
                     $event['event_rsvp_time'] = $meta_fields['_event_rsvp_time'] = $event['event_rsvp_time'];
                 } else {
                     $event['event_rsvp_date'] = $meta_fields['_event_rsvp_date'] = $event['event_start_date'];
                     $event['event_rsvp_time'] = $meta_fields['_event_rsvp_time'] = $event['event_start_time'];
                 }
                 if ($this->recurrence_days > 0) {
                     $event['event_end_date'] = $meta_fields['_event_end_date'] = date("Y-m-d", $meta_fields['_start_ts'] + $this->recurrence_days * 60 * 60 * 24);
                 } else {
                     $event['event_end_date'] = $meta_fields['_event_end_date'] = $event['event_start_date'];
                 }
                 $meta_fields['_end_ts'] = strtotime($event['event_end_date'] . ' ' . $event['event_end_time']);
                 //create the event
                 if ($wpdb->insert($wpdb->posts, $post_fields)) {
                     $event['post_id'] = $meta_fields['_post_id'] = $post_id = $post_ids[] = $wpdb->insert_id;
                     //post id saved into event and also as a var for later user
                     // Set GUID and event slug as per wp_insert_post
                     $wpdb->update($wpdb->posts, array('guid' => get_permalink($post_id)), array('ID' => $post_id));
                     //insert into events index table
                     $event_saves[] = $wpdb->insert(EM_EVENTS_TABLE, $event);
                     $event_ids[$post_id] = $event_id = $wpdb->insert_id;
                     $event_dates[$event_id] = $meta_fields['_start_ts'];
                     //create the meta inserts for each event
                     $meta_fields['_event_id'] = $event_id;
                     foreach ($meta_fields as $meta_key => $meta_val) {
                         $meta_inserts[] = $wpdb->prepare("(%d, %s, %s)", array($post_id, $meta_key, $meta_val));
                     }
                 } else {
                     $event_saves[] = false;
                 }
                 //if( EM_DEBUG ){ echo "Entering recurrence " . date("D d M Y", $day)."<br/>"; }
             }
             //insert the metas in one go, faster than one by one
             if (count($meta_inserts) > 0) {
                 $result = $wpdb->query("INSERT INTO " . $wpdb->postmeta . " (post_id,meta_key,meta_value) VALUES " . implode(',', $meta_inserts));
                 if ($result === false) {
                     $this->add_error('There was a problem adding custom fields to your recurring events.', 'dbem');
                 }
             }
             //copy the event tags and categories
             $taxonomies = self::get_taxonomies();
             foreach ($taxonomies as $tax_name => $tax_data) {
                 //In MS Global mode, we also save category meta information for global lookups so we use our objects
                 if (EM_MS_GLOBAL && $tax_name == 'category') {
                     //use EM_Categories as this is a special taxonomy in global mode
                     $EM_Categories = new EM_Categories($this);
                     //we save index data for each category in in MS Global mode
                     foreach ($event_ids as $post_id => $event_id) {
                         foreach ($EM_Categories->categories as $EM_Category) {
                             $EM_Categories->event_id = $event_id;
                             $EM_Categories->post_id = $post_id;
                             $EM_Categories->save();
                         }
                     }
                 } else {
                     //general taxonomies including event tags
                     $terms = get_the_terms($this->post_id, $tax_data['name']);
                     $term_slugs = array();
                     if (is_array($terms)) {
                         foreach ($terms as $term) {
                             if (!empty($term->slug)) {
                                 $term_slugs[] = $term->slug;
                             }
                             //save of category will soft-fail if slug is empty
                         }
                     }
                     foreach ($post_ids as $post_id) {
                         wp_set_object_terms($post_id, $term_slugs, $tax_data['name']);
                     }
                 }
             }
             //featured images
             if (!empty($this->attributes['thumbnail_id'])) {
                 $image_inserts = array();
                 foreach ($post_ids as $post_ids) {
                     $image_inserts[] = "({$this->post_id}, '_thumbnail_id', {$this->attributes['thumbnail_id']})";
                 }
                 if (count($image_inserts) > 0) {
                     $wpdb->query('INSERT INTO ' . $wpdb->postmeta . ' (post_id, meta_key, meta_value) VALUES ' . implode(', ', $image_inserts));
                 }
             }
             //MS Global Categories
             if ($cat_slugs_count > 0 && EM_MS_GLOBAL) {
                 foreach ($categories as $EM_Category) {
                     foreach ($event_ids as $event_id) {
                         $wpdb->insert(EM_META_TABLE, array('meta_value' => $EM_Category->term_id, 'object_id' => $event_id, 'meta_key' => 'event-category'));
                     }
                 }
             }
             //now, save booking info for each event
             if ($this->event_rsvp) {
                 $meta_inserts = array();
                 foreach ($this->get_tickets() as $EM_Ticket) {
                     /* @var $EM_Ticket EM_Ticket */
                     //get array, modify event id and insert
                     $ticket = $EM_Ticket->to_array();
                     //empty cut-off dates of ticket, add them at per-event level
                     unset($ticket['ticket_start']);
                     unset($ticket['ticket_end']);
                     if (!empty($ticket['ticket_meta']['recurrences'])) {
                         $ticket_meta_recurrences = $ticket['ticket_meta']['recurrences'];
                         unset($ticket['ticket_meta']['recurrences']);
                     }
                     //unset id
                     unset($ticket['ticket_id']);
                     //clean up ticket values
                     foreach ($ticket as $k => $v) {
                         if (empty($v) && $k != 'ticket_name') {
                             $ticket[$k] = 'NULL';
                         } else {
                             $data_type = !empty($EM_Ticket->fields[$k]['type']) ? $EM_Ticket->fields[$k]['type'] : '%s';
                             if (is_array($ticket[$k])) {
                                 $v = serialize($ticket[$k]);
                             }
                             $ticket[$k] = $wpdb->prepare($data_type, $v);
                         }
                     }
                     foreach ($event_ids as $event_id) {
                         $ticket['event_id'] = $event_id;
                         //sort out cut-of dates
                         if (!empty($ticket_meta_recurrences)) {
                             if (array_key_exists('start_days', $ticket_meta_recurrences)) {
                                 $ticket_start_days = $ticket_meta_recurrences['start_days'] >= 0 ? '+' . $ticket_meta_recurrences['start_days'] : $ticket_meta_recurrences['start_days'];
                                 $ticket_start_date = date('Y-m-d', strtotime($ticket_start_days . ' days', $event_dates[$event_id]));
                                 $ticket['ticket_start'] = "'" . $ticket_start_date . ' ' . $ticket_meta_recurrences['start_time'] . "'";
                             }
                             if (array_key_exists('end_days', $ticket_meta_recurrences)) {
                                 $ticket_end_days = $ticket_meta_recurrences['end_days'] >= 0 ? '+' . $ticket_meta_recurrences['end_days'] : $ticket_meta_recurrences['end_days'];
                                 $ticket_end_date = date('Y-m-d', strtotime($ticket_end_days . ' days', $event_dates[$event_id]));
                                 $ticket['ticket_end'] = "'" . $ticket_end_date . ' ' . $ticket_meta_recurrences['end_time'] . "'";
                             }
                         }
                         //add insert data
                         $meta_inserts[] = "(" . implode(",", $ticket) . ")";
                     }
                 }
                 $keys = "(" . implode(",", array_keys($ticket)) . ")";
                 $values = implode(',', $meta_inserts);
                 $sql = "INSERT INTO " . EM_TICKETS_TABLE . " {$keys} VALUES {$values}";
                 $result = $wpdb->query($sql);
             }
         } else {
             $this->add_error('You have not defined a date range long enough to create a recurrence.', 'dbem');
             $result = false;
         }
         return apply_filters('em_event_save_events', !in_array(false, $event_saves) && $result !== false, $this, $event_ids, $post_ids);
     }
     return apply_filters('em_event_save_events', false, $this, $event_ids, $post_ids);
 }
 public static function create_event_from_feed(array $FEED_ = NULL, $event_id = NULL)
 {
     global $ESS_Notices, $current_site;
     $EM_Event = NULL;
     if ($FEED_ != NULL) {
         //dd( $FEED_ );
         $EM_Event = new EM_Event(intval($event_id) > 0 ? $event_id : 0);
         // set eventID for update
         // -- Populate $_POST global var for EM functions
         if (ESS_Import::set_post_from_feed($FEED_)) {
             //dd($_POST);
             if ($EM_Event->can_manage('edit_events', 'edit_recurring_events', 'edit_others_events') && $EM_Event->get_post()) {
                 // -- temporarily remove the save listener to prevent multi-pushing to search engines
                 ESS_IO::set_save_filter(FALSE);
                 $EM_Location = NULL;
                 $EM_Categories = NULL;
                 $EM_Tickets = NULL;
                 $blog_id = isset($current_site) ? $current_site->blog_id : NULL;
                 // used as global by some functions (Cf: EM_location::save())
                 if (empty($event_id)) {
                     $EM_Event->force_status = intval(get_option('ess_syndication_status')) >= 1 ? ESS_Database::EVENT_STATUS_PUBLISH : ESS_Database::EVENT_STATUS_DRAFT;
                     $EM_Event->event_status = 1;
                     $EM_Event->previous_status = 1;
                 } else {
                     $EM_Event->event_id = $event_id;
                     // -- Remove old images in case of event's update
                     if (get_option('ess_feed_import_images') && intval($EM_Event->post_id) > 0) {
                         ESS_Images::delete($EM_Event->post_id);
                     }
                 }
                 $EM_Event->post_status = strtolower($_POST['event_access']) == 'private' ? 'private' : ESS_Database::EVENT_STATUS_PUBLISH;
                 // == GENERAL
                 if (strlen($_POST['content']) > 0) {
                     if (get_option('ess_backlink_enabled')) {
                         $feed_uri = $FEED_['generals']['uri'];
                         $feed_uri_host = parse_url($feed_uri, PHP_URL_HOST);
                         $_POST['content'] .= "<h6>" . __("Source:", 'dbem') . " <a title=\"" . __("Source:", 'dbem') . " " . $feed_uri_host . "\" href=\"" . $feed_uri . "\">" . parse_url($feed_uri, PHP_URL_HOST) . "</a></h6>";
                     }
                 }
                 // == PLACE / LOCATION
                 //dd( $_POST['location_name'] );
                 if ($_POST['no_location'] === FALSE && strlen($_POST['location_name']) > 0 && get_option('dbem_locations_enabled')) {
                     $EM_Location = new EM_Location();
                     if ($EM_Location->can_manage('publish_locations') && $EM_Location->get_post(FALSE)) {
                         //d( $EM_Location );
                         // -- Search if this location already exists in the database
                         $similar_ = ESS_Import::load_similar_location(array('location_name' => $EM_Location->location_name, 'location_address' => $EM_Location->location_address, 'location_town' => $EM_Location->location_town, 'location_state' => $EM_Location->location_state, 'location_postcode' => $EM_Location->location_postcode, 'location_country' => $EM_Location->location_country));
                         //dd( $similar_ );
                         // if the location already exists use it instead.
                         if (@count($similar_) > 0 && $similar_ != NULL) {
                             foreach ($similar_ as $key => $val) {
                                 $EM_Location->{$key} = $val;
                             }
                         } else {
                             $EM_Location->post_status = 'publish';
                             $EM_Location->location_status = 1;
                             $EM_Location->post_content = '';
                         }
                         // -- Search & defines latitude / longitude if not set
                         if (FeedValidator::isValidLatitude((string) $_POST['location_latitude']) == FALSE || FeedValidator::isValidLongitude((string) $_POST['location_longitude']) == FALSE) {
                             require_once EM_ESS_DIR . "/inc/libs/geocoder/GoogleGeocode.php";
                             $geocode_ = GoogleGeocode::getGeocodeFromAddress(trim($EM_Location->location_address . " " . $EM_Location->location_town . " " . $EM_Location->location_postcode . " " . $EM_Location->location_country));
                             $lat = (string) $geocode_['results'][0]['geometry']['location']['lat'];
                             $lng = (string) $geocode_['results'][0]['geometry']['location']['lng'];
                             //echo "latitude: " .  $lat . " ==> ".((FeedValidator::isValidLatitude(  $lat ))?'TRUE':'FALSE')."<br/>";
                             //echo "longitude: " . $lng . " ==> ".((FeedValidator::isValidLongitude( $lng ))?'TRUE':'FALSE')."<br/>";
                             if (FeedValidator::isValidLatitude($lat) && FeedValidator::isValidLongitude($lng)) {
                                 $EM_Location->location_latitude = $lat;
                                 $EM_Location->location_longitude = $lng;
                             }
                         }
                         if ($EM_Location->save() === FALSE) {
                             $ESS_Notices->add_error($EM_Location->get_errors());
                         }
                         $EM_Event->location_id = $EM_Location->location_id;
                     } else {
                         $ESS_Notices->add_error($EM_Location->get_errors());
                     }
                 }
                 // end add location
                 //dd( $EM_Location );
                 // == PRICE / TICKETS
                 //dd( $_POST['em_tickets'] );
                 if (@count($_POST['em_tickets']) > 0 && get_option('dbem_rsvp_enabled')) {
                     $EM_Tickets = new EM_Tickets($EM_Event);
                     $ticket_data = NULL;
                     // Create tickets only if they doesn't exists
                     if (@count($EM_Tickets->tickets) <= 0) {
                         foreach ($_POST['em_tickets'] as $ticket_data) {
                             $EM_Ticket = new EM_Ticket();
                             $EM_Ticket->get_post($ticket_data);
                             $EM_Tickets->tickets[] = $EM_Ticket;
                         }
                     }
                     if ($ticket_data != NULL) {
                         $EM_Event->event_rsvp = TRUE;
                         $EM_Event->event_rsvp_date = $ticket_data['event_rsvp_date'];
                         $EM_Event->event_rsvp_time = $ticket_data['event_rsvp_time'];
                         $EM_Event->event_spaces = $ticket_data['event_spaces'];
                         $EM_Event->rsvp_time = $ticket_data['event_rsvp_time'];
                     }
                 }
                 // end add tickets
                 //dd( $EM_Tickets );
                 // == CATEGORIES
                 //dd( $_POST['event_categories'] );
                 if (@count($_POST['event_categories']) > 0 && get_option('dbem_categories_enabled')) {
                     $EM_Categories = new EM_Categories();
                     if ($EM_Categories->can_manage('edit_event_categories')) {
                         $caregory_ids_ = array();
                         foreach ($_POST['event_categories'] as $category_name) {
                             $category_term = get_term_by('name', $category_name, EM_TAXONOMY_CATEGORY);
                             // DEBUG: 2014-01-30
                             // Fix a internationalization bug report: http://wordpress.org/support/topic/finding-event-category-by-slug-is-not-always-a-good-idea
                             //$category_slug = sanitize_title_with_dashes( $category_name );
                             //$category_term = get_term_by( 'slug', $category_slug, EM_TAXONOMY_CATEGORY );
                             if ($category_term === FALSE) {
                                 // Term (with category taxonomy) not created yet, let's create it
                                 //$term_array = wp_insert_term( $category_name, EM_TAXONOMY_CATEGORY, array( 'slug' => $category_slug ) );
                                 $term_array = wp_insert_term($category_name, EM_TAXONOMY_CATEGORY, array('name' => $category_name));
                                 if (intval($term_array['term_id']) > 0) {
                                     array_push($caregory_ids_, intval($term_array['term_id']));
                                 }
                             } else {
                                 if (intval($category_term->term_id) > 0) {
                                     array_push($caregory_ids_, intval($category_term->term_id));
                                 }
                             }
                         }
                         $_POST['event_categories'] = $caregory_ids_;
                         if ($EM_Categories->get_post() === FALSE) {
                             $ESS_Notices->add_error($EM_Categories->get_errors());
                         }
                     } else {
                         $ESS_Notices->add_error($EM_Categories->get_errors());
                     }
                 }
                 // end add categories
                 $EM_Event->categories = $EM_Categories;
                 //dd( $EM_Categories );
                 // == TAGS
                 //dd( $_POST['event_tags'] );
                 if (@count($_POST['event_tags']) > 0 && get_option('dbem_tags_enabled')) {
                     $EM_Tags = new EM_Tags();
                     $tag_ids_ = array();
                     foreach ($_POST['event_tags'] as $tag_name) {
                         $tag_slug = sanitize_title_with_dashes($tag_name);
                         $tag_term = get_term_by('slug', $tag_slug, EM_TAXONOMY_TAG);
                         if ($tag_term === FALSE) {
                             // -- Term (with tag taxonomy) not created yet, let's create it
                             $term_array = wp_insert_term($tag_name, EM_TAXONOMY_TAG, array('slug' => $tag_slug));
                             if (intval($term_array['term_id']) > 0) {
                                 array_push($tag_ids_, intval($term_array['term_id']));
                             }
                         } else {
                             if (intval($tag_term->term_id) > 0) {
                                 array_push($tag_ids_, intval($tag_term->term_id));
                             }
                         }
                     }
                     $_POST['event_tags'] = $tag_ids_;
                     if ($EM_Tags->get_post() === FALSE) {
                         $ESS_Notices->add_error($EM_Categories->get_errors());
                     }
                 }
                 // end add tags
                 //dd( $EM_Tags );
                 // == DATE (force date values)
                 if (strlen($_POST['event_start_date']) > 0) {
                     $EM_Event->event_start_date = $_POST['event_start_date'];
                     $EM_Event->start_date = $_POST['event_start_date'];
                     $EM_Event->event_start_time = $_POST['event_start_time'];
                     $EM_Event->start_time = $_POST['event_start_time'];
                     $EM_Event->event_end_date = $_POST['event_end_date'];
                     $EM_Event->end_date = $_POST['event_end_date'];
                     $EM_Event->event_end_time = $_POST['event_end_time'];
                     $EM_Event->end_time = $_POST['event_end_time'];
                     $EM_Event->start = strtotime($EM_Event->event_start_date . " " . $EM_Event->event_start_time);
                     $EM_Event->end = strtotime($EM_Event->event_end_date . " " . $EM_Event->event_end_time);
                     if ($EM_Event->end < date('U')) {
                         $ESS_Notices->add_info(__("An event imported is already finished: " . ESS_Elements::get_ahref($FEED_['generals']['uri']), 'dbem'));
                     }
                 }
                 // end add date
                 // == PEOPLE
                 $EM_Event->post_excerpt = strlen($_POST['event_excerpt']) > 0 ? $_POST['event_excerpt'] : '';
                 // -- update the information already set line 187
                 //dd( get_option( 'ess_syndication_status' ) );
                 $EM_Event->force_status = intval(get_option('ess_syndication_status')) >= 1 ? ESS_Database::EVENT_STATUS_PUBLISH : ESS_Database::EVENT_STATUS_DRAFT;
                 //dd( $EM_Event );
                 // == SAVE EVENT ======
                 $res = $EM_Event->save();
                 //dd( $res ); // return FALSE if two of some functions are not updated in EM_Events()
                 //echo "event post id: ". $EM_Event->post_id ."<br/>";
                 //echo "event event id: ". $EM_Event->event_id."<br/>";
                 if (intval($EM_Event->post_id) > 0) {
                     // == MEDIA ==========
                     if (@count($_POST['event_media'])) {
                         //var_dump( $_POST['event_media'] );
                         $media_attachement_ = array();
                         foreach ($_POST['event_media'] as $media_) {
                             if (ESS_IO::is_file_exists($media_['uri'])) {
                                 // Use the same 'manage' value to control the importation of 'images', 'sounds' or 'videos'.
                                 if ($EM_Event->can_manage('upload_event_images')) {
                                     // == IMAGES
                                     if (FeedValidator::getMediaType($media_['uri']) == 'image' && get_option('ess_feed_import_images')) {
                                         $attachment_id = ESS_Images::add(array('uri' => $media_['uri'], 'name' => $media_['name'], 'post_id' => $EM_Event->post_id));
                                         if ($attachment_id !== FALSE && intval($attachment_id) > 0) {
                                             array_push($media_attachement_, array('attachement_id' => $attachment_id, 'uri' => $media_['uri']));
                                         } else {
                                             $ESS_Notices->add_error(__("Impossible to upload the event's image: ", 'dbem') . ESS_Elements::get_ahref($media_['uri']));
                                         }
                                     }
                                     // end add images
                                     // == VIDEOS (TODO...)
                                     if (FeedValidator::getMediaType($media_['uri']) == 'video' && get_option('ess_feed_import_videos')) {
                                         if (ESS_Videos::add(array('uri' => $media_['uri'], 'name' => $media_['name'], 'post_id' => $EM_Event->post_id)) === FALSE) {
                                             $ESS_Notices->add_error(__("Impossible to upload the event's video: ", 'dbem') . ESS_Elements::get_ahref($media_['uri']));
                                         }
                                     }
                                     // end add videos
                                     // == SOUNDS (TODO...)
                                     if (FeedValidator::getMediaType($media_['uri']) == 'sound' && get_option('ess_feed_import_sounds')) {
                                         if (ESS_Sounds::add(array('uri' => $media_['uri'], 'name' => $media_['name'], 'post_id' => $EM_Event->post_id)) === FALSE) {
                                             $ESS_Notices->add_error(__("Impossible to upload the event's audio file: ", 'dbem') . ESS_Elements::get_ahref($media_['uri']));
                                         }
                                     }
                                     // end add sounds
                                 } else {
                                     $ESS_Notices->add_error($EM_Event->get_errors());
                                 }
                             } else {
                                 $ESS_Notices->add_info(sprintf(__("A media file defined in the ESS feed is not reachable: <a href='%s' target='_blank'>%s</a>", 'dbem'), $media_['uri'], $media_['uri']));
                             }
                         }
                         // -- Define image with the highest 'priority' as first attachement
                         $priority_test = 1;
                         foreach ($_POST['event_media'] as $media_) {
                             if (get_option('ess_feed_import_images') == FALSE) {
                                 break;
                             }
                             if (@$media_['priority'] == $priority_test) {
                                 if (FeedValidator::getMediaType($media_['uri']) == 'image') {
                                     foreach ($media_attachement_ as $ma_) {
                                         if ($ma_['uri'] == $media_['uri'] && $ma_['attachement_id'] > 0) {
                                             ESS_Images::delete($EM_Event->post_id, $ma_['attachement_id']);
                                             $err = ESS_Images::add(array('uri' => $media_['uri'], 'name' => $media_['name'], 'post_id' => $EM_Event->post_id));
                                         }
                                     }
                                 } else {
                                     $priority_test++;
                                 }
                             }
                         }
                         // -- Display all the media files thumbnail at the bottom of the event's description
                         $imgs_ = ESS_Images::get_thumbnails($EM_Event->post_id);
                         //var_dump( $imgs_ );die;
                         if (@count($imgs_) > 0) {
                             $EM_Event->post_content .= "<br/><hr/>";
                             foreach ($imgs_ as $img_) {
                                 if (FeedValidator::isValidURL($img_['url'])) {
                                     $EM_Event->post_content .= "<img src='" . $img_['url'] . "' width='" . $img_['width'] . "' height='" . $img_['height'] . "' style='display:inline;margin:5px;'/>";
                                 }
                             }
                             // -- UPDATE event's description with thumbnail images at the bottom
                             $res = $EM_Event->save();
                         }
                     }
                     // end add media
                     // == TICKETS ==========
                     if (@count($EM_Tickets->tickets) > 0 && get_option('dbem_rsvp_enabled')) {
                         $EM_Tickets->blog_id = $blog_id;
                         $EM_Tickets->event_id = $EM_Event->event_id;
                         if ($EM_Tickets->save() === FALSE) {
                             $ESS_Notices->add_error($EM_Tickets->get_errors());
                         }
                     }
                     // end assign event to categories
                     // == CATEGORIES ==========
                     if (@count($EM_Categories->categories) > 0 && get_option('dbem_categories_enabled')) {
                         $EM_Categories->blog_id = $blog_id;
                         $EM_Categories->event_id = $EM_Event->event_id;
                         if ($EM_Categories->save() === FALSE) {
                             $ESS_Notices->add_error($EM_Categories->get_errors());
                         }
                     }
                     // end assign event to categories
                     // == TAGS ==========
                     if (@count($EM_Tags->tags) > 0 && get_option('dbem_tags_enabled')) {
                         //var_dump( $EM_Tags->tags );
                         $EM_Tags->blog_id = $blog_id;
                         $EM_Tags->event_id = $EM_Event->event_id;
                         // this function doesn't seem to work...
                         if ($EM_Tags->save() === FALSE) {
                             $ESS_Notices->add_error($EM_Tags->get_errors());
                         }
                         $tags_ = array();
                         foreach ($EM_Tags->tags as $EM_Tag) {
                             if (strlen($EM_Tag->slug) > 0) {
                                 array_push($tags_, $EM_Tag->slug);
                             }
                         }
                         if (@count($tags_) > 0) {
                             wp_set_object_terms($EM_Event->post_id, $tags_, EM_TAXONOMY_TAG);
                         }
                     }
                     // end assign event to tags
                     // == LOCATION ==========
                     ESS_Database::clear_locations();
                     //dd( $EM_Event );
                     ESS_IO::set_save_filter(TRUE);
                 }
             } else {
                 $ESS_Notices->add_error($EM_Event->get_errors());
             }
         }
     }
     return $EM_Event;
 }