コード例 #1
0
function edit_mc_templates()
{
    global $wpdb;
    $mcdb = $wpdb;
    $templates = get_option('mc_templates');
    if (!empty($_POST)) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
    }
    if (isset($_POST['mc_grid_template'])) {
        $mc_grid_template = $_POST['mc_grid_template'];
        $templates['grid'] = $mc_grid_template;
        update_option('mc_templates', $templates);
        update_option('mc_use_grid_template', empty($_POST['mc_use_grid_template']) ? 0 : 1);
        echo "<div class=\"updated\"><p><strong>" . __('Grid Output Template saved', 'my-calendar') . ".</strong></p></div>";
    }
    if (isset($_POST['mc_rss_template'])) {
        $mc_rss_template = $_POST['mc_rss_template'];
        $templates['rss'] = $mc_rss_template;
        update_option('mc_templates', $templates);
        update_option('mc_use_rss_template', empty($_POST['mc_use_rss_template']) ? 0 : 1);
        echo "<div class=\"updated\"><p><strong>" . __('RSS Feed Output Template saved', 'my-calendar') . ".</strong></p></div>";
    }
    if (isset($_POST['mc_list_template'])) {
        $mc_list_template = $_POST['mc_list_template'];
        $templates['list'] = $mc_list_template;
        update_option('mc_templates', $templates);
        update_option('mc_use_list_template', empty($_POST['mc_use_list_template']) ? 0 : 1);
        echo "<div class=\"updated\"><p><strong>" . __('List Output Template saved', 'my-calendar') . ".</strong></p></div>";
    }
    if (isset($_POST['mc_mini_template'])) {
        $mc_mini_template = $_POST['mc_mini_template'];
        $templates['mini'] = $mc_mini_template;
        update_option('mc_templates', $templates);
        update_option('mc_use_mini_template', empty($_POST['mc_use_mini_template']) ? 0 : 1);
        echo "<div class=\"updated\"><p><strong>" . __('Mini Output Template saved', 'my-calendar') . ".</strong></p></div>";
    }
    if (isset($_POST['mc_details_template'])) {
        $mc_details_template = $_POST['mc_details_template'];
        $templates['details'] = $mc_details_template;
        update_option('mc_templates', $templates);
        update_option('mc_use_details_template', empty($_POST['mc_use_details_template']) ? 0 : 1);
        echo "<div class=\"updated\"><p><strong>" . __('Event Details Template saved', 'my-calendar') . ".</strong></p></div>";
    }
    global $grid_template, $list_template, $mini_template, $single_template, $rss_template;
    $mc_grid_template = stripslashes($templates['grid'] != '' ? $templates['grid'] : $grid_template);
    $mc_use_grid_template = get_option('mc_use_grid_template');
    $mc_rss_template = stripslashes($templates['rss'] != '' ? $templates['rss'] : $rss_template);
    $mc_use_rss_template = get_option('mc_use_rss_template');
    $mc_list_template = stripslashes($templates['list'] != '' ? $templates['list'] : $list_template);
    $mc_use_list_template = get_option('mc_use_list_template');
    $mc_mini_template = stripslashes($templates['mini'] != '' ? $templates['mini'] : $mini_template);
    $mc_use_mini_template = get_option('mc_use_mini_template');
    $mc_details_template = stripslashes($templates['details'] != '' ? $templates['details'] : $single_template);
    $mc_use_details_template = get_option('mc_use_details_template');
    ?>
    <div class="wrap jd-my-calendar">
	<?php 
    my_calendar_check_db();
    ?>
    <h2><?php 
    _e('My Calendar Information Templates', 'my-calendar');
    ?>
</h2>
	
<div class="postbox-container jcd-wide">
<div class="metabox-holder">
	
	<p><?php 
    _e('Advanced users may customize the HTML template for each event. This page lets you create a customized view of your events in each context. All available template tags are documented on the Help page. These default templates are based on the default views with all output enabled. <strong>Custom templates will override any other output rules in your settings.</strong>', 'my-calendar');
    ?>
 <a href="<?php 
    echo admin_url("admin.php?page=my-calendar-help#templates");
    ?>
"><?php 
    _e("Templates Help", 'my-calendar');
    ?>
</a> &raquo;</p>

	<div class="ui-sortable meta-box-sortables">   
	<div class="postbox">
		<h3><?php 
    _e('My Calendar: Grid Event Template', 'my-calendar');
    ?>
</h3>
		<div class="inside">	
		<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-templates");
    ?>
">
		<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
		<p>
		<input type="checkbox" id="mc_use_grid_template" name="mc_use_grid_template" value="1" <?php 
    mc_is_checked('mc_use_grid_template', 1);
    ?>
/> <label for="mc_use_grid_template"><?php 
    _e('Use this grid event template', 'my-calendar');
    ?>
</label>
		</p>
		<p>
		<label for="mc_grid_template"><?php 
    _e('Your custom template for events in the calendar grid output.', 'my-calendar');
    ?>
</label><br /><textarea id="mc_grid_template" name="mc_grid_template" class="template-editor" rows="16" cols="76"><?php 
    echo $mc_grid_template;
    ?>
</textarea>
		</p>
		<p>
			<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save Grid Template', 'my-calendar');
    ?>
" />
		</p>
		</form>
		</div>
	</div>
	</div>

	<div class="ui-sortable meta-box-sortables">   
	<div class="postbox">
		<h3><?php 
    _e('My Calendar: List Event Template', 'my-calendar');
    ?>
</h3>
		<div class="inside">	
		<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-templates");
    ?>
">
		<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
		<p>
		<input type="checkbox" id="mc_use_list_template" name="mc_use_list_template" value="1" <?php 
    mc_is_checked('mc_use_list_template', 1);
    ?>
/> <label for="mc_use_list_template"><?php 
    _e('Use this list event template', 'my-calendar');
    ?>
</label>
		</p>
		<p>
		<label for="mc_list_template"><?php 
    _e('Your custom template for events in calendar list output.', 'my-calendar');
    ?>
</label><br /><textarea id="mc_list_template" name="mc_list_template" class="template-editor" rows="16" cols="76"><?php 
    echo $mc_list_template;
    ?>
</textarea>
		</p>
		<p>
			<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save List Template', 'my-calendar');
    ?>
" />
		</p>
		</form>
		</div>
	</div>
	</div>

	<div class="ui-sortable meta-box-sortables">   
	<div class="postbox">
		<h3><?php 
    _e('My Calendar: Mini Calendar Template', 'my-calendar');
    ?>
</h3>
		<div class="inside">	
		<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-templates");
    ?>
">
		<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
		<p>
		<input type="checkbox" id="mc_use_mini_template" name="mc_use_mini_template" value="1" <?php 
    mc_is_checked('mc_use_mini_template', 1);
    ?>
/> <label for="mc_use_mini_template"><?php 
    _e('Use this mini event template', 'my-calendar');
    ?>
</label>
		</p>
		<p>
		<label for="mc_mini_template"><?php 
    _e('Your custom template for events in sidebar/mini calendar output.', 'my-calendar');
    ?>
</label><br /><textarea id="mc_mini_template" name="mc_mini_template" rows="16" cols="76" class="template-editor"><?php 
    echo $mc_mini_template;
    ?>
</textarea>
		</p>
		<p>
			<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save Mini Template', 'my-calendar');
    ?>
" />
		</p>
		</form>
		</div>
	</div>
	</div>

	<div class="ui-sortable meta-box-sortables">   
	<div class="postbox">
		<h3><?php 
    _e('My Calendar: Event Details Page Template', 'my-calendar');
    ?>
</h3>
		<div class="inside">	
		<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-templates");
    ?>
">
		<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
		<p>
		<input type="checkbox" id="mc_use_details_template" name="mc_use_details_template" value="1" <?php 
    mc_is_checked('mc_use_details_template', 1);
    ?>
/> <label for="mc_use_details_template"><?php 
    _e('Use this details template', 'my-calendar');
    ?>
</label>
		</p>
		<p>
		<label for="mc_details_template"><?php 
    _e('Your custom template for events on the event details page.', 'my-calendar');
    ?>
</label><br /><textarea id="mc_details_template" name="mc_details_template" rows="16" cols="76" class="template-editor"><?php 
    echo $mc_details_template;
    ?>
</textarea>
		</p>
		<p>
			<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save Details Template', 'my-calendar');
    ?>
" />
		</p>
		</form>
		</div>
	</div>
	</div>
	
	<div class="ui-sortable meta-box-sortables">   
	<div class="postbox">
		<h3><?php 
    _e('My Calendar: RSS Event Template', 'my-calendar');
    ?>
</h3>
		<div class="inside">
		<p><?php 
    _e('Notice: HTML templates are very forgiving of errors. RSS templates are not. Be sure to test your changes.', 'my-calendar');
    ?>
</p>
		<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-templates");
    ?>
">
		<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
		<p>
		<input type="checkbox" id="mc_use_rss_template" name="mc_use_rss_template" value="1" <?php 
    mc_is_checked('mc_use_rss_template', 1);
    ?>
/> <label for="mc_use_grid_template"><?php 
    _e('Use this custom RSS event template', 'my-calendar');
    ?>
</label>
		</p>
		<p>
		<label for="mc_rss_template"><?php 
    _e('Your custom template for events in the RSS feed.', 'my-calendar');
    ?>
</label><br /><textarea id="mc_rss_template" name="mc_rss_template" class="template-editor" rows="16" cols="76"><?php 
    echo $mc_rss_template;
    ?>
</textarea>
		</p>
		<p>
			<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save RSS Template', 'my-calendar');
    ?>
" />
		</p>
		</form>
		</div>
	</div>
	</div>
</div>
</div>
	<?php 
    mc_show_sidebar('templates');
}
コード例 #2
0
function my_calendar_manage_locations()
{
    global $wpdb;
    $mcdb = $wpdb;
    ?>
	<div class="wrap jd-my-calendar">
	<?php 
    my_calendar_check_db();
    // We do some checking to see what we're doing
    mc_update_location_controls();
    mc_mass_delete_locations();
    if (!empty($_POST) && (!isset($_POST['mc_locations']) && !isset($_POST['mass_delete']))) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
    }
    if (isset($_POST['mode']) && $_POST['mode'] == 'add') {
        $add = array('location_label' => $_POST['location_label'], 'location_street' => $_POST['location_street'], 'location_street2' => $_POST['location_street2'], 'location_city' => $_POST['location_city'], 'location_state' => $_POST['location_state'], 'location_postcode' => $_POST['location_postcode'], 'location_region' => $_POST['location_region'], 'location_country' => $_POST['location_country'], 'location_url' => $_POST['location_url'], 'location_longitude' => $_POST['location_longitude'], 'location_latitude' => $_POST['location_latitude'], 'location_zoom' => $_POST['location_zoom'], 'location_phone' => $_POST['location_phone'], 'location_phone2' => $_POST['location_phone2'], 'location_access' => isset($_POST['location_access']) ? serialize($_POST['location_access']) : '');
        $results = mc_insert_location($add);
        do_action('mc_save_location', $results, $add);
        if ($results) {
            echo "<div class=\"updated\"><p><strong>" . __('Location added successfully', 'my-calendar') . "</strong></p></div>";
        } else {
            echo "<div class=\"error\"><p><strong>" . __('Location could not be added to database', 'my-calendar') . "</strong></p></div>";
        }
    } else {
        if (isset($_GET['location_id']) && $_GET['mode'] == 'delete') {
            $sql = "DELETE FROM " . my_calendar_locations_table() . " WHERE location_id=" . (int) $_GET['location_id'];
            $results = $mcdb->query($sql);
            do_action('mc_delete_location', $results, (int) $_GET['location_id']);
            if ($results) {
                echo "<div class=\"updated\"><p><strong>" . __('Location deleted successfully', 'my-calendar') . "</strong></p></div>";
            } else {
                echo "<div class=\"error\"><p><strong>" . __('Location could not be deleted', 'my-calendar') . "</strong></p></div>";
            }
        } else {
            if (isset($_GET['mode']) && isset($_GET['location_id']) && $_GET['mode'] == 'edit' && !isset($_POST['mode'])) {
                $cur_loc = (int) $_GET['location_id'];
                mc_show_location_form('edit', $cur_loc);
            } else {
                if (isset($_POST['location_id']) && isset($_POST['location_label']) && $_POST['mode'] == 'edit') {
                    $update = array('location_label' => $_POST['location_label'], 'location_street' => $_POST['location_street'], 'location_street2' => $_POST['location_street2'], 'location_city' => $_POST['location_city'], 'location_state' => $_POST['location_state'], 'location_postcode' => $_POST['location_postcode'], 'location_region' => $_POST['location_region'], 'location_country' => $_POST['location_country'], 'location_url' => $_POST['location_url'], 'location_longitude' => $_POST['location_longitude'], 'location_latitude' => $_POST['location_latitude'], 'location_zoom' => $_POST['location_zoom'], 'location_phone' => $_POST['location_phone'], 'location_phone2' => $_POST['location_phone2'], 'location_access' => isset($_POST['location_access']) ? serialize($_POST['location_access']) : '');
                    $where = array('location_id' => (int) $_POST['location_id']);
                    $results = mc_modify_location($update, $where);
                    do_action('mc_modify_location', $where, $update);
                    if ($results === false) {
                        echo "<div class=\"error\"><p><strong>" . __('Location could not be edited.', 'my-calendar') . "</strong></p></div>";
                    } else {
                        if ($results == 0) {
                            echo "<div class=\"updated error\"><p><strong>" . __('Location was not changed.', 'my-calendar') . "</strong></p></div>";
                        } else {
                            echo "<div class=\"updated\"><p><strong>" . __('Location edited successfully', 'my-calendar') . "</strong></p></div>";
                        }
                    }
                    $cur_loc = (int) $_POST['location_id'];
                    mc_show_location_form('edit', $cur_loc);
                }
            }
        }
    }
    if (isset($_GET['mode']) && $_GET['mode'] != 'edit' || isset($_POST['mode']) && $_POST['mode'] != 'edit' || !isset($_GET['mode']) && !isset($_POST['mode'])) {
        mc_show_location_form('add');
    }
}
コード例 #3
0
function edit_my_calendar_styles()
{
    $dir = plugin_dir_path(__FILE__);
    if (isset($_POST['mc_edit_style'])) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        $my_calendar_style = isset($_POST['style']) ? stripcslashes($_POST['style']) : false;
        $mc_css_file = stripcslashes($_POST['mc_css_file']);
        $stylefile = mc_get_style_path($mc_css_file);
        $wrote_styles = $my_calendar_style !== false ? mc_write_styles($stylefile, $my_calendar_style) : 'disabled';
        if ($wrote_styles == true) {
            // updates from pre version 1.7.0
            delete_option('mc_file_permissions');
            delete_option('mc_style');
        }
        if ($wrote_styles === 'disabled') {
            $message = "<p>" . __("Styles are disabled, and were not edited.", 'my-calendar') . "</p>";
        } else {
            $message = $wrote_styles == true ? '<p>' . __('The stylesheet has been updated.', 'my-calendar') . '</p>' : '<p><strong>' . __('Write Error! Please verify write permissions on the style file.', 'my-calendar') . '</strong></p>';
        }
        $mc_show_css = empty($_POST['mc_show_css']) ? '' : stripcslashes($_POST['mc_show_css']);
        update_option('mc_show_css', $mc_show_css);
        $use_styles = empty($_POST['use_styles']) ? '' : 'true';
        update_option('mc_use_styles', $use_styles);
        if (!empty($_POST['reset_styles'])) {
            $stylefile = mc_get_style_path();
            $styles = mc_default_style();
            $wrote_old_styles = mc_write_styles($stylefile, $styles);
            if ($wrote_old_styles) {
                $message .= "<p>" . __('Stylesheet reset to default.', 'my-calendar') . "</p>";
            }
        }
        $message .= "<p><strong>" . __('Style Settings Saved', 'my-calendar') . ".</strong></p>";
        echo "<div id='message' class='updated fade'>{$message}</div>";
    }
    if (isset($_POST['mc_choose_style'])) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        $mc_css_file = stripcslashes($_POST['mc_css_file']);
        update_option('mc_css_file', $mc_css_file);
        $message = '<p><strong>' . __('New theme selected.', 'my-calendar') . '</strong></p>';
        echo "<div id='message' class='updated fade'>{$message}</div>";
    }
    $mc_show_css = get_option('mc_show_css');
    $stylefile = mc_get_style_path();
    if ($stylefile) {
        $f = fopen($stylefile, 'r');
        $file = fread($f, filesize($stylefile));
        $my_calendar_style = $file;
        fclose($f);
        $mc_current_style = mc_default_style();
    } else {
        $mc_current_style = '';
        $my_calendar_style = __('Sorry. The file you are looking for doesn\'t appear to exist. Please check your file name and location!', 'my-calendar');
    }
    ?>
	<div class="wrap jd-my-calendar">
	<?php 
    my_calendar_check_db();
    ?>
	<h2><?php 
    _e('My Calendar Styles', 'my-calendar');
    ?>
</h2>
	<div class="postbox-container jcd-wide">
		<div class="metabox-holder">
			<div class="ui-sortable meta-box-sortables">
				<div class="postbox">
					<h3><?php 
    _e('Calendar Style Settings', 'my-calendar');
    ?>
</h3>

					<div class="inside">

						<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-styles");
    ?>
">
							<div><input type="hidden" name="_wpnonce"
							            value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
"/></div>
							<div><input type="hidden" value="true" name="mc_choose_style"/></div>
							<fieldset>
								<p>
									<label
										for="mc_css_file"><?php 
    _e('Select My Calendar Theme', 'my-calendar');
    ?>
</label>
									<select name="mc_css_file" id="mc_css_file"><?php 
    $custom_directory = str_replace('/my-calendar/', '', $dir) . '/my-calendar-custom/styles/';
    $directory = dirname(__FILE__) . '/styles/';
    $files = @my_csslist($custom_directory);
    if (!empty($files)) {
        echo "<optgroup label='" . __('Your Custom Stylesheets', 'my-calendar') . "'>\n";
        foreach ($files as $value) {
            $filepath = mc_get_style_path($value);
            $path = pathinfo($filepath);
            if ($path['extension'] == 'css') {
                $test = "mc_custom_" . $value;
                $selected = get_option('mc_css_file') == $test ? " selected='selected'" : "";
                echo "<option value='" . esc_attr('mc_custom_' . $value) . "'{$selected}>{$value}</option>\n";
            }
        }
        echo "</optgroup>";
    }
    $files = my_csslist($directory);
    echo "<optgroup label='" . __('Installed Stylesheets', 'my-calendar') . "'>\n";
    foreach ($files as $value) {
        $filepath = mc_get_style_path($value);
        $path = pathinfo($filepath);
        if ($path['extension'] == 'css') {
            $selected = get_option('mc_css_file') == $value ? " selected='selected'" : "";
            echo "<option value='" . esc_attr($value) . "'{$selected}>{$value}</option>\n";
        }
    }
    echo "</optgroup>";
    ?>
									</select>
									<input type="submit" name="save" class="button-secondary"
									       value="<?php 
    _e('Choose Style', 'my-calendar');
    ?>
"/>
								</p>
							</fieldset>
						</form>
						<hr/>
						<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-styles");
    ?>
">
							<div><input type="hidden" name="_wpnonce"
							            value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
"/></div>
							<div><input type="hidden" value="true" name="mc_edit_style"/>
								<input type="hidden" name="mc_css_file"
								       value="<?php 
    esc_attr_e(get_option('mc_css_file'));
    ?>
"/>
							</div>
							<fieldset style="position:relative;">
								<legend><?php 
    _e('CSS Style Options', 'my-calendar');
    ?>
</legend>
								<p>
									<label
										for="mc_show_css"><?php 
    _e('Apply CSS on these pages (comma separated IDs)', 'my-calendar');
    ?>
</label>
									<input type="text" id="mc_show_css" name="mc_show_css"
									       value="<?php 
    esc_attr_e($mc_show_css);
    ?>
"/>
								</p>

								<p>
									<input type="checkbox" id="reset_styles"
									       name="reset_styles" <?php 
    if (mc_is_custom_style(get_option('mc_css_file'))) {
        echo "disabled='disabled'";
    }
    ?>
 /> <label
										for="reset_styles"><?php 
    _e('Restore My Calendar stylesheet', 'my-calendar');
    ?>
</label>
									<input type="checkbox" id="use_styles"
									       name="use_styles" <?php 
    mc_is_checked('mc_use_styles', 'true');
    ?>
 />
									<label
										for="use_styles"><?php 
    _e('Disable My Calendar Stylesheet', 'my-calendar');
    ?>
</label>
								</p>
								<p>						
								<?php 
    if (mc_is_custom_style(get_option('mc_css_file'))) {
        _e('The editor is not available for custom CSS files. You should edit your custom CSS locally, then upload your changes.', 'my-calendar');
    } else {
        ?>
									<label
										for="style"><?php 
        _e('Edit the stylesheet for My Calendar', 'my-calendar');
        ?>
</label><br/><textarea
										class="style-editor" id="style" name="style" rows="30"
										cols="80"<?php 
        if (get_option('mc_use_styles') == 'true') {
            echo "disabled='disabled'";
        }
        ?>
><?php 
        echo $my_calendar_style;
        ?>
</textarea>

								<?php 
    }
    ?>
								</p>
								<p>
									<input type="submit" name="save" class="button-primary button-adjust"
									       value="<?php 
    _e('Save Changes', 'my-calendar');
    ?>
"/>
								</p>
							</fieldset>
						</form>
						<?php 
    $left_string = normalize_whitespace($my_calendar_style);
    $right_string = normalize_whitespace($mc_current_style);
    if ($right_string) {
        // if right string is blank, there is no default
        if (isset($_GET['diff'])) {
            echo '<div class="wrap jd-my-calendar" id="diff">';
            echo wp_text_diff($left_string, $right_string, array('title' => __('Comparing Your Style with latest installed version of My Calendar', 'my-calendar'), 'title_right' => __('Latest (from plugin)', 'my-calendar'), 'title_left' => __('Current (in use)', 'my-calendar')));
            echo '</div>';
        } else {
            if (trim($left_string) != trim($right_string)) {
                echo '<div class="wrap jd-my-calendar">';
                echo '<div class="updated"><p>' . __('There have been updates to the stylesheet.', 'my-calendar') . ' <a href="' . admin_url("admin.php?page=my-calendar-styles&amp;diff#diff") . '">' . __('Compare Your Stylesheet with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
                echo '</div>';
            } else {
                echo '
						<div class="wrap jd-my-calendar">
							<p>' . __('Your stylesheet matches that included with My Calendar.', 'my-calendar') . '</p>
						</div>';
            }
        }
    }
    ?>
					</div>
				</div>
				<p><?php 
    _e('Resetting your stylesheet will set your stylesheet to the version currently distributed with the plug-in.', 'my-calendar');
    ?>
</p>
			</div>
		</div>
	</div>
	<?php 
    mc_show_sidebar();
    ?>
	</div><?php 
}
コード例 #4
0
function edit_my_calendar_groups()
{
    global $current_user, $wpdb, $users_entries;
    $mcdb = $wpdb;
    // First some quick cleaning up
    $edit = $save = false;
    $action = !empty($_POST['event_action']) ? $_POST['event_action'] : '';
    $event_id = !empty($_POST['event_id']) ? $_POST['event_id'] : '';
    $group_id = !empty($_POST['group_id']) ? $_POST['group_id'] : '';
    if (isset($_GET['mode'])) {
        if ($_GET['mode'] == 'edit') {
            $action = "edit";
            $event_id = (int) $_GET['event_id'];
            $group_id = (int) $_GET['group_id'];
        }
    }
    if (isset($_POST['event_action'])) {
        global $mc_output;
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            wp_die("Security check failed");
        }
        $proceed = false;
        switch ($_POST['event_action']) {
            case 'edit':
                if (isset($_POST['apply']) && is_array($_POST['apply'])) {
                    $mc_output = mc_check_group_data($action, $_POST);
                    foreach ($_POST['apply'] as $event_id) {
                        $response = my_calendar_save_group($action, $mc_output, $event_id);
                        echo $response;
                    }
                }
                break;
            case 'break':
                foreach ($_POST['break'] as $event_id) {
                    $update = array('event_group_id' => 0);
                    $formats = array('%d');
                    //$mcdb->show_errors();
                    $result = $mcdb->update(my_calendar_table(), $update, array('event_id' => $event_id), $formats, '%d');
                    //$mcdb->print_error();
                    $url = get_option('mc_uri') != '' && !is_numeric(get_option('mc_uri')) ? ' ' . sprintf(__('View <a href="%s">your calendar</a>.', 'my-calendar'), get_option('mc_uri')) : '';
                    if ($result === false) {
                        $message = "<div class='error'><p><strong>" . __('Error', 'my-calendar') . ":</strong>" . __('Event not updated.', 'my-calendar') . "{$url}</p></div>";
                    } else {
                        if ($result === 0) {
                            $message = "<div class='updated'><p>#{$event_id}: " . __('Nothing was changed in that update.', 'my-calendar') . "{$url}</p></div>";
                        } else {
                            $message = "<div class='updated'><p>#{$event_id}: " . __('Event updated successfully', 'my-calendar') . ".{$url}</p></div>";
                        }
                    }
                }
                break;
            case 'group':
                if (isset($_POST['group']) && is_array($_POST['group'])) {
                    $events = $_POST['group'];
                    sort($events);
                }
                foreach ($events as $event_id) {
                    $group_id = $events[0];
                    $update = array('event_group_id' => $group_id);
                    $formats = array('%d');
                    //$mcdb->show_errors();
                    $result = $mcdb->update(my_calendar_table(), $update, array('event_id' => $event_id), $formats, '%d');
                    //$mcdb->print_error();
                    if ($result === false) {
                        $message = "<div class='error'><p><strong>" . __('Error', 'my-calendar') . ":</strong>" . __('Event not grouped.', 'my-calendar') . "</p></div>";
                    } else {
                        if ($result === 0) {
                            $message = "<div class='updated'><p>#{$event_id}: " . __('Nothing was changed in that update.', 'my-calendar') . "</p></div>";
                        } else {
                            $message = "<div class='updated'><p>#{$event_id}: " . __('Event grouped successfully', 'my-calendar') . "</p></div>";
                        }
                    }
                }
                break;
        }
    }
    ?>

	<div class="wrap jd-my-calendar" id="my-calendar"><?php 
    my_calendar_check_db();
    if ($action == 'edit' || $action == 'edit' && $error_with_saving == 1) {
        ?>
			<div id="icon-edit" class="icon32"></div>		
			<h2><?php 
        _e('Edit Event Group', 'my-calendar');
        ?>
</h2>
			<?php 
        if (empty($event_id) || empty($group_id)) {
            echo "<div class=\"error\"><p>" . __("You must provide an event group id in order to edit it", 'my-calendar') . "</p></div>";
        } else {
            mc_edit_groups('edit', $event_id, $group_id);
        }
    } else {
        ?>
	
		<div id="icon-edit" class="icon32"></div>
		<h2><?php 
        _e('Manage Event Groups', 'my-calendar');
        ?>
</h2>
		<p>
			<?php 
        _e('Grouped events can be edited simultaneously. When you choose a group of events to edit, the form will be pre-filled with the content applicable to the member of the event group you started from. (e.g., if you click on the "Edit Group" link for the 3rd of a set of events, the boxes will use the content applicable to that event.). You will also receive a set of checkboxes which will indicate which events in the group should have these changes applied. (All grouped events can also be edited individually.)', 'my-calendar');
        ?>
		</p>

		<div class="postbox-container jcd-wide">
		<div class="metabox-holder">
			<div class="ui-sortable meta-box-sortables">
				<div class="postbox">	
					<h3><?php 
        _e('Manage Event Groups', 'my-calendar');
        ?>
</h3>
					<div class="inside">
						<p><?php 
        _e('Select an event group to edit.', 'my-calendar');
        ?>
</p>
					</div>
				</div>
			</div>
			<div class="ui-sortable meta-box-sortables">
				<div class="postbox">	
					<h3><?php 
        _e('Create/Modify Groups', 'my-calendar');
        ?>
</h3>
					<?php 
        mc_list_groups();
        ?>
				</div>
			</div>
		</div>
		</div><?php 
    }
    mc_show_sidebar();
    ?>
	</div><?php 
}
コード例 #5
0
function edit_my_calendar()
{
    global $current_user, $wpdb, $users_entries;
    $mcdb = $wpdb;
    if (get_option('ko_calendar_imported') != 'true') {
        if (function_exists('check_calendar')) {
            echo "<div id='message'class='updated'>";
            echo "<p>";
            _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?', 'my-calendar');
            echo "</p>";
            ?>
			<form method="post" action="<?php 
            echo admin_url('admin.php?page=my-calendar-config');
            ?>
">
				<div><input type="hidden" name="_wpnonce"
				            value="<?php 
            echo wp_create_nonce('my-calendar-nonce');
            ?>
"/>
				</div>
				<div>
					<input type="hidden" name="import" value="true"/>
					<input type="submit" value="<?php 
            _e('Import from Calendar', 'my-calendar');
            ?>
"
					       name="import-calendar" class="button-primary"/>
				</div>
			</form>
			<?php 
            echo "<p>";
            _e('Although it is possible that this import could fail to import your events correctly, it should not have any impact on your existing Calendar database. If you encounter any problems, <a href="http://www.joedolson.com/contact.php">please contact me</a>!', 'my-calendar');
            echo "</p>";
            echo "</div>";
        }
    }
    $action = !empty($_POST['event_action']) ? $_POST['event_action'] : '';
    $event_id = !empty($_POST['event_id']) ? $_POST['event_id'] : '';
    if (isset($_GET['mode'])) {
        $action = $_GET['mode'];
        if ($action == 'edit' || $action == 'copy') {
            $event_id = (int) $_GET['event_id'];
        }
    }
    if (isset($_POST['event_action'])) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        global $mc_output;
        $count = 0;
        if (isset($_POST['event_begin']) && is_array($_POST['event_begin'])) {
            $count = count($_POST['event_begin']);
        } else {
            $response = my_calendar_save($action, $mc_output, (int) $_POST['event_id']);
            echo $response['message'];
        }
        for ($i = 0; $i < $count; $i++) {
            $mc_output = mc_check_data($action, $_POST, $i);
            if ($action == 'add' || $action == 'copy') {
                $response = my_calendar_save($action, $mc_output);
            } else {
                $response = my_calendar_save($action, $mc_output, (int) $_POST['event_id']);
            }
            echo $response['message'];
        }
        if (isset($_POST['ref'])) {
            $url = esc_url(urldecode($_POST['ref']));
            echo "<p class='return'><a href='{$url}'>" . __('Return to Calendar', 'my-calendar') . "</a></p>";
        }
    }
    ?>

	<div class="wrap jd-my-calendar">
	<?php 
    my_calendar_check_db();
    if (get_site_option('mc_multisite') == 2) {
        if (get_option('mc_current_table') == 0) {
            $message = __('Currently editing your local calendar', 'my-calendar');
        } else {
            $message = __('Currently editing your central calendar', 'my-calendar');
        }
        echo "<div class='message updated'><p>{$message}</p></div>";
    }
    if ($action == 'edit') {
        ?>
		<h1><?php 
        _e('Edit Event', 'my-calendar');
        ?>
</h1>
		<?php 
        if (empty($event_id)) {
            echo "<div class='error'><p>" . __("You must provide an event id in order to edit it", 'my-calendar') . "</p></div>";
        } else {
            mc_edit_event_form('edit', $event_id);
        }
    } else {
        if ($action == 'copy') {
            ?>
		<h1><?php 
            _e('Copy Event', 'my-calendar');
            ?>
</h1>
		<?php 
            if (empty($event_id)) {
                echo "<div class=\"error\"><p>" . __("You must provide an event id in order to edit it", 'my-calendar') . "</p></div>";
            } else {
                mc_edit_event_form('copy', $event_id);
            }
        } else {
            ?>
		<h1><?php 
            _e('Add Event', 'my-calendar');
            ?>
</h1><?php 
            mc_edit_event_form();
        }
    }
    mc_show_sidebar();
    ?>
	</div><?php 
}
コード例 #6
0
function edit_my_calendar_config()
{
    global $wpdb;
    $mcdb = $wpdb;
    check_my_calendar();
    if (!empty($_POST)) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        if (isset($_POST['remigrate'])) {
            echo "<div class='updated fade'><ol>";
            echo "<li>" . __('Dropping occurrences database table', 'my-calendar') . "</li>";
            mc_drop_table('my_calendar_event_table');
            sleep(1);
            echo "<li>" . __('Reinstalling occurrences database table.', 'my-calendar') . "</li>";
            mc_upgrade_db();
            sleep(1);
            echo "<li>" . __('Generating event occurrences.', 'my-calendar') . "</li>";
            mc_migrate_db();
            echo "<li>" . __('Event generation completed.', 'my-calendar') . "</li>";
            echo "</ol></div>";
        }
    }
    if (isset($_POST['mc_manage'])) {
        // management
        $clear = '';
        $mc_event_approve = !empty($_POST['mc_event_approve']) && $_POST['mc_event_approve'] == 'on' ? 'true' : 'false';
        $mc_api_enabled = !empty($_POST['mc_api_enabled']) && $_POST['mc_api_enabled'] == 'on' ? 'true' : 'false';
        $mc_remote = !empty($_POST['mc_remote']) && $_POST['mc_remote'] == 'on' ? 'true' : 'false';
        if (isset($_POST['mc_clear_cache']) && $_POST['mc_clear_cache'] == 'clear') {
            mc_delete_cache();
            $clear = __('My Calendar Cache cleared', 'my-calendar');
        }
        update_option('mc_event_approve', $mc_event_approve);
        update_option('mc_api_enabled', $mc_api_enabled);
        update_option('mc_remote', $mc_remote);
        update_option('mc_default_sort', $_POST['mc_default_sort']);
        if (get_site_option('mc_multisite') == 2) {
            $mc_current_table = (int) $_POST['mc_current_table'];
            update_option('mc_current_table', $mc_current_table);
        }
        echo "<div class='updated'><p><strong>" . __('My Calendar Management Settings saved', 'my-calendar') . ". {$clear}</strong></p></div>";
    }
    if (isset($_POST['mc_permissions'])) {
        $perms = $_POST['mc_caps'];
        $caps = array('mc_add_events' => __('Add Events', 'my-calendar'), 'mc_approve_events' => __('Approve Events', 'my-calendar'), 'mc_manage_events' => __('Manage Events', 'my-calendar'), 'mc_edit_cats' => __('Edit Categories', 'my-calendar'), 'mc_edit_locations' => __('Edit Locations', 'my-calendar'), 'mc_edit_styles' => __('Edit Styles', 'my-calendar'), 'mc_edit_behaviors' => __('Edit Behaviors', 'my-calendar'), 'mc_edit_templates' => __('Edit Templates', 'my-calendar'), 'mc_edit_settings' => __('Edit Settings', 'my-calendar'), 'mc_view_help' => __('View Help', 'my-calendar'));
        foreach ($perms as $key => $value) {
            $role = get_role($key);
            if (is_object($role)) {
                foreach ($caps as $k => $v) {
                    if (isset($value[$k])) {
                        $role->add_cap($k);
                    } else {
                        $role->remove_cap($k);
                    }
                }
            }
        }
        echo "<div class='updated'><p><strong>" . __('My Calendar Permissions Updated', 'my-calendar') . "</strong></p></div>";
    }
    // output
    if (isset($_POST['mc_show_months'])) {
        $mc_open_day_uri = !empty($_POST['mc_open_day_uri']) ? $_POST['mc_open_day_uri'] : '';
        update_option('mc_uri', $_POST['mc_uri']);
        update_option('mc_use_permalinks', !empty($_POST['mc_use_permalinks']) ? 'true' : 'false');
        update_option('mc_open_uri', !empty($_POST['mc_open_uri']) && $_POST['mc_open_uri'] == 'on' && get_option('mc_uri') != '' ? 'true' : 'false');
        update_option('mc_mini_uri', $_POST['mc_mini_uri']);
        update_option('mc_open_day_uri', $mc_open_day_uri);
        update_option('mc_skip_holidays', !empty($_POST['mc_skip_holidays']) && $_POST['mc_skip_holidays'] == 'on' ? 'true' : 'false');
        update_option('mc_display_author', !empty($_POST['mc_display_author']) && $_POST['mc_display_author'] == 'on' ? 'true' : 'false');
        update_option('mc_show_event_vcal', !empty($_POST['mc_show_event_vcal']) && $_POST['mc_show_event_vcal'] == 'on' ? 'true' : 'false');
        update_option('mc_show_gcal', !empty($_POST['mc_show_gcal']) && $_POST['mc_show_gcal'] == 'on' ? 'true' : 'false');
        update_option('mc_display_jump', !empty($_POST['mc_display_jump']) && $_POST['mc_display_jump'] == 'on' ? 'true' : 'false');
        update_option('mc_show_list_info', !empty($_POST['mc_show_list_info']) && $_POST['mc_show_list_info'] == 'on' ? 'true' : 'false');
        update_option('mc_show_months', (int) $_POST['mc_show_months']);
        // calculate sequence for navigation elements
        $top = $bottom = array();
        $nav = $_POST['mc_nav'];
        $set = 'top';
        foreach ($nav as $n) {
            if ($n == 'calendar') {
                $set = 'bottom';
            } else {
                if ($set == 'top') {
                    $top[] = $n;
                } else {
                    $bottom[] = $n;
                }
            }
            if ($n == 'stop') {
                break;
            }
        }
        update_option('mc_bottomnav', implode(',', $bottom));
        update_option('mc_topnav', implode(',', $top));
        update_option('mc_show_map', !empty($_POST['mc_show_map']) && $_POST['mc_show_map'] == 'on' ? 'true' : 'false');
        update_option('mc_gmap', !empty($_POST['mc_gmap']) && $_POST['mc_gmap'] == 'on' ? 'true' : 'false');
        update_option('mc_show_address', !empty($_POST['mc_show_address']) && $_POST['mc_show_address'] == 'on' ? 'true' : 'false');
        update_option('mc_hide_icons', !empty($_POST['mc_hide_icons']) && $_POST['mc_hide_icons'] == 'on' ? 'true' : 'false');
        update_option('mc_event_link_expires', !empty($_POST['mc_event_link_expires']) && $_POST['mc_event_link_expires'] == 'on' ? 'true' : 'false');
        update_option('mc_apply_color', $_POST['mc_apply_color']);
        update_option('mc_event_registration', !empty($_POST['mc_event_registration']) && $_POST['mc_event_registration'] == 'on' ? 'true' : 'false');
        update_option('mc_inverse_color', !empty($_POST['mc_inverse_color']) && $_POST['mc_inverse_color'] == 'on' ? 'true' : 'false');
        update_option('mc_short', !empty($_POST['mc_short']) && $_POST['mc_short'] == 'on' ? 'true' : 'false');
        update_option('mc_desc', !empty($_POST['mc_desc']) && $_POST['mc_desc'] == 'on' ? 'true' : 'false');
        update_option('mc_process_shortcodes', !empty($_POST['mc_process_shortcodes']) && $_POST['mc_process_shortcodes'] == 'on' ? 'true' : 'false');
        update_option('mc_details', !empty($_POST['mc_details']) && $_POST['mc_details'] == 'on' ? 'true' : 'false');
        update_option('mc_event_link', !empty($_POST['mc_event_link']) && $_POST['mc_event_link'] == 'on' ? 'true' : 'false');
        update_option('mc_show_weekends', !empty($_POST['mc_show_weekends']) && $_POST['mc_show_weekends'] == 'on' ? 'true' : 'false');
        update_option('mc_convert', !empty($_POST['mc_convert']) && $_POST['mc_convert'] == 'on' ? 'true' : 'false');
        update_option('mc_no_fifth_week', !empty($_POST['mc_no_fifth_week']) && $_POST['mc_no_fifth_week'] == 'on' ? 'true' : 'false');
        echo "<div class=\"updated\"><p><strong>" . __('Output Settings saved', 'my-calendar') . "</strong></p></div>";
    }
    // input
    if (isset($_POST['mc_dates'])) {
        update_option('mc_date_format', stripslashes($_POST['mc_date_format']));
        update_option('mc_week_format', stripslashes($_POST['mc_week_format']));
        update_option('mc_time_format', stripslashes($_POST['mc_time_format']));
        update_option('mc_month_format', stripslashes($_POST['mc_month_format']));
        $mc_ical_utc = !empty($_POST['mc_ical_utc']) && $_POST['mc_ical_utc'] == 'on' ? 'true' : 'false';
        update_option('mc_ical_utc', $mc_ical_utc);
        echo "<div class=\"updated\"><p><strong>" . __('Date/Time Format Settings saved', 'my-calendar') . "</strong></p></div>";
    }
    if (isset($_POST['mc_input'])) {
        $mc_input_options_administrators = !empty($_POST['mc_input_options_administrators']) && $_POST['mc_input_options_administrators'] == 'on' ? 'true' : 'false';
        $mc_input_options = array('event_short' => !empty($_POST['mci_event_short']) && $_POST['mci_event_short'] ? 'on' : '', 'event_desc' => !empty($_POST['mci_event_desc']) && $_POST['mci_event_desc'] ? 'on' : '', 'event_category' => !empty($_POST['mci_event_category']) && $_POST['mci_event_category'] ? 'on' : '', 'event_image' => !empty($_POST['mci_event_image']) && $_POST['mci_event_image'] ? 'on' : '', 'event_link' => !empty($_POST['mci_event_link']) && $_POST['mci_event_link'] ? 'on' : '', 'event_recurs' => !empty($_POST['mci_event_recurs']) && $_POST['mci_event_recurs'] ? 'on' : '', 'event_open' => !empty($_POST['mci_event_open']) && $_POST['mci_event_open'] ? 'on' : '', 'event_location' => !empty($_POST['mci_event_location']) && $_POST['mci_event_location'] ? 'on' : '', 'event_location_dropdown' => !empty($_POST['mci_event_location_dropdown']) && $_POST['mci_event_location_dropdown'] ? 'on' : '', 'event_specials' => !empty($_POST['mci_event_specials']) && $_POST['mci_event_specials'] ? 'on' : '', 'event_access' => !empty($_POST['mci_event_access']) && $_POST['mci_event_access'] ? 'on' : '');
        update_option('mc_input_options', $mc_input_options);
        update_option('mc_input_options_administrators', $mc_input_options_administrators);
        echo "<div class=\"updated\"><p><strong>" . __('Input Settings saved', 'my-calendar') . ".</strong></p></div>";
    }
    if (current_user_can('manage_network')) {
        if (isset($_POST['mc_network'])) {
            $mc_multisite = (int) $_POST['mc_multisite'];
            update_site_option('mc_multisite', $mc_multisite);
            $mc_multisite_show = (int) $_POST['mc_multisite_show'];
            update_site_option('mc_multisite_show', $mc_multisite_show);
            echo "<div class=\"updated\"><p><strong>" . __('Multisite settings saved', 'my-calendar') . ".</strong></p></div>";
        }
    }
    // custom text
    if (isset($_POST['mc_previous_events'])) {
        $mc_title_template = $_POST['mc_title_template'];
        $mc_details_label = $_POST['mc_details_label'];
        $mc_link_label = $_POST['mc_link_label'];
        $mc_event_title_template = $_POST['mc_event_title_template'];
        $mc_notime_text = $_POST['mc_notime_text'];
        $mc_previous_events = $_POST['mc_previous_events'];
        $mc_next_events = $_POST['mc_next_events'];
        $mc_event_open = $_POST['mc_event_open'];
        $mc_event_closed = $_POST['mc_event_closed'];
        $mc_week_caption = $_POST['mc_week_caption'];
        $mc_caption = $_POST['mc_caption'];
        $templates = get_option('mc_templates');
        $templates['title'] = $mc_title_template;
        $templates['label'] = $mc_details_label;
        $templates['link'] = $mc_link_label;
        update_option('mc_templates', $templates);
        update_option('mc_event_title_template', $mc_event_title_template);
        update_option('mc_notime_text', $mc_notime_text);
        update_option('mc_week_caption', $mc_week_caption);
        update_option('mc_next_events', $mc_next_events);
        update_option('mc_previous_events', $mc_previous_events);
        update_option('mc_caption', $mc_caption);
        update_option('mc_event_open', $mc_event_open);
        update_option('mc_event_closed', $mc_event_closed);
        echo "<div class=\"updated\"><p><strong>" . __('Custom text settings saved', 'my-calendar') . ".</strong></p></div>";
    }
    // Mail function by Roland
    if (isset($_POST['mc_email'])) {
        $mc_event_mail = !empty($_POST['mc_event_mail']) && $_POST['mc_event_mail'] == 'on' ? 'true' : 'false';
        $mc_html_email = !empty($_POST['mc_html_email']) && $_POST['mc_html_email'] == 'on' ? 'true' : 'false';
        $mc_event_mail_to = $_POST['mc_event_mail_to'];
        $mc_event_mail_from = $_POST['mc_event_mail_from'];
        $mc_event_mail_subject = $_POST['mc_event_mail_subject'];
        $mc_event_mail_message = $_POST['mc_event_mail_message'];
        update_option('mc_event_mail_to', $mc_event_mail_to);
        update_option('mc_event_mail_from', $mc_event_mail_from);
        update_option('mc_event_mail_subject', $mc_event_mail_subject);
        update_option('mc_event_mail_message', $mc_event_mail_message);
        update_option('mc_event_mail', $mc_event_mail);
        update_option('mc_html_email', $mc_html_email);
        echo "<div class=\"updated\"><p><strong>" . __('Email notice settings saved', 'my-calendar') . ".</strong></p></div>";
    }
    // Custom User Settings
    apply_filters('mc_save_settings', '', $_POST);
    // pull templates for passing into functions.
    $templates = get_option('mc_templates');
    $mc_title_template = esc_attr(stripslashes($templates['title']));
    $mc_details_label = esc_attr(stripslashes($templates['label']));
    $mc_link_label = esc_attr(stripslashes($templates['link']));
    ?>
 

<div class="wrap jd-my-calendar mc-settings-page" id="mc_settings">
<?php 
    my_calendar_check_db();
    ?>
    <div id="icon-options-general" class="icon32"><br /></div>
	<h2><?php 
    _e('My Calendar Options', 'my-calendar');
    ?>
</h2>
<div class="postbox-container jcd-wide">
<div class="metabox-holder">
  <?php 
    //update_option( 'ko_calendar_imported','false' ); // for testing importing.
    if (isset($_POST['import']) && $_POST['import'] == 'true') {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        my_calendar_import();
    }
    if (get_option('ko_calendar_imported') != 'true') {
        if (function_exists('check_calendar')) {
            ?>
	<div class='import upgrade-db'>
	<p>
	<?php 
            _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?', 'my-calendar');
            ?>
	</p>
		<form method="post" action="<?php 
            echo admin_url("admin.php?page=my-calendar-config");
            ?>
">
		<div><input type="hidden" name="_wpnonce" value="<?php 
            echo wp_create_nonce('my-calendar-nonce');
            ?>
" /></div>		
		<div>
		<input type="hidden" name="import" value="true" />
		<input type="submit" value="<?php 
            _e('Import from Calendar', 'my-calendar');
            ?>
" name="import-calendar" class="button-primary" />
		</div>
		</form>
	</div>
<?php 
        }
    }
    ?>

<div class="ui-sortable meta-box-sortables">   
<div class="postbox">
	<h3><?php 
    _e('My Calendar Settings', 'my-calendar');
    ?>
</h3>
	<div class="inside">
	<ul class="mc-settings checkboxes">
		<li><a href="#my-calendar-manage"><?php 
    _e('Management', 'my-calendar');
    ?>
</a></li>
		<li><a href="#my-calendar-text"><?php 
    _e('Customizable Text', 'my-calendar');
    ?>
</a></li>
		<li><a href="#my-calendar-output"><?php 
    _e('Output', 'my-calendar');
    ?>
</a></li>
		<li><a href="#my-calendar-time"><?php 
    _e('Date/Time', 'my-calendar');
    ?>
</a></li>
		<li><a href="#my-calendar-input"><?php 
    _e('Input', 'my-calendar');
    ?>
</a></li>
		<?php 
    if (current_user_can('manage_network')) {
        ?>
		<li><a href="#my-calendar-multisite"><?php 
        _e('Multi-site', 'my-calendar');
        ?>
</a></li>		
		<?php 
    }
    ?>
		<li><a href="#my-calendar-permissions"><?php 
    _e('Permissions', 'my-calendar');
    ?>
</a></li>
		<li><a href="#my-calendar-email"><?php 
    _e('Email Notifications', 'my-calendar');
    ?>
</a></li>
		<?php 
    echo apply_filters('mc_settings_section_links', '');
    ?>
	</ul>
	</div>
</div>
</div>

<div class="ui-sortable meta-box-sortables">   
<div class="postbox" id="my-calendar-manage">
	<h3><?php 
    _e('My Calendar Management', 'my-calendar');
    ?>
</h3>
	<div class="inside">
	<?php 
    if (current_user_can('administrator')) {
        ?>
    <form method="post" action="<?php 
        echo admin_url("admin.php?page=my-calendar-config");
        ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
        echo wp_create_nonce('my-calendar-nonce');
        ?>
" /></div> 	
	<fieldset>
    <legend><?php 
        _e('Management', 'my-calendar');
        ?>
</legend>
    <ul>
	<li><?php 
        mc_settings_field('mc_remote', __('Get data (events, categories and locations) from a remote database.', 'my-calendar'), '', '', array(), 'checkbox-single');
        ?>
</li>
	<?php 
        if (get_option('mc_remote') == 'true') {
            ?>
	<li><?php 
            _e('Add this code to your theme\'s <code>functions.php</code> file:', 'my-calendar');
            ?>
<pre>function mc_remote_db() {
	$mcdb = new wpdb('DB_USER','DB_PASSWORD','DB_NAME','DB_ADDRESS');
	return $mcdb;
}</pre>
		<?php 
            _e('You will need to allow remote connections from this site to the site hosting your My Calendar events. Replace the above placeholders with the host-site information. The two sites must have the same WP table prefix. While this option is enabled, you may not enter or edit events through this installation.', 'my-calendar');
            ?>
	</li>	
	<?php 
        }
        ?>
	<li><?php 
        mc_settings_field('mc_event_approve', __('Enable approval options.', 'my-calendar'), '', '', array(), 'checkbox-single');
        ?>
</li>
	<li><?php 
        mc_settings_field('mc_api_enabled', __('Enable external API.', 'my-calendar'), '', '', array(), 'checkbox-single');
        ?>
</li>	
	<?php 
        if (apply_filters('mc_caching_clear', false)) {
            ?>
	<li><?php 
            mc_settings_field('mc_clear_cache', __('Clear current cache. (Necessary if you edit shortcodes to change displayed categories, for example.)', 'my-calendar'), '', '', array(), 'checkbox-single');
            ?>
</li>	
	<?php 
        }
        ?>
	<li><?php 
        mc_settings_field('mc_default_sort', __('Default Sort order for Admin Events List', 'my-calendar'), array('1' => __('Event ID', 'my-calendar'), '2' => __('Title', 'my-calendar'), '3' => __('Description', 'my-calendar'), '4' => __('Start Date', 'my-calendar'), '5' => __('Author', 'my-calendar'), '6' => __('Category', 'my-calendar'), '7' => __('Location Name', 'my-calendar')), '', array(), 'select');
        ?>
</li>
	<?php 
        if (get_site_option('mc_multisite') == 2 && MY_CALENDAR_TABLE != MY_CALENDAR_GLOBAL_TABLE) {
            mc_settings_field('mc_current_table', array('0' => __('Currently editing my local calendar', 'my-calendar'), '1' => __('Currently editing the network calendar', 'my-calendar')), '0', '', array(), 'radio');
        } else {
            if (get_option('mc_remote') != 'true' && current_user_can('manage_network')) {
                ?>
			<li><?php 
                _e('You are currently working in the primary site for this network; your local calendar is also the global table.', 'my-calendar');
                ?>
</li><?php 
            }
        }
        ?>
	<li><?php 
        mc_settings_field('remigrate', __('Re-generate event occurrences table.', 'my-calendar'), '', '', array(), 'checkbox-single');
        ?>
</li>
	</ul>
	</fieldset>
		<p>
		<input type="submit" name="mc_manage" class="button-primary" value="<?php 
        _e('Save Management Settings', 'my-calendar');
        ?>
" />
		</p>
	</form>
	<?php 
    } else {
        ?>
		<?php 
        _e('My Calendar management settings are only available to administrators.', 'my-calendar');
        ?>
	<?php 
    }
    ?>
	</div>
</div>
</div>

<div class="ui-sortable meta-box-sortables">   
<div class="postbox" id="my-calendar-text">
	<h3><?php 
    _e('Text Settings', 'my-calendar');
    ?>
</h3>
	<div class="inside">
	    <form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-config");
    ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>		
<fieldset>
	<legend><?php 
    _e('Customize Text Fields', 'my-calendar');
    ?>
</legend>
	<ul>
	<li><?php 
    mc_settings_field('mc_notime_text', __('Label for all-day events', 'my-calendar'), 'N/A');
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_previous_events', __('Previous events link', 'my-calendar'), __('Previous', 'my-calendar'), __('Use <code>{date}</code> to display date in navigation.', 'my-calendar'));
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_next_events', __('Next events link', 'my-calendar'), __('Next', 'my-calendar'), __('Use <code>{date}</code> to display date in navigation.', 'my-calendar'));
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_event_open', __('If events are open', 'my-calendar'), __('Registration is open', 'my-calendar'));
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_event_closed', __('If events are closed', 'my-calendar'), __('Registration is closed', 'my-calendar'));
    ?>
</li>	
	<li><?php 
    mc_settings_field('mc_week_caption', __('Week view caption:', 'my-calendar'), '', __('Available tag: <code>{date format=""}</code>', 'my-calendar'));
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_caption', __('Extended caption:', 'my-calendar'), '', __('Follows month/year in list views.', 'my-calendar'));
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_title_template', __('Event title template', 'my-calendar'), $mc_title_template, "<a href='" . admin_url("admin.php?page=my-calendar-help#templates") . "'>" . __("Templating Help", 'my-calendar') . '</a>');
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_details_label', __('Event details link text', 'my-calendar'), $mc_details_label, __('Tags: <code>{title}</code>, <code>{location}</code>, <code>{color}</code>, <code>{icon}</code>, <code>{date}</code>, <code>{time}</code>.', 'my-calendar'));
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_link_label', __('Event URL link text', 'my-calendar'), $mc_link_label, "<a href='" . admin_url("admin.php?page=my-calendar-help#templates") . "'>" . __("Templating Help", 'my-calendar') . '</a>');
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_event_title_template', __('Title element template', 'my-calendar'), '{title} &raquo; {date}', __('Current: %s', 'my-calendar'));
    ?>
</li>		
	</ul>
	</fieldset>	
		<p>
		<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save Custom Text Settings', 'my-calendar');
    ?>
" />
	</p>
	</form>
</div>
</div>
</div>

<div class="ui-sortable meta-box-sortables">   
<div class="postbox" id="my-calendar-output">
	<h3><?php 
    _e('Output Settings', 'my-calendar');
    ?>
</h3>
	<div class="inside">
	<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-config");
    ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
	<fieldset>
	<legend><?php 
    _e('Calendar Link Targets', 'my-calendar');
    ?>
</legend>
	<ul>
	<?php 
    /* <li><?php mc_settings_field( 'mc_use_permalinks', __( 'Use Pretty Permalinks for Events','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> This just isn't ready; add in a point release. */
    ?>
	<?php 
    $guess = mc_guess_calendar();
    ?>
	<li><?php 
    mc_settings_field('mc_uri', __('Where is your main calendar page?', 'my-calendar'), '', "<br /><small>" . __('Can be any Page or Post which includes the <code>[my_calendar]</code> shortcode.', 'my-calendar') . " {$guess}</small>", array('size' => '60'), 'url');
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_mini_uri', __('Target <abbr title="Uniform resource locator">URL</abbr> for mini calendar date links:', 'my-calendar'), '', "<br /><small>" . __('Can be any Page or Post which includes the <code>[my_calendar]</code> shortcode.', 'my-calendar') . "</small>", array('size' => '60'), 'url');
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_open_uri', __('Open calendar links to event details URL', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
	<?php 
    $disabled = !get_option('mc_uri') && !get_option('mc_mini_uri') ? array('disabled' => 'disabled') : array();
    ?>
	<li><?php 
    mc_settings_field('mc_open_day_uri', __('Mini calendar widget date links to:', 'my-calendar'), array('false' => __('jQuery pop-up view', 'my-calendar'), 'true' => __('daily view page (above)', 'my-calendar'), 'listanchor' => __('in-page anchor on main calendar page (list)', 'my-calendar'), 'calendaranchor' => __('in-page anchor on main calendar page (grid)', 'my-calendar')), '', $disabled, 'select');
    ?>
</li>
	</ul>
	<?php 
    // End General Options //
    ?>
	</fieldset>
	
	<fieldset> 
	<legend><?php 
    _e('Set Default Navigation Element Order (can be overridden in shortcodes)', 'my-calendar');
    ?>
</legend>
	<?php 
    $topnav = explode(',', get_option('mc_topnav'));
    $calendar = array('calendar');
    $botnav = explode(',', get_option('mc_bottomnav'));
    $order = array_merge($topnav, $calendar, $botnav);
    $nav_elements = array('nav' => '<div class="dashicons dashicons-arrow-left-alt2"></div> <div class="dashicons dashicons-arrow-right-alt2"></div> ' . __('Primary Previous/Next Buttons', 'my-calendar'), 'toggle' => '<div class="dashicons dashicons-list-view"></div> <div class="dashicons dashicons-calendar"></div> ' . __('Switch between list and grid views', 'my-calendar'), 'jump' => '<div class="dashicons dashicons-redo"></div> ' . __('Jump to any other month/year', 'my-calendar'), 'print' => '<div class="dashicons dashicons-list-view"></div> ' . __('Link to printable view', 'my-calendar'), 'timeframe' => '<div class="dashicons dashicons-clock"></div> ' . __('Toggle between day, week, and month view', 'my-calendar'), 'calendar' => '<div class="dashicons dashicons-calendar"></div> ' . __('The calendar', 'my-calendar'), 'key' => '<div class="dashicons dashicons-admin-network"></div> ' . __('Categories', 'my-calendar'), 'feeds' => '<div class="dashicons dashicons-rss"></div> ' . __('Links to RSS and iCal output', 'my-calendar'), 'stop' => '<div class="dashicons dashicons-no"></div> ' . __('Elements below here will be hidden.'));
    echo "<div id='mc-sortable-update' aria-live='polite'></div>";
    echo "<ul id='mc-sortable'>";
    foreach ($order as $k) {
        $k = trim($k);
        $v = isset($nav_elements[$k]) ? $nav_elements[$k] : false;
        if ($v !== false) {
            $inserted[$k] = $v;
            echo "<li class='ui-state-default mc-{$k}'><button class='up'><i class='dashicons dashicons-arrow-up'></i><span class='screen-reader-text'>Up</span></button> <button class='down'><i class='dashicons dashicons-arrow-down'></i><span class='screen-reader-text'>Down</span></button> <code>{$k}</code> {$v} <input type='hidden' name='mc_nav[]' value='{$k}' /></li>";
        }
    }
    $missed = array_diff($nav_elements, $inserted);
    foreach ($missed as $k => $v) {
        echo "<li class='ui-state-default mc-{$k}'><button class='up'><i class='dashicons dashicons-arrow-up'></i><span class='screen-reader-text'>Up</span></button> <button class='down'><i class='dashicons dashicons-arrow-down'></i><span class='screen-reader-text'>Down</span></button> <code>{$k}</code> {$v} <input type='hidden' name='mc_nav[]' value='{$k}' /></li>";
    }
    echo "</ul>";
    ?>
	</fieldset>	
	
	<fieldset>
	<legend><?php 
    _e('Grid Layout Options', 'my-calendar');
    ?>
</legend>
	<ul>
	<li><?php 
    mc_settings_field('mc_show_weekends', __('Show Weekends on Calendar', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_convert', __('Switch to list view on mobile devices', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>	
	</ul>	
	<?php 
    // End Grid Options //
    ?>
	</fieldset>	
	
	<fieldset>
	<legend><?php 
    _e('List Layout Options', 'my-calendar');
    ?>
</legend>
	<ul>
	<li><?php 
    mc_settings_field('mc_show_months', __('How many months of events to show at a time:', 'my-calendar'), '', '', array('size' => '3'), 'text');
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_show_list_info', __('Show the first event\'s title and the number of events that day next to the date.', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>	
	</ul>	
	<?php 
    // End List Options //
    ?>
	</fieldset>	

	<fieldset>
	<legend><?php 
    _e('Event Details Pop-up', 'my-calendar');
    ?>
</legend>
		<p><?php 
    _e('The checked items will be shown in your event details view. Does not apply if you are using a custom template', 'my-calendar');
    ?>
		<ul class="checkboxes">
			<li><?php 
    mc_settings_field('mc_display_author', __('Author\'s name', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_show_event_vcal', __('Link to single event iCal download', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_show_gcal', __('Link to submit event to Google Calendar', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>		
			<li><?php 
    mc_settings_field('mc_hide_icons', __('Hide Category icons', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_show_map', __('Link to Google Map', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_gmap', __('Google Map (single event view only)', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>			
			<li><?php 
    mc_settings_field('mc_show_address', __('Event Address', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_short', __('Short description', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_desc', __('Full description', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_process_shortcodes', __('Process WordPress shortcodes in descriptions', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>	
			<li><?php 
    mc_settings_field('mc_details', __('Link to event details (requires <a href=\'#mc_uri\'>URL</a>)', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_event_link', __('External link', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_event_registration', __('Registration info', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
		</ul>
	</fieldset>
	<fieldset>
	<legend><?php 
    _e('Event Category Display', 'my-calendar');
    ?>
</legend>
		<ul class='checkboxes'>
			<?php 
    mc_settings_field('mc_apply_color', array('default' => __('No category colors with titles.', 'my-calendar'), 'font' => __('Titles are in category colors.', 'my-calendar'), 'background' => __('Titles have category color as background.', 'my-calendar')), 'default', '', array(), 'radio');
    ?>
			<li><?php 
    mc_settings_field('mc_inverse_color', __('Optimize contrast for category colors.', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
		</ul>	
	<?php 
    // End Event Options //
    ?>
	</fieldset>
	<fieldset>
	<legend><?php 
    _e('Event Scheduling Defaults', 'my-calendar');
    ?>
</legend>
		<ul>
			<li><?php 
    mc_settings_field('mc_event_link_expires', __('Event links expire after event passes.', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>	
			<li><?php 
    mc_settings_field('mc_no_fifth_week', __('If a recurring event falls on a date that doesn\'t exist (like the 5th Wednesday in February), move it back one week.', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
			<li><?php 
    mc_settings_field('mc_skip_holidays', __('If an event coincides with an event in the designated "Holiday" category, do not show the event.', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
		</ul>	
	<?php 
    // End Scheduling Options //
    ?>
	</fieldset>
	<p><input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save Output Settings', 'my-calendar');
    ?>
" /></p>
</form>
</div>
</div>
</div>

<div class="ui-sortable meta-box-sortables">
<div class="postbox" id="my-calendar-time">
	<h3><?php 
    _e('Calendar Time Formats', 'my-calendar');
    ?>
</h3>
	<div class="inside">
	<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-config");
    ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
	<fieldset>
	<legend><?php 
    _e('Set default date/time formats', 'my-calendar');
    ?>
</legend>
	<div><input type='hidden' name='mc_dates' value='true' /></div>
	<ul>	
	<?php 
    $month_format = get_option('mc_month_format') == '' ? date_i18n('F Y') : date_i18n(get_option('mc_month_format'));
    $time_format = get_option('mc_time_format') == '' ? date_i18n(get_option('time_format')) : date_i18n(get_option('mc_time_format'));
    $week_format = get_option('mc_week_format') == '' ? date_i18n('M j, \'y') : date_i18n(get_option('mc_week_format'));
    $date_format = get_option('mc_date_format') == '' ? date_i18n(get_option('date_format')) : date_i18n(get_option('mc_date_format'));
    ?>
	<li><?php 
    mc_settings_field('mc_month_format', __('Month format (calendar headings)', 'my-calendar'), '', $month_format);
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_time_format', __('Time format', 'my-calendar'), '', $time_format);
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_week_format', __('Date in grid mode, week view', 'my-calendar'), '', $week_format);
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_date_format', __('Date Format in other views', 'my-calendar'), '', $date_format);
    ?>
</li>
	<li>
	<?php 
    _e('Date formats use syntax from the <a href="http://php.net/date">PHP <code>date()</code> function</a>. Save to update sample output.', 'my-calendar');
    ?>
	</li>
	<li><?php 
    mc_settings_field('mc_ical_utc', __('iCal times are UTC', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
	</ul>
	</fieldset>
		<p>
		<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save Date/Time Settings', 'my-calendar');
    ?>
" />
		</p>
	</form>	
	</div>
</div>
</div>


<div class="ui-sortable meta-box-sortables">   
<div class="postbox" id="my-calendar-input">
	<h3><?php 
    _e('Calendar Input Settings', 'my-calendar');
    ?>
</h3>
	<div class="inside">
<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-config");
    ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
	<fieldset>
	<legend><?php 
    _e('Select which input fields will be available when adding or editing events.', 'my-calendar');
    ?>
</legend>
	<div><input type='hidden' name='mc_input' value='true' /></div>
	<ul class="checkboxes">
	<?php 
    $input_options = get_option('mc_input_options');
    $input_labels = array('event_location_dropdown' => __('Event Location Dropdown Menu', 'my-calendar'), 'event_short' => __('Event Short Description field', 'my-calendar'), 'event_desc' => __('Event Description Field', 'my-calendar'), 'event_category' => __('Event Category field', 'my-calendar'), 'event_image' => __('Event Image field', 'my-calendar'), 'event_link' => __('Event Link field', 'my-calendar'), 'event_recurs' => __('Event Recurrence Options', 'my-calendar'), 'event_open' => __('Event Registration options', 'my-calendar'), 'event_location' => __('Event Location fields', 'my-calendar'), 'event_specials' => __('Set Special Scheduling options', 'my-calendar'), 'event_access' => __("Event Accessibility", 'my-calendar'));
    $output = '';
    // if input options isn't an array, we'll assume that this plugin wasn't upgraded properly, and reset them to the default.
    if (!is_array($input_options)) {
        update_option('mc_input_options', array('event_short' => 'on', 'event_desc' => 'on', 'event_category' => 'on', 'event_image' => 'on', 'event_link' => 'on', 'event_recurs' => 'on', 'event_open' => 'on', 'event_location' => 'on', 'event_location_dropdown' => 'on', 'event_specials' => 'on', 'event_access' => 'on'));
    }
    foreach ($input_options as $key => $value) {
        $checked = $value == 'on' ? "checked='checked'" : '';
        if (isset($input_labels[$key])) {
            $output .= "<li><input type=\"checkbox\" id=\"mci_{$key}\" name=\"mci_{$key}\" {$checked} /> <label for=\"mci_{$key}\">{$input_labels[$key]}</label></li>";
        }
    }
    echo $output;
    ?>
	<li><?php 
    mc_settings_field('mc_input_options_administrators', __('Administrators see all input options', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
	</ul>
	</fieldset>
		<p>
		<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save Input Settings', 'my-calendar');
    ?>
" />
		</p>
</form>
</div>
</div>
</div>

<?php 
    if (current_user_can('manage_network')) {
        ?>
<div class="ui-sortable meta-box-sortables">   
<div class="postbox" id="my-calendar-multisite">
	<h3><?php 
        _e('Multisite Settings (Network Administrators only)', 'my-calendar');
        ?>
</h3>
	<div class="inside">
	<form method="post" action="<?php 
        echo admin_url("admin.php?page=my-calendar-config");
        ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
        echo wp_create_nonce('my-calendar-nonce');
        ?>
" /></div>	
	<div><input type='hidden' name='mc_network' value='true' /></div>	
	<fieldset>
	<legend><?php 
        _e('WP MultiSite configurations', 'my-calendar');
        ?>
</legend>
	<p><?php 
        _e('The central calendar is the calendar associated with the primary site in your WordPress Multisite network.', 'my-calendar');
        ?>
</p>	
	<ul>
	<li><input type="radio" value="0" id="ms0" name="mc_multisite"<?php 
        echo jd_option_selected(get_site_option('mc_multisite'), '0');
        ?>
 /> <label for="ms0"><?php 
        _e('Site owners may only post to their local calendar', 'my-calendar');
        ?>
</label></li>
	<li><input type="radio" value="1" id="ms1" name="mc_multisite"<?php 
        echo jd_option_selected(get_site_option('mc_multisite'), '1');
        ?>
 /> <label for="ms1"><?php 
        _e('Site owners may only post to the central calendar', 'my-calendar');
        ?>
</label></li>
	<li><input type="radio" value="2" id="ms2" name="mc_multisite"<?php 
        echo jd_option_selected(get_site_option('mc_multisite'), 2);
        ?>
 /> <label for="ms2"><?php 
        _e('Site owners may manage either calendar', 'my-calendar');
        ?>
</label></li>
	</ul>
	<p class="notice"><strong>*</strong> <?php 
        _e('Changes only effect input permissions. Public-facing calendars will be unchanged.', 'my-calendar');
        ?>
</p>
	<ul>
	<li><input type="radio" value="0" id="mss0" name="mc_multisite_show"<?php 
        echo jd_option_selected(get_site_option('mc_multisite_show'), '0');
        ?>
 /> <label for="mss0"><?php 
        _e('Sub-site calendars show events from their local calendar.', 'my-calendar');
        ?>
</label></li>
	<li><input type="radio" value="1" id="mss1" name="mc_multisite_show"<?php 
        echo jd_option_selected(get_site_option('mc_multisite_show'), '1');
        ?>
 /> <label for="mss1"><?php 
        _e('Sub-site calendars show events from the central calendar.', 'my-calendar');
        ?>
</label></li>
	</ul>
	</fieldset>
		<p>
		<input type="submit" name="save" class="button-primary" value="<?php 
        _e('Save Multisite Settings', 'my-calendar');
        ?>
" />
		</p>
</form>	
	</div>
</div>
</div>
<?php 
    }
    ?>

<div class="ui-sortable meta-box-sortables">   
<div class="postbox" id="my-calendar-permissions">
	<h3><?php 
    _e('My Calendar Permissions', 'my-calendar');
    ?>
</h3>
	<div class="inside mc-tabs">	
	<?php 
    if (current_user_can('administrator')) {
        ?>

    <form method="post" action="<?php 
        echo admin_url("admin.php?page=my-calendar-config");
        ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
        echo wp_create_nonce('my-calendar-nonce');
        ?>
" /></div> 	
	<?php 
        function mc_check_caps($role, $cap)
        {
            $role = get_role($role);
            if ($role->has_cap($cap)) {
                return " checked='checked'";
            }
        }
        function mc_cap_checkbox($role, $cap, $name)
        {
            return "<li><input type='checkbox' id='mc_caps_{$role}_{$cap}' name='mc_caps[{$role}][{$cap}]' value='on'" . mc_check_caps($role, $cap) . " /> <label for='mc_caps_{$role}_{$cap}'>{$name}</label></li>";
        }
        global $wp_roles;
        $roles = $wp_roles->get_names();
        $caps = array('mc_add_events' => __('Add Events', 'my-calendar'), 'mc_approve_events' => __('Approve Events', 'my-calendar'), 'mc_manage_events' => __('Manage Events', 'my-calendar'), 'mc_edit_cats' => __('Edit Categories', 'my-calendar'), 'mc_edit_locations' => __('Edit Locations', 'my-calendar'), 'mc_edit_styles' => __('Edit Styles', 'my-calendar'), 'mc_edit_behaviors' => __('Edit Behaviors', 'my-calendar'), 'mc_edit_templates' => __('Edit Templates', 'my-calendar'), 'mc_edit_settings' => __('Edit Settings', 'my-calendar'), 'mc_view_help' => __('View Help', 'my-calendar'));
        $role_tabs = $role_container = '';
        foreach ($roles as $role => $rolename) {
            if ($role == 'administrator') {
                continue;
            }
            $role_tabs .= "<li><a href='#mc_{$role}'>{$rolename}</a></li>\n";
            $role_container .= "<div class='wptab mc_{$role}' id='mc_{$role}' aria-live='polite'><fieldset id='mc_{$role}' class='roles'><legend>{$rolename}</legend>";
            $role_container .= "<input type='hidden' value='none' name='mc_caps[" . $role . "][none]' />\n\t\t\t<ul class='mc-settings checkboxes'>";
            foreach ($caps as $cap => $name) {
                $role_container .= mc_cap_checkbox($role, $cap, $name);
            }
            $role_container .= "\n\t\t\t</ul></fieldset></div>\n";
        }
        echo "\n\t\t<ul class='tabs'>\n\t\t\t{$role_tabs}\n\t\t</ul>\n\t\t{$role_container}";
        ?>
	
		<p>
		<input type="submit" name="mc_permissions" class="button-primary" value="<?php 
        _e('Save Permissions', 'my-calendar');
        ?>
" />
		</p>
	</form>
	<?php 
    } else {
        ?>
		<?php 
        _e('My Calendar permission settings are only available to administrators.', 'my-calendar');
        ?>
	<?php 
    }
    ?>
	
	</div>
</div>
</div>

<div class="ui-sortable meta-box-sortables">   
<div class="postbox" id="my-calendar-email">
	<h3><?php 
    _e('Calendar Email Settings', 'my-calendar');
    ?>
</h3>
	<div class="inside">
<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-config");
    ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
	<fieldset>
	<legend><?php 
    _e('Email Notifications', 'my-calendar');
    ?>
</legend>
	<div><input type='hidden' name='mc_email' value='true' /></div>
	<ul>
	<li><?php 
    mc_settings_field('mc_event_mail', __('Send Email Notifications when new events are scheduled or reserved.', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_event_mail_to', __('Notification messages are sent to:', 'my-calendar'), get_bloginfo('admin_email'));
    ?>
</li>	
	<li><?php 
    mc_settings_field('mc_event_mail_from', __('Notification messages are sent from:', 'my-calendar'), get_bloginfo('admin_email'));
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_event_mail_subject', __('Email subject', 'my-calendar'), get_bloginfo('name') . ': ' . __('New event added', 'my-calendar'), '', array('size' => 60));
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_event_mail_message', __('Message Body', 'my-calendar'), __('New Event:', 'my-calendar') . "\n{title}: {date}, {time} - {event_status}", "<br /><a href='" . admin_url("admin.php?page=my-calendar-help#templates") . "'>" . __("Templating Help", 'my-calendar') . '</a>', array('cols' => 60, 'rows' => 6), 'textarea');
    ?>
</li>
	<li><?php 
    mc_settings_field('mc_html_email', __('Send HTML email', 'my-calendar'), '', '', array(), 'checkbox-single');
    ?>
</li>
	</ul>
	</fieldset>
		<p>
		<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save Email Settings', 'my-calendar');
    ?>
" />
		</p>
</form>
</div>
</div>
</div>

<?php 
    echo apply_filters('mc_after_settings', '');
    ?>

</div>
</div>

	<?php 
    mc_show_sidebar();
    ?>

</div>
<?php 
}
コード例 #7
0
function edit_my_calendar_behaviors()
{
    if (isset($_POST['mc-js-save'])) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        $use_custom_js = isset($_POST['mc_use_custom_js']) ? 1 : 0;
        update_option('mc_use_custom_js', $use_custom_js);
        update_option('mc_calendar_javascript', empty($_POST['calendar_js']) ? 0 : 1);
        update_option('mc_list_javascript', empty($_POST['list_js']) ? 0 : 1);
        update_option('mc_mini_javascript', empty($_POST['mini_js']) ? 0 : 1);
        update_option('mc_ajax_javascript', empty($_POST['ajax_js']) ? 0 : 1);
        // set js
        if (isset($_POST['mc_caljs'])) {
            $mc_caljs = $_POST['mc_caljs'];
            $mc_listjs = $_POST['mc_listjs'];
            $mc_minijs = $_POST['mc_minijs'];
            $mc_ajaxjs = $_POST['mc_ajaxjs'];
            update_option('mc_listjs', $mc_listjs);
            update_option('mc_minijs', $mc_minijs);
            update_option('mc_caljs', $mc_caljs);
            update_option('mc_ajaxjs', $mc_ajaxjs);
        }
        $mc_show_js = $_POST['mc_show_js'] == '' ? '' : $_POST['mc_show_js'];
        update_option('mc_show_js', $mc_show_js);
        echo "<div class=\"updated\"><p><strong>" . __('Behavior Settings saved', 'my-calendar') . ".</strong></p></div>";
    }
    $mc_listjs = stripcslashes(get_option('mc_listjs'));
    $mc_caljs = stripcslashes(get_option('mc_caljs'));
    $mc_minijs = stripcslashes(get_option('mc_minijs'));
    $mc_ajaxjs = stripcslashes(get_option('mc_ajaxjs'));
    $mc_show_js = stripcslashes(get_option('mc_show_js'));
    // Now we render the form
    ?>
	<div class="wrap jd-my-calendar">
		<?php 
    my_calendar_check_db();
    ?>
		<h2><?php 
    _e('My Calendar Scripting', 'my-calendar');
    ?>
</h2>

		<div class="postbox-container jcd-wide">
			<div class="metabox-holder">

				<div class="ui-sortable meta-box-sortables">
					<div class="postbox" id="cdiff">

						<h3><?php 
    _e('My Calendar Script Manager', 'my-calendar');
    ?>
</h3>

						<div class="inside">
							<form id="my-calendar" method="post"
							      action="<?php 
    echo admin_url('admin.php?page=my-calendar-behaviors');
    ?>
">
								<div><input type="hidden" name="_wpnonce"
								            value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
"/></div>
								<p>
									<input type="checkbox" name="mc_use_custom_js"
									       id="mc_use_custom_js" <?php 
    mc_is_checked('mc_use_custom_js', 1);
    ?>
 />
									<label for="mc_use_custom_js"><?php 
    _e('Use Custom JS', 'my-calendar');
    ?>
</label>
								</p>

								<p>
									<label
										for="mc_show_js"><?php 
    _e('Insert scripts on these pages (comma separated post IDs)', 'my-calendar');
    ?>
</label>
									<input type="text" id="mc_show_js" name="mc_show_js"
									       value="<?php 
    echo $mc_show_js;
    ?>
"/>
								</p>

								<div class='controls'>
									<ul class="checkboxes">
										<li><input type="checkbox" id="calendar_js" name="calendar_js"
										           value="1" <?php 
    mc_is_checked('mc_calendar_javascript', 1);
    ?>
/>
											<label
												for="calendar_js"><?php 
    _e('Disable Grid JS', 'my-calendar');
    ?>
</label>
										</li>
										<li><input type="checkbox" id="list_js" name="list_js"
										           value="1" <?php 
    mc_is_checked('mc_list_javascript', 1);
    ?>
 />
											<label
												for="list_js"><?php 
    _e('Disable List JS', 'my-calendar');
    ?>
</label>
										</li>
										<li><input type="checkbox" id="mini_js" name="mini_js"
										           value="1" <?php 
    mc_is_checked('mc_mini_javascript', 1);
    ?>
 />
											<label
												for="mini_js"><?php 
    _e('Disable Mini JS', 'my-calendar');
    ?>
</label>
										</li>
										<li><input type="checkbox" id="ajax_js" name="ajax_js"
										           value="1" <?php 
    mc_is_checked('mc_ajax_javascript', 1);
    ?>
 />
											<label
												for="ajax_js"><?php 
    _e('Disable AJAX', 'my-calendar');
    ?>
</label></li>
									</ul>
								</div>
								<?php 
    if (get_option('mc_use_custom_js') == 1) {
        ?>
									<p>
										<label
											for="calendar-js"><?php 
        _e('Calendar Behaviors: Grid View', 'my-calendar');
        ?>
</label><br/><textarea
											id="calendar-js" name="mc_caljs" rows="12"
											cols="80"><?php 
        echo $mc_caljs;
        ?>
</textarea>
									</p>
									<p>
										<label
											for="list-js"><?php 
        _e('Calendar Behaviors: List View', 'my-calendar');
        ?>
</label><br/><textarea
											id="list-js" name="mc_listjs" rows="12"
											cols="80"><?php 
        echo $mc_listjs;
        ?>
</textarea>
									</p>
									<p>
										<label
											for="mini-js"><?php 
        _e('Calendar Behaviors: Mini Calendar View', 'my-calendar');
        ?>
</label><br/><textarea
											id="mini-js" name="mc_minijs" rows="12"
											cols="80"><?php 
        echo $mc_minijs;
        ?>
</textarea>
									</p>
									<p>
										<label
											for="ajax-js"><?php 
        _e('Calendar Behaviors: AJAX', 'my-calendar');
        ?>
</label><br/><textarea
											id="ajax-js" name="mc_ajaxjs" rows="12"
											cols="80"><?php 
        echo $mc_ajaxjs;
        ?>
</textarea>
									</p>
								<?php 
    }
    ?>
								<p>
									<input type="submit" name="mc-js-save" class="button-primary"
									       value="<?php 
    _e('Save', 'my-calendar');
    ?>
"/>
								</p>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php 
    mc_show_sidebar();
    ?>
	</div>
<?php 
}
コード例 #8
0
function my_calendar_manage_categories()
{
    global $wpdb;
    $mcdb = $wpdb;
    $formats = array('%s', '%s', '%s');
    ?>
	<div class="wrap jd-my-calendar">
		<?php 
    my_calendar_check_db();
    // We do some checking to see what we're doing
    if (!empty($_POST)) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
    }
    if (isset($_POST['mode']) && $_POST['mode'] == 'add') {
        $term = wp_insert_term($_POST['category_name'], 'mc-event-category');
        if (!is_wp_error($term)) {
            $term = $term['term_id'];
        } else {
            $term = false;
        }
        $add = array('category_name' => $_POST['category_name'], 'category_color' => $_POST['category_color'], 'category_icon' => $_POST['category_icon'], 'category_private' => isset($_POST['category_private']) ? 1 : 0, 'category_term' => $term);
        // actions and filters
        $add = apply_filters('mc_pre_add_category', $add, $_POST);
        $results = $mcdb->insert(my_calendar_categories_table(), $add, $formats);
        do_action('mc_post_add_category', $add, $results, $_POST);
        $cat_ID = $mcdb->insert_id;
        if (isset($_POST['mc_default_category'])) {
            update_option('mc_default_category', $cat_ID);
            $append = __('Default category changed.', 'my-calendar');
        } else {
            $append = '';
        }
        if (isset($_POST['mc_skip_holidays_category'])) {
            update_option('mc_skip_holidays_category', $cat_ID);
            $append .= __('Holiday category changed.', 'my-calendar');
        }
        if ($results) {
            echo "<div class=\"updated\"><p><strong>" . __('Category added successfully', 'my-calendar') . ". {$append}</strong></p></div>";
        } else {
            echo "<div class=\"updated error\"><p><strong>" . __('Category addition failed.', 'my-calendar') . "</strong></p></div>";
        }
    } else {
        if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'delete') {
            $cat_ID = (int) $_GET['category_id'];
            $sql = "DELETE FROM " . my_calendar_categories_table() . " WHERE category_id={$cat_ID}";
            $results = $mcdb->query($sql);
            if ($results) {
                $sql = "UPDATE " . my_calendar_table() . " SET event_category=1 WHERE event_category={$cat_ID}";
                $cal_results = $mcdb->query($sql);
                mc_delete_cache();
            } else {
                $cal_results = false;
            }
            if (get_option('mc_default_category') == $cat_ID) {
                update_option('mc_default_category', 1);
            }
            if ($results && $cal_results) {
                echo "<div class=\"updated\"><p><strong>" . __('Category deleted successfully. Categories in calendar updated.', 'my-calendar') . "</strong></p></div>";
            } else {
                if ($results && !$cal_results) {
                    echo "<div class=\"updated\"><p><strong>" . __('Category deleted successfully. Categories in calendar not updated.', 'my-calendar') . "</strong></p></div>";
                } else {
                    if (!$results && $cal_results) {
                        echo "<div class=\"updated error\"><p><strong>" . __('Category not deleted. Categories in calendar updated.', 'my-calendar') . "</strong></p></div>";
                    }
                }
            }
        } else {
            if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'edit' && !isset($_POST['mode'])) {
                $cur_cat = (int) $_GET['category_id'];
                mc_edit_category_form('edit', $cur_cat);
            } else {
                if (isset($_POST['mode']) && isset($_POST['category_id']) && isset($_POST['category_name']) && isset($_POST['category_color']) && $_POST['mode'] == 'edit') {
                    $update = array('category_name' => $_POST['category_name'], 'category_color' => $_POST['category_color'], 'category_icon' => $_POST['category_icon'], 'category_private' => isset($_POST['category_private']) ? 1 : 0);
                    $where = array('category_id' => (int) $_POST['category_id']);
                    $append = '';
                    if (isset($_POST['mc_default_category'])) {
                        update_option('mc_default_category', (int) $_POST['category_id']);
                        $append .= __('Default category changed.', 'my-calendar');
                    } else {
                        if (get_option('mc_default_category') == (int) $_POST['category_id']) {
                            delete_option('mc_default_category');
                        }
                    }
                    if (isset($_POST['mc_skip_holidays_category'])) {
                        update_option('mc_skip_holidays_category', (int) $_POST['category_id']);
                        $append .= __('Holiday category changed.', 'my-calendar');
                    } else {
                        if (get_option('mc_skip_holidays_category') == (int) $_POST['category_id']) {
                            delete_option('mc_skip_holidays_category');
                        }
                    }
                    $results = $mcdb->update(my_calendar_categories_table(), $update, $where, $formats, '%d');
                    mc_delete_cache();
                    if ($results) {
                        echo "<div class=\"updated\"><p><strong>" . __('Category edited successfully.', 'my-calendar') . " {$append}</strong></p></div>";
                    } else {
                        echo "<div class=\"updated error\"><p><strong>" . __('Category was not edited.', 'my-calendar') . " {$append}</strong></p></div>";
                    }
                    $cur_cat = (int) $_POST['category_id'];
                    mc_edit_category_form('edit', $cur_cat);
                }
            }
        }
    }
    if (isset($_GET['mode']) && $_GET['mode'] != 'edit' || isset($_POST['mode']) && $_POST['mode'] != 'edit' || !isset($_GET['mode']) && !isset($_POST['mode'])) {
        mc_edit_category_form('add');
    }
    ?>
</div>
<?php 
}
コード例 #9
0
function edit_mc_templates()
{
    $templates = get_option('mc_templates');
    if (!empty($_POST)) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
    }
    if (isset($_POST['mc_template_key'])) {
        $key = $_POST['mc_template_key'];
    } else {
        $key = isset($_GET['mc_template']) ? $_GET['mc_template'] : 'grid';
    }
    if (isset($_POST['delete'])) {
        delete_option('mc_ctemplate_' . $key);
        echo "<div class=\"updated\"><p>" . __('Custom template deleted', 'my-calendar') . "</p></div>";
        $key = 'grid';
    } else {
        if (mc_is_core_template($key) && isset($_POST['add-new'])) {
            echo "<div class=\"updated\"><p>" . __('Custom templates cannot have the same key as a core template', 'my-calendar') . "</p></div>";
        } else {
            if (mc_is_core_template($key) && isset($_POST['mc_template'])) {
                $template = $_POST['mc_template'];
                $templates[$key] = $template;
                update_option('mc_templates', $templates);
                update_option('mc_use_' . $key . '_template', empty($_POST['mc_use_template']) ? 0 : 1);
                echo "<div class=\"updated\"><p>" . sprintf(__('%s Template saved', 'my-calendar'), ucfirst($key)) . "</p></div>";
            } else {
                if (isset($_POST['mc_template'])) {
                    $template = $_POST['mc_template'];
                    if (mc_key_exists($key)) {
                        $key = mc_update_template($key, $template);
                    } else {
                        $key = mc_create_template($template);
                    }
                    echo "<div class='updated'><p>" . __('Custom Template saved', 'my-calendar') . "</p></div>";
                }
            }
        }
    }
    // TODO: create UI for managing additional templates
    // TODO: create admin system for modifying shortcodes
    global $grid_template, $list_template, $mini_template, $single_template, $rss_template;
    $mc_grid_template = $templates['grid'] != '' ? $templates['grid'] : $grid_template;
    $mc_rss_template = $templates['rss'] != '' ? $templates['rss'] : $rss_template;
    $mc_list_template = $templates['list'] != '' ? $templates['list'] : $list_template;
    $mc_mini_template = $templates['mini'] != '' ? $templates['mini'] : $mini_template;
    $mc_details_template = $templates['details'] != '' ? $templates['details'] : $single_template;
    $template = mc_is_core_template($key) ? ${"mc_" . $key . "_template"} : mc_get_custom_template($key);
    $template = stripslashes($template);
    $core = mc_template_description($key);
    ?>
	<div class="wrap jd-my-calendar">
		<?php 
    my_calendar_check_db();
    ?>
		<h1 class="wp-heading-inline"><?php 
    _e('My Calendar Templates', 'my-calendar');
    ?>
</h1>
		<a href="<?php 
    echo add_query_arg('mc_template', 'add-new', admin_url("admin.php?page=my-calendar-templates"));
    ?>
" class="page-title-action"><?php 
    _e('Add New', 'my-calendar');
    ?>
</a> 
		<hr class="wp-header-end">
		<div class="postbox-container jcd-wide">
			<div class="metabox-holder">
				<div class="ui-sortable meta-box-sortables">
					<div class="postbox">
						<h2><?php 
    _e('Edit Template', 'my-calendar');
    ?>
</h2>
						<div class="inside">
							<p>
								<a href="<?php 
    echo admin_url("admin.php?page=my-calendar-help#templates");
    ?>
"><?php 
    _e("Templates Help", 'my-calendar');
    ?>
</a> &raquo;
							</p>
							<?php 
    if ($core != '') {
        echo "<p class='template-description'>{$core}</p>";
    }
    ?>
							<?php 
    if ($key == 'add-new') {
        ?>
								<form method="post" action="<?php 
        echo add_query_arg('mc_template', $key, admin_url("admin.php?page=my-calendar-templates"));
        ?>
">
								<div>
									<input type="hidden" name="_wpnonce" value="<?php 
        echo wp_create_nonce('my-calendar-nonce');
        ?>
"/>
								</div>
								<p>
									<label for="mc_template_key"><?php 
        _e('Template Description (required)', 'my-calendar');
        ?>
</label><br />
									<input type="text" class="widefat" name="mc_template_key" id="mc_template_key" value="" required />
								</p>
								<p>
									<label for="mc_template"><?php 
        _e('Custom Template', 'my-calendar');
        ?>
</label><br/>
									<textarea id="mc_template" name="mc_template" class="template-editor widefat" rows="32" cols="76"></textarea>
								</p>

								<p>
									<input type="submit" name="save" class="button-primary" value="<?php 
        _e('Add Template', 'my-calendar');
        ?>
" />
								</p>
							</form>								
							<?php 
    } else {
        ?>
							<form method="post" action="<?php 
        echo add_query_arg('mc_template', $key, admin_url("admin.php?page=my-calendar-templates"));
        ?>
">
								<div>
									<input type="hidden" name="_wpnonce" value="<?php 
        echo wp_create_nonce('my-calendar-nonce');
        ?>
"/>
									<input type="hidden" name="mc_template_key" value="<?php 
        esc_attr_e($key);
        ?>
"/>
								</div>
								<?php 
        if (mc_is_core_template($key)) {
            ?>
								<p>
									<input type="checkbox" id="mc_use_template" name="mc_use_template" value="1" <?php 
            mc_is_checked("mc_use_" . $key . "_template", 1);
            ?>
 /> <label for="mc_use_template"><?php 
            _e('Use this template', 'my-calendar');
            ?>
</label>
								</p>
								<?php 
        }
        ?>
								<p>
									<label for="mc_template"><?php 
        _e('Custom Template', 'my-calendar');
        ?>
</label><br/>
									<textarea id="mc_template" name="mc_template" class="template-editor widefat" rows="32" cols="76"><?php 
        echo $template;
        ?>
</textarea>
								</p>
								<p>
									<input type="submit" name="save" class="button-primary" value="<?php 
        _e('Update Template', 'my-calendar');
        ?>
" />
								<?php 
        if (!mc_is_core_template($key)) {
            ?>
									<input type="submit" name="delete" class="button-secondary" value=<?php 
            _e('Delete Template', 'my-calendar');
            ?>
" />
								<?php 
        }
        ?>
								</p>
							</form>
							<?php 
    }
    ?>
						</div>
					</div>
				</div>
			</div>
			<div class="metabox-holder">
				<div class="ui-sortable meta-box-sortables">
					<div class="postbox">
						<h2><?php 
    _e('Templates', 'my-calendar');
    ?>
</h2>

						<div class="inside">
							<?php 
    mc_list_templates();
    ?>
							<p>
								<a href="<?php 
    echo add_query_arg('mc_template', 'add-new', admin_url("admin.php?page=my-calendar-templates"));
    ?>
"><?php 
    _e('Add New Template', 'my-calendar');
    ?>
</a>
							</p>							
						</div>
					</div>
				</div>
			</div>
			<div class="metabox-holder">
				<div class="ui-sortable meta-box-sortables">
					<div class="postbox">
						<h2 class='hndle'><?php 
    _e('Event Template Tags', 'my-calendar');
    ?>
</h2>

						<div class='mc_template_tags inside'>
							<p>
								<a href="<?php 
    echo admin_url('admin.php?page=my-calendar-help#templates');
    ?>
"><?php 
    _e('All Template Tags &raquo;', 'my-calendar');
    ?>
</a>
							</p>						
							<dl>
								<dt><code>{title}</code></dt>
								<dd><?php 
    _e('Title of the event.', 'my-calendar');
    ?>
</dd>

								<dt><code>{link_title}</code></dt>
								<dd><?php 
    _e('Title of the event as a link if a URL is present, or the title alone if not.', 'my-calendar');
    ?>
</dd>

								<dt><code>{time}</code></dt>
								<dd><?php 
    _e('Start time for the event.', 'my-calendar');
    ?>
</dd>

								<dt><code>{date}</code></dt>
								<dd><?php 
    _e('Date on which the event begins.', 'my-calendar');
    ?>
</dd>

								<dt><code>{daterange}</code></dt>
								<dd><?php 
    _e('Beginning date to end date; excludes end date if same as beginning.', 'my-calendar');
    ?>
</dd>

								<dt><code>{multidate}</code></dt>
								<dd><?php 
    _e('Multi-day events: an unordered list of dates/times. Otherwise, beginning date/time.', 'my-calendar');
    ?>
</dd>

								<dt><code>{author}</code></dt>
								<dd><?php 
    _e('Author who posted the event.', 'my-calendar');
    ?>
</dd>

								<dt><code>{host}</code></dt>
								<dd><?php 
    _e('Name of the assigned host for the event.', 'my-calendar');
    ?>
</dd>

								<dt><code>{shortdesc}</code></dt>
								<dd><?php 
    _e('Short event description.', 'my-calendar');
    ?>
</dd>

								<dt><code>{description}</code></dt>
								<dd><?php 
    _e('Description of the event.', 'my-calendar');
    ?>
</dd>

								<dt><code>{image}</code></dt>
								<dd><?php 
    _e('Image associated with the event.', 'my-calendar');
    ?>
</dd>

								<dt><code>{link}</code></dt>
								<dd><?php 
    _e('URL provided for the event.', 'my-calendar');
    ?>
</dd>

								<dt><code>{details}</code></dt>
								<dd><?php 
    _e('Link to an auto-generated page containing information about the event.', 'my-calendar');
    ?>

								<dt><code>{event_open}</code></dt>
								<dd><?php 
    _e('Whether event is currently open for registration.', 'my-calendar');
    ?>
</dd>

								<dt><code>{event_status}</code></dt>
								<dd><?php 
    _e('Current status of event: either "Published" or "Reserved."', 'my-calendar');
    ?>
</dd>
							</dl>

							<h3><?php 
    _e('Location Template Tags', 'my-calendar');
    ?>
</h3>
							<dl>
								<dt><code>{location}</code></dt>
								<dd><?php 
    _e('Name of the location of the event.', 'my-calendar');
    ?>
</dd>

								<dt><code>{street}</code></dt>
								<dd><?php 
    _e('First line of the site address.', 'my-calendar');
    ?>
</dd>

								<dt><code>{street2}</code></dt>
								<dd><?php 
    _e('Second line of the site address.', 'my-calendar');
    ?>
</dd>

								<dt><code>{city}</code></dt>
								<dd><?php 
    _e('City', 'my-calendar');
    ?>
</dd>

								<dt><code>{state}</code></dt>
								<dd><?php 
    _e('State', 'my-calendar');
    ?>
</dd>

								<dt><code>{postcode}</code></dt>
								<dd><?php 
    _e('Postal Code', 'my-calendar');
    ?>
</dd>

								<dt><code>{region}</code></dt>
								<dd><?php 
    _e('Custom region.', 'my-calendar');
    ?>
</dd>

								<dt><code>{country}</code></dt>
								<dd><?php 
    _e('Country for the event location.', 'my-calendar');
    ?>
</dd>

								<dt><code>{sitelink}</code></dt>
								<dd><?php 
    _e('Output the URL for the location.', 'my-calendar');
    ?>
</dd>

								<dt><code>{hcard}</code></dt>
								<dd><?php 
    _e('Event address in <a href="http://microformats.org/wiki/hcard">hcard</a> format.', 'my-calendar');
    ?>
</dd>

								<dt><code>{link_map}</code></dt>
								<dd><?php 
    _e('Link to Google Map to the event, if address information is available.', 'my-calendar');
    ?>
</dd>
							</dl>
							<h3><?php 
    _e('Category Template Tags', 'my-calendar');
    ?>
</h3>

							<dl>
								<dt><code>{category}</code></dt>
								<dd><?php 
    _e('Name of the category of the event.', 'my-calendar');
    ?>
</dd>

								<dt><code>{icon}</code></dt>
								<dd><?php 
    _e('URL for the event\'s category icon.', 'my-calendar');
    ?>
</dd>

								<dt><code>{color}</code></dt>
								<dd><?php 
    _e('Hex code for the event\'s category color.', 'my-calendar');
    ?>
</dd>

								<dt><code>{cat_id}</code></dt>
								<dd><?php 
    _e('ID of the category of the event.', 'my-calendar');
    ?>
</dd>
							</dl>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php 
    mc_show_sidebar();
}
コード例 #10
0
function mcs_settings()
{
    mcs_check();
    $response = mcs_update_settings($_POST);
    echo $response;
    $options = get_option('mcs_options');
    $defaults = $options['defaults'];
    $mcs_to = get_option('mcs_to');
    // send to
    $mcs_from = get_option('mcs_from');
    // send from
    $mcs_subject = get_option('mcs_subject') ? get_option('mcs_subject') : $defaults['mcs_subject'];
    // subject line
    $mcs_edit_subject = get_option('mcs_edit_subject') ? get_option('mcs_edit_subject') : $defaults['mcs_subject'];
    // subject line
    $mcs_response = get_option('mcs_response') ? get_option('mcs_response') : $defaults['mcs_response'];
    // admin email after submission
    $mcs_confirmation = get_option('mcs_confirmation') ? get_option('mcs_confirmation') : $defaults['mcs_confirmation'];
    // submitter email after submission
    $mcs_confirmation_subject = get_option('mcs_confirmation_subject') ? get_option('mcs_confirmation_subject') : $defaults['mcs_confirmation_subject'];
    // subject line
    $mcs_edit_confirmation_subject = get_option('mcs_edit_confirmation_subject') ? get_option('mcs_edit_confirmation_subject') : $defaults['mcs_confirmation_subject'];
    // subject line
    $mcs_payments = get_option('mcs_payments') ? get_option('mcs_payments') : $defaults['mcs_payments'];
    // are payments required?
    //$mcs_payments_approved = ( get_option('mcs_payments_approved') )?get_option('mcs_payments_approved'):$defaults['mcs_payments_approved']; // paid submissions auto approved
    $mcs_payment_subject = get_option('mcs_payment_subject') ? get_option('mcs_payment_subject') : $defaults['mcs_payment_subject'];
    // subject line
    $mcs_payment_response = get_option('mcs_payment_response') ? get_option('mcs_payment_response') : $defaults['mcs_payment_response'];
    // admin email after submission
    $mcs_payment_confirmation = get_option('mcs_payment_confirmation') ? get_option('mcs_payment_confirmation') : $defaults['mcs_payment_confirmation'];
    // submitter email after submission
    $mcs_payment_confirmation_subject = get_option('mcs_payment_confirmation_subject') ? get_option('mcs_payment_confirmation_subject') : $defaults['mcs_payment_confirmation_subject'];
    // subject line
    $mcs_payment_message = get_option('mcs_payment_message') ? get_option('mcs_payment_message') : $defaults['mcs_payment_message'];
    // subject line
    $mcs_submission_fee = get_option('mcs_submission_fee') ? get_option('mcs_submission_fee') : $defaults['mcs_submission_fee'];
    // posting cost for public
    $mcs_members_discount = get_option('mcs_members_discount');
    // discount for members (percentage)
    $mcs_criteria = get_option('mcs_criteria') ? get_option('mcs_criteria') : $defaults['mcs_criteria'];
    // who can submit events
    $mcs_paypal_email = get_option('mcs_paypal_email');
    // paypal email
    $mcs_purchase_page = get_option('mcs_purchase_page');
    $mcs_use_sandbox = get_option('mcs_use_sandbox') ? get_option('mcs_use_sandbox') : $defaults['mcs_use_sandbox'];
    // use sandbox
    $mcs_paypal_merchant_id = get_option('mcs_paypal_merchant_id');
    // paypal merchant ID
    $mcs_button = get_option('mcs_button');
    $mcs_submit_id = get_option('mcs_submit_id');
    $mcs_date_format = get_option('mcs_date_format');
    $mcs_time_format = get_option('mcs_time_format');
    $mcs_currency = get_option('mcs_currency');
    $mcs_quantity = get_option('mcs_quantity');
    $mcs_discount = get_option('mcs_discount');
    $mcs_gateway = get_option('mcs_gateway');
    $mcs_authnet_api = get_option('mcs_authnet_api');
    $mcs_authnet_key = get_option('mcs_authnet_key');
    $mcs_authnet_hash = get_option('mcs_authnet_hash');
    $mcs_check_conflicts = get_option('mcs_check_conflicts');
    $mcs_upload_images = get_option('mcs_upload_images');
    $mcs_automatic_approval = get_option('mcs_automatic_approval');
    $mcs_dont_send_submitter_email = get_option('mcs_dont_send_submitter_email');
    $mcs_dont_send_admin_email = get_option('mcs_dont_send_admin_email');
    ?>
    <div class="wrap jd-my-calendar" id="mc_settings">
	<?php 
    my_calendar_check_db();
    ?>
	<h2><?php 
    _e('My Calendar Pro', 'my-calendar-submissions');
    ?>
</h2>
	<div class="mc-tabs mcs-tabs">
		<ul class="tabs" role="tablist">
			<li role="tab" id="tab_mcs" aria-controls="mcs_tab"><a href="#mcs_tab"><?php 
    _e('Submissions', 'my-calendar');
    ?>
</a></li>
			<li role="tab" id="tab_mcs_payments" aria-controls="mcs_payments_tab"><a href="#mcs_payments_tab"><?php 
    _e('Payments', 'my-calendar');
    ?>
</a></li>
			<?php 
    $tabs = apply_filters('mcs_settings_tabs', array());
    foreach ($tabs as $key => $value) {
        $key = sanitize_title($key);
        $value = esc_html($value);
        echo '<li role="tab" id="tab_mcs_' . $key . '" aria-controls="mcs_' . $key . '_tab"><a href="#mcs_' . $key . '_tab">' . $value . '</a></li>' . "\n";
    }
    ?>
		</ul>
	<div class="mcs-settings settings postbox-container jcd-wide">
		
	<div class="metabox-holder wptab" aria-labelledby="tab_mcs" role="tabpanel" aria-live="assertive" id="mcs_tab">
		
		<div class="ui-sortable meta-box-sortables">   
		<div class="postbox">
			<h3><?php 
    _e('Event Submissions Settings', 'my-calendar-submissions');
    ?>
</h3>
			<div class="inside">
			<p>
			<a href="<?php 
    echo admin_url('admin.php?page=my-calendar-manage&amp;limit=reserved#my-calendar-admin-table');
    ?>
"><?php 
    _e('View pending event submissions', 'my-calendar-submissions');
    ?>
</a>
			</p>
			<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-submissions");
    ?>
">
			<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-submissions');
    ?>
" /></div>
			<p>
			<label for="mcs_submit_id"><?php 
    _e('Event Submission Page ID', 'my-calendar-submissions');
    ?>
</label> <input type="text" name="mcs_submit_id" id="mcs_submit_id" size="6" value="<?php 
    echo esc_attr(trim($mcs_submit_id));
    ?>
" />
			</p>			
			<p class='format'>
			<label for="mcs_date_format"><?php 
    _e('Date format hint', 'my-calendar-submissions');
    ?>
</label> <select name="mcs_date_format" id="mcs_date_format">
			<option value="m/d/Y" <?php 
    echo mc_is_selected('mcs_date_format', 'm/d/y');
    ?>
><?php 
    echo date('m/d/Y');
    ?>
</option>
			<option value="d-m-Y" <?php 
    echo mc_is_selected('mcs_date_format', 'd-m-Y');
    ?>
><?php 
    echo date('d-m-Y');
    ?>
</option>
			<option value="Y-m-d" <?php 
    echo mc_is_selected('mcs_date_format', 'Y-m-d');
    ?>
><?php 
    echo date('Y-m-d');
    ?>
</option>
			<option value="j F Y" <?php 
    echo mc_is_selected('mcs_date_format', 'j F Y');
    ?>
><?php 
    echo date_i18n('j F Y');
    ?>
</option>
			<option value="M j, Y" <?php 
    echo mc_is_selected('mcs_date_format', 'M j, Y');
    ?>
><?php 
    echo date('M j, Y');
    ?>
</option>
			</select>
			</p>
			<p class='format'>
			<label for="mcs_time_format"><?php 
    _e('Time format hint', 'my-calendar-submissions');
    ?>
</label> <select name="mcs_time_format" id="mcs_time_format">
			<option value="h:i a" <?php 
    echo mc_is_selected('mcs_time_format', 'h:i a');
    ?>
><?php 
    echo date('h:i a');
    ?>
</option>
			<option value="H:i" <?php 
    echo mc_is_selected('mcs_time_format', 'H:i');
    ?>
><?php 
    echo date('H:i');
    ?>
</option>
			</select>
			</p>			
			<p>
			<input type="checkbox" id="mcs_check_conflicts" name="mcs_check_conflicts" <?php 
    mc_is_checked('mcs_check_conflicts', 'true');
    ?>
 /> <label for="mcs_check_conflicts"><?php 
    _e('Prevent conflicting events. (if locations are used, checks only for conflicts at that location.)', 'my-calendar-submissions');
    ?>
</label>
			</p>
			<p>
			<input type="checkbox" id="mcs_upload_images" name="mcs_upload_images" <?php 
    mc_is_checked('mcs_upload_images', 'true');
    ?>
 /> <label for="mcs_upload_images"><?php 
    _e('Allow public event submitters to upload their own images', 'my-calendar-submissions');
    ?>
</label>
			</p>			
			<p>
			<input type="checkbox" id="mcs_automatic_approval" name="mcs_automatic_approval" <?php 
    mc_is_checked('mcs_automatic_approval', 'true');
    ?>
 /> <label for="mcs_automatic_approval"><?php 
    _e('Submitted events do not require approval.', 'my-calendar-submissions');
    ?>
</label>
			</p>
			<p>
			<input type="checkbox" id="mcs_dont_send_submitter_email" name="mcs_dont_send_submitter_email" <?php 
    mc_is_checked('mcs_dont_send_submitter_email', 'true');
    ?>
 /> <label for="mcs_dont_send_submitter_email"><?php 
    _e('Disable submitter email notification on automatically approved events.', 'my-calendar-submissions');
    ?>
</label>
			</p>
			<p>
			<input type="checkbox" id="mcs_dont_send_admin_email" name="mcs_dont_send_admin_email" <?php 
    mc_is_checked('mcs_dont_send_admin_email', 'true');
    ?>
 /> <label for="mcs_dont_send_admin_email"><?php 
    _e('Disable admin email notification on automatically approved events.', 'my-calendar-submissions');
    ?>
</label>
			</p>			
			<h4><?php 
    _e('New event messages', 'my-calendar-submissions');
    ?>
</h4>
			<p>
			<input type="checkbox" id="mcs_html_email" name="mcs_html_email" <?php 
    mc_is_checked('mcs_html_email', 'true');
    ?>
 /> <label for="mcs_html_email"><?php 
    _e('Send email notifications as HTML.', 'my-calendar-submissions');
    ?>
</label>
			</p>
			<fieldset>
			<legend><?php 
    _e('Sent to administrators', 'my-calendar-submissions');
    ?>
</legend>
			<ul>
			<li>
			<label for="mcs_to"><?php 
    _e('Send notifications to:', 'my-calendar-submissions');
    ?>
</label> <input type="text" name="mcs_to" id="mcs_to" size="60" value="<?php 
    echo $mcs_to == '' ? get_bloginfo('admin_email') : esc_attr($mcs_to);
    ?>
" />
			</li>
			<li>
			<label for="mcs_from"><?php 
    _e('Send notifications from:', 'my-calendar-submissions');
    ?>
</label> <input type="text" name="mcs_from" id="mcs_from" size="60" value="<?php 
    echo $mcs_from == '' ? get_bloginfo('admin_email') : esc_attr($mcs_from);
    ?>
" />
			</li>
			<li>
			<label for="mcs_subject"><?php 
    _e('Notification Subject', 'my-calendar-submissions');
    ?>
</label> <input type="text" name="mcs_subject" id="mcs_subject" size="60" value="<?php 
    echo stripslashes(esc_attr($mcs_subject));
    ?>
" />
			</li>
			<li>
			<label for="mcs_edit_subject"><?php 
    _e('Notification Subject (Edits)', 'my-calendar-submissions');
    ?>
</label> <input type="text" name="mcs_edit_subject" id="mcs_edit_subject" size="60" value="<?php 
    echo stripslashes(esc_attr($mcs_edit_subject));
    ?>
" />
			</li>		
			<li>
			<label for="mcs_response"><?php 
    _e('Notification message', 'my-calendar-submissions');
    ?>
</label><br /><textarea name="mcs_response" id="mcs_response" rows="4" cols="60"><?php 
    echo stripslashes(esc_attr($mcs_response));
    ?>
</textarea>
			<?php 
    $edit_link = mcs_submit_url() ? ', <code>edit_link</code>' : '';
    ?>
			<em><?php 
    echo __('Available template tags: <code>first_name</code>, <code>last_name</code>, <code>email</code>, <code>title</code>, <code>date</code>, <code>time</code>, <code>description</code>, <code>short</code>, <code>image</code>, <code>url</code>, <code>location</code>, <code>street</code>, <code>city</code>, <code>phone</code>, <code>blogname</code>', 'my-calendar-submissions') . $edit_link;
    ?>
</em>
			</li>
			</ul>
			</fieldset>
			<fieldset>
			<legend><?php 
    _e('Sent to event submitter', 'my-calendar-submissions');
    ?>
</legend>
			<ul>
			<li>
			<label for="mcs_confirmation_subject"><?php 
    _e('Confirmation Subject', 'my-calendar-submissions');
    ?>
</label> <input type="text" name="mcs_confirmation_subject" id="mcs_confirmation_subject" size="60" value="<?php 
    echo stripslashes(esc_attr($mcs_confirmation_subject));
    ?>
" />
			</li>
			<li>
			<label for="mcs_edit_confirmation_subject"><?php 
    _e('Confirmation Subject', 'my-calendar-submissions');
    ?>
</label> <input type="text" name="mcs_edit_confirmation_subject" id="mcs_edit_confirmation_subject" size="60" value="<?php 
    echo stripslashes(esc_attr($mcs_edit_confirmation_subject));
    ?>
" />
			</li>			
			<li>
			<label for="mcs_confirmation"><?php 
    _e('Submitter confirmation message', 'my-calendar-submissions');
    ?>
</label><br /><textarea name="mcs_confirmation" id="mcs_confirmation" rows="4" cols="60"><?php 
    echo stripslashes(esc_attr($mcs_confirmation));
    ?>
</textarea>
			<em><?php 
    _e('Available template tags: <code>first_name</code>, <code>last_name</code>, <code>email</code>, <code>title</code>, <code>date</code>, <code>time</code>, <code>description</code>, <code>short</code>, <code>image</code>, <code>url</code>, <code>location</code>, <code>street</code>, <code>city</code>, <code>phone</code> <code>blogname</code>, <code>edit_link</code>', 'my-calendar-submissions');
    ?>
</em>
			</li>	
			</ul>
			</fieldset>
			<h4><?php 
    _e('Event Submission Criteria', 'my-calendar-submissions');
    ?>
</h4>
			<fieldset>
			<legend><?php 
    _e('Who may use the front-end event submission widget?', 'my-calendar-submissions');
    ?>
</legend>
			<ul>
			<li>
			<input type="radio" id="mcs_public" name="mcs_criteria" value="1" <?php 
    mc_is_checked('mcs_criteria', '1');
    ?>
 /> <label for="mcs_public"><?php 
    _e('General public.', 'my-calendar-submissions');
    ?>
</label>
			</li>			
			<li>
			<input type="radio" id="mcs_members_only" name="mcs_criteria" value="2" <?php 
    mc_is_checked('mcs_criteria', '2');
    ?>
 /> <label for="mcs_members_only"><?php 
    _e('Members.', 'my-calendar-submissions');
    ?>
</label>
			</li>
			<li>
			<input type="radio" id="mcs_member_status" name="mcs_criteria" value="3" <?php 
    mc_is_checked('mcs_criteria', '3');
    ?>
 /> <label for="mcs_member_status"><?php 
    _e('Members with the "mc_add_events" capability.', 'my-calendar-submissions');
    ?>
</label>
			</li>
			</ul>
			</fieldset>
			<p><input type="submit" name="mc-submit-settings" class="button-primary" value="<?php 
    _e('Save Submissions Settings', 'my-calendar-submissions');
    ?>
" /></p>			
			</form>			
			</div>
		</div>
		</div>
	</div>
	<div class="metabox-holder wptab" aria-labelledby="tab_payments_mcs" role="tabpanel" aria-live="assertive" id="mcs_payments_tab">
	<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-submissions#mcs_payments_tab");
    ?>
">
	<div class="ui-sortable meta-box-sortables">   
		<div class="postbox">
			<h3><?php 
    _e('Payment Settings', 'my-calendar-submissions');
    ?>
</h3>
			<div class="inside">
			<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-submissions');
    ?>
" /></div>
			<ul>
			<li>
			<input type="checkbox" id="mcs_payments" name="mcs_payments" <?php 
    mc_is_checked('mcs_payments', 'true');
    ?>
 /> <label for="mcs_payments"><?php 
    _e('Require payment to submit an event', 'my-calendar-submissions');
    ?>
</label>
			</li>
			<?php 
    if (get_option('mcs_payments') == 'true') {
        ?>
			<li>
			<input type="checkbox" id="mcs_use_sandbox" name="mcs_use_sandbox" <?php 
        mc_is_checked('mcs_use_sandbox', 'true');
        ?>
 /> <label for="mcs_use_sandbox"><?php 
        _e('Place gateway in Testing mode', 'my-calendar-submissions');
        ?>
</label>
			</li>
			<li>
			<input type="checkbox" id="mcs_quantity" name="mcs_quantity" <?php 
        mc_is_checked('mcs_quantity', 'true');
        ?>
 /> <label for="mcs_quantity"><?php 
        _e('Visitors may purchase multiple-use payment keys', 'my-calendar-submissions');
        ?>
</label>
			</li>
			<li>
			<label for="mcs_payment_message"><?php 
        _e('Payment Form Message (shows above payments form)', 'my-calendar-submissions');
        ?>
</label> <textarea type="text" name="mcs_payment_message" id="mcs_payment_message" rows="2" cols="60"><?php 
        echo stripslashes(esc_attr($mcs_payment_message));
        ?>
</textarea>
			<em><?php 
        _e('Available template tags: <code>blogname</code>, <code>begins</code>, <code>ends</code>, <code>price</code>, <code>discount</code>, <code>currency</code>', 'my-calendar-submissions');
        ?>
</em>
			</li>			
			</ul>
			<h4><?php 
        _e('New purchase messages', 'my-calendar-submissions');
        ?>
</h4>
			<fieldset>
			<legend><?php 
        _e('Sent to administrators', 'my-calendar-submissions');
        ?>
</legend>
			<ul>
			<li>
			<label for="mcs_payment_subject"><?php 
        _e('Payment Notification Subject', 'my-calendar-submissions');
        ?>
</label> <input type="text" name="mcs_payment_subject" id="mcs_payment_subject" size="60" value="<?php 
        echo stripslashes(esc_attr($mcs_payment_subject));
        ?>
" />
			</li>
			<li>
			<label for="mcs_payment_response"><?php 
        _e('Payment Notification message', 'my-calendar-submissions');
        ?>
</label><br /><textarea name="mcs_payment_response" id="mcs_payment_response" rows="4" cols="60"><?php 
        echo stripslashes(esc_attr($mcs_payment_response));
        ?>
</textarea>
			<em><?php 
        _e('Available template tags: <code>blogname</code>, <code>first_name</code>, <code>last_name</code>, <code>price</code>, <code>key</code>, <code>quantity</code>, <code>receipt</code>', 'my-calendar-submissions');
        ?>
</em>
			</li>
			</ul>
			</fieldset>
			<fieldset>
			<legend><?php 
        _e('Sent to purchaser', 'my-calendar-submissions');
        ?>
</legend>
			<ul>
			<li>
			<label for="mcs_payment_confirmation_subject"><?php 
        _e('Payment Confirmation Subject', 'my-calendar-submissions');
        ?>
</label> <input type="text" name="mcs_payment_confirmation_subject" id="mcs_payment_confirmation_subject" size="60" value="<?php 
        echo stripslashes(esc_attr($mcs_payment_confirmation_subject));
        ?>
" />
			</li>
			<li>
			<label for="mcs_payment_confirmation"><?php 
        _e('Payment Submitter confirmation message', 'my-calendar-submissions');
        ?>
</label><br /><textarea name="mcs_payment_confirmation" id="mcs_payment_confirmation" rows="4" cols="60"><?php 
        echo stripslashes(esc_attr($mcs_payment_confirmation));
        ?>
</textarea>
			<em><?php 
        _e('Available template tags: <code>first_name</code>, <code>last_name</code>, <code>price</code>, <code>key</code>, <code>quantity</code>, <code>receipt</code>', 'my-calendar-submissions');
        ?>
</em>
			</li>	
			</ul>
			</fieldset>
			<ul>
			<li>
			<?php 
        $pricing = apply_filters('mcs_submission_fee_settings', false);
        if (!$pricing) {
            ?>
			<label for="mcs_submission_fee"><?php 
            _e('Base price:', 'my-calendar-submissions');
            ?>
</label> <input type="text" name="mcs_submission_fee" id="mcs_submission_fee" size="60" value="<?php 
            echo esc_attr($mcs_submission_fee);
            ?>
" />
			<?php 
        } else {
            echo $pricing;
        }
        ?>
			</li>
			<li><label for="mcs_currency"><?php 
        _e('Currency:', 'my-calendar-submissions');
        ?>
</label> 
			<?php 
        $mcs_currency_codes = array("USD" => __('U.S. Dollars ($)', 'my-calendar-submissions'), "EUR" => __('Euros (€)', 'my-calendar-submissions'), "AUD" => __('Australian Dollars (A $)', 'my-calendar-submissions'), "CAD" => __('Canadian Dollars (C $)', 'my-calendar-submissions'), "GBP" => __('Pounds Sterling (£)', 'my-calendar-submissions'), "JPY" => __('Yen (¥)', 'my-calendar-submissions'), "NZD" => __('New Zealand Dollar ($)', 'my-calendar-submissions'), "CHF" => __('Swiss Franc', 'my-calendar-submissions'), "HKD" => __('Hong Kong Dollar ($)', 'my-calendar-submissions'), "SGD" => __('Singapore Dollar ($)', 'my-calendar-submissions'), "SEK" => __('Swedish Krona', 'my-calendar-submissions'), "DKK" => __('Danish Krone', 'my-calendar-submissions'), "PLN" => __('Polish Zloty', 'my-calendar-submissions'), "NOK" => __('Norwegian Krone', 'my-calendar-submissions'), "HUF" => __('Hungarian Forint', 'my-calendar-submissions'), "ILS" => __('Israeli Shekel', 'my-calendar-submissions'), "MXN" => __('Mexican Peso', 'my-calendar-submissions'), "BRL" => __('Brazilian Real (only for Brazilian users)', 'my-calendar-submissions'), "MYR" => __('Malaysian Ringgits (only for Malaysian users)', 'my-calendar-submissions'), "PHP" => __('Philippine Pesos', 'my-calendar-submissions'), "TWD" => __('Taiwan New Dollars', 'my-calendar-submissions'), "THB" => __('Thai Baht', 'my-calendar-submissions'), "TRY" => __('Turkish Lira (only for Turkish users)', 'my-calendar-submissions'));
        echo "<select name='mcs_currency' id='mcs_currency'>";
        foreach ($mcs_currency_codes as $code => $currency) {
            $selected = get_option('mcs_currency') == $code ? "selected='selected'" : "";
            echo "<option value='{$code}' {$selected}>{$currency}</option>";
        }
        echo "</select>";
        ?>
			</li>
			<li>
			<label for="mcs_members_discount"><?php 
        _e('Member discount (%)', 'my-calendar-submissions');
        ?>
</label> <input type="text" name="mcs_members_discount" id="mcs_members_discount" size="3" value="<?php 
        echo esc_attr($mcs_members_discount);
        ?>
" /> <?php 
        _e('Member\'s discounted cost:', 'my-calendar-submissions');
        ?>
 <?php 
        echo mcs_get_price(true);
        ?>
			</li>
			<?php 
        echo apply_filters('mcs_custom_fields', '');
        ?>
			</ul>
			</div>
		</div>
	</div>
	<div class="ui-sortable meta-box-sortables">   
		<div class="postbox">
			<h3><?php 
        _e('Payment Gateways', 'my-calendar-submissions');
        ?>
</h3>
			<div class="inside">
			<ul>
			<li>
			<input type="radio" id="mcs_gateway_paypal" name="mcs_gateway" value="paypal" <?php 
        mc_is_checked('mcs_gateway', 'paypal');
        ?>
 /> <label for="mcs_gateway_paypal"><?php 
        _e('Use Paypal', 'my-calendar-submissions');
        ?>
</label>
			</li>
			<li>
			<input type="radio" id="mcs_gateway_authorizenet" name="mcs_gateway" value="authorizenet" <?php 
        mc_is_checked('mcs_gateway', 'authorizenet');
        ?>
 /> <label for="mcs_gateway_authorizenet"><?php 
        _e('Use Authorize.net', 'my-calendar-submissions');
        ?>
</label>
			</li>
			<li>
			<input type="checkbox" id="mcs_ssl" name="mcs_ssl" value="true" aria-describedby="mcs_ssl_desc" <?php 
        mc_is_checked('mcs_ssl', 'true');
        ?>
 /> <label for="mcs_ssl"><?php 
        _e('Use SSL for Payment pages.', 'my-calendar-submissions');
        ?>
</label><br />
			<span id="mcs_ssl_desc"><?php 
        _e('SSL is not required for My Calendar Pro to be secure, but can improve the comfort level of your users on your site.', 'my-calendar-submissions');
        ?>
</span>
			</li>
			<li>
			<?php 
        if (get_option('mcs_ssl') == 'true') {
            $required = 'required aria-required="true"';
        } else {
            $required = '';
        }
        ?>
			<input type="text" size='4' id="mcs_purchase_page" name="mcs_purchase_page" value="<?php 
        echo esc_attr($mcs_purchase_page);
        ?>
"<?php 
        echo $required;
        ?>
 /> <label for="mcs_purchase_page"><?php 
        _e('Post ID for My Calendar Submissions form.', 'my-calendar-submissions');
        ?>
</label><br />
			</li>			
			</ul>
			<?php 
        if (get_option('mcs_gateway') == 'authorizenet') {
            ?>
			<h4><?php 
            _e('Authorize.net Settings', 'my-calendar-submissions');
            ?>
</h4>
			<fieldset>
			<div>
				<input type="hidden" name="mcs_paypal_email" value="<?php 
            echo esc_attr($mcs_paypal_email);
            ?>
" />
				<input type="hidden" name="mcs_paypal_merchant_id" value="<?php 
            echo esc_attr($mcs_paypal_merchant_id);
            ?>
" />
			</div>
			<legend><?php 
            _e('Authorize.net Settings', 'my-calendar-submissions');
            ?>
</legend>
			<ul>
			<li>
			<label for="mcs_authnet_api"><?php 
            _e('API Login ID', 'my-calendar-submissions');
            ?>
</label> <input type="text" name="mcs_authnet_api" id="mcs_authnet_api" size="60" value="<?php 
            echo esc_attr($mcs_authnet_api);
            ?>
" />
			</li>
			<li>
			<label for="mcs_authnet_key"><?php 
            _e('Transaction Key', 'my-calendar-submissions');
            ?>
</label> <input type="text" name="mcs_authnet_key" id="mcs_authnet_key" size="60" value="<?php 
            echo esc_attr($mcs_authnet_key);
            ?>
" />
			</li>
			<li>
			<label for="mcs_authnet_hash"><?php 
            _e('MD5 Hash Value', 'my-calendar-submissions');
            ?>
</label> <input type="text" name="mcs_authnet_hash" id="mcs_authnet_hash" size="60" value="<?php 
            echo esc_attr($mcs_authnet_hash);
            ?>
" />
			</li>			
			</ul>
			</fieldset>	
			
			<?php 
        } else {
            ?>
			<h4><?php 
            _e('PayPal Settings', 'my-calendar-submissions');
            ?>
</h4>
			<fieldset>
			<div>
				<input type="hidden" name="mcs_authnet_api" value="<?php 
            echo esc_attr($mcs_authnet_api);
            ?>
" />
				<input type="hidden" name="mcs_authnet_key" value="<?php 
            echo esc_attr($mcs_authnet_key);
            ?>
" />
				<input type="hidden" name="mcs_authnet_hash" value="<?php 
            echo esc_attr($mcs_authnet_hash);
            ?>
" />
			</div>			
			<legend><?php 
            _e('PayPal Settings', 'my-calendar-submissions');
            ?>
</legend>
			<ul>
			<li>
			<label for="mcs_paypal_email"><?php 
            _e('Paypal email (primary)', 'my-calendar-submissions');
            ?>
</label> <input type="text" name="mcs_paypal_email" id="mcs_paypal_email" size="60" value="<?php 
            echo esc_attr($mcs_paypal_email);
            ?>
" />
			</li>
			<li>
			<label for="mcs_paypal_merchant_id"><?php 
            _e('Paypal merchant ID', 'my-calendar-submissions');
            ?>
</label> <input type="text" name="mcs_paypal_merchant_id" id="mcs_paypal_merchant_id" size="60" value="<?php 
            echo esc_attr($mcs_paypal_merchant_id);
            ?>
" />
			</li>
			</ul>
			</fieldset>
			
			<?php 
        }
        ?>
			<ul>
			<li>
			<label for="mcs_button"><?php 
        _e('Purchase Button image', 'my-calendar-submissions');
        ?>
</label> <input type="text" name="mcs_button" id="mcs_button" size="60" value="<?php 
        echo esc_url($mcs_button);
        ?>
" />
			</li>
			</ul>
			</div>
		</div>
	</div>
	<div class="ui-sortable meta-box-sortables">   
		<div class="postbox">
			<h3><?php 
        _e('Configure a Sale', 'my-calendar-submissions');
        ?>
</h3>
			<div class="inside">
			<fieldset>
			<legend><?php 
        _e('Sale settings', 'my-calendar-submissions');
        ?>
</legend>
			<?php 
        $sales = apply_filters('mcs_custom_sale', false);
        if (!$sales) {
            ?>
				<ul>
				<li>
				<label for="mcs_sale_begins"><?php 
            _e('Date sale begins (e.g. November 24th, 2013)', 'my-calendar-submissions');
            ?>
</label> <input type="text" name="mcs_discount[begins]" id="mcs_sale_begins" size="20" value="<?php 
            echo isset($mcs_discount['begins']) ? esc_attr($mcs_discount['begins']) : '';
            ?>
" /> <?php 
            _e('Discounted cost per event:', 'my-calendar-submissions');
            ?>
 <?php 
            echo sprintf('$%01.2f', mcs_get_price(true));
            ?>
				</li>
				<li>
				<label for="mcs_sale_ends"><?php 
            _e('Date sale ends (e.g. December 25th, 2013)', 'my-calendar-submissions');
            ?>
</label> <input type="text" name="mcs_discount[ends]" id="mcs_sale_ends" size="20" value="<?php 
            echo isset($mcs_discount['ends']) ? esc_attr($mcs_discount['ends']) : '';
            ?>
" />
				</li>
				<li>
				<label for="mcs_sale_rate"><?php 
            _e('Percentage discount', 'my-calendar-submissions');
            ?>
</label> <input type="text" name="mcs_discount[rate]" id="mcs_sale_rate" size="3" value="<?php 
            echo isset($mcs_discount['rate']) ? esc_attr($mcs_discount['rate']) : '';
            ?>
" />
				</li>
				</ul>
			<?php 
        } else {
            echo $sales;
        }
        ?>
				<p><?php 
        _e('<strong>Note:</strong> if members have a discount, the additional sale rate will not be compounded with their normal rate.', 'my-calendar-submissions');
        ?>
</p>
			</fieldset>
			<?php 
    } else {
        ?>
				<div>
				<input type="hidden" name="mcs_payment_response" value="<?php 
        echo $mcs_payment_response;
        ?>
" />
				<input type="hidden" name="mcs_payment_confirmation" value="<?php 
        echo $mcs_payment_confirmation;
        ?>
" />
				<input type="hidden" name="mcs_payment_subject" value="<?php 
        echo $mcs_payment_subject;
        ?>
" />
				<input type="hidden" name="mcs_payment_message" value="<?php 
        echo $mcs_payment_message;
        ?>
" />
				<input type="hidden" name="mcs_payment_confirmation_subject" value="<?php 
        echo $mcs_payment_confirmation_subject;
        ?>
" />
				<input type="hidden" name="mcs_submission_fee" value="<?php 
        echo $mcs_submission_fee;
        ?>
" />
				<input type="hidden" name="mcs_members_discount" value="<?php 
        echo $mcs_members_discount;
        ?>
" />
				<input type="hidden" name="mcs_paypal_email" value="<?php 
        echo $mcs_paypal_email;
        ?>
" />
				<input type="hidden" name="mcs_paypal_merchant_id" value="<?php 
        echo $mcs_paypal_merchant_id;
        ?>
" />
				<input type="hidden" name="mcs_button" value="<?php 
        echo $mcs_button;
        ?>
" />
				<input type="hidden" name="mcs_currency" value="<?php 
        echo $mcs_currency;
        ?>
" />
				<input type="hidden" name="mcs_discount[begins]" value="<?php 
        echo $mcs_discount['begins'];
        ?>
" />
				<input type="hidden" name="mcs_discount[ends]" value="<?php 
        echo $mcs_discount['ends'];
        ?>
" />
				<input type="hidden" name="mcs_discount[rate]" value="<?php 
        echo $mcs_discount['rate'];
        ?>
" />
				</div>
			<?php 
    }
    ?>
				<p><input type="submit" name="mc-payment-settings" class="button-primary" value="<?php 
    _e('Save Payment Settings', 'my-calendar-submissions');
    ?>
" /></p>			
			</div>
		</div>		
	</div>
	</form>	
	</div>		
	<?php 
    $panels = apply_filters('mcs_settings_panels', array());
    foreach ($panels as $key => $value) {
        $content = is_array($value) && isset($value['content']) ? $value['content'] : $value;
        $label = is_array($value) && isset($value['label']) ? $value['label'] : __('Save Settings');
        $wp_nonce = wp_nonce_field($key, '_wpnonce', true, false);
        $top = '
			<div class="metabox-holder wptab" aria-labelledby="tab_' . $key . '_mcs" role="tabpanel" aria-live="assertive" id="mcs_' . $key . '_tab">
				<form method="post" action="' . admin_url("admin.php?page=my-calendar-submissions#mcs_{$key}" . '_tab') . '" enctype="multipart/form-data">' . $wp_nonce . '<div class="ui-sortable meta-box-sortables">   
						<div class="postbox">';
        $bottom = '
						</div>
					</div>
				</form>
			</div>';
        $middle = str_replace('{submit}', '<p><input type="submit" name="' . $key . '_settings" class="button-primary" value="' . $label . '" /></p>', $content);
        echo $top . $middle . $bottom;
    }
    ?>
	</div>
	<?php 
    if (function_exists('mcs_submit_exists')) {
        $remove = true;
    } else {
        $remove = false;
    }
    $guide_url = plugins_url('/My-Calendar-Pro.pdf', __FILE__);
    $add = array('Event Submissions Shortcode' => '<p>' . __('The event submissions form can be configured via shortcode or via widget.', 'my-calendar-submissions') . '</p>
			<p>' . __('New events are always submitted with approval pending and must be approved by a user with appropriate permissions in order to appear on the site.', 'my-calendar-submissions') . '</p>
			<p>' . sprintf(__('Use the <a href="%s">shortcode generator</a> to create your My Calendar submissions form!', 'my-calendar-submissions'), admin_url('admin.php?page=my-calendar-help#mc-generator')) . '</p>', 'Responsive Mode' => '<p>' . __('The file <code>mc-responsive.css</code> in your theme directory will replace the My Calendar PRO responsive stylesheet.', 'my-calendar-submissions') . '</p>');
    ?>
	<?php 
    mc_show_sidebar('', $add, $remove);
    ?>
</div>
</div>
<?php 
    // creates settings page for my calendar appointments
}
コード例 #11
0
function edit_my_calendar_behaviors()
{
    global $wpdb, $initial_listjs, $initial_caljs, $initial_minijs, $initial_ajaxjs;
    $mcdb = $wpdb;
    if (isset($_POST['mc_caljs'])) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        $mc_caljs = $_POST['mc_caljs'];
        $mc_listjs = $_POST['mc_listjs'];
        $mc_minijs = $_POST['mc_minijs'];
        $mc_ajaxjs = $_POST['mc_ajaxjs'];
        update_option('mc_calendar_javascript', empty($_POST['calendar_javascript']) ? 0 : 1);
        update_option('mc_list_javascript', empty($_POST['list_javascript']) ? 0 : 1);
        update_option('mc_mini_javascript', empty($_POST['mini_javascript']) ? 0 : 1);
        update_option('mc_ajax_javascript', empty($_POST['ajax_javascript']) ? 0 : 1);
        // set js
        update_option('mc_listjs', $mc_listjs);
        update_option('mc_minijs', $mc_minijs);
        update_option('mc_caljs', $mc_caljs);
        update_option('mc_ajaxjs', $mc_ajaxjs);
        $mc_show_js = $_POST['mc_show_js'] == '' ? '' : $_POST['mc_show_js'];
        update_option('mc_show_js', $mc_show_js);
        if (!empty($_POST['reset_caljs'])) {
            update_option('mc_caljs', $initial_caljs);
        }
        if (!empty($_POST['reset_listjs'])) {
            update_option('mc_listjs', $initial_listjs);
        }
        if (!empty($_POST['reset_minijs'])) {
            update_option('mc_minijs', $initial_minijs);
        }
        if (!empty($_POST['reset_ajaxjs'])) {
            update_option('mc_ajaxjs', $initial_ajaxjs);
        }
        echo "<div class=\"updated\"><p><strong>" . __('Behavior Settings saved', 'my-calendar') . ".</strong></p></div>";
    }
    $mc_listjs = stripcslashes(get_option('mc_listjs'));
    $list_javascript = get_option('mc_list_javascript');
    $mc_caljs = stripcslashes(get_option('mc_caljs'));
    $calendar_javascript = get_option('mc_calendar_javascript');
    $mc_minijs = stripcslashes(get_option('mc_minijs'));
    $mini_javascript = get_option('mc_mini_javascript');
    $mc_ajaxjs = stripcslashes(get_option('mc_ajaxjs'));
    $ajax_javascript = get_option('mc_ajax_javascript');
    $mc_show_js = stripcslashes(get_option('mc_show_js'));
    // Now we render the form
    ?>
<div class="wrap jd-my-calendar">
	<?php 
    my_calendar_check_db();
    ?>
    <h2><?php 
    _e('My Calendar Behaviors', 'my-calendar');
    ?>
</h2>
	<div class="postbox-container jcd-wide">
	<div class="metabox-holder">

	<div class="ui-sortable meta-box-sortables">
	<div class="postbox" id="cdiff">
	
	<h3><?php 
    _e('Calendar Behavior Settings', 'my-calendar');
    ?>
</h3>
	<div class="inside">	
    <form id="my-calendar" method="post" action="<?php 
    echo admin_url('admin.php?page=my-calendar-behaviors');
    ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
	<p>
	<label for="mc_show_js"><?php 
    _e('Insert scripts on these pages (comma separated post IDs)', 'my-calendar');
    ?>
</label> <input type="text" id="mc_show_js" name="mc_show_js" value="<?php 
    echo $mc_show_js;
    ?>
" />
	</p>  
	<fieldset>
	<legend><?php 
    _e('Calendar Behaviors: Grid View', 'my-calendar');
    ?>
</legend>
	<p>
	<input type="checkbox" id="reset_caljs" name="reset_caljs" /> <label for="reset_caljs"><?php 
    _e('Restore Grid View JavaScript', 'my-calendar');
    ?>
</label> <input type="checkbox" id="calendar_javascript" name="calendar_javascript" value="1"  <?php 
    mc_is_checked('mc_calendar_javascript', 1);
    ?>
/> <label for="calendar_javascript"><?php 
    _e('Disable Grid Javascript', 'my-calendar');
    ?>
</label>
	</p>
	<p>
	<label for="calendar-javascript"><?php 
    _e('Edit jQuery scripts for My Calendar in Grid View', 'my-calendar');
    ?>
</label><br /><textarea id="calendar-javascript" name="mc_caljs" rows="8" cols="80"><?php 
    echo $mc_caljs;
    ?>
</textarea>
	</p>
	<?php 
    $args = array('title' => __('Comparing scripts with latest installed version of My Calendar', 'my-calendar'), 'title_right' => __('Latest (from plugin)', 'my-calendar'), 'title_left' => __('Current (in use)', 'my-calendar'));
    $left_string = normalize_whitespace($mc_caljs);
    $right_string = normalize_whitespace($initial_caljs);
    if (isset($_GET['cdiff'])) {
        echo wp_text_diff($left_string, $right_string, $args);
    } else {
        if (trim($left_string) != trim($right_string)) {
            echo '<div class="updated"><p>' . __('There have been updates to the calendar view scripts.', 'my-calendar') . ' <a href="' . admin_url('admin.php?page=my-calendar-behaviors&amp;cdiff#cdiff') . '">' . __('Compare your scripts with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
        } else {
            _e('Your script matches that included with My Calendar.', 'my-calendar');
        }
    }
    ?>
	
	<p>
		<input type="submit" name="save" class="button-secondary" value="<?php 
    _e('Save', 'my-calendar');
    ?>
" />
	</p>	
	</fieldset>

    <fieldset id="ldiff">
	<legend><?php 
    _e('Calendar Behaviors: List View', 'my-calendar');
    ?>
</legend>
	<p>
	<input type="checkbox" id="reset_listjs" name="reset_listjs" /> <label for="reset_listjs"><?php 
    _e('Restore List JavaScript', 'my-calendar');
    ?>
</label> <input type="checkbox" id="list_javascript" name="list_javascript" value="1" <?php 
    mc_is_checked('mc_list_javascript', 1);
    ?>
 /> <label for="list_javascript"><?php 
    _e('Disable List JavaScript', 'my-calendar');
    ?>
</label> 
	</p>
	<p>
	<label for="list-javascript"><?php 
    _e('Edit the jQuery scripts for My Calendar in List format', 'my-calendar');
    ?>
</label><br /><textarea id="list-javascript" name="mc_listjs" rows="8" cols="80"><?php 
    echo $mc_listjs;
    ?>
</textarea>
	</p>
	<?php 
    $left_string = normalize_whitespace($mc_listjs);
    $right_string = normalize_whitespace($initial_listjs);
    if (isset($_GET['ldiff'])) {
        echo wp_text_diff($left_string, $right_string, $args);
    } else {
        if (trim($left_string) != trim($right_string)) {
            echo '<div class="updated"><p>' . __('There have been updates to the list view scripts.', 'my-calendar') . ' <a href="' . admin_url('admin.php?page=my-calendar-behaviors&amp;ldiff#ldiff') . '">' . __('Compare your scripts with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
        } else {
            _e('Your script matches that included with My Calendar.', 'my-calendar');
        }
    }
    ?>
	
	<p>
		<input type="submit" name="save" class="button-secondary" value="<?php 
    _e('Save', 'my-calendar');
    ?>
" />
	</p>	
	</fieldset>

   <fieldset id="mdiff">
	<legend><?php 
    _e('Calendar Behaviors: Mini Calendar View', 'my-calendar');
    ?>
</legend>
	<p>
	<input type="checkbox" id="reset_minijs" name="reset_minijs" /> <label for="reset_minijs"><?php 
    _e('Restore Mini View JavaScript', 'my-calendar');
    ?>
</label> <input type="checkbox" id="mini_javascript" name="mini_javascript" value="1" <?php 
    mc_is_checked('mc_mini_javascript', 1);
    ?>
 /> <label for="mini_javascript"><?php 
    _e('Disable Mini JavaScript', 'my-calendar');
    ?>
</label> 
	</p>
	<p>
	<label for="mini-javascript"><?php 
    _e('Edit jQuery scripts in Mini view', 'my-calendar');
    ?>
</label><br /><textarea id="mini-javascript" name="mc_minijs" rows="8" cols="80"><?php 
    echo $mc_minijs;
    ?>
</textarea>
	</p>
	<?php 
    $left_string = normalize_whitespace($mc_minijs);
    $right_string = normalize_whitespace($initial_minijs);
    if (isset($_GET['mdiff'])) {
        echo wp_text_diff($left_string, $right_string, $args);
    } else {
        if (trim($left_string) != trim($right_string)) {
            echo '<div class="updated"><p>' . __('There have been updates to the mini view scripts.', 'my-calendar') . ' <a href="' . admin_url('admin.php?page=my-calendar-behaviors&amp;mdiff#mdiff') . '">' . __('Compare your scripts with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
        } else {
            _e('Your script matches that included with My Calendar.', 'my-calendar');
        }
    }
    ?>
	<p>
		<input type="submit" name="save" class="button-secondary" value="<?php 
    _e('Save', 'my-calendar');
    ?>
" />
	</p>	
	</fieldset>
	
    <fieldset id="adiff">
	<legend><?php 
    _e('Calendar Behaviors: AJAX', 'my-calendar');
    ?>
</legend>
	<p>
	<input type="checkbox" id="reset_ajaxjs" name="reset_ajaxjs" /> <label for="reset_ajaxjs"><?php 
    _e('Restore AJAX JavaScript', 'my-calendar');
    ?>
</label> <input type="checkbox" id="ajax_javascript" name="ajax_javascript" value="1" <?php 
    mc_is_checked('mc_ajax_javascript', 1);
    ?>
 /> <label for="ajax_javascript"><?php 
    _e('Disable AJAX Navigation', 'my-calendar');
    ?>
</label> 
	</p>
	<p>
	<label for="ajax-javascript"><?php 
    _e('Edit jQuery scripts for AJAX navigation', 'my-calendar');
    ?>
</label><br /><textarea id="ajax-javascript" name="mc_ajaxjs" rows="8" cols="80"><?php 
    echo $mc_ajaxjs;
    ?>
</textarea>
	</p>
	<?php 
    $left_string = normalize_whitespace($mc_ajaxjs);
    $right_string = normalize_whitespace($initial_ajaxjs);
    if (isset($_GET['adiff'])) {
        echo wp_text_diff($left_string, $right_string, $args);
    } else {
        if (trim($left_string) != trim($right_string)) {
            echo '<div class="updated"><p>' . __('There have been updates to the AJAX scripts.', 'my-calendar') . ' <a href="' . admin_url('admin.php?page=my-calendar-behaviors&amp;adiff#adiff') . '">' . __('Compare your scripts with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
        } else {
            _e('Your script matches that included with My Calendar.', 'my-calendar');
        }
    }
    ?>
		
	</fieldset>
	<p>
		<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save', 'my-calendar');
    ?>
" />
	</p>		
  </form>
  </div>
 </div>
</div>
<p><?php 
    _e('Resetting JavaScript will set that script to the version currently distributed with the plug-in.', 'my-calendar');
    ?>
</p>
 </div>
 </div>
 <?php 
    mc_show_sidebar();
    ?>
 </div>
<?php 
}