コード例 #1
0
ファイル: rsvpmaker-admin.php プロジェクト: ryan2407/Vision
function rsvpmaker_admin_notice()
{
    global $wpdb;
    global $rsvp_options;
    if (isset($_GET["update"]) && $_GET["update"] == "eventslug") {
        $wpdb->query("UPDATE {$wpdb->posts} SET post_type='rsvpmaker' WHERE post_type='event' OR post_type='rsvp-event' ");
    }
    if (isset($_GET["noeventpageok"]) && $_GET["noeventpageok"]) {
        $rsvp_options["noeventpageok"] = 1;
        update_option('RSVPMAKER_Options', $options);
    } elseif ((!isset($rsvp_options["eventpage"]) || empty($rsvp_options["eventpage"])) && !isset($rsvp_options["noeventpageok"])) {
        $sql = "SELECT ID from {$wpdb->posts} WHERE post_status='publish' AND post_content LIKE '%[rsvpmaker_upcoming%' ";
        $front = get_option('page_on_front');
        if ($front) {
            $sql .= " AND ID != {$front} ";
        }
        if ($id = $wpdb->get_var($sql)) {
            $rsvp_options["eventpage"] = get_permalink($id);
            update_option('RSVPMAKER_Options', $rsvp_options);
        } else {
            echo '<div class="updated" style="background-color:#fee;"><p>RSVPMaker needs you to create a page with the [rsvpmaker_upcoming] shortcode to display event listings. (<a href="options-general.php?page=rsvpmaker-admin.php&noeventpageok=1">Turn off this warning</a>)</p></div>';
        }
    }
    if (!isset($rsvp_options["posttypecheck"]) || !$rsvp_options["posttypecheck"]) {
        $sql = "SELECT count(*) from {$wpdb->posts} WHERE post_type='event' OR post_type='rsvp-event' ";
        if ($count = $wpdb->get_var($sql)) {
            echo '<div class="updated" style="background-color:#fee;"><p>RSVPMaker has detected ' . $count . ' posts that appear to have been created with an earlier release. You need to update them to reflect the new permalink naming. Update now? <a href="./index.php?post_type=rsvpmaker&update=eventslug" style="font-weight: bold;">Yes</a> (The post_type field will be changed from &quot;event&quot; to &quot;rsvpmaker&quot; also changing the permalink structure).</p></div>';
        }
        $rsvp_options["posttypecheck"] = 1;
        update_option('RSVPMAKER_Options', $rsvp_options);
    }
    if (isset($rsvp_options["profile_table"]) && !empty($rsvp_options["profile_table"])) {
        echo '<div class="updated" style="background-color:#fee;"><p>Notice: RSVPMaker 2.5 introduced a new method for customizing the RSVP form. If you had customized the form to include additional or alternate fields, you will have to make an update on the RSVPMaker settings screen to restore those changes.</p></div>';
        $rsvp_options["profile_table"] = NULL;
        update_option('RSVPMAKER_Options', $rsvp_options);
    }
    if (isset($_GET["smtptest"])) {
        $mail["to"] = $rsvp_options["rsvp_to"];
        $mail["from"] = "*****@*****.**";
        $mail["fromname"] = "RSVPMaker";
        $mail["subject"] = "Testing SMTP email notification";
        $mail["html"] = ' <h1>SMTP Test</h1>
<p>I hope you will find this is a more reliable way to send email notifications related to RSVP Events.</p>

<p>In normal operation, RSVPMaker sends the event organizer a notification as people RSVP. It also sends attendees a confirmation message with the rsvp_to email address as the From email address.';
        $result = rsvpmailer($mail);
        echo '<div class="updated" style="background-color:#fee;">' . "<strong>Sending test email {$result} </strong></div>";
    }
}
コード例 #2
0
 function rsvp_daily_reminder()
 {
     global $wpdb;
     global $rsvp_options;
     $today = date('Y-m-d');
     $sql = "SELECT * FROM `wp_postmeta` WHERE `meta_key` LIKE '_rsvp_reminder' AND `meta_value`='{$today}'";
     if ($reminders = $wpdb->get_results($sql)) {
         foreach ($reminders as $reminder) {
             $postID = $reminder->post_id;
             $q = "p={$postID}&post_type=rsvpmaker";
             echo "Post {$postID} is scheduled for a reminder {$q}<br />";
             global $post;
             query_posts($q);
             global $wp_query;
             // treat as single, display rsvp button, not form
             $wp_query->is_single = false;
             the_post();
             if ($post->post_title) {
                 $event_title = $post->post_title;
                 ob_start();
                 echo "<h1>";
                 the_title();
                 echo "</h1>\n<div>\n";
                 the_content();
                 echo "\n</div>\n";
                 $event = ob_get_clean();
                 $rsvpto = get_post_meta($postID, '_rsvp_to', true);
                 $sql = "SELECT * FROM " . $wpdb->prefix . "rsvpmaker WHERE event={$postID} AND yesno=1";
                 $rsvps = $wpdb->get_results($sql, ARRAY_A);
                 if ($rsvps) {
                     foreach ($rsvps as $row) {
                         $notify = $row["email"];
                         $row["yesno"] = $row["yesno"] ? "YES" : "NO";
                         $notification = "<p>" . __("This is an automated reminder that we have you on the RSVP list for the event shown below. If your plans have changed, you can update your response by clicking on the RSVP button again.", 'rsvpmaker') . "</p>";
                         $notification .= '<h3>' . $row["yesno"] . " " . $row["first"] . " " . $row["last"] . " " . $row["email"];
                         if ($row["guestof"]) {
                             $notification .= " (" . __('guest of', 'rsvpmaker') . " " . $row["guestof"] . ")";
                         }
                         $notification .= "</h3>\n";
                         $notification .= "<p>";
                         if ($row["details"]) {
                             $details = unserialize($row["details"]);
                             foreach ($details as $name => $value) {
                                 if ($value) {
                                     $notification .= "{$name}: {$value}<br />";
                                 }
                             }
                         }
                         if ($row["note"]) {
                             $notification .= "note: " . nl2br($row["note"]) . "<br />";
                         }
                         $t = strtotime($row["timestamp"]);
                         $notification .= 'posted: ' . date($rsvp_options["short_date"], $t);
                         $notification .= "</p>";
                         $notification .= "<h3>Event Details</h3>\n" . str_replace('*|EMAIL|*', $notify, $event);
                         echo "Notification for {$notify}<br />{$notification}";
                         $subject = '=?UTF-8?B?' . base64_encode(__("Event Reminder for", 'rsvpmaker') . ' ' . $event_title) . '?=';
                         if (isset($rsvp_options["smtp"]) && !empty($rsvp_options["smtp"])) {
                             $mail["subject"] = __("Event Reminder for", 'rsvpmaker') . ' ' . $event_title;
                             $mail["html"] = $notification;
                             $mail["to"] = $notify;
                             $mail["from"] = $rsvp_to;
                             $mail["fromname"] = get_bloginfo('name');
                             rsvpmailer($mail);
                         } else {
                             $subject = '=?UTF-8?B?' . base64_encode(__("Event Reminder for", 'rsvpmaker') . ' ' . $event_title) . '?=';
                             mail($notify, $subject, $notification, "From: {$rsvpto}\nContent-Type: text/html; charset=UTF-8");
                         }
                     }
                 }
             }
         }
     } else {
         echo "none found";
     }
 }