<!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>[2354] 2013/codebykat/post-by-email/trunk: Code style fixes and using human_time_diff instead of hardcoding timeout in log message.</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/2354">2354</a></dd>
<dt>Author</dt> <dd>codebykat</dd>
<dt>Date</dt> <dd>2013-09-22 01:40:51 +0000 (Sun, 22 Sep 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Code style fixes and using human_time_diff instead of hardcoding timeout in log message. Fixes GSOC Trac <a href="http://gsoc.trac.wordpress.org/ticket/377">#377</a>
http://gsoc.trac.wordpress.org/ticket/377</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#2013codebykatpostbyemailtrunk22942_updated_for_37diff">2013/codebykat/post-by-email/trunk/22942_updated_for_3.7.diff</a></li>
<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="#2013codebykatpostbyemailtrunkjsadminjs">2013/codebykat/post-by-email/trunk/js/admin.js</a></li>
<li><a href="#2013codebykatpostbyemailtrunkviewsadminphp">2013/codebykat/post-by-email/trunk/views/admin.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="2013codebykatpostbyemailtrunk22942_updated_for_37diff"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/22942_updated_for_3.7.diff (2353 => 2354)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/22942_updated_for_3.7.diff 2013-09-21 18:17:04 UTC (rev 2353)
+++ 2013/codebykat/post-by-email/trunk/22942_updated_for_3.7.diff 2013-09-22 01:40:51 UTC (rev 2354)
</span><span class="lines">@@ -422,5 +422,5 @@
</span><span class="cx"> -}
</span><span class="cx"> -
</span><span class="cx"> -$pop3->quit();
</span><del>-+do_action('wp-mail.php');
</del><ins>++do_action( 'wp-mail.php' );
</ins><span class="cx"> \ No newline at end of file
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkclasspostbyemailadminphp"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php (2353 => 2354)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php 2013-09-21 18:17:04 UTC (rev 2353)
+++ 2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php 2013-09-22 01:40:51 UTC (rev 2354)
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx"> $options['pin_required'] = false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if( strpos( $options['pin'], ']' ) ) {
</del><ins>+ if ( strpos( $options['pin'], ']' ) ) {
</ins><span class="cx"> $error_message = __( 'Error: PIN cannot contain shortcode delimiters.', 'post-by-email' );
</span><span class="cx"> add_settings_error( 'post_by_email_options',
</span><span class="cx"> 'post_by_email_options[mailserver_pin]',
</span><span class="lines">@@ -198,10 +198,11 @@
</span><span class="cx"> array( $this, 'display_plugin_admin_page' )
</span><span class="cx"> );
</span><span class="cx"> WP_Screen::get($this->plugin_screen_hook_suffix)->add_help_tab( array(
</span><del>- 'id' => 'options-postemail',
- 'title' => __( 'Post Via Email' ),
- 'content' => '<p>' . __( 'Post via email settings allow you to send your WordPress install an email with the content of your post. You must set up a secret e-mail account with POP3 access to use this, and any mail received at this address will be posted, so it’s a good idea to keep this address very secret.', 'post-by-email' ) . '</p>',
- ) );
</del><ins>+ 'id' => 'options-postemail',
+ 'title' => __( 'Post Via Email' ),
+ 'content' => '<p>' . __( 'Post via email settings allow you to send your WordPress install an email with the content of your post. You must set up a secret e-mail account with POP3 access to use this, and any mail received at this address will be posted, so it’s a good idea to keep this address very secret.', 'post-by-email' ) . '</p>',
+ )
+ );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -225,6 +226,13 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> wp_enqueue_script( 'post-by-email-admin-js', plugins_url( 'js/admin.js', __FILE__ ), 'jquery', '', true );
</span><ins>+
+ // add nonces
+ $nonces = array(
+ 'logNonce' => wp_create_nonce( 'post-by-email-clear-log' ),
+ 'pinNonce' => wp_create_nonce( 'post-by-email-generate-pin' ),
+ );
+ wp_localize_script( 'post-by-email-admin-js', 'PostByEmailNonces', $nonces );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkclasspostbyemailphp"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/class-post-by-email.php (2353 => 2354)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/class-post-by-email.php 2013-09-21 18:17:04 UTC (rev 2353)
+++ 2013/codebykat/post-by-email/trunk/class-post-by-email.php 2013-09-22 01:40:51 UTC (rev 2354)
</span><span class="lines">@@ -225,7 +225,8 @@
</span><span class="cx"> $last_checked = get_transient( 'mailserver_last_checked' );
</span><span class="cx">
</span><span class="cx"> if ( $last_checked && ! WP_DEBUG ) {
</span><del>- $log_message = __( 'Please wait at least five minutes to check mail again!', 'post-by-email' );
</del><ins>+ $time_diff = __( human_time_diff( time(), time() + WP_MAIL_INTERVAL ), 'post-by-email' );
+ $log_message = sprintf( __( 'Please wait %s to check mail again!', 'post-by-email' ), $time_diff );
</ins><span class="cx"> $this->save_log_message( $log_message );
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -330,7 +331,7 @@
</span><span class="cx"> $pin = $this->find_shortcode( 'pin', $post_content );
</span><span class="cx"> $pin = implode( $pin );
</span><span class="cx">
</span><del>- if( $pin != $options['pin'] ) {
</del><ins>+ if ( $pin != $options['pin'] ) {
</ins><span class="cx"> // security check failed - move on to the next message
</span><span class="cx"> $log_message .= '<br />"' . $post_title . '" ' . __( 'failed PIN authentication; discarding.', 'post-by-email' );
</span><span class="cx"> continue;
</span><span class="lines">@@ -353,7 +354,7 @@
</span><span class="cx"> $post_category[] = $term->term_id;
</span><span class="cx"> } else { // create new category
</span><span class="cx"> $new_category = wp_insert_term( $cat, 'category' );
</span><del>- if( $new_category ) {
</del><ins>+ if ( $new_category ) {
</ins><span class="cx"> $post_category[] = $new_category['term_id'];
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -391,7 +392,7 @@
</span><span class="cx"> // get all registered custom taxonomies
</span><span class="cx"> $args = array(
</span><span class="cx"> 'public' => true,
</span><del>- '_builtin' => false
</del><ins>+ '_builtin' => false,
</ins><span class="cx"> );
</span><span class="cx"> $registered_taxonomies = get_taxonomies( $args, 'names', 'and' );
</span><span class="cx">
</span><span class="lines">@@ -412,7 +413,7 @@
</span><span class="cx"> // add gallery to posts with attachments
</span><span class="cx"> $post_info = array(
</span><span class="cx"> 'ID' => $post_ID,
</span><del>- 'post_content' => $post_content . '[gallery]'
</del><ins>+ 'post_content' => $post_content . '[gallery]',
</ins><span class="cx"> );
</span><span class="cx"> wp_update_post( $post_info );
</span><span class="cx"> }
</span><span class="lines">@@ -534,8 +535,9 @@
</span><span class="cx"> $headerquery = new Horde_Imap_Client_Fetch_Query();
</span><span class="cx"> $headerquery->headerText( array() );
</span><span class="cx"> $headerlist = $this->connection->fetch( 'INBOX', $headerquery, array(
</span><del>- 'ids' => $uid
- ));
</del><ins>+ 'ids' => $uid,
+ )
+ );
</ins><span class="cx">
</span><span class="cx"> $headers = $headerlist->first()->getHeaderText( 0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE );
</span><span class="cx"> return $headers;
</span><span class="lines">@@ -626,8 +628,9 @@
</span><span class="cx"> $query->structure();
</span><span class="cx">
</span><span class="cx"> $list = $this->connection->fetch( 'INBOX', $query, array(
</span><del>- 'ids' => $uid
- ));
</del><ins>+ 'ids' => $uid,
+ )
+ );
</ins><span class="cx">
</span><span class="cx"> $part = $list->first()->getStructure();
</span><span class="cx"> $body_id = $part->findBody('html');
</span><span class="lines">@@ -638,13 +641,15 @@
</span><span class="cx">
</span><span class="cx"> $query2 = new Horde_Imap_Client_Fetch_Query();
</span><span class="cx"> $query2->bodyPart( $body_id, array(
</span><del>- 'decode' => true,
- 'peek' => true
- ));
</del><ins>+ 'decode' => true,
+ 'peek' => true,
+ )
+ );
</ins><span class="cx">
</span><span class="cx"> $list2 = $this->connection->fetch( 'INBOX', $query2, array(
</span><del>- 'ids' => $uid
- ));
</del><ins>+ 'ids' => $uid,
+ )
+ );
</ins><span class="cx">
</span><span class="cx"> $message2 = $list2->first();
</span><span class="cx"> $content = $message2->getBodyPart( $body_id );
</span><span class="lines">@@ -675,8 +680,9 @@
</span><span class="cx"> $query->structure();
</span><span class="cx">
</span><span class="cx"> $list = $this->connection->fetch( 'INBOX', $query, array(
</span><del>- 'ids' => $uid
- ));
</del><ins>+ 'ids' => $uid,
+ )
+ );
</ins><span class="cx">
</span><span class="cx"> $part = $list->first()->getStructure();
</span><span class="cx"> $map = $part->ContentTypeMap();
</span><span class="lines">@@ -694,13 +700,15 @@
</span><span class="cx">
</span><span class="cx"> $query2 = new Horde_Imap_Client_Fetch_Query();
</span><span class="cx"> $query2->bodyPart( $mime_id, array(
</span><del>- 'decode' => true,
- 'peek' => true
- ));
</del><ins>+ 'decode' => true,
+ 'peek' => true,
+ )
+ );
</ins><span class="cx">
</span><span class="cx"> $list2 = $this->connection->fetch( 'INBOX', $query2, array(
</span><del>- 'ids' => $uid
- ));
</del><ins>+ 'ids' => $uid,
+ )
+ );
</ins><span class="cx">
</span><span class="cx"> $message = $list2->first();
</span><span class="cx">
</span><span class="lines">@@ -756,9 +764,10 @@
</span><span class="cx">
</span><span class="cx"> try {
</span><span class="cx"> $this->connection->store( 'INBOX', array(
</span><del>- 'add' => array( $flag ),
- 'ids' => $uids
- ) );
</del><ins>+ 'add' => array( $flag ),
+ 'ids' => $uids,
+ )
+ );
</ins><span class="cx"> }
</span><span class="cx"> catch ( Horde_Imap_Client_Exception $e ) {
</span><span class="cx"> $this->save_error_message( __( 'An error occurred: ', 'post-by-email' ) . $e->getMessage() );
</span><span class="lines">@@ -798,7 +807,7 @@
</span><span class="cx"> // get all registered custom taxonomies
</span><span class="cx"> $args = array(
</span><span class="cx"> 'public' => true,
</span><del>- '_builtin' => false
</del><ins>+ '_builtin' => false,
</ins><span class="cx"> );
</span><span class="cx"> $registered_taxonomies = get_taxonomies( $args, 'names', 'and' );
</span><span class="cx">
</span><span class="lines">@@ -835,7 +844,11 @@
</span><span class="cx"> protected function save_log_message( $message, $error=false ) {
</span><span class="cx"> $log = get_option( 'post_by_email_log', array() );
</span><span class="cx">
</span><del>- array_unshift( $log, array( 'timestamp'=>current_time( 'timestamp' ), 'message'=>$message ) );
</del><ins>+ array_unshift( $log, array(
+ 'timestamp' => current_time( 'timestamp' ),
+ 'message' => $message,
+ )
+ );
</ins><span class="cx">
</span><span class="cx"> update_option( 'post_by_email_log', $log );
</span><span class="cx">
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkjsadminjs"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/js/admin.js (2353 => 2354)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/js/admin.js 2013-09-21 18:17:04 UTC (rev 2353)
+++ 2013/codebykat/post-by-email/trunk/js/admin.js 2013-09-22 01:40:51 UTC (rev 2354)
</span><span class="lines">@@ -6,14 +6,14 @@
</span><span class="cx">
</span><span class="cx"> var data = {
</span><span class="cx"> action: 'post_by_email_clear_log',
</span><del>- security: logNonce
</del><ins>+ security: PostByEmailNonces['logNonce']
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> jQuery.post( ajaxurl, data, function( response ) {
</span><span class="cx"> jQuery(' table#logTable' ).hide();
</span><span class="cx"> jQuery( 'a#clearLog' ).hide();
</span><del>- });
- });
</del><ins>+ } );
+ } );
</ins><span class="cx">
</span><span class="cx"> // AJAX request for a new PIN
</span><span class="cx"> jQuery( 'input#generatePIN' ).click( function( e ) {
</span><span class="lines">@@ -21,13 +21,13 @@
</span><span class="cx">
</span><span class="cx"> var data = {
</span><span class="cx"> action: 'post_by_email_generate_pin',
</span><del>- security: pinNonce
</del><ins>+ security: PostByEmailNonces['pinNonce']
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> jQuery.post( ajaxurl, data, function( response ) {
</span><span class="cx"> jQuery( 'input#post_by_email_options\\\[pin\\\]' ).val( response );
</span><del>- });
- });
</del><ins>+ } );
+ } );
</ins><span class="cx">
</span><span class="cx"> // tab switching
</span><span class="cx"> jQuery( 'a.nav-tab' ).click( function( e ) {
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx"> jQuery( 'div#tab-'+id ).show();
</span><span class="cx"> jQuery( 'a.nav-tab-active' ).removeClass( 'nav-tab-active' );
</span><span class="cx"> jQuery( e.target ).addClass( 'nav-tab-active' );
</span><del>- });
</del><ins>+ } );
</ins><span class="cx">
</span><span class="cx"> // reset advanced options to default (SSL+IMAP)
</span><span class="cx"> jQuery( 'input#resetButton' ).click( function( e ) {
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> jQuery( 'input#post_by_email_options\\[mailserver_port\\]' ).val( 993 );
</span><span class="cx"> jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'checked', 'checked' );
</span><span class="cx"> jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'disabled', false );
</span><del>- });
</del><ins>+ } );
</ins><span class="cx">
</span><span class="cx"> if ( 'POP3' == jQuery( 'select#post_by_email_options\\[mailserver_protocol\\]' ).val() ) {
</span><span class="cx"> jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'checked', 'checked' );
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx"> } else {
</span><span class="cx"> jQuery( 'input#post_by_email_options\\[delete_messages\\]' ).attr( 'disabled', false );
</span><span class="cx"> }
</span><del>- });
</del><ins>+ } );
</ins><span class="cx">
</span><span class="cx"> // PIN tab
</span><span class="cx"> jQuery( 'input#post_by_email_options\\[pin_required\\]' ).click( function( e ) {
</span><span class="lines">@@ -69,6 +69,6 @@
</span><span class="cx"> } else {
</span><span class="cx"> jQuery( 'tr.post-by-email-pin-settings' ).hide();
</span><span class="cx"> }
</span><del>- });
</del><ins>+ } );
</ins><span class="cx">
</span><del>-});
</del><span class="cx">\ No newline at end of file
</span><ins>+} );
</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 (2353 => 2354)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/views/admin.php 2013-09-21 18:17:04 UTC (rev 2353)
+++ 2013/codebykat/post-by-email/trunk/views/admin.php 2013-09-22 01:40:51 UTC (rev 2354)
</span><span class="lines">@@ -286,9 +286,4 @@
</span><span class="cx"> </table>
</span><span class="cx"> <?php endif; ?>
</span><span class="cx"> </div>
</span><del>-</div>
-
-<script type="text/javascript">
- var logNonce = "<?php echo wp_create_nonce( 'post-by-email-clear-log' ); ?>";
- var pinNonce = "<?php echo wp_create_nonce( 'post-by-email-generate-pin' ); ?>";
-</script>
</del><span class="cx">\ No newline at end of file
</span><ins>+</div>
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>