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 mc_settings_field($name, $label, $default = '', $note = '', $atts = array('size' => '30'), $type = 'text')
{
    $options = $attributes = '';
    if (is_array($atts) && !empty($atts)) {
        foreach ($atts as $key => $value) {
            $attributes .= " {$key}='{$value}'";
        }
    }
    $value = get_option($name) != '' ? esc_attr(stripslashes(get_option($name))) : $default;
    switch ($type) {
        case 'text':
        case 'url':
        case 'email':
            if ($note) {
                $note = sprintf($note, "<code>{$value}</code>");
                $note = "<span id='{$name}-note'>{$note}</span>";
                $aria = " aria-describedby='{$name}-note'";
            } else {
                $note = $aria = '';
            }
            echo "<label for='{$name}'>{$label}</label> <input type='{$type}' id='{$name}' name='{$name}' value='{$value}'{$aria}{$attributes} /> {$note}";
            break;
        case 'textarea':
            if ($note) {
                $note = sprintf($note, "<code>{$value}</code>");
                $note = "<span id='{$name}-note'>{$note}</span>";
                $aria = " aria-describedby='{$name}-note'";
            } else {
                $note = $aria = '';
            }
            echo "<label for='{$name}'>{$label}</label><br /><textarea id='{$name}' name='{$name}'{$aria}{$attributes}>{$value}</textarea>{$note}";
            break;
        case 'checkbox-single':
            $checked = mc_is_checked($name, 'true', '', true);
            if ($note) {
                $note = sprintf($note, "<code>{$value}</code>");
            } else {
                $note = '';
            }
            echo "<input type='checkbox' id='{$name}' name='{$name}' value='on' {$checked}{$attributes} /> <label for='{$name}' class='checkbox-label'>{$label} {$note}</label>";
            break;
        case 'checkbox':
        case 'radio':
            if ($note) {
                $note = sprintf($note, "<code>{$value}</code>");
                $note = "<span id='{$name}-note'>{$note}</span>";
                $aria = " aria-describedby='{$name}-note'";
            } else {
                $note = $aria = '';
            }
            foreach ($label as $k => $v) {
                $checked = $k == $value ? ' checked="checked"' : '';
                $options .= "<li><input type='radio' id='{$name}-{$k}' value='{$k}' name='{$name}'{$aria}{$attributes}{$checked} /> <label for='{$name}-{$k}'>{$v}</label></li>";
            }
            echo "{$options} {$note}";
            break;
        case 'select':
            if ($note) {
                $note = sprintf($note, "<code>{$value}</code>");
                $note = "<span id='{$name}-note'>{$note}</span>";
                $aria = " aria-describedby='{$name}-note'";
            } else {
                $note = $aria = '';
            }
            foreach ($default as $k => $v) {
                $checked = $k == $value ? ' selected="selected"' : '';
                $options .= "<option value='{$k}'{$checked}>{$v}</option>";
            }
            echo "\n\t\t\t<label for='{$name}'>{$label}</label> \n\t\t\t\t<select id='{$name}' name='{$name}'{$aria}{$attributes} />\n\t\t\t\t\t{$options}\n\t\t\t\t</select>\n\t\t\t{$note}";
            break;
    }
}
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_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 
}
function mc_edit_category_form($view = 'edit', $catID = '')
{
    global $wpdb;
    $dir = plugin_dir_path(__FILE__);
    $url = plugin_dir_url(__FILE__);
    $mcdb = $wpdb;
    $cur_cat = false;
    if ($catID != '') {
        $catID = (int) $catID;
        $sql = "SELECT * FROM " . my_calendar_categories_table() . " WHERE category_id={$catID}";
        $cur_cat = $mcdb->get_row($sql);
    }
    if (is_custom_icon()) {
        $directory = str_replace('/my-calendar', '', $dir) . '/my-calendar-custom/';
        $path = '/my-calendar-custom';
        $iconlist = my_dirlist($directory);
    } else {
        $directory = dirname(__FILE__) . '/images/icons/';
        $path = '/' . dirname(plugin_basename(__FILE__)) . '/images/icons';
        $iconlist = my_dirlist($directory);
    }
    if ($view == 'add') {
        ?>
		<h2><?php 
        _e('Add Category', 'my-calendar');
        ?>
</h2>
	<?php 
    } else {
        ?>
		<h2><?php 
        _e('Edit Category', 'my-calendar');
        ?>
</h2>
	<?php 
    }
    ?>

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

			<div class="ui-sortable meta-box-sortables">
				<div class="postbox">
					<h3><?php 
    _e('Category Editor', 'my-calendar');
    ?>
</h3>

					<div class="inside">
						<form id="my-calendar" method="post"
						      action="<?php 
    echo admin_url('admin.php?page=my-calendar-categories');
    ?>
">
							<div><input type="hidden" name="_wpnonce"
							            value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
"/></div>
							<?php 
    if ($view == 'add') {
        ?>
								<div>
									<input type="hidden" name="mode" value="add"/>
									<input type="hidden" name="category_id" value=""/>
								</div>
							<?php 
    } else {
        ?>
								<div>
									<input type="hidden" name="mode" value="edit"/>
									<input type="hidden" name="category_id"
									       value="<?php 
        if (is_object($cur_cat)) {
            echo $cur_cat->category_id;
        }
        ?>
"/>
								</div>
							<?php 
    }
    ?>
							<fieldset>
								<legend><?php 
    if ($view == 'add') {
        _e('Add Category', 'my-calendar');
    } else {
        _e('Edit Category', 'my-calendar');
    }
    ?>
</legend><?php 
    if (!empty($cur_cat) && is_object($cur_cat)) {
        $color = strpos($cur_cat->category_color, '#') !== 0 ? '#' : '';
        $color .= $cur_cat->category_color;
    } else {
        $color = '';
    }
    ?>
								<ul>
								<li>
								<label for="cat_name"><?php 
    _e('Category Name', 'my-calendar');
    ?>
</label> <input
									type="text" id="cat_name" name="category_name" class="input" size="30"
									value="<?php 
    if (!empty($cur_cat) && is_object($cur_cat)) {
        echo stripslashes(esc_attr($cur_cat->category_name));
    }
    ?>
"/>
								<label for="cat_color"><?php 
    _e('Color', 'my-calendar');
    ?>
</label> <input
									type="text
									id="cat_color"
									name="category_color"
									class="mc-color-input"
									size="10"
									maxlength="7"
									value="<?php 
    esc_attr_e($color);
    ?>
"/>
								</li>
								<li>
								<label for="cat_icon"><?php 
    _e('Category Icon', 'my-calendar');
    ?>
</label> <select
									name="category_icon" id="cat_icon">
									<?php 
    foreach ($iconlist as $value) {
        $selected = !empty($cur_cat) && is_object($cur_cat) && $cur_cat->category_icon == $value ? " selected='selected'" : '';
        echo "<option value='" . esc_attr($value) . "'{$selected} style='background: url(" . str_replace('my-calendar/', '', esc_url($url . "{$path}/{$value}")) . ") left 50% no-repeat;'>{$value}</option>";
    }
    ?>
								</select>
								</li>
								<li>
									<?php 
    if ($view == 'add') {
        $private_checked = '';
    } else {
        if (!empty($cur_cat) && is_object($cur_cat) && $cur_cat->category_private == 1) {
            $private_checked = ' checked="checked"';
        } else {
            $private_checked = '';
        }
    }
    ?>
									<?php 
    $checked = $view == 'add' ? '' : mc_is_checked('mc_default_category', $cur_cat->category_id, '', true);
    ?>
									<?php 
    $holiday_checked = $view == 'add' ? '' : mc_is_checked('mc_skip_holidays_category', $cur_cat->category_id, '', true);
    ?>
									<input type="checkbox" value="on" name="category_private"
									       id="cat_private"<?php 
    echo $private_checked;
    ?>
 /> <label
										for="cat_private"><?php 
    _e('Private category (logged-in users only)', 'my-calendar');
    ?>
</label>
									<input type="checkbox" value="on" name="mc_default_category"
									       id="mc_default_category"<?php 
    echo $checked;
    ?>
 /> <label
										for="mc_default_category"><?php 
    _e('Default category', 'my-calendar');
    ?>
</label>
									<input type="checkbox" value="on" name="mc_skip_holidays_category"
									       id="mc_shc"<?php 
    echo $holiday_checked;
    ?>
 /> <label
										for="mc_shc"><?php 
    _e('Holiday Category', 'my-calendar');
    ?>
</label>
								</li>
								<?php 
    echo apply_filters('mc_category_fields', '', $cur_cat);
    ?>
							</ul>
							</fieldset>
							<p>
								<input type="submit" name="save" class="button-primary"
								       value="<?php 
    if ($view == 'add') {
        _e('Add Category', 'my-calendar');
    } else {
        _e('Save Changes', 'my-calendar');
    }
    ?>
 &raquo;"/>
							</p>
							<?php 
    do_action('mc_post_category_form', $cur_cat, $view);
    ?>
						</form>
					</div>
				</div>
			</div>
			<?php 
    if ($view == 'edit') {
        ?>
				<p>
					<a href="<?php 
        echo admin_url('admin.php?page=my-calendar-categories');
        ?>
"><?php 
        _e('Add a New Category', 'my-calendar');
        ?>
 &raquo;</a>
				</p>
			<?php 
    }
    ?>
			<div class="ui-sortable meta-box-sortables">
				<div class="postbox">
					<h3><?php 
    _e('Category List', 'my-calendar');
    ?>
</h3>

					<div class="inside">
						<?php 
    mc_manage_categories();
    ?>
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php 
    mc_show_sidebar();
}
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();
}
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
}
Пример #8
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 
}