// Create a fake, temporary comment. $comment = array('comment_post_ID' => $post->ID, 'comment_author' => '(Name)', 'comment_author_email' => $send_sample_email, 'comment_author_url' => get_option('siteurl'), 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 'comment_date' => date('Y-m-d H:i:s'), 'comment_date_gmt' => gmdate('Y-m-d H:i:s'), 'comment_content' => 'This is just a sample comment that I\'ve written', 'comment_approved' => 1, 'comment_agent' => $_SERVER['HTTP_USER_AGENT'], 'comment_type' => '', 'comment_parent' => 0, 'user_id' => 0); $comment = get_comment(wp_insert_comment($comment), OBJECT); $email_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . $tml->table_name("emails") . " WHERE email = %s", $send_sample_email)); if ($email_id === NULL) { // no row was found in the table: insert one; get an ID $wpdb->insert($tml->table_name("emails"), array("email" => $send_sample_email, "subscribed" => true), array("%s", "%b")); $email_id = $wpdb->insert_id; } $wpdb->insert($tml->table_name("queue"), array("email_ID" => $email_id, "comment_ID" => $comment->comment_ID, "send_time" => time() - 3600, "message_uid" => $values["uid"]), array("%d", "%d", "%d", "%d")); $sched_id = $wpdb->insert_id; $tml->send_mail($sched_id); // delete the comment wp_delete_comment($comment->comment_ID); $message = sprintf(__("A sample e-mail was sent to %s", 'thankmelater'), wp_specialchars($send_sample_email)); TML_form::show_message($message, TML_form::MESSAGE_UPDATED); } } else { // show error message ?> <p><div id="message" class="error"><p><strong> <?php $tml_form_errors->list_errors(); ?> </strong></p></div></p> <?php // include the form to fix errors require_once TML_DIR . "/" . TML_INCLUDES_DIR . "admin/messages/edit_message/message_form.php"; } } else { // no POST
</strong></p></div></p> <?php } // does table need update? (checks table structure, existance) $needs_update = $tml_install->needs_update($table_name, $table["structure"]); $error = false; $status = '<span class="ok">' . __("OK", "thankmelater") . '</span>'; if ($needs_update) { $error = true; // table needs update; give link to fix table $status = '<span class="not_ok">' . sprintf(__("Error: %sRepair Table%s.", "thankmelater"), '<a href="?' . attribute_escape(TML_admin_pages_hierarchy::build_query()) . '&repair_table=' . attribute_escape(urlencode($table_name)) . '">', '</a>') . '</span>'; } // add row $parameters[] = array("error" => $error, "param_name" => sprintf(__("Table '%s'", "thankmelater"), $table_name), "status" => $status); } TML_form::show_message(sprintf(__("Need help? %sVisit the support forum%s.", 'thankmelater'), '<a href="http://infinity-infinity.com/forums/forum/3" target="_blank">', '</a>'), TML_form::MESSAGE_INFO); ?> <h3><?php _e("Environment Status", "thankmelater"); ?> </h3> <p><?php _e("The following parameters have been tested. Any parameter which may cause a problem with TML's operation will be labelled 'Error'.", "thankmelater"); ?> </p> <table class="tml-table widefat"> <thead>
} $prob_sum = 0; // the total sum of all probabilities (this should be 1; if not, it will be corrected on update) // calculate the $prob_sum foreach ($opt_messages as $email) { //$prob = (float)round($email["prob"],3); $prob_sum += (double) $email["prob"]; } if (!count($opt_messages)) { // no messages: let the user know $message = sprintf(__("You have not created any messages yet. %sCreate one now »%s", "thankmelater"), '<a href="?' . attribute_escape(TML_admin_pages_hierarchy::build_query($tml_admin_messages->level_id, "new_message")) . '">', '</a>'); TML_form::show_message($message, TML_form::MESSAGE_ERROR); } elseif (!$prob_sum) { // probabilities are 0; e-mails not being sent. $message = __("All probabilities are set to 0. Thank Me Later will not send any e-mails until at least one message has a non-zero, positive probability.", "thankmelater"); TML_form::show_message($message, TML_form::MESSAGE_ERROR); } ?> <script type="text/javascript"> // sum the probabilities function tml_sum_prob() { var sum = 0; for( var i = 0; document.getElementById("prob_" + i); i++ ) { var v = parseFloat( document.getElementById("prob_" + i).value ); if(v) sum += v; } var output_el = document.getElementById("tml_total_prob");
exit; } require_once "admin_pages.php"; require_once "form_functions.php"; // admin pages are typically forms; $tml_form_errors will allow // errors to be recorded/displayed/managed $tml_form_errors = new TML_form_errors(); class TML_admin extends TML_admin_pages { } $pages = array("messages" => array("display" => __("Messages", "thankmelater")), "additional_options" => array("display" => __("Additional Options", "thankmelater")), "help" => array("display" => __("Installation and Information", "thankmelater"))); $tml_admin = new TML_admin($pages, "messages"); $last_cron = $tml->get_option("last_wpcron_tick"); if ($last_cron < time() - 3600 * 1.2) { //echo date("Y-m-d H:i:s", $last_cron); TML_form::show_message(__("WP-Cron doesn't seem to be working. Thank Me Later is emulating the behaviour of WP-Cron, which may slightly slow down some page loads. You may wish to seek a solution to this problem, although the impact is usually negligible.", "thankmelater"), TML_form::MESSAGE_ERROR); } ?> <div class="wrap"> <h2><?php _e("Thank Me Later", "thankmelater"); ?> </h2> <?php $tml_admin->nav(); ?> <?php $tml_admin->content();