function mc_tweet_approval($prev, $new)
{
    if (function_exists('jd_doTwitterAPIPost') && isset($_POST['mc_twitter']) && trim($_POST['mc_twitter']) != '') {
        if (($prev == 0 || $prev == 2) && $new == 1) {
            jd_doTwitterAPIPost(stripslashes($_POST['mc_twitter']));
        }
    }
}
function jd_check_functions()
{
    $message = "<div class='update'><ul>";
    // grab or set necessary variables
    $testurl = get_bloginfo('url');
    $shortener = get_option('jd_shortener');
    $title = urlencode('Your blog home');
    $shrink = jd_shorten_link($testurl, $title, false, 'true');
    $api_url = $jdwp_api_post_status;
    $yourls_URL = "";
    if ($shrink == FALSE) {
        if ($shortener == 1) {
            $error = htmlentities(get_option('wp_supr_error'));
        } else {
            if ($shortener == 2) {
                $error = htmlentities(get_option('wp_bitly_error'));
            } else {
                $error = _('No error information is available for your shortener.', 'wp-to-twitter');
            }
        }
        $message .= __("<li class=\"error\"><strong>WP to Twitter was unable to contact your selected URL shortening service.</strong></li>", 'wp-to-twitter');
        $message .= "<li><code>{$error}</code></li>";
    } else {
        $message .= __("<li><strong>WP to Twitter successfully contacted your selected URL shortening service.</strong>  The following link should point to your blog homepage:", 'wp-to-twitter');
        $message .= " <a href='{$shrink}'>{$shrink}</a></li>";
    }
    //check twitter credentials
    if (wtt_oauth_test()) {
        $rand = rand(1000000, 9999999);
        $testpost = jd_doTwitterAPIPost("This is a test of WP to Twitter. {$shrink} ({$rand})");
        if ($testpost) {
            $message .= __("<li><strong>WP to Twitter successfully submitted a status update to Twitter.</strong></li>", 'wp-to-twitter');
        } else {
            $error = get_option('jd_status_message');
            $message .= __("<li class=\"error\"><strong>WP to Twitter failed to submit an update to Twitter.</strong></li>", 'wp-to-twitter');
            $message .= "<li class=\"error\">{$error}</li>";
        }
    } else {
        $message .= "<strong>" . _e('You have not connected WordPress to Twitter.', 'wp-to-twitter') . "</strong> ";
    }
    // If everything's OK, there's  no reason to do this again.
    if ($testpost == FALSE && $shrink == FALSE) {
        $message .= __("<li class=\"error\"><strong>Your server does not appear to support the required methods for WP to Twitter to function.</strong> You can try it anyway - these tests aren't perfect.</li>", 'wp-to-twitter');
    } else {
    }
    if ($testpost && $shrink) {
        $message .= __("<li><strong>Your server should run WP to Twitter successfully.</strong></li>", 'wp-to-twitter');
    }
    $message .= "</ul>\r\n\t</div>";
    return $message;
}
예제 #3
0
function wpt_auto_schedule()
{
    $notify_user = get_option('wpt_autopost_notification');
    // select post from criteria:
    $template = get_option('wpt_schedule_template') != '' ? get_option('wpt_schedule_template') : '#title# #url#';
    $post = wpt_select_post();
    // $post = $post_ID
    if (!$post) {
        if ($notify_user && is_email($notify_user)) {
            wp_mail($notify_user, __('Failed to select any post for Tweeting', 'wp-tweets-pro'), __('WP Tweets PRO did not find a valid post to repost. This may mean that there are no posts between the selected minimum and maximum ages.', 'wp-tweets-pro'));
        }
        die;
    }
    /**
     * If a custom template is set on this post & the option to use them is enabled, use the custom template instead of the setting.
     */
    $custom_template = get_post_meta($post_ID, '_jd_twitter', true);
    $template = get_option('wpt_schedule_custom') == 'true' && $custom_template != '' ? $custom_template : $template;
    $post_info = wpt_post_info($post);
    $sentence = jd_truncate_tweet($template, $post_info, $post);
    $media = get_option('wpt_media') == 1 && (has_post_thumbnail($post) || wpt_post_attachment($post)) ? true : false;
    $media = apply_filters('wpt_upload_media', $media, $post);
    // filter based on post ID
    $tweet = jd_doTwitterAPIPost($sentence, false, $post, $media);
    do_action('wpt_autopost', $tweet, $post);
    // if Tweeted successfully, add to post meta so this will not be Tweeted again until all old posts have been Tweeted.
    if ($tweet) {
        if ($notify_user && is_email($notify_user)) {
            wp_mail($notify_user, __('Autoposted Tweet succeeded', 'wp-tweets-pro'), sprintf(__("Tweet autoposted: %s", 'wp-tweets-pro'), $sentence));
        }
        update_post_meta($post, '_wpt_autoposted', '1');
    } else {
        if ($notify_user && is_email($notify_user)) {
            $log = wpt_log('wpt_status_message', $post);
            wp_mail($notify_user, __('Autoposted Tweet failed', 'wp-tweets-pro'), sprintf(__("Site failed to automatically post. Tweet attempted: %s", 'wp-tweets-pro') . "\n\n" . __('Error message from Twitter:', 'wp-tweets-pro') . ' ' . $log, $sentence));
        }
    }
}
예제 #4
0
function jd_twit_link($link_ID)
{
    wpt_check_version();
    global $wpt_version;
    $thislinkprivate = $_POST['link_visible'];
    if ($thislinkprivate != 'N') {
        $thislinkname = stripcslashes($_POST['link_name']);
        $thispostlink = $_POST['link_url'];
        $thislinkdescription = stripcslashes($_POST['link_description']);
        $sentence = stripcslashes(get_option('newlink-published-text'));
        $sentence = str_ireplace("#title#", $thislinkname, $sentence);
        $sentence = str_ireplace("#description#", $thislinkdescription, $sentence);
        if (mb_strlen($sentence) > 118) {
            $sentence = mb_substr($sentence, 0, 114) . '...';
        }
        $shrink = apply_filters('wptt_shorten_link', $thispostlink, $thislinkname, false, 'link');
        if (stripos($sentence, "#url#") === FALSE) {
            $sentence = $sentence . " " . $shrink;
        } else {
            $sentence = str_ireplace("#url#", $shrink, $sentence);
        }
        if ($sentence != '') {
            $tweet = jd_doTwitterAPIPost($sentence, false, $link_ID);
            if ($tweet == false) {
                update_option('wp_twitter_failure', '2');
            }
        }
        return $link_ID;
    } else {
        return;
    }
}
function my_calendar_save($action, $output, $event_id = false)
{
    global $wpdb, $event_author;
    $mcdb = $wpdb;
    $proceed = $output[0];
    $message = '';
    $formats = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%f', '%f');
    if (($action == 'add' || $action == 'copy') && $proceed == true) {
        $add = $output[2];
        // add format here
        $add = apply_filters('mc_before_save_insert', $add);
        // this db write takes most of the processing time for this process.
        $result = $mcdb->insert(my_calendar_table(), $add, $formats);
        $event_id = $mcdb->insert_id;
        mc_increment_event($event_id);
        if (!$result) {
            $message = "<div class='error notice'><p><strong>" . __('Error', 'my-calendar') . ":</strong> " . __('I\'m sorry! I couldn\'t add that event to the database.', 'my-calendar') . "</p></div>";
        } else {
            // do an action using the $action and processed event data
            $data = $add;
            $event_error = '';
            do_action('mc_save_event', $action, $data, $event_id, $result);
            // Call mail function
            if (get_option('mc_event_mail') == 'true') {
                $event = mc_get_first_event($event_id);
                // insert_id is last occurrence inserted in the db
                my_calendar_send_email($event);
            }
            if ($add['event_approved'] == 0) {
                $message = "<div class='updated notice'><p>" . __('Event saved. An administrator will review and approve your event.', 'my-calendar') . "</p></div>";
            } else {
                if (function_exists('jd_doTwitterAPIPost') && isset($_POST['mc_twitter']) && trim($_POST['mc_twitter']) != '') {
                    jd_doTwitterAPIPost(stripslashes($_POST['mc_twitter']));
                }
                if (get_option('mc_uri') != '') {
                    $event_ids = mc_get_occurrences($event_id);
                    //$event_link = mc_build_url( array( 'mc_id' => $event_ids[0]->occur_id ), array( 'page' ), get_option( 'mc_uri' ) );
                    //$event_link = add_query_arg( 'mc_id', $event_ids[0]->occur_id, get_option( 'mc_uri' ) );
                    $event_link = mc_get_details_link($event_ids[0]->occur_id);
                    $event_error = mc_error_check($event_ids[0]->occur_event_id);
                } else {
                    $event_link = false;
                }
                if ($event_error != '') {
                    $message = $event_error;
                } else {
                    $message = "<div class='updated notice'><p>" . __('Event added. It will now show on the calendar.', 'my-calendar');
                    if ($event_link !== false) {
                        $message .= sprintf(__(' <a href="%s">View Event</a>', 'my-calendar'), $event_link);
                    }
                    $message .= "</p></div>";
                }
            }
            mc_delete_cache();
        }
    }
    if ($action == 'edit' && $proceed == true) {
        $current_user = wp_get_current_user();
        $result = true;
        $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 (mc_can_edit_event($event_id)) {
            $update = $output[2];
            $update = apply_filters('mc_before_save_update', $update, $event_id);
            $endtime = date("H:i:00", strtotime($update['event_endtime']));
            $date_changed = $update['event_begin'] != $_POST['prev_event_begin'] || date("H:i:00", strtotime($update['event_time'])) != $_POST['prev_event_time'] || $update['event_end'] != $_POST['prev_event_end'] || $endtime != $_POST['prev_event_endtime'] && ($_POST['prev_event_endtime'] != '' && $endtime != '23:59:59') ? true : false;
            if (isset($_POST['event_instance'])) {
                $is_changed = mc_compare($update, $event_id);
                // compares the information sent to the information saved for a given event.
                $event_instance = (int) $_POST['event_instance'];
                if ($is_changed) {
                    // if changed, create new event, match group id, update instance to reflect event connection, same group id.
                    // if group ID == 0, need to add group ID to both records.
                    // if a single instance is edited, it should *not* inherit the recurring settings from parent.
                    $update['event_recur'] = 'S1';
                    if ($update['event_group_id'] == 0) {
                        $update['event_group_id'] = $event_id;
                        mc_update_data($event_id, 'event_group_id', $event_id);
                    }
                    $mcdb->insert(my_calendar_table(), $update, $formats);
                    $new_event = $mcdb->insert_id;
                    // need to get this variable into URL for form submit
                    $result = mc_update_instance($event_instance, $new_event, $update);
                    mc_delete_cache();
                } else {
                    if ($update['event_begin'][0] == $_POST['prev_event_begin'] && $update['event_end'][0] == $_POST['prev_event_end']) {
                        // There were no changes at all.
                    } else {
                        $result = mc_update_instance($event_instance, $event_id, $update);
                        // Only dates were changed
                        $message = "<div class='updated notice'><p>" . __('Date/time information for this event has been updated.', 'my-calendar') . " {$url}</p></div>";
                        mc_delete_cache();
                    }
                }
            } else {
                $result = $mcdb->update(my_calendar_table(), $update, array('event_id' => $event_id), $formats, '%d');
                $recur_changed = $update['event_repeats'] != $_POST['prev_event_repeats'] || $update['event_recur'] != $_POST['prev_event_recur'] ? true : false;
                if ($date_changed || $recur_changed) {
                    // TODO: if date or recur changed, do generation of new instances, then iterate over existing occurrences
                    // to update & delete remaining
                    mc_delete_instances($event_id);
                    mc_increment_event($event_id);
                    mc_delete_cache();
                }
            }
            $data = $update;
            do_action('mc_save_event', $action, $data, $event_id, $result);
            if ($result === false) {
                $message = "<div class='error'><p><strong>" . __('Error', 'my-calendar') . ":</strong>" . __('Your event was not updated.', 'my-calendar') . " {$url}</p></div>";
            } else {
                // do an action using the $action and processed event data
                $event_approved = isset($_POST['event_approved']) ? intval($_POST['event_approved']) : 0;
                do_action('mc_transition_event', (int) $_POST['prev_event_status'], $event_approved);
                $message = "<div class='updated'><p>" . __('Event updated successfully', 'my-calendar') . ". {$url}</p></div>";
                mc_delete_cache();
            }
        } else {
            $message = "<div class='error'><p><strong>" . __('You do not have sufficient permissions to edit that event.', 'my-calendar') . "</strong></p></div>";
        }
    }
    $message = $message . "\n" . $output[3];
    return array('event_id' => $event_id, 'message' => $message);
}
예제 #6
0
function wpt_twit_comment($comment)
{
    if (isset($_REQUEST['tweet']) && $_REQUEST['tweet'] == 'false') {
        return;
    }
    $block = wpt_filter_comment_info($comment);
    $delay = get_option('wpt_comment_delay') == '' ? false : get_option('wpt_comment_delay');
    // $block == true means block this comment.
    if (!$block) {
        $comment_id = $comment->comment_ID;
        $post_ID = $comment->comment_post_ID;
        $sentence = get_comment_meta($comment_id, 'wpt_comment_tweet', true);
        if ($sentence && !$delay) {
            $tweet = jd_doTwitterAPIPost($sentence, false, $post_ID);
        } else {
            $delay = apply_filters('wpt_schedule_comment_delay', (int) $delay * 60, $post_ID);
            wp_schedule_single_event(time() + $delay, 'wpt_schedule_tweet_action', array('id' => false, 'sentence' => $sentence, 'rt' => 0, 'post_id' => $post_ID));
        }
    }
}
예제 #7
0
function jd_twit_comment($comment_id, $approved)
{
    $_t = get_comment($comment_id);
    $post_ID = $_t->comment_post_ID;
    $commenter = $_t->comment_author;
    $jd_tweet_this = get_post_meta($post_ID, '_jd_tweet_this', TRUE);
    if ($jd_tweet_this != 'no' && $_t->comment_approved == 1) {
        // comments only tweeted on posts which are tweeted
        $post_info = jd_post_info($post_ID);
        $sentence = '';
        $sentence = stripcslashes(get_option('comment-published-text'));
        if ($post_info['shortUrl'] != '') {
            $shrink = $post_info['shortUrl'];
        } else {
            $shrink = jd_shorten_link($post_info['postLink'], $post_info['postTitle'], $post_ID);
            store_url($post_ID, $shrink);
        }
        $sentence = jd_truncate_tweet($sentence, $post_info, $shrink, $post_ID);
        $sentence = str_replace("#commenter#", $commenter, $sentence);
        if ($sentence != '') {
            $sendToTwitter = jd_doTwitterAPIPost($sentence);
        }
    }
    return $post_ID;
}
예제 #8
0
/**
 * Handle Tweets sent via Ajax Tweet Now/Schedule Tweet buttons.
 *
 * @return string Confirmation message indicating success or failure of Tweeting.
 */
function wpt_ajax_tweet()
{
    if (!check_ajax_referer('wpt-tweet-nonce', 'security', false)) {
        echo "Invalid Security Check";
        die;
    }
    $action = $_REQUEST['tweet_action'] == 'tweet' ? 'tweet' : 'schedule';
    // This isn't used right now, because of time.
    $authors = isset($_REQUEST['tweet_auth']) && $_REQUEST['tweet_auth'] != null ? $_REQUEST['tweet_auth'] : false;
    $current_user = wp_get_current_user();
    if (function_exists('wpt_pro_exists') && wpt_pro_exists()) {
        if (wtt_oauth_test($current_user->ID, 'verify')) {
            $auth = $user_ID = $current_user->ID;
        } else {
            $auth = false;
            $user_ID = $current_user->ID;
        }
    } else {
        $auth = false;
        $user_ID = $current_user->ID;
    }
    if (current_user_can('wpt_can_tweet')) {
        $options = get_option('wpt_post_types');
        $post_ID = intval($_REQUEST['tweet_post_id']);
        $type = get_post_type($post_ID);
        $default = isset($options[$type]['post-edited-text']) ? $options[$type]['post-edited-text'] : '';
        $sentence = isset($_REQUEST['tweet_text']) && trim($_REQUEST['tweet_text']) != '' ? $_REQUEST['tweet_text'] : $default;
        $sentence = stripcslashes(trim($sentence));
        $post_info = wpt_post_info($post_ID);
        $sentence = jd_truncate_tweet($sentence, $post_info, $post_ID, false, $user_ID);
        $schedule = isset($_REQUEST['tweet_schedule']) ? strtotime($_REQUEST['tweet_schedule']) : rand(60, 240);
        $print_schedule = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), $schedule);
        $offset = 60 * 60 * get_option('gmt_offset');
        $schedule = $schedule - $offset;
        $media = wpt_post_with_media($post_ID, $post_info);
        switch ($action) {
            case 'tweet':
                jd_doTwitterAPIPost($sentence, $auth, $post_ID, $media);
                break;
            case 'schedule':
                wp_schedule_single_event($schedule, 'wpt_schedule_tweet_action', array('id' => $auth, 'sentence' => $sentence, 'rt' => 0, 'post_id' => $post_ID));
                break;
        }
        $return = $action == 'tweet' ? wpt_log('wpt_status_message', $post_ID) : "Tweet scheduled: '{$sentence}' for {$print_schedule}";
        echo $return;
    } else {
        echo __('You are not authorized to perform this action', 'wp-to-twitter');
    }
    die;
}
예제 #9
0
function wpt_twit_comment($comment)
{
    if (isset($_REQUEST['tweet']) && $_REQUEST['tweet'] == 'false') {
        return;
    }
    $comment_id = $comment->comment_ID;
    $post_ID = $comment->comment_post_ID;
    $sentence = get_comment_meta($comment_id, 'wpt_comment_tweet', true);
    if ($sentence) {
        $tweet = jd_doTwitterAPIPost($sentence, false, $post_ID);
    }
}
function my_calendar_save($action, $output, $event_id = false)
{
    global $wpdb, $event_author;
    $mcdb = $wpdb;
    $proceed = $output[0];
    $message = '';
    $formats = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%f', '%f');
    if (($action == 'add' || $action == 'copy') && $proceed == true) {
        $add = $output[2];
        // add format here
        $add = apply_filters('mc_before_save_insert', $add);
        $result = $mcdb->insert(my_calendar_table(), $add, $formats);
        $event_id = $mcdb->insert_id;
        mc_increment_event($event_id);
        if (!$result) {
            $message = "<div class='error notice'><p><strong>" . __('Error', 'my-calendar') . ":</strong> " . __('I\'m sorry! I couldn\'t add that event to the database.', 'my-calendar') . "</p></div>";
        } else {
            // do an action using the $action and processed event data
            $data = $add;
            do_action('mc_save_event', $action, $data, $event_id, $result);
            // Call mail function
            if (get_option('mc_event_mail') == 'true') {
                $event = mc_get_first_event($event_id);
                // insert_id is last occurrence inserted in the db
                my_calendar_send_email($event);
            }
            if ($add['event_approved'] == 0) {
                $message = "<div class='updated notice'><p>" . __('Event saved. An administrator will review and approve your event.', 'my-calendar') . "</p></div>";
            } else {
                if (function_exists('jd_doTwitterAPIPost') && isset($_POST['mc_twitter']) && trim($_POST['mc_twitter']) != '') {
                    jd_doTwitterAPIPost(stripslashes($_POST['mc_twitter']));
                }
                if (get_option('mc_uri') != '') {
                    $event_ids = mc_get_occurrences($event_id);
                    $event_link = mc_build_url(array('mc_id' => $event_ids[0]->occur_id), array('page'), get_option('mc_uri'));
                } else {
                    $event_link = false;
                }
                $message = "<div class='updated notice'><p>" . __('Event added. It will now show on the calendar.', 'my-calendar');
                if ($event_link !== false) {
                    $message .= sprintf(__(' <a href="%s">View Event</a>', 'my-calendar'), $event_link);
                }
                $message .= "</p></div>";
            }
            mc_delete_cache();
        }
    }
    if ($action == 'edit' && $proceed == true) {
        $result = true;
        $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')) : '';
        $event_author = (int) $_POST['event_author'];
        if (mc_can_edit_event($event_author)) {
            $update = $output[2];
            $update = apply_filters('mc_before_save_update', $update, $event_id);
            $date_changed = $update['event_begin'] != $_POST['prev_event_begin'] || date("H:i:00", strtotime($update['event_time'])) != $_POST['prev_event_time'] || $update['event_end'] != $_POST['prev_event_end'] || date("H:i:00", strtotime($update['event_endtime'])) != $_POST['prev_event_endtime'] && ($_POST['prev_event_endtime'] != '' && date("H:i:00", strtotime($update['event_endtime'])) != '00:00:00') ? true : false;
            if (isset($_POST['event_instance'])) {
                $is_changed = mc_compare($update, $event_id);
                // compares the information sent to the information saved for a given event.
                $event_instance = (int) $_POST['event_instance'];
                if ($is_changed) {
                    // if changed, create new event, match group id, update instance to reflect event connection, same group id.
                    // if group ID == 0, need to add group ID to both records.
                    if ($update['event_group_id'] == 0) {
                        $update['event_group_id'] = $event_id;
                        mc_update_data($event_id, 'event_group_id', $event_id);
                    }
                    $mcdb->insert(my_calendar_table(), $update, $formats);
                    $new_event = $mcdb->insert_id;
                    // need to get this variable into URL for form submit
                    $result = mc_update_instance($event_instance, $new_event, $update);
                    mc_delete_cache();
                } else {
                    if ($update['event_begin'][0] == $_POST['prev_event_begin'] && $update['event_end'][0] == $_POST['prev_event_end']) {
                        // There were no changes at all.
                    } else {
                        $result = mc_update_instance($event_instance, $event_id, $update);
                        // Only dates were changed
                        $message = "<div class='updated notice'><p>" . __('Date/time information for this event has been updated.', 'my-calendar') . "{$url}</p></div>";
                        mc_delete_cache();
                    }
                }
            } else {
                $result = $mcdb->update(my_calendar_table(), $update, array('event_id' => $event_id), $formats, '%d');
                $recur_changed = $update['event_repeats'] != $_POST['prev_event_repeats'] || $update['event_recur'] != $_POST['prev_event_recur'] ? true : false;
                if ($date_changed || $recur_changed) {
                    mc_delete_instances($event_id);
                    mc_increment_event($event_id);
                    mc_delete_cache();
                }
            }
            $data = $update;
            do_action('mc_save_event', $action, $data, $event_id, $result);
            if ($result === false) {
                $message = "<div class='error'><p><strong>" . __('Error', 'my-calendar') . ":</strong>" . __('Your event was not updated.', 'my-calendar') . "{$url}</p></div>";
            } else {
                // do an action using the $action and processed event data
                do_action('mc_transition_event', (int) $_POST['prev_event_status'], (int) $_POST['event_approved']);
                $message = "<div class='updated'><p>" . __('Event updated successfully', 'my-calendar') . ".{$url}</p></div>";
                mc_delete_cache();
            }
        } else {
            $message = "<div class='error'><p><strong>" . __('You do not have sufficient permissions to edit that event.', 'my-calendar') . "</strong></p></div>";
        }
    }
    if ($action == 'delete') {
        // Deal with deleting an event from the database
        if (empty($event_id)) {
            $message = "<div class='error'><p><strong>" . __('Error', 'my-calendar') . ":</strong>" . __("You can't delete an event if you haven't submitted an event id", 'my-calendar') . "</p></div>";
        } else {
            $post_id = mc_get_data('event_post', $event_id);
            if (empty($_POST['event_instance'])) {
                $sql = "DELETE FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "'";
                $delete_occurrences = "DELETE FROM " . my_calendar_event_table() . " WHERE occur_event_id = " . (int) $event_id;
                $mcdb->query($delete_occurrences);
                $mcdb->query($sql);
                $sql = "SELECT event_id FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "'";
                $result = $mcdb->get_results($sql);
            } else {
                $delete = "DELETE FROM " . my_calendar_event_table() . " WHERE occur_id = " . (int) $_POST['event_instance'];
                $result = $mcdb->get_results($delete);
            }
            if (empty($result) || empty($result[0]->event_id)) {
                mc_delete_cache();
                // do an action using the event_id
                do_action('mc_delete_event', $event_id, $post_id);
                $message = "<div class='updated'><p>" . __('Event deleted successfully', 'my-calendar') . "</p></div>";
            } else {
                $message = "<div class='error'><p><strong>" . __('Error', 'my-calendar') . ":</strong>" . __('Despite issuing a request to delete, the event still remains in the database. Please investigate.', 'my-calendar') . "</p></div>";
            }
        }
    }
    $message = $message . "\n" . $output[3];
    return array('event_id' => $event_id, 'message' => $message);
}