/** * Output the meta box markup. * * @since 3.0.0 * * @param \WP_Post $post */ public static function html($post) { // @see Meta_Boxes::save_meta_boxes() wp_nonce_field('simcal_save_data', 'simcal_meta_nonce'); $calendars = simcal_get_calendars(); simcal_print_field(array('type' => 'select', 'id' => '_simcal_attach_calendar_id', 'name' => '_simcal_attach_calendar_id', 'enhanced' => count($calendars) > 15 ? 'enhanced' : '', 'allow_void' => 'allow_void', 'value' => absint(get_post_meta($post->ID, '_simcal_attach_calendar_id', true)), 'options' => $calendars, 'attributes' => array('data-allowclear' => 'true'))); $position = get_post_meta($post->ID, '_simcal_attach_calendar_position', true); simcal_print_field(array('type' => 'radio', 'id' => '_simcal_attach_calendar_position', 'name' => '_simcal_attach_calendar_position', 'value' => $position ? $position : 'after', 'options' => array('after' => __('After Content', 'google-calendar-events'), 'before' => __('Before Content', 'google-calendar-events')))); }
/** * Print the advanced settings panel. * * @since 3.0.0 * @access private * * @param \WP_Post $post */ private static function advanced_settings_panel($post) { ?> <table> <thead> <tr><th colspan="2"><?php _e('Date and Time', 'google-calendar-events'); ?> </th></tr> </thead> <tbody class="simcal-panel-section simcal-panel-datetime-formatting"> <tr class="simcal-panel-field"> <th><label for="_calendar_timezone_setting"><?php _e('Timezone', 'google-calendar-events'); ?> </label></th> <td> <?php $timezone_wordpress = simcal_get_wp_timezone(); $timezone_default = $timezone_wordpress ? $timezone_wordpress : 'UTC'; $timezone_setting = esc_attr(get_post_meta($post->ID, '_feed_timezone_setting', true)); $timezone = esc_attr(get_post_meta($post->ID, '_feed_timezone', true)); $timezone = $timezone ? $timezone : $timezone_default; ?> <select name="_feed_timezone_setting" id="_feed_timezone_setting" class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" data-show-next-if-value="use_custom"> <option value="use_calendar" <?php selected('use_calendar', $timezone_setting, true); ?> ><?php _ex('Events source default', 'Use the calendar default setting', 'google-calendar-events'); ?> </option> <option value="use_site" <?php selected('use_site', $timezone_setting, true); ?> ><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events') . ' (%s)', $timezone_default); ?> </option> <option value="use_custom" <?php selected('use_custom', $timezone_setting, true); ?> ><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?> </option> </select> <select name="_feed_timezone" id="_feed_timezone" class="simcal-field simcal-field-select simcal-field-inline" <?php echo 'use_custom' != $timezone_setting ? 'style="display: none;"' : ''; ?> > <?php echo wp_timezone_choice($timezone); ?> </select> <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events'); ?> "></i> </td> </tr> <tr class="simcal-panel-field"> <th><label for="_calendar_date_format_setting"><?php _e('Date format', 'google-calendar-events'); ?> </label></th> <td> <?php $date_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_date_format_setting', true)); $date_format_default = esc_attr(get_option('date_format')); $date_format = esc_attr(get_post_meta($post->ID, '_calendar_date_format', true)); $date_format_php = esc_attr(get_post_meta($post->ID, '_calendar_date_format_php', true)); $date_format_php = $date_format_php ? $date_format_php : $date_format_default; ?> <select name="_calendar_date_format_setting" id="_calendar_date_format_setting" class="simcal-field simcal-field-select simcal-field-show-other"> <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected('use_site', $date_format_setting, true); ?> ><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?> </option> <option value="use_custom" data-show-field="_calendar_date_format" <?php selected('use_custom', $date_format_setting, true); ?> ><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?> </option> <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected('use_custom_php', $date_format_setting, true); ?> ><?php _e('Custom (PHP format)', 'google-calendar-events'); ?> </option> </select> <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events'); ?> "></i> <p id="_calendar_date_format_default" style="<?php echo $date_format_setting != 'use_site' ? 'display: none;' : ''; ?> "> <em><?php _e('Preview', 'google-calendar-events'); ?> :</em> <code><?php echo date_i18n($date_format_default, time()); ?> </code> </p> <?php simcal_print_field(array('type' => 'datetime-format', 'subtype' => 'date', 'name' => '_calendar_date_format', 'id' => '_calendar_date_format', 'value' => $date_format, 'style' => $date_format_setting != 'use_custom' ? array('display' => 'none') : '')); ?> <div class="simcal-field-datetime-format-php" id="_calendar_date_format_php_field" style="<?php echo $date_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?> "> <br> <label for="_calendar_date_format_php"> <input type="text" name="_calendar_date_format_php" id="_calendar_date_format_php" class="simcal-field simcal-field-text simcal-field-small" value="<?php echo $date_format_php; ?> " /> <?php printf(__('Enter a date format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> </label> <p> <em><?php _e('Preview', 'google-calendar-events'); ?> :</em> <code><?php echo date_i18n($date_format_php, time()); ?> </code> </p> </div> </td> </tr> <tr class="simcal-panel-field"> <th><label for="_calendar_datetime_separator"><?php _e('Separator', 'google-calendar-events'); ?> </label></th> <td> <?php $separator = get_post_meta($post->ID, '_calendar_datetime_separator', true); $separator = false == $separator ? '@' : $separator; simcal_print_field(array('type' => 'standard', 'subtype' => 'text', 'name' => '_calendar_datetime_separator', 'id' => '_calendar_datetime_separator', 'value' => $separator, 'tooltip' => __('Used to divide date and time when both are shown.', 'google-calendar-events'), 'class' => array('simcal-field-tiny'))); ?> </td> </tr> <tr class="simcal-panel-field"> <th><label for="_calendar_time_format_setting"><?php _e('Time format', 'google-calendar-events'); ?> </label></th> <td> <?php $time_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_time_format_setting', true)); $time_format_default = esc_attr(get_option('time_format')); $time_format = esc_attr(get_post_meta($post->ID, '_calendar_time_format', true)); $time_format_php = esc_attr(get_post_meta($post->ID, '_calendar_time_format_php', true)); $time_format_php = $time_format_php ? $time_format_php : $time_format_default; ?> <select name="_calendar_time_format_setting" id="_calendar_time_format_setting" class="simcal-field simcal-field-select simcal-field-show-other"> <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected('use_site', $time_format_setting, true); ?> ><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?> </option> <option value="use_custom" data-show-field="_calendar_time_format" <?php selected('use_custom', $time_format_setting, true); ?> ><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?> </option> <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected('use_custom_php', $time_format_setting, true); ?> ><?php _e('Custom (PHP format)', 'google-calendar-events'); ?> </option> </select> <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events'); ?> "></i> <p id="_calendar_time_format_default" style="<?php echo $time_format_setting != 'use_site' ? 'display: none;' : ''; ?> "> <em><?php _e('Preview', 'google-calendar-events'); ?> :</em> <code><?php echo date_i18n($time_format_default, time()); ?> </code> </p> <?php simcal_print_field(array('type' => 'datetime-format', 'subtype' => 'time', 'name' => '_calendar_time_format', 'id' => '_calendar_time_format', 'value' => $time_format, 'style' => $time_format_setting != 'use_custom' ? array('display' => 'none') : '')); ?> <div class="simcal-field-datetime-format-php" id="_calendar_time_format_php_field" style="<?php echo $time_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?> "> <br> <label for="_calendar_date_format_php"> <input type="text" name="_calendar_time_format_php" id="_calendar_time_format_php" class="simcal-field simcal-field-text simcal-field-small" value="<?php echo $time_format_php; ?> "/> <?php printf(__('Enter a time format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> </label> <p> <em><?php _e('Preview', 'google-calendar-events'); ?> :</em> <code><?php echo date_i18n($time_format_php, time()); ?> </code> </p> </div> </td> </tr> <tr class="simcal-panel-field"> <th><label for="_calendar_week_starts_on_setting"><?php _e('Week starts on', 'google-calendar-events'); ?> </label></th> <td> <?php $week_starts_setting = esc_attr(get_post_meta($post->ID, '_calendar_week_starts_on_setting', true)); $week_starts_default = esc_attr(get_option('start_of_week')); $week_starts = intval(get_post_meta($post->ID, '_calendar_week_starts_on', true)); $week_starts = is_numeric($week_starts) ? strval($week_starts) : $week_starts_default; ?> <select name="_calendar_week_starts_on_setting" id="_calendar_week_starts_on_setting" class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" data-show-next-if-value="use_custom"> <option value="use_site" <?php selected('use_site', $week_starts_setting, true); ?> ><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events') . ' (%s)', date_i18n('l', strtotime("Sunday + {$week_starts_default} Days"))); ?> </option> <option value="use_custom" <?php selected('use_custom', $week_starts_setting, true); ?> ><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?> </option> </select> <select name="_calendar_week_starts_on" id="_calendar_week_starts_on" class="simcal-field simcal-field-select simcal-field-inline" <?php echo 'use_custom' != $week_starts_setting ? 'style="display: none;"' : ''; ?> > <?php $day_names = simcal_get_calendar_names_i18n('day', 'full'); ?> <?php for ($i = 0; $i <= 6; $i++) { ?> <option value="<?php echo $i; ?> " <?php selected($i, $week_starts, true); ?> ><?php echo $day_names[$i]; ?> </option> <?php } ?> </select> <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events'); ?> "></i> </td> </tr> </tbody> </table> <table> <thead> <tr><th colspan="2"><?php _e('Cache', 'google-calendar-events'); ?> </th></tr> </thead> <tbody class="simcal-panel-section simcal-panel-section-cache"> <?php $cache_freq = esc_attr(get_post_meta($post->ID, '_feed_cache_user_amount', true)); $cache_unit = esc_attr(get_post_meta($post->ID, '_feed_cache_user_unit', true)); $cache_freq = $cache_freq ? $cache_freq : '2'; $cache_unit = $cache_unit ? $cache_unit : '3600'; ?> <tr class="simcal-panel-field"> <th><label for="_feed_cache_user_amount"><?php _ex('Refresh interval', 'Cache maximum interval', 'google-calendar-events'); ?> </label></th> <td> <input type="number" name="_feed_cache_user_amount" id="_feed_cache_user_amount" class="simcal-field simcal-field-number simcal-field-tiny simcal-field-inline" value="<?php echo $cache_freq; ?> " min="1" /> <select name="_feed_cache_user_unit" id="_feed_cache_user_unit" class="simcal-field simcalfield-select simcal-field-inline"> <option value="60" <?php selected('60', $cache_unit, true); ?> ><?php _e('Minute(s)', 'google-calendar-events'); ?> </option> <option value="3600" <?php selected('3600', $cache_unit, true); ?> ><?php _e('Hour(s)', 'google-calendar-events'); ?> </option> <option value="86400" <?php selected('86400', $cache_unit, true); ?> ><?php _e('Day(s)', 'google-calendar-events'); ?> </option> <option value="604800" <?php selected('604800', $cache_unit, true); ?> ><?php _e('Week(s)', 'google-calendar-events'); ?> </option> </select> <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events'); ?> "></i> </td> </tr> </tbody> </table> <?php }
/** * Extend the calendar section panel of the settings meta box. * * @since 3.0.0 * * @param int $post_id */ public function add_settings_meta_calendar_panel($post_id) { ?> <table id="default-calendar-settings"> <thead> <tr><th colspan="2"><?php _e('Default calendar', 'google-calendar-events'); ?> </th></tr> </thead> <tbody class="simcal-panel-section"> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th></th> <td> <p class="description"> <?php _e("Tip: If calendar styles appear to be missing and/or navigation isn't working, try going to", 'google-calendar-events'); ?> <a href="<?php echo esc_url(add_query_arg(array('page' => 'simple-calendar_settings', 'tab' => 'advanced'), admin_url('admin.php'))); ?> "> <?php _e('Calendars → Settings → Advanced', 'google-calendar-events'); ?> </a> <?php _e('and enable', 'google-calendar-events'); ?> <strong><?php _e('Always Enqueue', 'google-calendar-events'); ?> </strong>. </p> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> <th><label for="_default_calendar_event_bubbles_action"><?php _e('Event bubbles', 'google-calendar-events'); ?> </label></th> <td> <?php $bubbles = get_post_meta($post_id, '_default_calendar_event_bubble_trigger', true); simcal_print_field(array('type' => 'radio', 'inline' => 'inline', 'name' => '_default_calendar_event_bubble_trigger', 'id' => '_default_calendar_event_bubble_trigger', 'tooltip' => __('Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events'), 'value' => $bubbles ? $bubbles : 'hover', 'default' => 'hover', 'options' => array('click' => __('Click', 'google-calendar-events'), 'hover' => __('Hover', 'google-calendar-events')))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> <th><label for="_default_calendar_trim_titles"><?php _e('Trim event titles', 'google-calendar-events'); ?> </label></th> <td> <?php $trim = get_post_meta($post_id, '_default_calendar_trim_titles', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_trim_titles', 'id' => '_default_calendar_trim_titles', 'class' => array('simcal-field-show-next'), 'value' => 'yes' == $trim ? 'yes' : 'no', 'attributes' => array('data-show-next-if-value' => 'yes'))); simcal_print_field(array('type' => 'standard', 'subtype' => 'number', 'name' => '_default_calendar_trim_titles_chars', 'id' => '_default_calendar_trim_titles_chars', 'tooltip' => __('Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events'), 'class' => array('simcal-field-tiny'), 'value' => 'yes' == $trim ? strval(max(absint(get_post_meta($post_id, '_default_calendar_trim_titles_chars', true)), 1)) : '20', 'attributes' => array('min' => '1'))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_list_grouped_span"><?php _e('Span', 'google-calendar-events'); ?> </label></th> <td> <?php $list_span = max(absint(get_post_meta($post_id, '_default_calendar_list_range_span', true)), 1); simcal_print_field(array('type' => 'standard', 'subtype' => 'number', 'name' => '_default_calendar_list_range_span', 'id' => '_default_calendar_list_range_span', 'class' => array('simcal-field-tiny', 'simcal-field-inline'), 'value' => strval($list_span), 'attributes' => array('min' => '1'))); $list_type = get_post_meta($post_id, '_default_calendar_list_range_type', true); simcal_print_field(array('type' => 'select', 'name' => '_default_calendar_list_range_type', 'id' => '_default_calendar_list_range_type', 'tooltip' => __('Range of events to show on each calendar page.', 'google-calendar-events'), 'class' => array('simcal-field-inline'), 'value' => $list_type, 'options' => array('monthly' => __('Month(s)', 'google-calendar-events'), 'weekly' => __('Week(s)', 'google-calendar-events'), 'daily' => __('Day(s)', 'google-calendar-events'), 'events' => __('Event(s)', 'google-calendar-events')))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_list_header"><?php _e('Hide header', 'google-calendar-events'); ?> </label></th> <td> <?php $header = get_post_meta($post_id, '_default_calendar_list_header', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_list_header', 'id' => '_default_calendar_list_header', 'tooltip' => __('You can use this to hide the month header for this calendar.', 'google-calendar-events'), 'value' => 'yes' == $header ? 'yes' : 'no')); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_compact_list"><?php _e('Compact list', 'google-calendar-events'); ?> </label></th> <td> <?php $compact = get_post_meta($post_id, '_default_calendar_compact_list', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_compact_list', 'id' => '_default_calendar_compact_list', 'tooltip' => __('Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events'), 'value' => 'yes' == $compact ? 'yes' : 'no')); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_limit_visible_events"><?php _e('Limit visible events', 'google-calendar-events'); ?> </label></th> <td> <?php $limit = get_post_meta($post_id, '_default_calendar_limit_visible_events', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_limit_visible_events', 'id' => '_default_calendar_limit_visible_events', 'value' => 'yes' == $limit ? 'yes' : 'no', 'class' => array('simcal-field-show-next'), 'attributes' => array('data-show-next-if-value' => 'yes'))); $visible_events = absint(get_post_meta($post_id, '_default_calendar_visible_events', true)); $visible_events = $visible_events > 0 ? $visible_events : 3; simcal_print_field(array('type' => 'standard', 'subtype' => 'number', 'name' => '_default_calendar_visible_events', 'id' => '_default_calendar_visible_events', 'tooltip' => __('Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events'), 'class' => array('simcal-field-tiny'), 'value' => $visible_events, 'attributes' => array('min' => '1'))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_event_bubbles_action"><?php _e('Expand multi-day events', 'google-calendar-events'); ?> </label></th> <td> <?php $post_meta = get_post_meta($post_id); if (!is_array($post_meta) && !empty($post_meta)) { $multi_day_value = 'current_day_only'; } else { $multi_day_value = get_post_meta($post_id, '_default_calendar_expand_multi_day_events', true); } simcal_print_field(array('type' => 'select', 'name' => '_default_calendar_expand_multi_day_events', 'id' => '_default_calendar_expand_multi_day_events', 'tooltip' => __('For events spanning multiple days, you can display them on each day of the event, ' . 'only on the first day of the event, or on all days of the event, but only up to the current day. ' . 'Third option applies to list views only.', 'google-calendar-events'), 'value' => $multi_day_value, 'options' => array('yes' => __('Yes, display on all days of event', 'google-calendar-events'), 'no' => __('No, display only on first day of event', 'google-calendar-events'), 'current_day_only' => __('No, display on all days of event up to current day (list view only)', 'google-calendar-events')), 'default' => 'current_day_only')); ?> </td> </tr> </tbody> <?php $settings = get_option('simple-calendar_settings_calendars'); $default_theme = isset($settings['default-calendar']['theme']) ? $settings['default-calendar']['theme'] : 'light'; $default_today_color = '#1e73be'; $default_days_events_color = '#000000'; ?> <tbody class="simcal-panel-section"> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_style_theme"><?php _e('Theme', 'google-calendar-events'); ?> </label></th> <td> <?php $saved = get_post_meta($post_id, '_default_calendar_style_theme', true); $value = !$saved ? $default_theme : $saved; simcal_print_field(array('type' => 'select', 'name' => '_default_calendar_style_theme', 'id' => '_default_calendar_style_theme', 'value' => $value, 'tooltip' => __('Choose a calendar theme to match your site theme.', 'google-calendar-events'), 'options' => array('light' => __('Light', 'google-calendar-events'), 'dark' => __('Dark', 'google-calendar-events')))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_style_today"><?php _e('Today', 'google-calendar-events'); ?> </label></th> <td> <?php $saved = get_post_meta($post_id, '_default_calendar_style_today', true); $value = !$saved ? $default_today_color : $saved; simcal_print_field(array('type' => 'standard', 'subtype' => 'color-picker', 'name' => '_default_calendar_style_today', 'id' => '_default_calendar_style_today', 'value' => $value)); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_style_days_events"><?php _e('Days with events', 'google-calendar-events'); ?> </label></th> <td> <?php $saved = get_post_meta($post_id, '_default_calendar_style_days_events', true); $value = !$saved ? $default_days_events_color : $saved; simcal_print_field(array('type' => 'standard', 'subtype' => 'color-picker', 'name' => '_default_calendar_style_days_events', 'id' => '_default_calendar_style_days_events', 'value' => $value)); ?> </td> </tr> </tbody> <?php ?> </table> <?php }
/** * Add a panel to the settings meta box. * * @since 3.0.0 * * @param int $post_id */ public function add_settings_meta_panel($post_id) { ?> <div id="grouped-calendars-settings-panel" class="simcal-panel"> <table> <thead> <tr><th colspan="2"><?php _e('Grouped Calendar Settings', 'google-calendar-events'); ?> </th></tr> </thead> <tbody class="simcal-panel-section"> <tr class="simcal-panel-field"> <th><label for="_grouped_calendars_source"><?php _e('Get Calendars From', 'google-calendar-events'); ?> </label></th> <td> <?php $source = esc_attr(get_post_meta($post_id, '_grouped_calendars_source', true)); $source = empty($source) ? 'ids' : $source; ?> <select name="_grouped_calendars_source" id="_grouped_calendars_source" class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other" data-show-field-on-choice="true"> <option value="ids" data-show-field="_grouped_calendars_ids" <?php selected('ids', $source, true); ?> ><?php _e('Manual selection', 'google-calendar-events'); ?> </option> <option value="category" data-show-field="_grouped_calendars_category" <?php selected('category', $source, true); ?> ><?php _e('Category', 'google-calendar-events'); ?> </option> </select> <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events'); ?> "></i> <br><br> <?php $cals = simcal_get_calendars($post_id); $meta = get_post_meta($post_id, '_grouped_calendars_ids', true); $ids = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : absint($meta); simcal_print_field(array('type' => 'select', 'multiselect' => 'multiselect', 'name' => '_grouped_calendars_ids', 'id' => '_grouped_calendars_ids', 'value' => $ids !== 0 ? $ids : '', 'options' => $cals, 'enhanced' => 'enhanced', 'style' => 'ids' == $source ? '' : array('display' => 'none'), 'attributes' => array('data-noresults' => __('No results found.', 'google-calendar-events')))); $meta = get_post_meta($post_id, '_grouped_calendars_category', true); $category = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : ''; $terms = get_terms('calendar_category'); if (!empty($terms)) { $categories = array(); foreach ($terms as $term) { $categories[$term->term_id] = $term->name; } simcal_print_field(array('type' => 'select', 'multiselect' => 'multiselect', 'name' => '_grouped_calendars_category', 'id' => '_grouped_calendars_category', 'value' => $category, 'options' => $categories, 'enhanced' => 'enhanced', 'style' => 'category' == $source ? '' : array('display' => 'none'), 'attributes' => array('data-noresults' => __('No results found.', 'google-calendar-events')))); } else { $style = 'category' == $source ? '' : 'display: none;'; $style .= ' width: 100%; max-width: 500px'; echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="' . $style . '" placeholder="' . __('There are no calendar categories yet.', 'google-calendar-events') . '" />'; } ?> </td> </tr> </tbody> </table> </div> <?php }
/** * Extend the calendar section panel of the settings meta box. * * @since 3.0.0 * * @param int $post_id */ public function add_settings_meta_calendar_panel($post_id) { ?> <table id="default-calendar-settings"> <thead> <tr><th colspan="2"><?php _e('Default Calendar', 'google-calendar-events'); ?> </th></tr> </thead> <tbody class="simcal-panel-section"> <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> <th><label for="_default_calendar_event_bubbles_action"><?php _e('Event Bubbles', 'google-calendar-events'); ?> </label></th> <td> <?php $bubbles = get_post_meta($post_id, '_default_calendar_event_bubble_trigger', true); simcal_print_field(array('type' => 'radio', 'inline' => 'inline', 'name' => '_default_calendar_event_bubble_trigger', 'id' => '_default_calendar_event_bubble_trigger', 'tooltip' => __('Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events'), 'value' => $bubbles ? $bubbles : 'hover', 'default' => 'hover', 'options' => array('click' => __('Click', 'google-calendar-events'), 'hover' => __('Hover', 'google-calendar-events')))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> <th><label for="_default_calendar_trim_titles"><?php _e('Trim Event Titles', 'google-calendar-events'); ?> </label></th> <td> <?php $trim = get_post_meta($post_id, '_default_calendar_trim_titles', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_trim_titles', 'id' => '_default_calendar_trim_titles', 'class' => array('simcal-field-show-next'), 'value' => 'yes' == $trim ? 'yes' : 'no', 'attributes' => array('data-show-next-if-value' => 'yes'))); simcal_print_field(array('type' => 'standard', 'subtype' => 'number', 'name' => '_default_calendar_trim_titles_chars', 'id' => '_default_calendar_trim_titles_chars', 'tooltip' => __('Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events'), 'class' => array('simcal-field-tiny'), 'value' => 'yes' == $trim ? strval(max(absint(get_post_meta($post_id, '_default_calendar_trim_titles_chars', true)), 1)) : '20', 'attributes' => array('min' => '1'))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_list_grouped_span"><?php _e('Span', 'google-calendar-events'); ?> </label></th> <td> <?php $list_span = max(absint(get_post_meta($post_id, '_default_calendar_list_range_span', true)), 1); simcal_print_field(array('type' => 'standard', 'subtype' => 'number', 'name' => '_default_calendar_list_range_span', 'id' => '_default_calendar_list_range_span', 'class' => array('simcal-field-tiny', 'simcal-field-inline'), 'value' => strval($list_span), 'attributes' => array('min' => '1'))); $list_type = get_post_meta($post_id, '_default_calendar_list_range_type', true); simcal_print_field(array('type' => 'select', 'name' => '_default_calendar_list_range_type', 'id' => '_default_calendar_list_range_type', 'tooltip' => __('Range of events to show on each calendar page.', 'google-calendar-events'), 'class' => array('simcal-field-inline'), 'value' => $list_type, 'options' => array('monthly' => __('Month(s)', 'google-calendar-events'), 'weekly' => __('Week(s)', 'google-calendar-events'), 'daily' => __('Day(s)', 'google-calendar-events'), 'events' => __('Event(s)', 'google-calendar-events')))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_list_header"><?php _e('Hide Header', 'google-calendar-events'); ?> </label></th> <td> <?php $header = get_post_meta($post_id, '_default_calendar_list_header', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_list_header', 'id' => '_default_calendar_list_header', 'tooltip' => __('You can use this to hide the month header for this calendar.', 'google-calendar-events'), 'value' => 'yes' == $header ? 'yes' : 'no')); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_compact_list"><?php _e('Compact List', 'google-calendar-events'); ?> </label></th> <td> <?php $compact = get_post_meta($post_id, '_default_calendar_compact_list', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_compact_list', 'id' => '_default_calendar_compact_list', 'tooltip' => __('Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events'), 'value' => 'yes' == $compact ? 'yes' : 'no')); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_limit_visible_events"><?php _e('Limit Visible Events', 'google-calendar-events'); ?> </label></th> <td> <?php $limit = get_post_meta($post_id, '_default_calendar_limit_visible_events', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_limit_visible_events', 'id' => '_default_calendar_limit_visible_events', 'value' => 'yes' == $limit ? 'yes' : 'no', 'class' => array('simcal-field-show-next'), 'attributes' => array('data-show-next-if-value' => 'yes'))); $visible_events = absint(get_post_meta($post_id, '_default_calendar_visible_events', true)); $visible_events = $visible_events > 0 ? $visible_events : 3; simcal_print_field(array('type' => 'standard', 'subtype' => 'number', 'name' => '_default_calendar_visible_events', 'id' => '_default_calendar_visible_events', 'tooltip' => __('Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events'), 'class' => array('simcal-field-tiny'), 'value' => $visible_events, 'attributes' => array('min' => '1'))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_event_bubbles_action"><?php _e('Expand Multi-day Events', 'google-calendar-events'); ?> </label></th> <td> <?php $post_meta = get_post_meta($post_id); if (!is_array($post_meta) && !empty($post_meta)) { $multi_day_value = 'current_day_only'; } else { $multi_day_value = get_post_meta($post_id, '_default_calendar_expand_multi_day_events', true); } simcal_print_field(array('type' => 'select', 'name' => '_default_calendar_expand_multi_day_events', 'id' => '_default_calendar_expand_multi_day_events', 'tooltip' => __('For events spanning multiple days, you can display them on each day of the event, ' . 'only on the first day of the event, or on all days of the event, but only up to the current day. ' . 'Third option applies to list views only.', 'google-calendar-events'), 'value' => $multi_day_value, 'options' => array('yes' => __('Yes, display on all days of event', 'google-calendar-events'), 'no' => __('No, display only on first day of event', 'google-calendar-events'), 'current_day_only' => __('No, display on all days of event up to current day (list view only)', 'google-calendar-events')), 'default' => 'yes')); ?> </td> </tr> </tbody> <?php // TODO Defaults repeated here and in process_meta(). Need to consolidate at some point. $settings = get_option('simple-calendar_settings_calendars'); $default_theme = isset($settings['default-calendar']['theme']) ? $settings['default-calendar']['theme'] : 'light'; $default_today_color = isset($settings['default-calendar']['today_color']) ? $settings['default-calendar']['today_color'] : '#1e73be'; $default_days_events_color = isset($settings['default-calendar']['days_events_color']) ? $settings['default-calendar']['days_events_color'] : '#000000'; ?> <tbody class="simcal-panel-section"> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_style_theme"><?php _e('Theme', 'google-calendar-events'); ?> </label></th> <td> <?php $saved = get_post_meta($post_id, '_default_calendar_style_theme', true); $value = !$saved ? $default_theme : $saved; simcal_print_field(array('type' => 'select', 'name' => '_default_calendar_style_theme', 'id' => '_default_calendar_style_theme', 'value' => $value, 'tooltip' => __('Choose a calendar theme to match your site theme.', 'google-calendar-events'), 'options' => array('light' => __('Light', 'google-calendar-events'), 'dark' => __('Dark', 'google-calendar-events')))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_style_today"><?php _e('Today', 'google-calendar-events'); ?> </label></th> <td> <?php $saved = get_post_meta($post_id, '_default_calendar_style_today', true); $value = !$saved ? $default_today_color : $saved; simcal_print_field(array('type' => 'standard', 'subtype' => 'color-picker', 'name' => '_default_calendar_style_today', 'id' => '_default_calendar_style_today', 'value' => $value, 'tooltip' => __("This option will set the background color for today's date. It will change the day number background and the border around the current day.", 'google-calendar-events'))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_style_days_events"><?php _e('Days with Events', 'google-calendar-events'); ?> </label></th> <td> <?php $saved = get_post_meta($post_id, '_default_calendar_style_days_events', true); $value = !$saved ? $default_days_events_color : $saved; simcal_print_field(array('type' => 'standard', 'subtype' => 'color-picker', 'name' => '_default_calendar_style_days_events', 'id' => '_default_calendar_style_days_events', 'value' => $value, 'tooltip' => __('This setting will modify the day number background for any days that have events on them.', 'google-calendar-events'))); ?> </td> </tr> </tbody> <?php ?> </table> <?php }
/** * Extend the calendar section panel of the settings meta box. * * @since 3.0.0 * * @param int $post_id */ public function add_settings_meta_calendar_panel($post_id) { ?> <table id="default-calendar-settings"> <thead> <tr><th colspan="2"><?php _e('Default calendar', 'google-calendar-events'); ?> </th></tr> </thead> <tbody class="simcal-panel-section"> <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> <th><label for="_default_calendar_event_bubbles_action"><?php _e('Event bubbles', 'google-calendar-events'); ?> </label></th> <td> <?php $bubbles = get_post_meta($post_id, '_default_calendar_event_bubble_trigger', true); simcal_print_field(array('type' => 'radio', 'inline' => 'inline', 'name' => '_default_calendar_event_bubble_trigger', 'id' => '_default_calendar_event_bubble_trigger', 'tooltip' => __('Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events'), 'value' => $bubbles ? $bubbles : 'hover', 'default' => 'hover', 'options' => array('click' => __('Click', 'google-calendar-events'), 'hover' => __('Hover', 'google-calendar-events')))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> <th><label for="_default_calendar_trim_titles"><?php _e('Trim event titles', 'google-calendar-events'); ?> </label></th> <td> <?php $trim = get_post_meta($post_id, '_default_calendar_trim_titles', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_trim_titles', 'id' => '_default_calendar_trim_titles', 'class' => array('simcal-field-show-next'), 'value' => 'yes' == $trim ? 'yes' : 'no', 'attributes' => array('data-show-next-if-value' => 'yes'))); simcal_print_field(array('type' => 'standard', 'subtype' => 'number', 'name' => '_default_calendar_trim_titles_chars', 'id' => '_default_calendar_trim_titles_chars', 'tooltip' => __('Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events'), 'class' => array('simcal-field-tiny'), 'value' => 'yes' == $trim ? strval(max(absint(get_post_meta($post_id, '_default_calendar_trim_titles_chars', true)), 1)) : '20', 'attributes' => array('min' => '1'))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_list_grouped_span"><?php _e('Span', 'google-calendar-events'); ?> </label></th> <td> <?php $list_span = max(absint(get_post_meta($post_id, '_default_calendar_list_range_span', true)), 1); simcal_print_field(array('type' => 'standard', 'subtype' => 'number', 'name' => '_default_calendar_list_range_span', 'id' => '_default_calendar_list_range_span', 'class' => array('simcal-field-tiny', 'simcal-field-inline'), 'value' => strval($list_span), 'attributes' => array('min' => '1'))); $list_type = get_post_meta($post_id, '_default_calendar_list_range_type', true); simcal_print_field(array('type' => 'select', 'name' => '_default_calendar_list_range_type', 'id' => '_default_calendar_list_range_type', 'tooltip' => __('Range of events to show on each calendar page.', 'google-calendar-events'), 'class' => array('simcal-field-inline'), 'value' => $list_type, 'options' => array('monthly' => __('Month(s)', 'google-calendar-events'), 'weekly' => __('Week(s)', 'google-calendar-events'), 'daily' => __('Day(s)', 'google-calendar-events'), 'events' => __('Event(s)', 'google-calendar-events')))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_list_header"><?php _e('Hide header', 'google-calendar-events'); ?> </label></th> <td> <?php $header = get_post_meta($post_id, '_default_calendar_list_header', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_list_header', 'id' => '_default_calendar_list_header', 'tooltip' => __('You can use this to hide the month header for this calendar.', 'google-calendar-events'), 'value' => 'yes' == $header ? 'yes' : 'no')); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_compact_list"><?php _e('Compact list', 'google-calendar-events'); ?> </label></th> <td> <?php $compact = get_post_meta($post_id, '_default_calendar_compact_list', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_compact_list', 'id' => '_default_calendar_compact_list', 'tooltip' => __('Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events'), 'value' => 'yes' == $compact ? 'yes' : 'no')); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_limit_visible_events"><?php _e('Limit visible events', 'google-calendar-events'); ?> </label></th> <td> <?php $limit = get_post_meta($post_id, '_default_calendar_limit_visible_events', true); simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_limit_visible_events', 'id' => '_default_calendar_limit_visible_events', 'value' => 'yes' == $limit ? 'yes' : 'no', 'class' => array('simcal-field-show-next'), 'attributes' => array('data-show-next-if-value' => 'yes'))); $visible_events = absint(get_post_meta($post_id, '_default_calendar_visible_events', true)); $visible_events = $visible_events > 0 ? $visible_events : 3; simcal_print_field(array('type' => 'standard', 'subtype' => 'number', 'name' => '_default_calendar_visible_events', 'id' => '_default_calendar_visible_events', 'tooltip' => __('Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events'), 'class' => array('simcal-field-tiny'), 'value' => $visible_events, 'attributes' => array('min' => '1'))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_event_bubbles_action"><?php _e('Expand multi day events', 'google-calendar-events'); ?> </label></th> <td> <?php simcal_print_field(array('type' => 'checkbox', 'name' => '_default_calendar_expand_multi_day_events', 'id' => '_default_calendar_expand_multi_day_events', 'tooltip' => __('Show events spanning multiple days on each day.', 'google-calendar-events'), 'value' => get_post_meta($post_id, '_default_calendar_expand_multi_day_events', true))); ?> </td> </tr> </tbody> <?php $settings = get_option('simple-calendar_settings_calendars'); $default_theme = isset($settings['default-calendar']['theme']) ? $settings['default-calendar']['theme'] : 'light'; $default_today_color = '#1e73be'; $default_days_events_color = '#000000'; ?> <tbody class="simcal-panel-section"> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_style_theme"><?php _e('Theme', 'google-calendar-events'); ?> </label></th> <td> <?php $saved = get_post_meta($post_id, '_default_calendar_style_theme', true); $value = !$saved ? $default_theme : $saved; simcal_print_field(array('type' => 'select', 'name' => '_default_calendar_style_theme', 'id' => '_default_calendar_style_theme', 'value' => $value, 'tooltip' => __('Choose a calendar theme to match your site theme.', 'google-calendar-events'), 'options' => array('light' => __('Light', 'google-calendar-events'), 'dark' => __('Dark', 'google-calendar-events')))); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_style_today"><?php _e('Today', 'google-calendar-events'); ?> </label></th> <td> <?php $saved = get_post_meta($post_id, '_default_calendar_style_today', true); $value = !$saved ? $default_today_color : $saved; simcal_print_field(array('type' => 'standard', 'subtype' => 'color-picker', 'name' => '_default_calendar_style_today', 'id' => '_default_calendar_style_today', 'value' => $value)); ?> </td> </tr> <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> <th><label for="_default_calendar_style_days_events"><?php _e('Days with events', 'google-calendar-events'); ?> </label></th> <td> <?php $saved = get_post_meta($post_id, '_default_calendar_style_days_events', true); $value = !$saved ? $default_days_events_color : $saved; simcal_print_field(array('type' => 'standard', 'subtype' => 'color-picker', 'name' => '_default_calendar_style_days_events', 'id' => '_default_calendar_style_days_events', 'value' => $value)); ?> </td> </tr> </tbody> <?php ?> </table> <?php }