function my_calendar_print_group_fields($data, $mode, $event_id, $group_id = '') { global $user_ID, $wpdb; $mcdb = $wpdb; get_currentuserinfo(); $has_data = empty($data) ? false : true; $user = get_userdata($user_ID); $mc_input_administrator = get_option('mc_input_options_administrators') == 'true' && current_user_can('manage_options') ? true : false; $mc_input = get_option('mc_input_options'); ?> <div class="postbox-container jcd-wide"> <div class="metabox-holder"> <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-groups&mode=edit&event_id={$event_id}&group_id={$group_id}"); ?> "> <div> <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?> " /> <input type="hidden" name="group_id" value="<?php if (!empty($data->event_group_id)) { echo $data->event_group_id; } else { echo mc_group_id(); } ?> " /> <input type="hidden" name="event_action" value="<?php echo $mode; ?> " /> <input type="hidden" name="event_id" value="<?php echo $event_id; ?> " /> <input type="hidden" name="event_author" value="<?php echo $user_ID; ?> " /> <input type="hidden" name="event_post" value="<?php echo $data->event_post; ?> " /> <input type="hidden" name="event_nonce_name" value="<?php echo wp_create_nonce('event_nonce'); ?> " /> </div> <div class="ui-sortable meta-box-sortables"> <div class="postbox"> <h3><?php _e('Manage Event Groups', 'my-calendar'); ?> </h3> <div class="inside"> <fieldset> <legend><?php _e('Enter your Event Information', 'my-calendar'); ?> </legend> <p> <label for="e_title"><?php _e('Event Title', 'my-calendar'); ?> <span><?php _e('(required)', 'my-calendar'); ?> </span><?php if (!mc_compare_group_members($group_id, 'event_title')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label><br /><input type="text" id="e_title" name="event_title" size="60" value="<?php if (!empty($data)) { echo stripslashes(esc_attr($data->event_title)); } ?> " /> </p> <?php $apply = mc_group_form($group_id, 'apply'); echo $apply; if ($data->event_repeats == 0 && ($data->event_recur == 'S1' || $data->event_recur == 'S')) { ?> <p> <input type="checkbox" value="1" id="e_span" name="event_span"<?php if (!empty($data) && $data->event_span == '1') { echo " checked=\"checked\""; } else { if (!empty($data) && $data->event_span == '0') { echo ""; } else { if (get_option('mc_event_span') == 'true') { echo " checked=\"checked\""; } } } ?> /> <label for="e_span"><?php _e('Selected dates are a single multi-day event.', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_span')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> </p> <?php } else { ?> <div><input type='hidden' name='event_span' value='<?php echo $data->event_span; ?> ' /></div> <?php } ?> <?php if ($mc_input['event_desc'] == 'on' || $mc_input_administrator) { ?> <div id="group_description"><?php if (!empty($data)) { $description = $data->event_desc; } else { $description = ''; } ?> <label for="content"><?php _e('Event Description (<abbr title="hypertext markup language">HTML</abbr> allowed)', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_desc')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label><br /><?php if (version_compare(get_bloginfo('version'), '3.3', '>=')) { wp_editor(stripslashes($description), 'content', array('textarea_rows' => 10)); } else { the_editor(stripslashes($description)); } ?> </div> <?php } ?> <?php if ($mc_input['event_short'] == 'on' || $mc_input_administrator) { ?> <p> <label for="e_short"><?php _e('Event Short Description (<abbr title="hypertext markup language">HTML</abbr> allowed)', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_short')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label><br /><textarea id="e_short" name="event_short" rows="2" cols="80"><?php if (!empty($data)) { echo stripslashes(esc_attr($data->event_short)); } ?> </textarea> </p> <?php } if (mc_show_edit_block('event_image')) { ?> <div class='mc-image-upload field-holder'> <?php if (!empty($data->event_image)) { ?> <div class="event_image"><img src="<?php if ($has_data) { echo esc_attr($data->event_image); } ?> " alt="" /></div> <?php } else { ?> <div class="event_image"></div> <?php } ?> <input type="hidden" name="event_image_id" value="" class="textfield" id="e_image_id" /> <label for="e_image"><?php _e("Add an image:", 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_image')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" name="event_image" id="e_image" size="60" value="<?php if ($has_data) { echo esc_attr($data->event_image); } ?> " placeholder="http://yourdomain.com/image.jpg" /> <a href="#" class="button textfield-field"><?php _e("Upload", 'my-calendar'); ?> </a> </div> <?php } else { ?> <div> <input type="hidden" name="event_image" value="<?php if ($has_data) { echo esc_attr($data->event_image); } ?> " /> <?php if (!empty($data->event_image)) { ?> <div class="event_image"><img src="<?php echo esc_attr($data->event_image); ?> " alt="" /></div> <?php } ?> </div> <?php } ?> <p> <label for="e_host"><?php _e('Event Host', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_host')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <select id="e_host" name="event_host"> <?php // Grab all the categories and list them $userList = my_calendar_getUsers(); foreach ($userList as $u) { echo '<option value="' . $u->ID . '"'; if (is_object($data) && $data->event_host == $u->ID) { echo ' selected="selected"'; } else { if (is_object($u) && $u->ID == $user->ID && empty($data->event_host)) { echo ' selected="selected"'; } } $display_name = $u->display_name == '' ? $u->user_nicename : $u->display_name; echo ">{$display_name}</option>\n"; } ?> </select> </p> <?php if ($mc_input['event_category'] == 'on' || $mc_input_administrator) { ?> <p> <label for="e_category"><?php _e('Event Category', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_category')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <select id="e_category" name="event_category"> <?php echo mc_category_select($data); ?> </select> </p> <?php } else { ?> <div> <input type="hidden" name="event_category" value="1" /> </div> <?php } ?> <?php if ($mc_input['event_link'] == 'on' || $mc_input_administrator) { ?> <p> <label for="e_link"><?php _e('Event Link (Optional)', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_link')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_link" name="event_link" size="40" value="<?php if (!empty($data)) { echo esc_url($data->event_link); } ?> " /> <input type="checkbox" value="1" id="e_link_expires" name="event_link_expires"<?php if (!empty($data) && $data->event_link_expires == '1') { echo " checked=\"checked\""; } else { if (!empty($data) && $data->event_link_expires == '0') { echo ""; } else { if (get_option('mc_event_link_expires') == 'true') { echo " checked=\"checked\""; } } } ?> /> <label for="e_link_expires"><?php _e('Link will expire after event.', 'my-calendar'); ?> </label> </p> <?php } ?> </fieldset> <p> <input type="submit" name="save" class="button-primary" value="<?php _e('Edit Event Group', 'my-calendar'); ?> " /> </p> </div> </div> </div> <?php if ($mc_input['event_open'] == 'on' || $mc_input_administrator) { // add a "don't change" option here ?> <div class="ui-sortable meta-box-sortables"> <div class="postbox"> <h3><?php _e('Event Registration Options', 'my-calendar'); ?> </h3> <div class="inside"> <fieldset> <legend><?php _e('Event Registration Status', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_open')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </legend> <?php echo apply_filters('mc_event_registration', '', $has_data, $data, 'admin'); ?> </fieldset> </div> </div> </div> <?php } else { ?> <div> <input type="hidden" name="event_open" value="<?php echo $has_data ? $data->event_open : '2'; ?> " /> <input type="hidden" name="event_tickets" value="<?php echo $has_data ? esc_attr($data->event_tickets) : ''; ?> " /> <input type="hidden" name="event_registration" value="<?php echo $has_data ? esc_attr($data->event_registration) : ''; ?> " /> </div> <?php } ?> <?php if ($mc_input['event_location'] == 'on' || $mc_input['event_location_dropdown'] == 'on' || $mc_input_administrator) { ?> <div class="ui-sortable meta-box-sortables"> <div class="postbox"> <h3><?php _e('Event Location', 'my-calendar'); ?> </h3> <div class="inside location_form"> <fieldset> <legend><?php _e('Event Location', 'my-calendar'); ?> </legend> <?php } ?> <?php if ($mc_input['event_location_dropdown'] == 'on' || $mc_input_administrator) { ?> <?php $locations = $mcdb->get_results("SELECT location_id,location_label FROM " . my_calendar_locations_table() . " ORDER BY location_label ASC"); if (!empty($locations)) { ?> <p> <label for="location_preset"><?php _e('Choose a preset location:', 'my-calendar'); ?> </label> <select name="location_preset" id="location_preset"> <option value="none"> -- </option> <?php foreach ($locations as $location) { echo "<option value=\"" . $location->location_id . "\">" . stripslashes($location->location_label) . "</option>"; } ?> </select> </p> <?php } else { ?> <input type="hidden" name="location_preset" value="none" /> <p><a href="<?php echo admin_url("admin.php?page=my-calendar-locations"); ?> "><?php _e('Add recurring locations for later use.', 'my-calendar'); ?> </a></p> <?php } ?> <?php } else { ?> <input type="hidden" name="location_preset" value="none" /> <?php } ?> <?php if ($mc_input['event_location'] == 'on' || $mc_input_administrator) { ?> <p> <label for="e_label"><?php _e('Name of Location (e.g. <em>Joe\'s Bar and Grill</em>)', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_label')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label><br /><input type="text" id="e_label" name="event_label" size="40" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_label)); } ?> " /> </p> <p> <label for="e_street"><?php _e('Street Address', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_street')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_street" name="event_street" size="40" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_street)); } ?> " /> </p> <p> <label for="e_street2"><?php _e('Street Address (2)', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_street2')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_street2" name="event_street2" size="40" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_street2)); } ?> " /> </p> <p> <label for="e_city"><?php _e('City', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_city')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_city" name="event_city" size="40" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_city)); } ?> " /> <label for="e_state"><?php _e('State/Province', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_state')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_state" name="event_state" size="10" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_state)); } ?> " /> </p> <p> <label for="e_postcode"><?php _e('Postal Code', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_postcode')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_postcode" name="event_postcode" size="10" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_postcode)); } ?> " /> <label for="e_region"><?php _e('Region', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_region')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_region" name="event_region" size="40" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_region)); } ?> " /> </p> <p> <label for="e_country"><?php _e('Country', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_country')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_country" name="event_country" size="10" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_country)); } ?> " /> </p> <p> <label for="e_zoom"><?php _e('Initial Zoom', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_zoom')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <select name="event_zoom" id="e_zoom"> <option value="16"<?php if (!empty($data) && $data->event_zoom == 16) { echo " selected=\"selected\""; } ?> ><?php _e('Neighborhood', 'my-calendar'); ?> </option> <option value="14"<?php if (!empty($data) && $data->event_zoom == 14) { echo " selected=\"selected\""; } ?> ><?php _e('Small City', 'my-calendar'); ?> </option> <option value="12"<?php if (!empty($data) && $data->event_zoom == 12) { echo " selected=\"selected\""; } ?> ><?php _e('Large City', 'my-calendar'); ?> </option> <option value="10"<?php if (!empty($data) && $data->event_zoom == 10) { echo " selected=\"selected\""; } ?> ><?php _e('Greater Metro Area', 'my-calendar'); ?> </option> <option value="8"<?php if (!empty($data) && $data->event_zoom == 8) { echo " selected=\"selected\""; } ?> ><?php _e('State', 'my-calendar'); ?> </option> <option value="6"<?php if (!empty($data) && $data->event_zoom == 6) { echo " selected=\"selected\""; } ?> ><?php _e('Region', 'my-calendar'); ?> </option> </select> </p> <p> <label for="e_phone"><?php _e('Phone', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_phone')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_phone" name="event_phone" size="32" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_phone)); } ?> " /> </p> <p> <label for="e_url"><?php _e('Location URL', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_url')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_url" name="event_url" size="40" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_url)); } ?> " /> </p> <fieldset> <legend><?php _e('GPS Coordinates (optional)', 'my-calendar'); ?> </legend> <p> <label for="e_latitude"><?php _e('Latitude', 'my-calendar'); if (!mc_compare_group_members($group_id, 'event_latitude')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } if (!mc_compare_group_members($group_id, 'event_longitude')) { echo " <span>" . __('Fields do not match', 'my-calendar') . "</span>"; } ?> </label> <input type="text" id="e_latitude" name="event_latitude" size="10" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_latitude)); } ?> " /> <label for="e_longitude"><?php _e('Longitude', 'my-calendar'); ?> </label> <input type="text" id="e_longitude" name="event_longitude" size="10" value="<?php if (!empty($data)) { esc_attr_e(stripslashes($data->event_longitude)); } ?> " /> </p> </fieldset> <fieldset> <legend><?php _e('Location Accessibility', 'my-calendar'); ?> </legend> <ul class='checkboxes'> <?php $access = apply_filters('mc_venue_accessibility', get_option('mc_location_access')); $access_list = ''; if (!empty($data)) { $location_access = unserialize($data->event_access); } else { $location_access = array(); } foreach ($access as $k => $a) { $id = "loc_access_{$k}"; $label = $a; $checked = ''; if (is_array($location_access)) { $checked = in_array($k, $location_access) ? " checked='checked'" : ''; } $item = sprintf('<li><input type="checkbox" id="%1$s" name="event_access[]" value="%4$s" class="checkbox" %2$s /> <label for="%1$s">%3$s</label></li>', $id, $checked, $label, $k); $access_list .= $item; } echo $access_list; ?> </ul> </fieldset> <?php } ?> <?php if ($mc_input['event_location'] == 'on' || $mc_input['event_location_dropdown'] == 'on' || $mc_input_administrator) { ?> </fieldset> </div> </div> </div> <?php } ?> <p> <input type="submit" name="save" class="button-secondary" value="<?php _e('Edit Event Group', 'my-calendar'); ?> " /> </p> </form> </div> </div> <?php }
function mc_form_fields($data, $mode, $event_id) { global $wpdb, $user_ID; $mcdb = $wpdb; $has_data = empty($data) ? false : true; if ($data) { $test = mc_test_occurrence_overlap($data); } $instance = isset($_GET['date']) ? (int) $_GET['date'] : false; if ($instance) { $ins = mc_get_instance_data($instance); $event_id = $ins->occur_event_id; $data = mc_get_event_core($event_id); } ?> <div class="postbox-container jcd-wide"> <div class="metabox-holder"> <?php if ($mode == 'add' || $mode == 'copy') { $query_args = array(); } else { $query_args = array('mode' => $mode, 'event_id' => $event_id); if ($instance) { $query_args['date'] = $instance; } } echo apply_filters('mc_before_event_form', '', $event_id); $action = add_query_arg($query_args, admin_url('admin.php?page=my-calendar')); if (!empty($data->event_group_id) && $mode != 'copy') { $group_id = $data->event_group_id; } else { $group_id = mc_group_id(); } if ($mode != 'edit') { $event_author = $user_ID; } else { $event_author = $data->event_author; } ?> <form id="my-calendar" method="post" action="<?php echo $action; ?> "> <div> <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?> " /> <?php if (isset($_GET['ref'])) { ?> <input type="hidden" name="ref" value="<?php echo esc_url($_GET['ref']); ?> " /> <?php } ?> <input type="hidden" name="event_group_id" value="<?php echo $group_id; ?> " /> <input type="hidden" name="event_action" value="<?php esc_attr_e($mode); ?> " /> <?php if (!empty($_GET['date'])) { ?> <input type="hidden" name="event_instance" value="<?php echo (int) $_GET['date']; ?> "/> <?php } ?> <input type="hidden" name="event_id" value="<?php echo (int) $event_id; ?> "/> <?php if ($mode == 'edit') { if ($has_data && (!property_exists($data, 'event_post') || !$data->event_post)) { $array_data = (array) $data; $post_id = mc_event_post('add', $array_data, $event_id); } else { $post_id = $has_data ? $data->event_post : false; } ?> <input type='hidden' name='event_post' value="<?php echo $post_id; ?> " /> <?php } else { $post_id = false; } ?> <input type="hidden" name="event_nonce_name" value="<?php echo wp_create_nonce('event_nonce'); ?> " /> </div> <div class="ui-sortable meta-box-sortables"> <div class="postbox"> <?php if ($mode == 'edit') { $text = __('Edit Event', 'my-calendar'); $args = ''; if (isset($_GET['date'])) { $id = is_numeric($_GET['date']) ? $_GET['date'] : false; if ($id) { $args = "&date={$id}"; } } $delete = " · <a href='" . admin_url("admin.php?page=my-calendar-manage&mode=delete&event_id={$event_id}{$args}") . "' class='delete'>" . __('Delete', 'my-calendar') . "</a>"; } else { $text = __('Add Event', 'my-calendar'); $delete = ''; } if (apply_filters('mc_use_permalinks', get_option('mc_use_permalinks')) == 'true') { $post_link = $post_id ? get_edit_post_link($post_id) : false; $text_link = $post_link ? sprintf(" · <a href='%s'>" . __('Edit Event Post', 'my-calendar') . "</a>", $post_link) : ''; } else { $text_link = ''; } ?> <h2><?php echo $text; ?> </h2> <div class="inside"> <p class='mc-controls'> <a href="<?php echo admin_url('admin.php?page=my-calendar-manage'); ?> "><?php echo current_user_can('mc_manage_events') ? __('Manage events', 'my-calendar') : __('Manage your events', 'my-calendar'); ?> </a> <?php echo $delete; echo $text_link; ?> <input type="submit" name="save" class="button-primary" value="<?php _e('Save Event', 'my-calendar'); ?> "/> </p> <?php if (!empty($_GET['date']) && $data->event_recur != 'S') { $event = mc_get_event($instance); $date = date_i18n(get_option('mc_date_format'), strtotime($event->occur_begin)); $message = __("You are editing the <strong>{$date}</strong> instance of this event. Other instances of this event will not be changed.", 'my-calendar'); //echo "<div><input type='hidden' name='event_instance' value='$instance' /></div>"; echo "<div class='message updated'><p>{$message}</p></div>"; } else { if (isset($_GET['date']) && empty($_GET['date'])) { echo "<div class='message updated'><p>" . __('There was an error acquiring information about this event instance. The ID for this event instance was not provided. <strong>You are editing this entire recurrence set.</strong>', 'my-calendar') . "</p></div>"; } } ?> <fieldset> <legend class="screen-reader-text"><?php _e('Event Details', 'my-calendar'); ?> </legend> <p> <label for="e_title"><?php _e('Event Title', 'my-calendar'); ?> </label><br/><input type="text" id="e_title" name="event_title" size="50" maxlength="255" value="<?php if ($has_data) { echo apply_filters('mc_manage_event_title', stripslashes(esc_attr($data->event_title)), $data); } ?> "/><?php if ($mode == 'edit') { ?> <input type='hidden' name='prev_event_status' value='<?php esc_attr_e($data->event_approved); ?> ' /><?php if (get_option('mc_event_approve') == 'true') { if (current_user_can('mc_approve_events')) { // Added by Roland P. if ($has_data && $data->event_approved == '1') { $checked = " checked=\"checked\""; } else { if ($has_data && $data->event_approved == '0') { $checked = ""; } else { if (get_option('mc_event_approve') == 'true') { $checked = "checked=\"checked\""; } } } ?> <input type="checkbox" value="1" id="e_approved" name="event_approved" <?php echo $checked; ?> /> <label for="e_approved"><?php _e('Approve', 'my-calendar'); ?> </label><?php } else { // case: editing, approval enabled, user cannot approve ?> <input type="hidden" value="0" name="event_approved" /><?php _e('An administrator must approve your new event.', 'my-calendar'); } } else { // Case: editing, approval system is disabled - auto approve ?> <input type="hidden" value="1" name="event_approved"/><?php } } else { // case: adding new event (if use can, then 1, else 0) if (get_option('mc_event_approve') != 'true') { $dvalue = 1; } else { if (current_user_can('mc_approve_events')) { $dvalue = 1; } else { $dvalue = 0; } } ?> <input type="hidden" value="<?php echo $dvalue; ?> " name="event_approved" /><?php } ?> </p> <?php if (is_object($data) && $data->event_flagged == 1) { ?> <div class="error"> <p> <input type="checkbox" value="0" id="e_flagged" name="event_flagged"<?php if ($has_data && $data->event_flagged == '0') { echo " checked=\"checked\""; } else { if ($has_data && $data->event_flagged == '1') { echo ""; } } ?> /> <label for="e_flagged"><?php _e('This event is not spam', 'my-calendar'); ?> </label> </p> </div> <?php } if (function_exists('jd_doTwitterAPIPost') && current_user_can('wpt_can_tweet')) { if (!($mode == 'edit' && $data->event_approved == 1)) { ?> <p class='mc-twitter'> <label for='mc_twitter'><?php _e('Post to Twitter (via WP to Twitter)', 'my-calendar'); ?> </label><br/> <textarea cols='70' rows='2' id='mc_twitter' name='mc_twitter'><?php do_action('mc_twitter_text', $data); ?> </textarea> </p><?php } } mc_show_block('event_desc', $has_data, $data); mc_show_block('event_short', $has_data, $data); mc_show_block('event_image', $has_data, $data); mc_show_block('event_host', $has_data, $data); mc_show_block('event_author', $has_data, $data, true, $event_author); mc_show_block('event_category', $has_data, $data); mc_show_block('event_link', $has_data, $data); echo apply_filters('mc_event_details', '', $has_data, $data, 'admin'); ?> </fieldset> </div> </div> </div> <div class="ui-sortable meta-box-sortables"> <div class="postbox"> <h2><?php _e('Date and Time', 'my-calendar'); ?> </h2> <div class="inside"> <?php if (is_object($data)) { // information for rewriting recurring data ?> <input type="hidden" name="prev_event_begin" value="<?php esc_attr_e($data->event_begin); ?> "/> <input type="hidden" name="prev_event_time" value="<?php esc_attr_e($data->event_time); ?> "/> <input type="hidden" name="prev_event_end" value="<?php esc_attr_e($data->event_end); ?> "/> <input type="hidden" name="prev_event_endtime" value="<?php esc_attr_e($data->event_endtime); ?> "/> <?php } ?> <fieldset> <legend class="screen-reader-text"><?php _e('Event Date and Time', 'my-calendar'); ?> </legend> <div id="e_schedule"> <div id="event1" class="clonedInput" aria-live="assertive"> <?php echo apply_filters('mc_datetime_inputs', '', $has_data, $data, 'admin'); ?> </div> <?php if ($mode != 'edit') { ?> <p id="event_span"> <input type="checkbox" value="1" id="e_span" name="event_span"<?php if ($has_data && $data->event_span == '1') { echo " checked=\"checked\""; } else { if ($has_data && $data->event_span == '0') { echo ""; } else { if (get_option('mc_event_span') == 'true') { echo " checked=\"checked\""; } } } ?> /> <label for="e_span"><?php _e('This is a multi-day event.', 'my-calendar'); ?> </label> </p> <p class="note"> <em><?php _e('Enter start and end dates/times for each occurrence of the event.', 'my-calendar'); ?> </em> </p> <div> <input type="button" id="add_field" value="<?php _e('Add another occurrence', 'my-calendar'); ?> " class="button" /> <input type="button" id="del_field" value="<?php _e('Remove last occurrence', 'my-calendar'); ?> " class="button" /> </div> <?php } else { ?> <div id='mc-accordion'> <?php if ($data->event_recur != 'S') { ?> <h4><span class='dashicons' aria-hidden='true'> </span><?php _e('Scheduled dates for this event', 'my-calendar'); ?> </h4> <div> <p> <?php _e('Editing a single date of an event changes only that date. Editing the root event changes all events in the series.', 'my-calendar'); ?> </p> <div class='mc_response' aria-live='assertive'></div> <ul class="columns instance-list"> <?php if (isset($_GET['date'])) { $date = (int) $_GET['date']; } else { $date = false; } ?> <?php echo mc_instance_list($data->event_id, $date); ?> </ul> <p><button type='button' class='add-occurrence' aria-expanded="false"><span class='dashicons' aria-hidden='true'> </span><?php _e('Add another date', 'my-calendar'); ?> </button></p> <div class='mc_add_new'> <?php echo mc_recur_datetime_input(); ?> <button type='button' class='save-occurrence'><?php _e('Add Date', 'my-calendar'); ?> </button> </div> </div> <?php } ?> <?php if ($data->event_group_id != 0) { ?> <?php $edit_group_url = admin_url('admin.php?page=my-calendar-groups&mode=edit&event_id=' . $data->event_id . '&group_id=' . $data->event_group_id); ?> <h4><span class='dashicons' aria-hidden="true"></span><?php _e('Related Events:', 'my-calendar'); ?> (<a href='<?php echo $edit_group_url; ?> '><?php _e('Edit group', 'my-calendar'); ?> </a>) </h4> <div> <ul class="columns"> <?php mc_related_events($data->event_group_id); ?> </ul> </div> <?php } ?> </div> <?php } ?> </div> </fieldset> </div> </div> </div> <?php mc_show_block('event_recurs', $has_data, $data); mc_show_block('event_access', $has_data, $data); mc_show_block('event_open', $has_data, $data); if (mc_show_edit_block('event_location') || mc_show_edit_block('event_location_dropdown')) { ?> <div class="ui-sortable meta-box-sortables"> <div class="postbox"> <h2><?php _e('Event Location', 'my-calendar'); ?> </h2> <div class="inside location_form"> <fieldset> <legend class='screen-reader-text'><?php _e('Event Location', 'my-calendar'); ?> </legend><?php } if (mc_show_edit_block('event_location_dropdown')) { $current_location = ''; $locs = $mcdb->get_results("SELECT location_id,location_label FROM " . my_calendar_locations_table() . " ORDER BY location_label ASC"); if (!empty($locs)) { ?> <p> <label for="l_preset"><?php _e('Choose a preset location:', 'my-calendar'); ?> </label> <select name="location_preset" id="l_preset" aria-describedby='mc-current-location'> <option value="none"> --</option><?php foreach ($locs as $loc) { if (is_object($loc)) { echo "<option value=\"" . $loc->location_id . "\">" . mc_kses_post(stripslashes($loc->location_label)) . "</option>"; if (is_object($data)) { if (property_exists($data, 'event_location')) { $event_location = $data->event_location; } else { $event_location = false; } if ($loc->location_id == $event_location) { $current_location = "<span id='mc-current-location'>" . sprintf(__('Current location: %s', 'my-calendar'), mc_kses_post($loc->location_label)) . "</span>"; } } } } ?> </select> <?php echo $current_location; ?> </p><?php } else { ?> <input type="hidden" name="location_preset" value="none"/> <p><a href="<?php echo admin_url('admin.php?page=my-calendar-locations'); ?> "><?php _e('Add recurring locations for later use.', 'my-calendar'); ?> </a> </p><?php } } else { ?> <input type="hidden" name="location_preset" value="none"/><?php } mc_show_block('event_location', $has_data, $data); if (mc_show_edit_block('event_location') || mc_show_edit_block('event_location_dropdown')) { ?> </fieldset> </div> </div> </div><?php } if (mc_show_edit_block('event_specials')) { ?> <div class="ui-sortable meta-box-sortables"> <div class="postbox"> <h2><?php _e('Special scheduling options', 'my-calendar'); ?> </h2> <div class="inside"> <fieldset> <legend class="screen-reader-text"><?php _e('Special Options', 'my-calendar'); ?> </legend> <p> <label for="e_holiday"><?php _e('Cancel this event if it occurs on a date with an event in the Holidays category', 'my-calendar'); ?> </label> <input type="checkbox" value="true" id="e_holiday" name="event_holiday"<?php if ($has_data && $data->event_holiday == '1') { echo " checked=\"checked\""; } else { if ($has_data && $data->event_holiday == '0') { echo ""; } else { if (get_option('mc_skip_holidays') == 'true') { echo " checked=\"checked\""; } } } ?> /> </p> <p> <label for="e_fifth_week"><?php _e('If this event recurs, and falls on the 5th week of the month in a month with only four weeks, move it back one week.', 'my-calendar'); ?> </label> <input type="checkbox" value="true" id="e_fifth_week" name="event_fifth_week"<?php if ($has_data && $data->event_fifth_week == '1') { echo " checked=\"checked\""; } else { if ($has_data && $data->event_fifth_week == '0') { echo ""; } else { if (get_option('mc_no_fifth_week') == 'true') { echo " checked=\"checked\""; } } } ?> /> </p> </fieldset> </div> </div> </div><?php } else { ?> <div> <input type="hidden" name="event_holiday" value="true" <?php checked(get_option('mc_skip_holidays'), 'true'); ?> /> <input type="hidden" name="event_fifth_week" value="true" <?php checked(get_option('mc_no_fifth_week'), 'true'); ?> /> </div><?php } ?> <p> <input type="submit" name="save" class="button-primary" value="<?php _e('Save Event', 'my-calendar'); ?> "/> </p> </form> </div> </div><?php }
function mc_submit_form($fields, $categories, $locations, $category, $location, $location_fields) { $fields = apply_filters('mcs_submit_fields', $fields); $location_fields = apply_filters('mcs_submit_location_fields', $location_fields); // the big function. This creates the form. wp_enqueue_script('pickadate', plugins_url('my-calendar/js/pickadate/picker.js')); wp_enqueue_script('pickadate.date', plugins_url('my-calendar/js/pickadate/picker.date.js')); wp_enqueue_script('pickadate.time', plugins_url('my-calendar/js/pickadate/picker.time.js')); wp_localize_script('pickadate.date', 'mc_months', array(date_i18n('F', strtotime('January 1')), date_i18n('F', strtotime('February 1')), date_i18n('F', strtotime('March 1')), date_i18n('F', strtotime('April 1')), date_i18n('F', strtotime('May 1')), date_i18n('F', strtotime('June 1')), date_i18n('F', strtotime('July 1')), date_i18n('F', strtotime('August 1')), date_i18n('F', strtotime('September 1')), date_i18n('F', strtotime('October 1')), date_i18n('F', strtotime('November 1')), date_i18n('F', strtotime('December 1')))); wp_localize_script('pickadate.date', 'mc_days', array(date_i18n('D', strtotime('Sunday')), date_i18n('D', strtotime('Monday')), date_i18n('D', strtotime('Tuesday')), date_i18n('D', strtotime('Wednesday')), date_i18n('D', strtotime('Thursday')), date_i18n('D', strtotime('Friday')), date_i18n('D', strtotime('Saturday')))); wp_register_script('mcs-submit-form', plugins_url('/js/jquery.mcs-submit.js', __FILE__), array('jquery')); wp_enqueue_script('mcs-submit-form'); $format = get_option('mcs_date_format'); switch ($format) { case "m/d/Y": $js_format = 'mm/dd/yyyy'; break; case "d-m-Y": $js_format = 'dd-mm-yyyy'; break; case "Y-m-d": $js_format = 'yy-mm-dd'; break; case "j F Y": $js_format = 'd mmmm yyyy'; break; case "M j, Y": $js_format = 'mmm d, yyyy'; break; default: $js_format = 'yy-mm-dd'; } $time = get_option('mcs_time_format'); switch ($time) { case "H:i": $js_time_format = 'HH:i'; break; default: $js_time_format = 'h:i a'; } $script = "\n<script>\n(function (\$) {\n\t\$(function() {\n\t\t\$( 'input.mc-date' ).pickadate({\n\t\t\tmonthsFull: mc_months,\n\t\t\tformat: '{$js_format}',\n\t\t\tweekdaysShort: mc_days,\n\t\t\tselectYears: true,\n\t\t\tselectMonths: true,\n\t\t\teditable: true\n\t\t});\n\t\t\$( 'input.mc-time' ).pickatime({\n\t\t\tinterval: 15,\n\t\t\tformat: '{$js_time_format}',\n\t\t\teditable: true\t\t\n\t\t});\n\t})\n})(jQuery);\n</script>"; global $user_ID; if (is_user_logged_in()) { $auth = $user_ID; } else { $auth = 0; } $nonce = "<input type='hidden' name='event_nonce_name' value='" . wp_create_nonce('event_nonce') . "' />"; $response = mcs_processor_response(); $event = false; if (empty($response[1]) && isset($_GET['mcs_id']) && is_user_logged_in()) { $mc_id = intval($_GET['mcs_id']); $event = mc_form_data($mc_id); if (!mc_can_edit_event($event->event_id)) { $event = false; } } if (isset($_GET['mcs_id']) && !is_user_logged_in()) { $message = "<div class='updated'><p>" . __("You'll need to log-in to edit this event.", 'my-calendar-submissions') . "</p></div>"; } else { $message = ''; } $data = !empty($response[1]) ? $response[1] : $event; $has_data = empty($data) ? false : true; $title = !empty($data) ? esc_attr($data->event_title) : ''; $desc = !empty($data) ? esc_attr($data->event_desc) : ''; $tickets = !empty($data) ? esc_attr($data->event_tickets) : ''; $registration = !empty($data) ? esc_attr($data->event_registration) : ''; $begin = !empty($data) ? esc_attr($data->event_begin) : ''; $format = date(get_option('mcs_date_format'), current_time('timestamp')); $format2 = date(get_option('mcs_time_format'), current_time('timestamp')); $endformat2 = date(get_option('mcs_time_format'), current_time('timestamp') + 3600); $end = !empty($data) ? esc_attr($data->event_end) : ''; $time = !empty($data) ? esc_attr($data->event_time) : $format2; $endtime = !empty($data) ? esc_attr($data->event_endtime) : $endformat2; $recur = !empty($data) ? esc_attr($data->event_recur) : 'S'; $recurs = str_split($recur, 1); $recur = $recurs[0]; $every = isset($recurs[1]) ? $recurs[1] : 1; if ($every == 1 && $recur == 'B') { $every = 2; } $repeats = !empty($data) ? esc_attr($data->event_repeats) : 0; $selected_category = !empty($data) ? esc_attr($data->event_category) : $category; $event_host = !empty($data) ? esc_attr($data->event_host) : $user_ID; $link = !empty($data) ? esc_attr($data->event_link) : ''; $label = !empty($data) ? esc_attr($data->event_label) : ''; $street = !empty($data) ? esc_attr($data->event_street) : ''; $street2 = !empty($data) ? esc_attr($data->event_street2) : ''; $city = !empty($data) ? esc_attr($data->event_city) : ''; $state = !empty($data) ? esc_attr($data->event_state) : ''; $postcode = !empty($data) ? esc_attr($data->event_postcode) : ''; $country = !empty($data) ? esc_attr($data->event_country) : ''; $region = !empty($data) ? esc_attr($data->event_region) : ''; $url = !empty($data) ? esc_attr($data->event_url) : ''; $longitude = !empty($data) ? esc_attr($data->event_longitude) : ''; $latitude = !empty($data) ? esc_attr($data->event_latitude) : ''; $phone = !empty($data) ? esc_attr($data->event_phone) : ''; $short = !empty($data) ? esc_attr($data->event_short) : ''; $image = !empty($data) ? esc_attr($data->event_image) : ''; $name = isset($_POST['event_name']) ? esc_attr($_POST['event_name']) : ''; $email = isset($_POST['event_email']) ? esc_attr($_POST['event_email']) : ''; $key = isset($_POST['event_key']) ? esc_attr($_POST['event_key']) : ''; $key = isset($_GET['event_key']) ? esc_attr($_GET['event_key']) : ''; if ($event) { $link_expires = $event->event_link_expires; $event_holiday = $event->event_holiday; $event_fifth_week = $event->event_fifth_week; $edit = "<input type='hidden' name='event_edit' value='{$mc_id}' />"; $edit .= "\n\t\t\t<input type='hidden' name='prev_event_begin' value='{$begin}' />\n\t\t\t<input type='hidden' name='prev_event_repeats' value='{$repeats}' />\n\t\t\t<input type='hidden' name='prev_event_recur' value='{$recur}' />\n\t\t\t<input type='hidden' name='prev_event_status' value='{$event->event_approved}' />\n\t\t\t<input type='hidden' name='event_post' value='{$event->event_post}' />"; } else { $link_expires = get_option('mc_event_link_expires') == 'false' ? 1 : 0; $event_holiday = get_option('mc_skip_holidays') == 'true' ? 'on' : 'false'; $event_fifth_week = get_option('mc_no_fifth_week') == 'true' ? 1 : ''; $edit = ''; } $selected_location = array('label' => $label, 'street' => $street, 'street2' => $street2, 'city' => $city, 'state' => $state, 'postcode' => $postcode, 'country' => $country, 'region' => $region, 'url' => $url, 'longitude' => $longitude, 'latitude' => $latitude, 'phone' => $phone); $payment_form = mcs_payment_required() ? mcs_payment_form() : ''; $check_conflicts = get_option('mcs_check_conflicts') == 'true' ? '<input type="hidden" name="mcs_check_conflicts" value="true" />' : ''; $approved = get_option('mcs_automatic_approval') == 'true' || current_user_can('mc_manage_events') ? 1 : 0; // need to set hidden inputs to default values. $enctype = get_option('mcs_upload_images') == 'true' ? ' enctype="multipart/form-data"' : ''; $return = "{$script}\n\t<div class='mc-submissions'>\n\t\t{$message}\n\t\t{$response['0']}\n\t\t{$payment_form}\n\t\t<form action='' method='post' class='mcs-submission'{$enctype}>\n\t\t<div>\n\t\t{$nonce}\n\t\t<input type='hidden' name='mcs_submission' value='on' />\n\t\t<input type='hidden' name='event_approved' value='{$approved}' /> \n\t\t<input type='hidden' name='event_author' value='{$auth}' />\n\t\t<input type='hidden' name='event_link_expires' value='" . $link_expires . "' />\n\t\t<input type='hidden' name='event_holiday' value='" . $event_holiday . "' />\n\t\t<input type='hidden' name='event_fifth_week' value='" . $event_fifth_week . "' />\n\t\t<input type='hidden' name='event_group_id' value='" . mc_group_id() . "' />\n\t\t<div style='display: none;'>\n\t\t\t<label for='your_name'>" . __('Do not complete this field.', 'my-calendar-submissions') . "</label>\n\t\t\t<input type='text' name='your_name' id='your_name' value='' />\n\t\t</div>\n\t\t{$edit}"; if (apply_filters('mcs_event_allday', 0) == true) { $return .= "<input type='hidden' name='event_allday' value='1' />"; } if (apply_filters('mcs_event_hide_end', 0) == true) { $return .= "<input type='hidden' name='event_hide_end' value='1' />"; } $return .= "{$check_conflicts}\n\t\t</div>"; if (mcs_payment_required()) { $return .= "<p><label for='mcs_key'>" . __('Payment Key', 'my-calendar-submissions') . ' <span>' . __('(required)', 'my-calendar-submissions') . "</span></label> <input type='text' name='mcs_key' id='mcs_key' value='{$key}' required='required' aria-required='true' /></p>"; } $flabel = isset($fields['event_title']) ? $fields['event_title'] : __('Event Title', 'my-calendar-submissions'); $dlabel = isset($fields['event_date']) ? $fields['event_date'] : __('Date', 'my-calendar-submissions'); $tlabel = isset($fields['event_time']) ? $fields['event_time'] : __('Time', 'my-calendar-submissions'); $return .= "\n\t\t<p>\n\t\t<label for='mc_event_title'>{$flabel} <span>" . __('(required)', 'my-calendar-submissions') . "</span></label> <input type='text' name='event_title' id='mc_event_title' value='{$title}' required='required' aria-required='true' />\n\t\t</p>\n\t\t<div class='mc_begin_container'>\n\t\t<p>\n\t\t<label for='mc_event_date'>{$dlabel} <span>" . __('(required)', 'my-calendar-submissions') . "</span></label> <input type='text' class='mc-date' name='event_begin[]' id='mc_event_date' value='{$begin}' required='required' aria-required='true' />\n\t\t</p>\n\t\t<p>\n\t\t<label for='mc_event_time'>{$tlabel}</label> <input type='time' name='event_time[]' id='mc_event_time' class='mc-time' value='{$time}' />\n\t\t</p>\n\t\t</div>"; if (isset($fields['end_date']) || isset($fields['end_time'])) { $return .= "<div class='mc_end_container'>"; } if (isset($fields['end_date'])) { $flabel = $fields['end_date'] != 'true' && $fields['end_date'] != 'End date' ? $fields['end_date'] : __('End date', 'my-calendar-submissions'); $return .= "<p>\n\t\t\t<label for='mc_event_enddate'>{$flabel}</label> <input type='text' class='mc-date' name='event_end[]' id='mc_event_enddate' value='{$end}' />\n\t\t\t</p>"; } else { $return .= "<input type='hidden' name='event_end[]' value='' />"; } if (isset($fields['end_time'])) { $flabel = $fields['end_time'] != 'true' && $fields['end_time'] != 'End time' ? $fields['end_time'] : __('End time', 'my-calendar-submissions'); $return .= "<p>\n\t\t\t<label for='mc_event_endtime'>{$flabel}</label> <input type='time' name='event_endtime[]' id='mc_event_endtime' class='mc-time' value='{$endtime}'/>\n\t\t\t</p>"; } if (isset($fields['end_date']) || isset($fields['end_time'])) { $return .= "</div>"; } if (is_user_logged_in()) { $current_user = wp_get_current_user(); $name = $current_user->display_name; $email = $current_user->user_email; } $disallow_user_changes = apply_filters('mcs_disallow_user_changes', false); $required = apply_filters('mcs_require_name_and_email', 'required="required"'); if ($disallow_user_changes && is_user_logged_in()) { $return .= "<input name='mcs_name' value='{$name}' type='hidden' /><input name='mcs_email' value='{$email}' type='hidden' />"; } else { $flabel = isset($fields['mcs_name']) && $fields['mcs_name'] != 'true' && $fields['mcs_name'] != 'Your Name' ? $fields['mcs_name'] : __('Your Name', 'my-calendar-submissions'); $return .= "<p>\n\t\t\t\t<label for='mcs_name'>{$flabel}</label> <input type='text' name='mcs_name' id='mcs_name' value='{$name}' {$required} />\n\t\t\t\t</p>"; $flabel = isset($fields['mcs_email']) && $fields['mcs_email'] != 'true' && $fields['mcs_email'] != 'Your Email' ? $fields['mcs_email'] : __('Your Email', 'my-calendar-submissions'); $return .= "<p>\n\t\t\t\t<label for='mcs_email'>{$flabel}</label> <input type='email' name='mcs_email' id='mcs_email' value='{$email}' {$required} />\n\t\t\t\t</p>"; } if (isset($fields['event_host'])) { $host_select = '<select id="e_host" name="event_host">'; // Grab all the users and list them $users = my_calendar_getUsers(); $num = 0; foreach ($users as $u) { $display_name = $u->display_name == '' ? $u->user_nicename : $u->display_name; if ($event_host == $u->ID) { $selected = ' selected="selected"'; } else { $selected = ''; } if (user_can($u->ID, apply_filters('mcs_eligible_hosts', 'mc_add_events'))) { $host_select .= "<option value='{$u->ID}'{$selected}>{$display_name}</option>\n"; $num++; $single_host = $u->ID; } } $host_select .= '</select>'; $flabel = isset($fields['event_host']) && $fields['event_host'] != 'true' && $fields['event_host'] != 'Event Host' ? $fields['event_host'] : __('Event Host', 'my-calendar-submissions'); if ($num <= 1) { $return .= "<input type='hidden' name='event_host' value='{$single_host}' />"; } else { $return .= "\n\t\t\t\t<p class='event_host'>\n\t\t\t\t\t<label for='e_host'>" . $flabel . "</label>\n\t\t\t\t\t{$host_select}\n\t\t\t\t</p>"; } } if (isset($fields['event_recurring'])) { $return .= "\n\t\t\t<p class='recurring'>\n\t\t\t<label for='event_repeats'>" . __('Repeats', 'my-calendar-submissions') . "</label> <input type='number' name='event_repeats' id='event_repeats' class='input' size='1' min='0' max='999' value='{$repeats}' /> \n\t\t\t<label for='event_every'>" . __('every', 'my-calendar') . "</label> <input type='number' name='event_every' id='event_every' class='input' size='1' min='1' max='9' maxlength='1' value='{$every}' /> \n\t\t\t<label for='event_recur' class='screen-reader-text'>" . __('Units', 'my-calendar-submissions') . "</label> <select name='event_recur' class='input' id='event_recur'>" . mc_recur_options($recur) . "\n\t\t\t</select> \n\t\t\t</p>"; // event_repeats, event_recur } else { $return .= "<div>\n\t\t\t\t\t<input type='hidden' name='event_repeats' value='0' />\n\t\t\t\t\t<input type='hidden' name='event_recur' value='S' />\n\t\t\t\t\t<input type='hidden' name='event_every' value='1' />\n\t\t\t\t\t</div>"; } // event_open, event_group if (isset($fields['description'])) { $flabel = $fields['description'] != 'true' && !($fields['description'] == 'Description' || $fields['description'] == 'Event Description') ? $fields['description'] : __('Description', 'my-calendar-submissions'); $return .= "<p><label for='mc_event_description'>{$flabel}</label> <textarea name='content' id='mc_event_description' class='full_description'>{$desc}</textarea></p>"; } if (isset($fields['short_description'])) { $flabel = $fields['short_description'] != 'true' && !($fields['short_description'] == 'Summary' || $fields['short_description'] == 'Short Description') ? $fields['short_description'] : __('Summary', 'my-calendar-submissions'); $return .= "<p><label for='mc_event_short_description'>{$flabel}</label> <textarea name='event_short' id='mc_event_short_description' class='short_description'>{$short}</textarea></p>"; } $return .= apply_filters('mc_event_details', '', $has_data, $data, 'public'); if (isset($fields['access']) && function_exists('mc_event_accessibility')) { $flabel = $fields['access'] != 'true' && $fields['access'] != 'Event Access' ? $fields['access'] : __('Event Access', 'my-calendar-submissions'); $return .= mc_event_accessibility('', $data, $flabel); } if (isset($fields['event_link'])) { $flabel = $fields['event_link'] != 'true' && !($fields['event_link'] == 'Link' || $fields['event_link'] == 'Event Link') ? $fields['event_link'] : __('Link', 'my-calendar-submissions'); $return .= "<p>\n\t\t\t\t<label for='mc_event_link'>{$flabel}</label> <input type='url' name='event_link' id='mc_event_link' value='{$link}' placeholder='http://' />\n\t\t\t\t</p>"; } if (isset($fields['event_image'])) { $flabel = $fields['event_image'] != 'true' && !($fields['event_image'] == 'Image (URL)' || $fields['event_image'] == 'Event image') ? $fields['event_image'] : __('Image (URL)', 'my-calendar-submissions'); if (get_option('mcs_upload_images') == 'true' && $image == '') { $input_type = 'file'; } else { $input_type = 'url'; } $return .= "<p>\n\t\t\t\t<label for='mc_event_image'>{$flabel}</label> <input type='{$input_type}' name='event_image' id='mc_event_image' value='{$image}' />\n\t\t\t\t</p>"; } $return .= mcs_submit_category($selected_category, $categories); if (isset($fields['registration'])) { $flabel = $fields['registration'] != 'true' && $fields['registration'] != 'Ticketing Information' ? $fields['registration'] : __('Ticketing Information', 'my-calendar-submissions'); $return .= "<fieldset>\n\t\t\t<legend>{$flabel}</legend>"; $return .= apply_filters('mc_event_registration', '', $has_data, $data, 'public'); $return .= "</fieldset>"; } $return .= mcs_submit_location($location, $locations, $location_fields, $selected_location); $return .= "<p><input type='submit' name='save' value='" . __('Submit your event', 'my-calendar-submissions') . "' /></p>"; $return .= "\n\t\t</form>\t\n\t</div>"; $return = apply_filters('mcs_after_submissions', $return, $response); return $return; }
function mcs_default_event_values() { if (get_option('mc_event_approve') != 'true') { $dvalue = 1; } else { if (current_user_can('mc_approve_events')) { $dvalue = 1; } else { $dvalue = 0; } } $expires = get_option('mc_event_link_expires') == 'false' ? 1 : 0; // import values from settings & autogenerate generated values $defaults = array('event_fifth_week' => get_option('event_fifth_week') == 'true' ? 1 : '', 'event_holiday' => get_option('mc_skip_holidays') == 'true' ? 1 : '', 'event_group_id' => mc_group_id(), 'event_nonce_name' => wp_create_nonce('event_nonce'), 'event_category' => 1, 'event_recur' => 'S', 'event_repeats' => 0, 'event_approved' => $dvalue, 'event_link_expires' => $expires); return apply_filters('mcs_default_event_values', $defaults); }
function mc_meta_box_form() { global $wpdb, $post; $has_data = false; $data = false; if (get_option('mc_event_approve') != 'true') { $dvalue = 1; } else { if (current_user_can('mc_approve_events')) { $dvalue = 1; } else { $dvalue = 0; } } if (get_option('mcs_approve_from_post') == 'true') { $dvalue = 0; } $event_desc = mc_show_block('event_desc', $has_data, $data, false); if ($event_desc) { $description = "<div class='event_description'>\n\t\t\t\t\t\t\t<label for='event_desc'>" . __('Event Description', 'my-calendar-submissions') . "</label><br />\n\t\t\t\t\t\t\t<textarea id='event_desc' class='event_desc widefat' cols='80' rows='8' name='event_desc'></textarea>\n\t\t\t\t\t\t</div>"; } else { $description = ''; } $event_host = mc_show_block('event_host', $has_data, $data, false); $event_category = mc_show_block('event_category', $has_data, $data, false); $event_link = mc_show_block('event_link', $has_data, $data, false); $event_recurs = mc_show_block('event_recurs', $has_data, $data, false); $mc_datetime = apply_filters('mc_datetime_inputs', '', $has_data, $data, 'admin'); if (mc_show_edit_block('event_location_dropdown')) { $locs = $wpdb->get_results("SELECT location_id,location_label FROM " . my_calendar_locations_table() . " ORDER BY location_label ASC"); if (!empty($locs)) { $location = '<p> <label for="l_preset">' . __('Choose a preset location:', 'my-calendar') . '</label> <select name="location_preset" id="l_preset"> <option value="none"> --</option>'; foreach ($locs as $loc) { if (is_object($loc)) { $location .= "<option value=\"" . $loc->location_id . "\">" . wp_kses_post(stripslashes($loc->location_label)) . "</option>"; } } $location .= '</select></p>'; } else { $location = '<input type="hidden" name="location_preset" value="none" />'; } } else { $location = '<input type="hidden" name="location_preset" value="none" />'; } $return = ' <div> <input type="hidden" name="event_group_id" value="' . mc_group_id() . '" /> <input type="hidden" name="event_action" value="add" /> <input type="hidden" name="event_source" value="post" /> <input type="hidden" name="event_nonce_name" value="' . wp_create_nonce('event_nonce') . '" /> </div> <fieldset> <legend class="screen-reader-text">' . __('Event Details', 'my-calendar') . '</legend> <p> <label for="e_title">' . __('Event Title', 'my-calendar') . ' <span class="required">(required)</span></label><br/><input type="text" id="e_title" name="event_title" size="50" maxlength="255" value="" /> <input type="hidden" value="' . $dvalue . '" name="event_approved" /> </p>' . $description . $event_host . $event_category . $event_link . ' </fieldset> <fieldset> <legend class="screen-reader-text">' . __('Event Date and Time', 'my-calendar') . '</legend> <div id="e_schedule">' . $mc_datetime . '</div> </fieldset>' . $event_recurs . '<fieldset> <legend class="screen-reader-text">' . __('Event Location', 'my-calendar') . '</legend>' . $location . '</fieldset>'; return $return; }