<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[2270] 2013/codebykat/post-by-email/trunk: massive admin page refactor.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://gsoc.trac.wordpress.org/changeset/2270">2270</a></dd>
<dt>Author</dt> <dd>codebykat</dd>
<dt>Date</dt> <dd>2013-09-10 20:03:11 +0000 (Tue, 10 Sep 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>massive admin page refactor. explicitely set protocol. TABS. do not check for mail until user has configured settings.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#2013codebykatpostbyemailtrunkclasspostbyemailadminphp">2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php</a></li>
<li><a href="#2013codebykatpostbyemailtrunkclasspostbyemailphp">2013/codebykat/post-by-email/trunk/class-post-by-email.php</a></li>
<li><a href="#2013codebykatpostbyemailtrunkviewsadminphp">2013/codebykat/post-by-email/trunk/views/admin.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>2013/codebykat/post-by-email/trunk/js/</li>
<li><a href="#2013codebykatpostbyemailtrunkjsadminjs">2013/codebykat/post-by-email/trunk/js/admin.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="2013codebykatpostbyemailtrunkclasspostbyemailadminphp"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php (2269 => 2270)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php 2013-09-10 18:32:18 UTC (rev 2269)
+++ 2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php 2013-09-10 20:03:11 UTC (rev 2270)
</span><span class="lines">@@ -39,6 +39,10 @@
</span><span class="cx">
</span><span class="cx"> // AJAX hook to clear the log
</span><span class="cx"> add_action( 'wp_ajax_post_by_email_clear_log', array( $this, 'clear_log') );
</span><ins>+
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
+
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -57,30 +61,55 @@
</span><span class="cx"> *
</span><span class="cx"> * @param array $input Form fields submitted from the settings page.
</span><span class="cx"> */
</span><del>- public function post_by_email_validate($input) {
</del><ins>+ public function post_by_email_validate( $input ) {
</ins><span class="cx"> // load all the options so we don't wipe out pre-existing stuff
</span><span class="cx"> $options = get_option( 'post_by_email_options' );
</span><span class="cx">
</span><del>- $options['mailserver_url'] = trim( $input['mailserver_url'] );
</del><ins>+ $default_options = Post_By_Email::$default_options;
</ins><span class="cx">
</span><ins>+ $mailserver_url = trim( $input['mailserver_url'] );
+ if( $mailserver_url != $default_options['mailserver_url'] ) {
+ $options['mailserver_url'] = $mailserver_url;
+ }
+
+ $mailserver_protocol = trim( $input['mailserver_protocol'] );
+ if( in_array( $options['mailserver_protocol'], array('POP3', 'IMAP') ) ) {
+ $options['mailserver_protocol'] = $mailserver_protocol;
+ }
+
</ins><span class="cx"> // port must be numeric and 16 digits max
</span><del>- $options['mailserver_port'] = trim( $input['mailserver_port'] );
- if( ! preg_match('/^[1-9][0-9]{0,15}$/', $options['mailserver_port'] ) ) {
- $options['mailserver_port'] = '';
</del><ins>+ $mailserver_port = trim( $input['mailserver_port'] );
+ if( preg_match('/^[1-9][0-9]{0,15}$/', $mailserver_port ) ) {
+ $options['mailserver_port'] = $mailserver_port;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- $options['mailserver_login'] = trim( $input['mailserver_login'] );
- $options['mailserver_pass'] = trim( $input['mailserver_pass'] );
</del><ins>+ $mailserver_login = trim( $input['mailserver_login'] );
+ if( $mailserver_login != $default_options['mailserver_login'] ) {
+ $options['mailserver_login'] = $mailserver_login;
+ }
</ins><span class="cx">
</span><ins>+ $mailserver_pass = trim( $input['mailserver_pass'] );
+ if( '' != $mailserver_pass ) {
+ $options['mailserver_pass'] = $mailserver_pass;
+ }
+
</ins><span class="cx"> // default email category must be the ID of a real category
</span><del>- $options['default_email_category'] = $input['default_email_category'];
- if( ! get_category( $options['default_email_category'] ) ) {
- $options['default_email_category'] = '';
</del><ins>+ $default_email_category = $input['default_email_category'];
+ if( get_category( $default_email_category ) ) {
+ $options['default_email_category'] = $default_email_category;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $options['ssl'] = isset( $input['ssl'] );
</span><span class="cx"> $options['delete_messages'] = isset( $input['delete_messages'] );
</span><span class="cx">
</span><ins>+ if( $options['mailserver_url'] && $options['mailserver_port']
+ && $options['mailserver_login'] && $options['mailserver_pass'] ) {
+ $options['status'] = 'ready';
+
+ // clear the transient if options have been updated
+ delete_transient( 'mailserver_last_checked' );
+ }
+
</ins><span class="cx"> return $options;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -114,6 +143,40 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Load up Javascript for the admin page.
+ *
+ * @since 1.0.1
+ *
+ * @param string $hook Name of the current admin page.
+ */
+ public function enqueue_scripts( $hook ) {
+ if( $hook != $this->plugin_screen_hook_suffix )
+ return;
+
+ wp_enqueue_script( 'post-by-email-admin-js', plugins_url( 'js/admin.js', __FILE__ ), 'jquery', '', true );
+ }
+
+ /**
+ * Display any errors or notices as an admin banner.
+ *
+ * @since 1.0.1
+ */
+ public function admin_notices() {
+ $options = get_option( 'post_by_email_options' );
+ $settings_url = admin_url( 'tools.php?page=post-by-email' );
+ if( ! $options || ! isset( $options['status'] ) || $options['status'] == 'unconfigured' ) {
+ echo "<div class='error'><p>";
+ _e( "Notice: Post by Email is currently disabled. To post to your blog via email, please <a href='$settings_url'>configure your settings now</a>.", 'post-by-email' );
+ echo "</p></div>";
+ }
+ elseif( $options['status'] == 'error' ) {
+ echo "<div class='error'><p>";
+ _e( "Post via Email encountered an error. Please double-check <a href='$settings_url'>the settings</a>.", 'post-by-email' );
+ echo "</p></div>";
+ }
+ }
+
+ /**
</ins><span class="cx"> * Clear the log file.
</span><span class="cx"> *
</span><span class="cx"> * @since 0.9.9
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkclasspostbyemailphp"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/class-post-by-email.php (2269 => 2270)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/class-post-by-email.php 2013-09-10 18:32:18 UTC (rev 2269)
+++ 2013/codebykat/post-by-email/trunk/class-post-by-email.php 2013-09-10 20:03:11 UTC (rev 2270)
</span><span class="lines">@@ -63,14 +63,16 @@
</span><span class="cx"> *
</span><span class="cx"> * @var array
</span><span class="cx"> */
</span><del>- protected static $default_options = array(
</del><ins>+ public static $default_options = array(
</ins><span class="cx"> 'mailserver_url' => 'mail.example.com',
</span><span class="cx"> 'mailserver_login' => 'login@example.com',
</span><del>- 'mailserver_pass' => 'password',
</del><ins>+ 'mailserver_pass' => '',
+ 'mailserver_protocol' => 'IMAP',
</ins><span class="cx"> 'mailserver_port' => 993,
</span><span class="cx"> 'ssl' => true,
</span><span class="cx"> 'default_email_category' => '',
</span><del>- 'delete_messages' => false
</del><ins>+ 'delete_messages' => true,
+ 'status' => 'unconfigured'
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -83,6 +85,15 @@
</span><span class="cx"> protected $connection;
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Connection protocol (POP3 or IMAP).
+ *
+ * @since 1.0.1
+ *
+ * @var string
+ */
+ protected $protocol;
+
+ /**
</ins><span class="cx"> * Initialize the plugin by setting localization, filters, and administration functions.
</span><span class="cx"> *
</span><span class="cx"> * @since 0.9.0
</span><span class="lines">@@ -139,6 +150,17 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ if( ! isset( $plugin_options['mailserver_protocol'] )
+ && in_array( $options['mailserver_port'], array( 110, 995 ) ) ) {
+ $options['mailserver_protocol'] = 'POP3';
+ $options['delete_messages'] = false;
+ }
+
+ if( ! isset( $plugin_options['ssl'] )
+ && in_array( $options['mailserver_port'], array( 110, 143 ) ) ) {
+ $options['ssl'] = false;
+ }
+
</ins><span class="cx"> update_option( 'post_by_email_options', $options );
</span><span class="cx">
</span><span class="cx"> // if log already exists, this will return false, and that is okay
</span><span class="lines">@@ -184,7 +206,7 @@
</span><span class="cx">
</span><span class="cx"> $this->check_email();
</span><span class="cx">
</span><del>- wp_safe_redirect( admin_url( 'tools.php?page=post-by-email' ) );
</del><ins>+ wp_safe_redirect( admin_url( 'tools.php?page=post-by-email&tab=log' ) );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -194,16 +216,12 @@
</span><span class="cx"> */
</span><span class="cx"> public function check_email() {
</span><span class="cx"> // Only check at this interval for new messages.
</span><del>- if ( ! defined( 'WP_MAIL_INTERVAL' ) )
</del><ins>+ if( ! defined( 'WP_MAIL_INTERVAL' ) )
</ins><span class="cx"> define( 'WP_MAIL_INTERVAL', 5 * MINUTE_IN_SECONDS );
</span><span class="cx">
</span><span class="cx"> $last_checked = get_transient( 'mailserver_last_checked' );
</span><span class="cx">
</span><del>- $options = get_option( 'post_by_email_options' );
- $options['last_checked'] = current_time( 'timestamp' );
- update_option( 'post_by_email_options', $options );
-
- if ( $last_checked && ! WP_DEBUG ) {
</del><ins>+ if( $last_checked && ! WP_DEBUG ) {
</ins><span class="cx"> $log_message = __( 'Slow down cowboy, no need to check for new mails so often!', 'post-by-email' );
</span><span class="cx"> $this->save_log_message( $log_message );
</span><span class="cx"> return;
</span><span class="lines">@@ -211,13 +229,13 @@
</span><span class="cx">
</span><span class="cx"> set_transient( 'mailserver_last_checked', true, WP_MAIL_INTERVAL );
</span><span class="cx">
</span><ins>+ $options = get_option( 'post_by_email_options' );
+ $options['last_checked'] = current_time( 'timestamp' );
+ update_option( 'post_by_email_options', $options );
+
</ins><span class="cx"> // if options aren't set, there's nothing to do, move along
</span><del>- foreach( array( 'mailserver_url', 'mailserver_login', 'mailserver_pass' ) as $optname ) {
- if( ! $options[$optname] || $options[$optname] == self::$default_options[$optname] ) {
- $log_message = __( 'Options not set; skipping.', 'post-by-email' );
- $this->save_log_message( $log_message );
- return;
- }
</del><ins>+ if( $options['status'] == 'unconfigured' ) {
+ return;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $this->connection = $this->open_mailbox_connection( $options );
</span><span class="lines">@@ -349,13 +367,14 @@
</span><span class="cx"> 'secure' => $options['ssl'] ? 'ssl' : false
</span><span class="cx"> );
</span><span class="cx">
</span><del>- if( in_array( $options['mailserver_port'], array( 143, 993 ) ) ) { // IMAP
</del><ins>+ if( 'POP3' == $options['mailserver_protocol'] ) {
+ $connection = new Horde_Imap_Client_Socket_Pop3( $connection_options );
+ $this->protocol = 'POP3';
+ }
+ else { // IMAP
</ins><span class="cx"> $connection = new Horde_Imap_Client_Socket( $connection_options );
</span><del>-
</del><ins>+ $this->protocol = 'IMAP';
</ins><span class="cx"> }
</span><del>- else { // POP3
- $connection = new Horde_Imap_Client_Socket_Pop3( $connection_options );
- }
</del><span class="cx"> $connection->_setInit( 'authmethod', 'USER' );
</span><span class="cx">
</span><span class="cx"> try {
</span><span class="lines">@@ -382,7 +401,7 @@
</span><span class="cx">
</span><span class="cx"> try {
</span><span class="cx"> // POP3 doesn't understand about read/unread messages
</span><del>- if( 'Horde_Imap_Client_Socket_Pop3' == get_class( $this->connection ) ) {
</del><ins>+ if( 'POP3' == $this->protocol ) {
</ins><span class="cx"> $test = $this->connection->search( 'INBOX' );
</span><span class="cx"> }
</span><span class="cx"> else {
</span><span class="lines">@@ -551,7 +570,7 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> $flag = Horde_Imap_Client::FLAG_SEEN;
</span><del>- if( $delete )
</del><ins>+ if( $delete || ( 'POP3' == $this->protocol ) )
</ins><span class="cx"> $flag = Horde_Imap_Client::FLAG_DELETED;
</span><span class="cx">
</span><span class="cx"> try {
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkjsadminjs"></a>
<div class="addfile"><h4>Added: 2013/codebykat/post-by-email/trunk/js/admin.js (0 => 2270)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/js/admin.js (rev 0)
+++ 2013/codebykat/post-by-email/trunk/js/admin.js 2013-09-10 20:03:11 UTC (rev 2270)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+jQuery( document ).ready( function() {
+
+ // AJAX request to clear the log
+ jQuery( 'a#clearLog' ).click( function( e ) {
+ e.preventDefault();
+
+ var data = {
+ action: 'post_by_email_clear_log',
+ security: '<?php echo wp_create_nonce( "post-by-email-clear-log" ); ?>'
+ };
+
+ jQuery.post( ajaxurl, data, function( response ) {
+ jQuery(' table#logTable' ).hide();
+ jQuery( 'a#clearLog' ).hide();
+ });
+ });
+
+ // tab switching
+ jQuery( 'a.nav-tab' ).click( function( e ) {
+ e.preventDefault();
+ var id = e.target.id.substr( 4 );
+ jQuery( 'div.tab-content').hide();
+ jQuery( 'div#tab-'+id ).show();
+ jQuery( 'a.nav-tab-active' ).removeClass( 'nav-tab-active' );
+ jQuery( e.target ).addClass( 'nav-tab-active' );
+ });
+
+ // reset advanced options to default (SSL+IMAP)
+ jQuery( 'input#resetButton' ).click( function( e ) {
+ jQuery( 'input#post_by_email_options\\[ssl\\]' ).attr( 'checked', 'checked' );
+ jQuery( 'select#post_by_email_options\\[mailserver_protocol\\]' ).val( 'IMAP' );
+ jQuery( 'input#post_by_email_options\\[mailserver_port\\]' ).val( 993 );
+ jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'checked', 'checked' );
+ jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'disabled', false );
+ });
+
+ if( 'POP3' == jQuery( 'select#post_by_email_options\\[mailserver_protocol\\]' ).val() ) {
+ jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'checked', 'checked' );
+ jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'disabled', true);
+ }
+
+ jQuery( 'select#post_by_email_options\\[mailserver_protocol\\]' ).change( function( e ) {
+ if( 'POP3' == jQuery( e.target ).val() ) {
+ jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'checked', 'checked' );
+ jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'disabled', true);
+ }
+ else {
+ jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'disabled', false );
+ }
+ });
+
+});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkviewsadminphp"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/views/admin.php (2269 => 2270)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/views/admin.php 2013-09-10 18:32:18 UTC (rev 2269)
+++ 2013/codebykat/post-by-email/trunk/views/admin.php 2013-09-10 20:03:11 UTC (rev 2270)
</span><span class="lines">@@ -16,169 +16,211 @@
</span><span class="cx"> <?php screen_icon(); ?>
</span><span class="cx"> <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
</span><span class="cx">
</span><del>- <p>
- <?php
- printf( __( 'To post to WordPress by e-mail you must set up a secret e-mail account
- with POP3 access. Any mail received at this address will be posted, so
- it’s a good idea to keep this address very secret. Here are three
- random strings you could use: <kbd>%s</kbd>, <kbd>%s</kbd>, <kbd>%s</kbd>.',
- 'post-by-email' ),
- wp_generate_password( 8, false ),
- wp_generate_password( 8, false ),
- wp_generate_password( 8, false ) )
- ?>
- </p>
</del><ins>+ <?php if( isset( $_GET['settings-updated'] ) ) : ?>
+ <div class='updated'>
+ <p><?php _e( 'Your settings have been saved.', 'post-by-email' ); ?></p>
+ </div>
+ <?php endif; ?>
</ins><span class="cx">
</span><ins>+ <?php $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'main'; ?>
+
+ <h2 class="nav-tab-wrapper">
+ <a id="nav-main" href="<?php echo admin_url('tools.php?page='.$_GET['page']); ?>" class="nav-tab <?php if( 'main' == $tab ) { echo 'nav-tab-active'; } ?>">
+ <?php _e( 'Basic Settings', 'post-by-email' ); ?>
+ </a>
+ <a id="nav-connection" href="<?php echo admin_url('tools.php?page='.$_GET['page'].'&tab=connection'); ?>" class="nav-tab <?php if( 'connection' == $tab ) { echo 'nav-tab-active'; } ?>">
+ <?php _e( 'Mailbox Details', 'post-by-email' ); ?>
+ </a>
+ <a id="nav-log" href="<?php echo admin_url('tools.php?page='.$_GET['page'].'&tab=log'); ?>" class="nav-tab <?php if( 'log' == $tab ) { echo 'nav-tab-active'; } ?>">
+ <?php _e( 'Activity Log', 'post-by-email' ); ?>
+ </a>
+ </h2>
+
</ins><span class="cx"> <form method="post" action="options.php">
</span><span class="cx"> <?php settings_fields( 'post_by_email_options' ); ?>
</span><span class="cx">
</span><span class="cx"> <?php $options = get_option( 'post_by_email_options' ); ?>
</span><span class="cx">
</span><del>- <table class="form-table">
- <tr valign="top">
- <th scope="row">
- <label for="post_by_email_options[mailserver_url]">
- <?php _e( 'Mail Server', 'post-by-email' ); ?>
- </label>
- </th>
- <td>
- <input name="post_by_email_options[mailserver_url]" type="text" id="mailserver_url" value="<?php echo esc_attr( $options['mailserver_url'] ); ?>" class="regular-text ltr" />
- <label for="post_by_email_options[mailserver_port]">
- <?php _e( 'Port', 'post-by-email' ); ?>
- </label>
- <input name="post_by_email_options[mailserver_port]" type="text" id="mailserver_port" value="<?php echo esc_attr( $options['mailserver_port'] ); ?>" class="small-text" />
- </td>
- </tr>
- <tr valign="top">
- <th scope="row">
- <label for="post_by_email_options[ssl]">
- <?php _e( 'Always use secure connection (SSL)?', 'post-by-email' ); ?>
- </label>
- </th>
- <td>
- <input name="post_by_email_options[ssl]" type="checkbox" id="ssl" <?php if( $options['ssl'] ) { echo 'checked="checked"'; } ?> />
- </td>
- </tr>
- <tr valign="top">
- <th scope="row">
- <label for="post_by_email_options[mailserver_login]">
- <?php _e( 'Login Name', 'post-by-email' ); ?>
- </label>
- </th>
- <td>
- <input name="post_by_email_options[mailserver_login]" type="text" id="mailserver_login" value="<?php echo esc_attr( $options['mailserver_login'] ); ?>" class="regular-text ltr" />
- </td>
- </tr>
- <tr valign="top">
- <th scope="row">
- <label for="post_by_email_options[mailserver_pass]">
- <?php _e( 'Password', 'post-by-email' ); ?>
- </label>
- </th>
- <td>
- <input name="post_by_email_options[mailserver_pass]" type="password" id="mailserver_pass" value="<?php echo esc_attr( $options['mailserver_pass'] ); ?>" class="regular-text ltr" />
- </td>
- </tr>
- <tr valign="top">
- <th scope="row">
- <label for="post_by_email_options[default_email_category]">
- <?php _e( 'Default Mail Category', 'post-by-email' ); ?>
- </label>
- </th>
- <td>
- <?php
- wp_dropdown_categories( array( 'hide_empty' => 0,
- 'name' => 'post_by_email_options[default_email_category]',
- 'orderby' => 'name',
- 'selected' => $options['default_email_category'],
- 'hierarchical' => true
- ) );
- ?>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row">
- <label for="post_by_email_options[delete_messages]">
- <?php _e( 'Delete messages after posting?', 'post-by-email' ); ?>
- </label>
- </th>
- <td>
- <input name="post_by_email_options[delete_messages]" type="checkbox" id="delete_messages" <?php if( $options['delete_messages'] ) { echo 'checked="checked"'; } ?> />
- </td>
- </tr>
- </table>
</del><ins>+ <div class='tab-content' id='tab-main' <?php if( 'main' != $tab ) { echo 'style="display:none;"'; } ?>>
+ <p>
+ <?php
+ printf( __( 'To post to WordPress by e-mail you must set up a secret e-mail account
+ with IMAP or POP3 access. Any mail received at this address will be posted, so
+ it’s a good idea to keep this address very secret. Here are three
+ random strings you could use: <kbd>%s</kbd>, <kbd>%s</kbd>, <kbd>%s</kbd>.',
+ 'post-by-email' ),
+ wp_generate_password( 8, false ),
+ wp_generate_password( 8, false ),
+ wp_generate_password( 8, false ) )
+ ?>
+ </p>
</ins><span class="cx">
</span><ins>+ <table class="form-table">
+ <tr valign="top">
+ <th scope="row">
+ <label for="post_by_email_options[mailserver_url]">
+ <?php _e( 'Mail Server', 'post-by-email' ); ?>
+ </label>
+ </th>
+ <td>
+ <input name="post_by_email_options[mailserver_url]" type="text" id="mailserver_url" value="<?php echo esc_attr( $options['mailserver_url'] ); ?>" class="regular-text ltr" />
+ <p class="description">
+ <?php _e( 'The address of the incoming mail server (IMAP or POP3).', 'post-by-email'); ?>
+ </p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">
+ <label for="post_by_email_options[mailserver_login]">
+ <?php _e( 'Login Name', 'post-by-email' ); ?>
+ </label>
+ </th>
+ <td>
+ <input name="post_by_email_options[mailserver_login]" type="text" id="mailserver_login" value="<?php echo esc_attr( $options['mailserver_login'] ); ?>" class="regular-text ltr" />
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">
+ <label for="post_by_email_options[mailserver_pass]">
+ <?php _e( 'Password', 'post-by-email' ); ?>
+ </label>
+ </th>
+ <td>
+ <input name="post_by_email_options[mailserver_pass]" type="password" id="mailserver_pass" value="<?php echo esc_attr( $options['mailserver_pass'] ); ?>" class="regular-text ltr" />
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">
+ <label for="post_by_email_options[default_email_category]">
+ <?php _e( 'Default Mail Category', 'post-by-email' ); ?>
+ </label>
+ </th>
+ <td>
+ <?php
+ wp_dropdown_categories( array( 'hide_empty' => 0,
+ 'name' => 'post_by_email_options[default_email_category]',
+ 'orderby' => 'name',
+ 'selected' => $options['default_email_category'],
+ 'hierarchical' => true
+ ) );
+ ?>
+ </td>
+ </tr>
+ </table>
</ins><span class="cx">
</span><del>- <?php submit_button(); ?>
- </form>
</del><span class="cx">
</span><del>- <h3><?php _e( 'Activity Log', 'post-by-email' ); ?></h3>
- <?php
- $options = get_option( 'post_by_email_options' );
- $log = get_option( 'post_by_email_log' );
- ?>
- <p>
- <?php _e( 'Last checked for new mail:', 'post-by-email' ); ?>
- <?php
- $date_format = get_option( 'date_format' );
- $time_format = get_option( 'time_format' );
- ?>
- <?php if( isset( $options['last_checked'] ) ) : ?>
- <?php echo date_i18n( "$date_format, $time_format", $options['last_checked'] ); ?>
- <?php else: ?>
- <?php _e( 'Never', 'post-by-email' ); ?>
- <?php endif; ?>
- <br />
- <?php _e( 'Next scheduled check:', 'post-by-email' ); ?>
- <?php
- $next = wp_next_scheduled( 'post-by-email-wp-mail.php' );
- echo get_date_from_gmt( date( 'Y-m-d H:i:s', $next ) , "$date_format, $time_format" );
- ?>
- </p>
- <p>
- <a href="<?php echo site_url( 'wp-mail.php' ); ?>" class="button-secondary">
- <?php _e( 'Check now', 'post-by-email' ); ?>
- </a>
- </p>
- <?php if( $log && sizeof($log) > 0 ) : ?>
</del><ins>+ <?php submit_button(); ?>
+ </div>
</ins><span class="cx">
</span><del>- <p>
- <a href="" id="clearLog" ><?php _e('Clear Log', 'post-by-email' ); ?></a>
</del><ins>+ <div class='tab-content' id='tab-connection' <?php if( 'connection' != $tab ) { echo 'style="display:none;"'; } ?>>
</ins><span class="cx">
</span><del>- <script type="text/javascript" >
- jQuery('a#clearLog').click(function(e) {
</del><ins>+ <p><?php _e( "Configure the details of your mailbox connection. The default settings should work with most email accounts, but if your mail server differs, you can enter it here.", 'post-by-email' ); ?></p>
</ins><span class="cx">
</span><del>- var data = {
- action: 'post_by_email_clear_log',
- security: '<?php echo wp_create_nonce("post-by-email-clear-log"); ?>'
- };
</del><ins>+ <table class="form-table">
+ <tr valign="top">
+ <th>
+ <label for="post_by_email_options[mailserver_protocol]">
+ <?php _e( 'Protocol', 'post-by-email' ); ?>
+ </label>
+ </th>
+ <td>
+ <select name="post_by_email_options[mailserver_protocol]" id="post_by_email_options[mailserver_protocol]">
+ <option value="POP3" <?php if( 'POP3' == $options['mailserver_protocol'] ) { echo 'selected'; } ?>>POP3</option>
+ <option value="IMAP" <?php if( 'IMAP' == $options['mailserver_protocol'] ) { echo 'selected'; } ?>>IMAP</option>
+ </select>
+ </td>
+ </tr>
+ <tr valign="top">
+ <th>
+ <label for="post_by_email_options[mailserver_port]">
+ <?php _e( 'Port', 'post-by-email' ); ?>
+ </label>
+ </th>
+ <td>
+ <input name="post_by_email_options[mailserver_port]" id="post_by_email_options[mailserver_port]" type="text" id="mailserver_port" value="<?php echo esc_attr( $options['mailserver_port'] ); ?>" class="small-text" />
+ <p class="description">
+ <?php _e( "Common port numbers: 143 (IMAP), 993 (IMAP/SSL), 110 (POP3), 995 (POP3/SSL).", 'post-by-email' ); ?>
+ </p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">
+ <label for="post_by_email_options[ssl]">
+ <?php _e( 'Always use secure connection (SSL)?', 'post-by-email' ); ?>
+ </label>
+ </th>
+ <td>
+ <input name="post_by_email_options[ssl]" id="post_by_email_options[ssl]" type="checkbox" id="ssl" <?php if( $options['ssl'] ) { echo 'checked="checked"'; } ?> />
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">
+ <label for="post_by_email_options[delete_messages]" >
+ <?php _e( 'Delete messages after posting?', 'post-by-email' ); ?>
+ </label>
+ </th>
+ <td>
+ <input name="post_by_email_options[delete_messages]" id="post_by_email_options[delete_messages]" type="checkbox" id="delete_messages" <?php if( $options['delete_messages'] ) { echo 'checked="checked"'; } ?> />
+ <p class="description"><?php _e( 'Uncheck this box to mark messages as read instead of deleting (requires IMAP).', 'post-by-email' ); ?></p>
+ </td>
+ </tr>
+ </table>
</ins><span class="cx">
</span><del>- jQuery.post(ajaxurl, data, function(response) {
- jQuery('table#logTable').hide();
- jQuery('a#clearLog').hide();
- });
</del><ins>+ <br />
+ <input type="button" id="resetButton" class="button-secondary" value="<?php _e( 'Reset to Defaults', 'post-by-email'); ?>" />
+ <?php submit_button(); ?>
+ </div>
+ </form>
</ins><span class="cx">
</span><del>- e.preventDefault();
</del><ins>+ <div class='tab-content' id='tab-log' <?php if( 'log' != $tab ) { echo 'style="display:none;"'; } ?>>
</ins><span class="cx">
</span><del>- });
- </script>
-
</del><ins>+ <?php
+ $log = get_option( 'post_by_email_log' );
+ ?>
+ <p>
+ <?php _e( 'Last checked for new mail:', 'post-by-email' ); ?>
+ <?php
+ $date_format = get_option( 'date_format' );
+ $time_format = get_option( 'time_format' );
+ ?>
+ <?php if( isset( $options['last_checked'] ) ) : ?>
+ <?php echo date_i18n( "$date_format, $time_format", $options['last_checked'] ); ?>
+ <?php else: ?>
+ <?php _e( 'Never', 'post-by-email' ); ?>
+ <?php endif; ?>
+ <br />
+ <?php _e( 'Next scheduled check:', 'post-by-email' ); ?>
+ <?php
+ $next = wp_next_scheduled( 'post-by-email-wp-mail.php' );
+ echo get_date_from_gmt( date( 'Y-m-d H:i:s', $next ) , "$date_format, $time_format" );
+ ?>
</ins><span class="cx"> </p>
</span><ins>+ <p>
+ <a href="<?php echo site_url( 'wp-mail.php' ); ?>" class="button-secondary">
+ <?php _e( 'Check now', 'post-by-email' ); ?>
+ </a>
+ </p>
+ <?php if( $log && sizeof($log) > 0 ) : ?>
</ins><span class="cx">
</span><del>- <table id="logTable" class="widefat fixed" cellspacing="0">
- <thead>
- <tr>
- <th colspan='2'><?php _e('Log Messages', 'post-by-email' ); ?></th>
- </tr>
- </thead>
- <tbody>
- <?php foreach( $log as $entry ) : ?>
- <tr class="alternate">
- <td><?php echo date_i18n( "$date_format, $time_format", $entry['timestamp'] ); ?></td>
- <td><?php echo $entry['message']; ?></td>
</del><ins>+ <p>
+ <a href="" id="clearLog" ><?php _e('Clear Log', 'post-by-email' ); ?></a>
+ </p>
+
+ <table id="logTable" class="widefat fixed" cellspacing="0">
+ <thead>
+ <tr>
+ <th colspan='2'><?php _e('Log Messages', 'post-by-email' ); ?></th>
</ins><span class="cx"> </tr>
</span><del>- <?php endforeach; ?>
- </tbody>
- </table>
- <?php endif; ?>
</del><ins>+ </thead>
+ <tbody>
+ <?php foreach( $log as $entry ) : ?>
+ <tr class="alternate">
+ <td><?php echo date_i18n( "$date_format, $time_format", $entry['timestamp'] ); ?></td>
+ <td><?php echo $entry['message']; ?></td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ <?php endif; ?>
+ </div>
</ins><span class="cx"> </div>
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>