Ticket #22942: 22942.2.diff
File 22942.2.diff, 16.0 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/schema.php
393 393 'comments_notify' => 1, 394 394 'posts_per_rss' => 10, 395 395 'rss_use_excerpt' => 0, 396 'mailserver_url' => 'mail.example.com',397 'mailserver_login' => 'login@example.com',398 'mailserver_pass' => 'password',399 'mailserver_port' => 110,400 396 'default_category' => 1, 401 397 'default_comment_status' => 'open', 402 398 'default_ping_status' => 'open', … … 499 495 500 496 // 4.3.0 501 497 'finished_splitting_shared_terms' => 1, 498 499 // 4.4 500 'post_by_email_enabled' => 0, 502 501 ); 503 502 504 503 // 3.3 -
src/wp-admin/includes/upgrade.php
540 540 541 541 maybe_disable_link_manager(); 542 542 543 maybe_disable_post_by_email(); 544 543 545 maybe_disable_automattic_widgets(); 544 546 545 547 update_option( 'db_version', $wp_db_version ); … … 1599 1601 } 1600 1602 1601 1603 /** 1604 * Executes changes made in WordPress 4.4.0 1605 * 1606 * @since 4.4.0 1607 */ 1608 function upgrade_440() { 1609 global $wp_current_db_version; 1610 if ( $wp_current_db_version < 33056 && 'mail.example.com' !== get_option( 'mailserver_url' ) ) { 1611 // Previously set to 0 by populate_options() 1612 update_option( 'post_by_email_enabled', 1 ); 1613 } 1614 } 1615 1616 /** 1602 1617 * Executes network-level upgrade routines. 1603 1618 * 1604 1619 * @since 3.0.0 … … 2562 2577 } 2563 2578 2564 2579 /** 2580 * Disables Post by Email options if, at the time of upgrade, the settings have not been changed from original defaults. 2581 * 2582 * @since 4.4.0 2583 * 2584 * @global int $wp_current_db_version 2585 */ 2586 function maybe_disable_post_by_email() { 2587 global $wp_current_db_version; 2588 2589 if ( $wp_current_db_version > 33056 && 'mail.example.com' === get_option( 'mailserver_url' ) ) { 2590 update_option( 'post_by_email_enabled', 0 ); 2591 } 2592 } 2593 2594 /** 2565 2595 * Runs before the schema is upgraded. 2566 2596 * 2567 2597 * @since 2.9.0 -
src/wp-admin/options-writing.php
22 22 '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>', 23 23 ) ); 24 24 25 /** This filter is documented in wp-admin/options.php */26 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) {27 get_current_screen()->add_help_tab( array(28 'id' => 'options-postemail',29 'title' => __( 'Post Via Email' ),30 '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.' ) . '</p>',31 ) );32 }33 34 25 /** This filter is documented in wp-admin/options-writing.php */ 35 26 if ( apply_filters( 'enable_update_services_configuration', true ) ) { 36 27 get_current_screen()->add_help_tab( array( … … 108 99 do_settings_fields('writing', 'remote_publishing'); // A deprecated section. 109 100 ?> 110 101 </table> 111 102 <?php if ( get_option( 'post_by_email_enabled' ) && apply_filters( 'enable_post_by_email_configuration', true ) ) { ?> 103 <h3 class="title"><?php _e( 'Post via e-mail' ) ?></h3> 104 <p><?php _e( 'This functionality is no longer packaged with WordPress. To continue using it, please install the <a href="http://wordpress.org/plugins/post-by-email">Post By Email plugin</a>.' ); ?></p> 112 105 <?php 113 /** This filter is documented in wp-admin/options.php */114 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) {115 ?>116 <h3 class="title"><?php _e('Post via e-mail') ?></h3>117 <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>.'), wp_generate_password(8, false), wp_generate_password(8, false), wp_generate_password(8, false)) ?></p>118 119 <table class="form-table">120 <tr>121 <th scope="row"><label for="mailserver_url"><?php _e('Mail Server') ?></label></th>122 <td><input name="mailserver_url" type="text" id="mailserver_url" value="<?php form_option('mailserver_url'); ?>" class="regular-text code" />123 <label for="mailserver_port"><?php _e('Port') ?></label>124 <input name="mailserver_port" type="text" id="mailserver_port" value="<?php form_option('mailserver_port'); ?>" class="small-text" />125 </td>126 </tr>127 <tr>128 <th scope="row"><label for="mailserver_login"><?php _e('Login Name') ?></label></th>129 <td><input name="mailserver_login" type="text" id="mailserver_login" value="<?php form_option('mailserver_login'); ?>" class="regular-text ltr" /></td>130 </tr>131 <tr>132 <th scope="row"><label for="mailserver_pass"><?php _e('Password') ?></label></th>133 <td>134 <input name="mailserver_pass" type="text" id="mailserver_pass" value="<?php form_option('mailserver_pass'); ?>" class="regular-text ltr" />135 </td>136 </tr>137 <tr>138 <th scope="row"><label for="default_email_category"><?php _e('Default Mail Category') ?></label></th>139 <td>140 <?php141 wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_category', 'orderby' => 'name', 'selected' => get_option('default_email_category'), 'hierarchical' => true));142 ?>143 </td>144 </tr>145 <?php do_settings_fields('writing', 'post_via_email'); ?>146 </table>147 <?php } ?>148 149 <?php150 106 /** 151 107 * Filter whether to enable the Update Services section in the Writing settings screen. 152 108 * -
src/wp-includes/default-filters.php
309 309 310 310 // If the upgrade hasn't run yet, assume link manager is used. 311 311 add_filter( 'default_option_link_manager_enabled', '__return_true' ); 312 // If the upgrade hasn't run yet, assume the post by mail options are set. 313 add_filter( 'default_option_post_by_email_enabled', '__return_true' ); 312 314 313 315 // This option no longer exists; tell plugins we always support auto-embedding. 314 316 add_filter( 'default_option_embed_autourls', '__return_true' ); -
src/wp-includes/formatting.php
3526 3526 case 'medium_size_h': 3527 3527 case 'large_size_w': 3528 3528 case 'large_size_h': 3529 case 'mailserver_port':3530 3529 case 'comment_max_links': 3531 3530 case 'page_on_front': 3532 3531 case 'page_for_posts': … … 3584 3583 3585 3584 case 'date_format': 3586 3585 case 'time_format': 3587 case 'mailserver_url':3588 case 'mailserver_login':3589 case 'mailserver_pass':3590 3586 case 'upload_path': 3591 3587 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 3592 3588 if ( is_wp_error( $value ) ) { -
src/wp-mail.php
1 1 <?php 2 2 /** 3 * Gets the email message from the user's mailbox to add as 4 * a WordPress post. Mailbox connection information must be 5 * configured under Settings > Writing 3 * This file is deprecated and has been replaced by the 4 * plugin Post By Email. Instead of loading wp-mail.php to 5 * trigger the "wp-mail.php" action, you should trigger it 6 * yourself, either in a plugin/theme hook or via wp_cron. 6 7 * 8 * For more information: 9 * http://wordpress.org/plugins/post-by-email/ 10 * http://codex.wordpress.org/Category:WP-Cron_Functions 11 * 7 12 * @package WordPress 8 13 */ 9 14 … … 10 15 /** Make sure that the WordPress bootstrap has run before continuing. */ 11 16 require(dirname(__FILE__) . '/wp-load.php'); 12 17 13 /** This filter is documented in wp-admin/options.php */ 14 if ( ! apply_filters( 'enable_post_by_email_configuration', true ) ) 15 wp_die( __( 'This action has been disabled by the administrator.' ) ); 18 _deprecated_file( basename( __FILE__ ), '4.4.0', 'wp-mail.php' ); 16 19 17 20 /** 18 21 * Fires to allow a plugin to do a complete takeover of Post by Email. … … 20 23 * @since 2.9.0 21 24 */ 22 25 do_action( 'wp-mail.php' ); 23 24 /** Get the POP3 class with which to access the mailbox. */25 require_once( ABSPATH . WPINC . '/class-pop3.php' );26 27 /** Only check at this interval for new messages. */28 if ( !defined('WP_MAIL_INTERVAL') )29 define('WP_MAIL_INTERVAL', 300); // 5 minutes30 31 $last_checked = get_transient('mailserver_last_checked');32 33 if ( $last_checked )34 wp_die(__('Slow down cowboy, no need to check for new mails so often!'));35 36 set_transient('mailserver_last_checked', true, WP_MAIL_INTERVAL);37 38 $time_difference = get_option('gmt_offset') * HOUR_IN_SECONDS;39 40 $phone_delim = '::';41 42 $pop3 = new POP3();43 44 if ( !$pop3->connect( get_option('mailserver_url'), get_option('mailserver_port') ) || !$pop3->user( get_option('mailserver_login') ) )45 wp_die( esc_html( $pop3->ERROR ) );46 47 $count = $pop3->pass( get_option('mailserver_pass') );48 49 if( false === $count )50 wp_die( esc_html( $pop3->ERROR ) );51 52 if( 0 === $count ) {53 $pop3->quit();54 wp_die( __('There doesn’t seem to be any new mail.') );55 }56 57 for ( $i = 1; $i <= $count; $i++ ) {58 59 $message = $pop3->get($i);60 61 $bodysignal = false;62 $boundary = '';63 $charset = '';64 $content = '';65 $content_type = '';66 $content_transfer_encoding = '';67 $post_author = 1;68 $author_found = false;69 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');70 foreach ($message as $line) {71 // Body signal.72 if ( strlen($line) < 3 )73 $bodysignal = true;74 if ( $bodysignal ) {75 $content .= $line;76 } else {77 if ( preg_match('/Content-Type: /i', $line) ) {78 $content_type = trim($line);79 $content_type = substr($content_type, 14, strlen($content_type) - 14);80 $content_type = explode(';', $content_type);81 if ( ! empty( $content_type[1] ) ) {82 $charset = explode('=', $content_type[1]);83 $charset = ( ! empty( $charset[1] ) ) ? trim($charset[1]) : '';84 }85 $content_type = $content_type[0];86 }87 if ( preg_match('/Content-Transfer-Encoding: /i', $line) ) {88 $content_transfer_encoding = trim($line);89 $content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding) - 27);90 $content_transfer_encoding = explode(';', $content_transfer_encoding);91 $content_transfer_encoding = $content_transfer_encoding[0];92 }93 if ( ( $content_type == 'multipart/alternative' ) && ( false !== strpos($line, 'boundary="') ) && ( '' == $boundary ) ) {94 $boundary = trim($line);95 $boundary = explode('"', $boundary);96 $boundary = $boundary[1];97 }98 if (preg_match('/Subject: /i', $line)) {99 $subject = trim($line);100 $subject = substr($subject, 9, strlen($subject) - 9);101 // Captures any text in the subject before $phone_delim as the subject102 if ( function_exists('iconv_mime_decode') ) {103 $subject = iconv_mime_decode($subject, 2, get_option('blog_charset'));104 } else {105 $subject = wp_iso_descrambler($subject);106 }107 $subject = explode($phone_delim, $subject);108 $subject = $subject[0];109 }110 111 /*112 * Set the author using the email address (From or Reply-To, the last used)113 * otherwise use the site admin.114 */115 if ( ! $author_found && preg_match( '/^(From|Reply-To): /', $line ) ) {116 if ( preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches) )117 $author = $matches[0];118 else119 $author = trim($line);120 $author = sanitize_email($author);121 if ( is_email($author) ) {122 echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>';123 $userdata = get_user_by('email', $author);124 if ( ! empty( $userdata ) ) {125 $post_author = $userdata->ID;126 $author_found = true;127 }128 }129 }130 131 if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'132 $ddate = trim($line);133 $ddate = str_replace('Date: ', '', $ddate);134 if (strpos($ddate, ',')) {135 $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));136 }137 $date_arr = explode(' ', $ddate);138 $date_time = explode(':', $date_arr[3]);139 140 $ddate_H = $date_time[0];141 $ddate_i = $date_time[1];142 $ddate_s = $date_time[2];143 144 $ddate_m = $date_arr[1];145 $ddate_d = $date_arr[0];146 $ddate_Y = $date_arr[2];147 for ( $j = 0; $j < 12; $j++ ) {148 if ( $ddate_m == $dmonths[$j] ) {149 $ddate_m = $j+1;150 }151 }152 153 $time_zn = intval($date_arr[4]) * 36;154 $ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);155 $ddate_U = $ddate_U - $time_zn;156 $post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference);157 $post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U);158 }159 }160 }161 162 // Set $post_status based on $author_found and on author's publish_posts capability163 if ( $author_found ) {164 $user = new WP_User($post_author);165 $post_status = ( $user->has_cap('publish_posts') ) ? 'publish' : 'pending';166 } else {167 // Author not found in DB, set status to pending. Author already set to admin.168 $post_status = 'pending';169 }170 171 $subject = trim($subject);172 173 if ( $content_type == 'multipart/alternative' ) {174 $content = explode('--'.$boundary, $content);175 $content = $content[2];176 177 // Match case-insensitive content-transfer-encoding.178 if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim) ) {179 $content = explode($delim[0], $content);180 $content = $content[1];181 }182 $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>');183 }184 $content = trim($content);185 186 /**187 * Filter the original content of the email.188 *189 * Give Post-By-Email extending plugins full access to the content, either190 * the raw content, or the content of the last quoted-printable section.191 *192 * @since 2.8.0193 *194 * @param string $content The original email content.195 */196 $content = apply_filters( 'wp_mail_original_content', $content );197 198 if ( false !== stripos($content_transfer_encoding, "quoted-printable") ) {199 $content = quoted_printable_decode($content);200 }201 202 if ( function_exists('iconv') && ! empty( $charset ) ) {203 $content = iconv($charset, get_option('blog_charset'), $content);204 }205 206 // Captures any text in the body after $phone_delim as the body207 $content = explode($phone_delim, $content);208 $content = empty( $content[1] ) ? $content[0] : $content[1];209 210 $content = trim($content);211 212 /**213 * Filter the content of the post submitted by email before saving.214 *215 * @since 1.2.0216 *217 * @param string $content The email content.218 */219 $post_content = apply_filters( 'phone_content', $content );220 221 $post_title = xmlrpc_getposttitle($content);222 223 if ($post_title == '') $post_title = $subject;224 225 $post_category = array(get_option('default_email_category'));226 227 $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');228 $post_data = wp_slash($post_data);229 230 $post_ID = wp_insert_post($post_data);231 if ( is_wp_error( $post_ID ) )232 echo "\n" . $post_ID->get_error_message();233 234 // We couldn't post, for whatever reason. Better move forward to the next email.235 if ( empty( $post_ID ) )236 continue;237 238 /**239 * Fires after a post submitted by email is published.240 *241 * @since 1.2.0242 *243 * @param int $post_ID The post ID.244 */245 do_action( 'publish_phone', $post_ID );246 247 echo "\n<p>" . sprintf(__('<strong>Author:</strong> %s'), esc_html($post_author)) . '</p>';248 echo "\n<p>" . sprintf(__('<strong>Posted title:</strong> %s'), esc_html($post_title)) . '</p>';249 250 if(!$pop3->delete($i)) {251 echo '<p>' . sprintf(__('Oops: %s'), esc_html($pop3->ERROR)) . '</p>';252 $pop3->reset();253 exit;254 } else {255 echo '<p>' . sprintf(__('Mission complete. Message <strong>%s</strong> deleted.'), $i) . '</p>';256 }257 258 }259 260 $pop3->quit();