本文整理汇总了PHP中my_calendar_check_db函数的典型用法代码示例。如果您正苦于以下问题:PHP my_calendar_check_db函数的具体用法?PHP my_calendar_check_db怎么用?PHP my_calendar_check_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了my_calendar_check_db函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_mc_templates
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> »</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);
?>
//.........这里部分代码省略.........
示例2: my_calendar_manage_locations
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: edit_my_calendar_styles
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);
//.........这里部分代码省略.........
示例4: edit_my_calendar_groups
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');
//.........这里部分代码省略.........
示例5: edit_my_calendar
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') {
?>
//.........这里部分代码省略.........
示例6: edit_my_calendar_config
//.........这里部分代码省略.........
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');
示例7: edit_my_calendar_behaviors
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
//.........这里部分代码省略.........
示例8: my_calendar_manage_categories
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 {
//.........这里部分代码省略.........
示例9: edit_mc_templates
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> »
</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>
//.........这里部分代码省略.........
示例10: mcs_settings
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
//.........这里部分代码省略.........
示例11: edit_my_calendar_behaviors
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');
?>
//.........这里部分代码省略.........