function mc_access_list($show = 'list', $group = 'single') { if (isset($_GET['mc_id'])) { return ''; } $output = ''; $current_url = mc_get_current_url(); $form = $group == 'single' ? "<form action='" . $current_url . "' method='get'>\r\n\t\t\t\t<div>" : ''; if ($group == 'single') { $qsa = array(); if (isset($_SERVER['QUERY_STRING'])) { parse_str($_SERVER['QUERY_STRING'], $qsa); } if (!isset($_GET['cid'])) { $form .= '<input type="hidden" name="cid" value="all" />'; } foreach ($qsa as $name => $argument) { $name = esc_attr(strip_tags($name)); $argument = esc_attr(strip_tags($argument)); if ($name != 'access') { $form .= ' <input type="hidden" name="' . $name . '" value="' . $argument . '" />' . "\n"; } } } $form .= $show == 'list' || $group == 'group' ? '' : '</div><p>'; $access_options = mc_event_access(); if (!empty($access_options) && count($access_options) >= 1) { $output = "<div id='mc_access'>\n"; $url = mc_build_url(array('access' => 'all'), array()); $not_selected = !isset($_GET['access']) ? 'selected="selected"' : ''; $output .= $show == 'list' ? "\r\n\t\t<ul>\r\n\t\t\t<li><a href='{$url}'>" . __('Accessibility Services', 'my-calendar') . "</a></li>" : $form . ' <label for="access">' . __('Accessibility Services', 'my-calendar') . '</label> <select name="access" id="access"> <option value="all"' . $not_selected . '>' . __('No Limit', 'my-calendar') . '</option>' . "\n"; foreach ($access_options as $key => $access) { $access_name = $access; $this_access = empty($_GET['access']) ? '' : (int) $_GET['access']; if ($show == 'list') { $this_url = mc_build_url(array('access' => $key), array()); $selected = $key == $this_access ? ' class="selected"' : ''; $output .= "\t\t\t<li{$selected}><a rel='nofollow' href='{$this_url}'>{$access_name}</a></li>"; } else { $selected = $this_access == $key ? ' selected="selected"' : ''; $output .= "\t\t\t<option{$selected} value='" . esc_attr($key) . "'>" . esc_html($access_name) . "</option>\n"; } } $output .= $show == 'list' ? '</ul>' : '</select>'; $output .= $show != 'list' && $group == 'single' ? "<p><input type='submit' value=" . __('Limit by Access', 'my-calendar') . " /></p></form>" : ''; $output .= "\n</div>"; } $output = apply_filters('mc_access_selector', $output, $access_options); return $output; }
function mc_event_accessibility($form, $data, $label) { $note_value = ''; $events_access = array(); $form .= "\r\n\t\t<fieldset>\r\n\t\t\t<legend>{$label}</legend>\r\n\t\t\t<ul class='accessibility-features checkboxes'>"; $access = apply_filters('mc_event_accessibility', mc_event_access()); if (!empty($data)) { if (property_exists($data, 'event_post')) { $events_access = get_post_meta($data->event_post, '_mc_event_access', true); } else { $events_access = array(); } } foreach ($access as $k => $a) { $id = "events_access_{$k}"; $label = $a; $checked = ''; if (is_array($events_access)) { $checked = in_array($k, $events_access) || in_array($a, $events_access) ? " checked='checked'" : ''; } $item = sprintf('<li><input type="checkbox" id="%1$s" name="events_access[]" value="%4$s" class="checkbox" %2$s /> <label for="%1$s">%3$s</label></li>', esc_attr($id), $checked, esc_html($label), esc_attr($a)); $form .= $item; } if (isset($events_access['notes'])) { $note_value = esc_attr($events_access['notes']); } $form .= '<li><label for="events_access_notes">' . __('Notes', 'my-calendar') . '</label> <input type="text" id="events_access_notes" name="events_access[notes]" value="' . esc_attr($note_value) . '" /></li>'; $form .= "</ul>\r\n\t</fieldset>"; return $form; }
function mc_access_limit($access) { $options = mc_event_access(); $format = isset($options[$access]) ? esc_sql($options[$access]) : false; $limit_string = $format ? " event_access LIKE '%{$format}%' AND" : ''; return $limit_string; }