示例#1
0
    /**
     * 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>&nbsp;&nbsp;
							<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>&nbsp;&nbsp;
								<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>&nbsp;&nbsp;
							<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>&nbsp;&nbsp;
								<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 
    }
/**
 * Common scripts variables.
 *
 * Variables to print in scripts localization
 *
 * @since  3.0.0
 *
 * @return array
 */
function simcal_common_scripts_variables()
{
    $vars = array('ajax_url' => \SimpleCalendar\plugin()->ajax_url(), 'nonce' => wp_create_nonce('simcal'), 'locale' => \SimpleCalendar\plugin()->locale, 'text_dir' => is_rtl() ? 'rtl' : 'ltr', 'months' => array('full' => simcal_get_calendar_names_i18n('month', 'full'), 'short' => simcal_get_calendar_names_i18n('month', 'short')), 'days' => array('full' => simcal_get_calendar_names_i18n('day', 'full'), 'short' => simcal_get_calendar_names_i18n('day', 'short')), 'meridiem' => simcal_get_calendar_names_i18n('meridiem'));
    return array_merge($vars, apply_filters('simcal_common_scripts_variables', array()));
}
    /**
     * Default calendar grid markup.
     *
     * @since  3.0.0
     */
    public function html()
    {
        $calendar = $this->calendar;
        if ($calendar instanceof Default_Calendar) {
            ?>
			<table class="simcal-calendar-grid"
			       data-event-bubble-trigger="<?php 
            echo $calendar->event_bubble_trigger;
            ?>
">
				<thead class="simcal-calendar-head">
					<tr>
						<?php 
            if (!$calendar->static) {
                ?>
							<th class="simcal-nav simcal-prev-wrapper" colspan="1">
								<button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php 
                _e('Previous Month', 'google-calendar-events');
                ?>
"><i class="simcal-icon-left"></i></button>
							</th>
						<?php 
            }
            ?>
						<th colspan="<?php 
            echo $calendar->static ? '7' : '5';
            ?>
"
						    class="simcal-nav simcal-current"
						    data-calendar-current="<?php 
            echo $calendar->start;
            ?>
">
							<?php 
            echo '<h3>';
            // Display month and year according to user date format preference.
            $year_pos = strcspn($calendar->date_format, 'Y y');
            $month_pos = strcspn($calendar->date_format, 'F M m n');
            $current = array('month' => 'F', 'year' => 'Y');
            if ($year_pos < $month_pos) {
                $current = array_reverse($current);
            }
            foreach ($current as $k => $v) {
                echo ' <span class="simcal-current-' . $k, '">' . date_i18n($v, $calendar->start) . '</span> ';
            }
            echo '</h3>';
            ?>
						</th>
						<?php 
            if (!$calendar->static) {
                ?>
							<th class="simcal-nav simcal-next-wrapper" colspan="1">
								<button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php 
                _e('Next Month', 'google-calendar-events');
                ?>
"><i class="simcal-icon-right"></i></button>
							</th>
						<?php 
            }
            ?>
					</tr>
					<tr>
						<?php 
            // Print day names in short or long form for different viewport sizes.
            $week_starts = $calendar->week_starts;
            $week_days_short = simcal_get_calendar_names_i18n('day', 'short');
            $week_days_full = simcal_get_calendar_names_i18n('day', 'full');
            for ($i = $week_starts; $i <= 6; $i++) {
                ?>
							<th class="simcal-week-day simcal-week-day-<?php 
                echo $i;
                ?>
"
							    data-screen-small="<?php 
                echo substr($week_days_short[$i], 0, 1);
                ?>
"
							    data-screen-medium="<?php 
                echo $week_days_short[$i];
                ?>
"
							    data-screen-large="<?php 
                echo $week_days_full[$i];
                ?>
"><?php 
                echo $week_days_short[$i];
                ?>
</th>
							<?php 
            }
            if ($week_starts !== 0) {
                for ($i = 0; $i < $week_starts; $i++) {
                    ?>
								<th class="simcal-week-day simcal-week-day-<?php 
                    echo $i;
                    ?>
"
								    data-screen-small="<?php 
                    echo substr($week_days_short[$i], 0, 1);
                    ?>
"
								    data-screen-medium="<?php 
                    echo $week_days_short[$i];
                    ?>
"
								    data-screen-large="<?php 
                    echo $week_days_full[$i];
                    ?>
"><?php 
                    echo $week_days_short[$i];
                    ?>
</th>
								<?php 
                }
            }
            ?>
					</tr>
				</thead>

				<?php 
            echo $this->draw_month(date('n', $calendar->start), date('Y', $calendar->start));
            ?>

			</table>
			<?php 
            echo '<div class="simcal-ajax-loader simcal-spinner-top" style="display: none;"><i class="simcal-icon-spinner simcal-icon-spin"></i></div>';
        }
    }