Ticket #22942: 22942_updated_for_3.7.2.diff
File 22942_updated_for_3.7.2.diff, 15.7 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/schema.php
diff --git wp-admin/includes/schema.php wp-admin/includes/schema.php index 037210a..a5e896b 100644
function populate_options() { 373 373 'comments_notify' => 1, 374 374 'posts_per_rss' => 10, 375 375 'rss_use_excerpt' => 0, 376 'mailserver_url' => 'mail.example.com',377 'mailserver_login' => 'login@example.com',378 'mailserver_pass' => 'password',379 'mailserver_port' => 110,380 376 'default_category' => 1, 381 377 'default_comment_status' => 'open', 382 378 'default_ping_status' => 'open', … … function populate_options() { 480 476 481 477 // 3.5 482 478 'link_manager_enabled' => 0, 479 480 // 3.7 481 'post_by_email_enabled' => 0, 483 482 ); 484 483 485 484 // 3.3 -
wp-admin/includes/upgrade.php
diff --git wp-admin/includes/upgrade.php wp-admin/includes/upgrade.php index cfbaac8..354cb6f 100644
function upgrade_all() { 402 402 if ( $wp_current_db_version < 22422 ) 403 403 upgrade_350(); 404 404 405 if ( $wp_current_db_version < 25448 ) 406 upgrade_370(); 407 405 408 maybe_disable_link_manager(); 406 409 407 410 maybe_disable_automattic_widgets(); 408 411 412 maybe_disable_post_by_email(); 413 409 414 update_option( 'db_version', $wp_db_version ); 410 415 update_option( 'db_upgraded', true ); 411 416 } … … function upgrade_350() { 1209 1214 } 1210 1215 1211 1216 /** 1217 * Execute changes made in WordPress 3.7. 1218 * 1219 * @since 3.7.0 1220 */ 1221 function upgrade_370() { 1222 global $wp_current_db_version; 1223 1224 if ( $wp_current_db_version < 25134 && 'mail.example.com' != get_option( 'mailserver_url' ) ) 1225 update_option( 'post_by_email_enabled', 1 ); // Previously set to 0 by populate_options() 1226 } 1227 1228 /** 1212 1229 * Execute network level changes 1213 1230 * 1214 1231 * @since 3.0.0 … … function maybe_disable_link_manager() { 1959 1976 } 1960 1977 1961 1978 /** 1979 * Disables Post by Email options if, at the time of upgrade, the settings have not been changed from original defaults. 1980 * 1981 * @since 3.7.0 1982 */ 1983 function maybe_disable_post_by_email() { 1984 global $wp_current_db_version; 1985 1986 if ( $wp_current_db_version >= 25448 && get_option( 'post_by_email_enabled' ) && 'mail.example.com' == get_option( 'mailserver_url' ) ) 1987 update_option( 'post_by_email_enabled', 0 ); 1988 } 1989 1990 /** 1962 1991 * Runs before the schema is upgraded. 1963 1992 * 1964 1993 * @since 2.9.0 -
wp-admin/options-writing.php
diff --git wp-admin/options-writing.php wp-admin/options-writing.php index 87fbf53..4202ef6 100644
get_current_screen()->add_help_tab( array( 28 28 'content' => '<p>' . __('Press This is a bookmarklet that makes it easy to blog about something you come across on the web. You can use it to just grab a link, or to post an excerpt. Press This will even allow you to choose from images included on the page and use them in your post. Just drag the Press This link on this screen to your bookmarks bar in your browser, and you’ll be on your way to easier content creation. Clicking on it while on another website opens a popup window with all these options.') . '</p>', 29 29 ) ); 30 30 31 //duplicate_hook32 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) {33 get_current_screen()->add_help_tab( array(34 'id' => 'options-postemail',35 'title' => __( 'Post Via Email' ),36 '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>',37 ) );38 }39 40 31 /** 41 32 * Toggle site update services configuration functionality. 42 33 * … … do_settings_fields('writing', 'remote_publishing'); // A deprecated section. 132 123 133 124 <?php 134 125 //duplicate_hook 135 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { 136 ?> 137 <h3 class="title"><?php _e('Post via e-mail') ?></h3> 138 <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> 139 140 <table class="form-table"> 141 <tr valign="top"> 142 <th scope="row"><label for="mailserver_url"><?php _e('Mail Server') ?></label></th> 143 <td><input name="mailserver_url" type="text" id="mailserver_url" value="<?php form_option('mailserver_url'); ?>" class="regular-text code" /> 144 <label for="mailserver_port"><?php _e('Port') ?></label> 145 <input name="mailserver_port" type="text" id="mailserver_port" value="<?php form_option('mailserver_port'); ?>" class="small-text" /> 146 </td> 147 </tr> 148 <tr valign="top"> 149 <th scope="row"><label for="mailserver_login"><?php _e('Login Name') ?></label></th> 150 <td><input name="mailserver_login" type="text" id="mailserver_login" value="<?php form_option('mailserver_login'); ?>" class="regular-text ltr" /></td> 151 </tr> 152 <tr valign="top"> 153 <th scope="row"><label for="mailserver_pass"><?php _e('Password') ?></label></th> 154 <td> 155 <input name="mailserver_pass" type="text" id="mailserver_pass" value="<?php form_option('mailserver_pass'); ?>" class="regular-text ltr" /> 156 </td> 157 </tr> 158 <tr valign="top"> 159 <th scope="row"><label for="default_email_category"><?php _e('Default Mail Category') ?></label></th> 160 <td> 161 <?php 162 wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_category', 'orderby' => 'name', 'selected' => get_option('default_email_category'), 'hierarchical' => true)); 163 ?> 164 </td> 165 </tr> 166 <?php do_settings_fields('writing', 'post_via_email'); ?> 167 </table> 126 if ( get_option( 'post_by_email_enabled' ) && apply_filters( 'enable_post_by_email_configuration', true ) ) { ?> 127 <h3 class="title"><?php _e( 'Post via e-mail' ) ?></h3> 128 <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> 168 129 <?php } ?> 169 130 170 131 <?php -
wp-includes/default-filters.php
diff --git wp-includes/default-filters.php wp-includes/default-filters.php index b6c7527..f70458c 100644
add_filter( 'heartbeat_nopriv_received', 'wp_auth_check', 10, 2 ); 301 301 add_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 ); 302 302 add_filter( 'authenticate', 'wp_authenticate_spam_check', 99 ); 303 303 304 // If the upgrade hasn't run yet, assume the post by mail options are set. 305 add_filter( 'default_option_post_by_email_enabled', '__return_true' ); 306 304 307 unset($filter, $action); -
wp-includes/formatting.php
diff --git wp-includes/formatting.php wp-includes/formatting.php index 58b4f9d..4655267 100644
function sanitize_option($option, $value) { 2819 2819 case 'medium_size_h': 2820 2820 case 'large_size_w': 2821 2821 case 'large_size_h': 2822 case 'mailserver_port':2823 2822 case 'comment_max_links': 2824 2823 case 'page_on_front': 2825 2824 case 'page_for_posts': … … function sanitize_option($option, $value) { 2871 2870 2872 2871 case 'date_format': 2873 2872 case 'time_format': 2874 case 'mailserver_url':2875 case 'mailserver_login':2876 case 'mailserver_pass':2877 2873 case 'upload_path': 2878 2874 $value = strip_tags( $value ); 2879 2875 $value = wp_kses_data( $value ); -
wp-mail.php
diff --git wp-mail.php wp-mail.php index 27290b1..4020a6a 100644
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. 7 * 8 * For more information: 9 * http://wordpress.org/plugins/post-by-email/ 10 * http://codex.wordpress.org/Category:WP-Cron_Functions 6 11 * 7 12 * @package WordPress 8 13 */ … … 10 15 /** Make sure that the WordPress bootstrap has run before continuing. */ 11 16 require(dirname(__FILE__) . '/wp-load.php'); 12 17 13 if ( ! apply_filters( 'enable_post_by_email_configuration', true ) ) 14 wp_die( __( 'This action has been disabled by the administrator.' ) ); 18 _doing_it_wrong( 'wp-mail.php', __( "This file is deprecated and should not be called directly. Schedule the action 'wp-mail.php' instead." ), '3.7' ); 15 19 16 20 /** Allow a plugin to do a complete takeover of Post by Email **/ 17 do_action('wp-mail.php'); 18 19 /** Get the POP3 class with which to access the mailbox. */ 20 require_once( ABSPATH . WPINC . '/class-pop3.php' ); 21 22 /** Only check at this interval for new messages. */ 23 if ( !defined('WP_MAIL_INTERVAL') ) 24 define('WP_MAIL_INTERVAL', 300); // 5 minutes 25 26 $last_checked = get_transient('mailserver_last_checked'); 27 28 if ( $last_checked ) 29 wp_die(__('Slow down cowboy, no need to check for new mails so often!')); 30 31 set_transient('mailserver_last_checked', true, WP_MAIL_INTERVAL); 32 33 $time_difference = get_option('gmt_offset') * HOUR_IN_SECONDS; 34 35 $phone_delim = '::'; 36 37 $pop3 = new POP3(); 38 39 if ( !$pop3->connect( get_option('mailserver_url'), get_option('mailserver_port') ) || !$pop3->user( get_option('mailserver_login') ) ) 40 wp_die( esc_html( $pop3->ERROR ) ); 41 42 $count = $pop3->pass( get_option('mailserver_pass') ); 43 44 if( false === $count ) 45 wp_die( esc_html( $pop3->ERROR ) ); 46 47 if( 0 === $count ) { 48 $pop3->quit(); 49 wp_die( __('There doesn’t seem to be any new mail.') ); 50 } 51 52 for ( $i = 1; $i <= $count; $i++ ) { 53 54 $message = $pop3->get($i); 55 56 $bodysignal = false; 57 $boundary = ''; 58 $charset = ''; 59 $content = ''; 60 $content_type = ''; 61 $content_transfer_encoding = ''; 62 $post_author = 1; 63 $author_found = false; 64 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); 65 foreach ($message as $line) { 66 // body signal 67 if ( strlen($line) < 3 ) 68 $bodysignal = true; 69 if ( $bodysignal ) { 70 $content .= $line; 71 } else { 72 if ( preg_match('/Content-Type: /i', $line) ) { 73 $content_type = trim($line); 74 $content_type = substr($content_type, 14, strlen($content_type) - 14); 75 $content_type = explode(';', $content_type); 76 if ( ! empty( $content_type[1] ) ) { 77 $charset = explode('=', $content_type[1]); 78 $charset = ( ! empty( $charset[1] ) ) ? trim($charset[1]) : ''; 79 } 80 $content_type = $content_type[0]; 81 } 82 if ( preg_match('/Content-Transfer-Encoding: /i', $line) ) { 83 $content_transfer_encoding = trim($line); 84 $content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding) - 27); 85 $content_transfer_encoding = explode(';', $content_transfer_encoding); 86 $content_transfer_encoding = $content_transfer_encoding[0]; 87 } 88 if ( ( $content_type == 'multipart/alternative' ) && ( false !== strpos($line, 'boundary="') ) && ( '' == $boundary ) ) { 89 $boundary = trim($line); 90 $boundary = explode('"', $boundary); 91 $boundary = $boundary[1]; 92 } 93 if (preg_match('/Subject: /i', $line)) { 94 $subject = trim($line); 95 $subject = substr($subject, 9, strlen($subject) - 9); 96 // Captures any text in the subject before $phone_delim as the subject 97 if ( function_exists('iconv_mime_decode') ) { 98 $subject = iconv_mime_decode($subject, 2, get_option('blog_charset')); 99 } else { 100 $subject = wp_iso_descrambler($subject); 101 } 102 $subject = explode($phone_delim, $subject); 103 $subject = $subject[0]; 104 } 105 106 // Set the author using the email address (From or Reply-To, the last used) 107 // otherwise use the site admin 108 if ( ! $author_found && preg_match( '/^(From|Reply-To): /', $line ) ) { 109 if ( preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches) ) 110 $author = $matches[0]; 111 else 112 $author = trim($line); 113 $author = sanitize_email($author); 114 if ( is_email($author) ) { 115 echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>'; 116 $userdata = get_user_by('email', $author); 117 if ( ! empty( $userdata ) ) { 118 $post_author = $userdata->ID; 119 $author_found = true; 120 } 121 } 122 } 123 124 if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37' 125 $ddate = trim($line); 126 $ddate = str_replace('Date: ', '', $ddate); 127 if (strpos($ddate, ',')) { 128 $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate))); 129 } 130 $date_arr = explode(' ', $ddate); 131 $date_time = explode(':', $date_arr[3]); 132 133 $ddate_H = $date_time[0]; 134 $ddate_i = $date_time[1]; 135 $ddate_s = $date_time[2]; 136 137 $ddate_m = $date_arr[1]; 138 $ddate_d = $date_arr[0]; 139 $ddate_Y = $date_arr[2]; 140 for ( $j = 0; $j < 12; $j++ ) { 141 if ( $ddate_m == $dmonths[$j] ) { 142 $ddate_m = $j+1; 143 } 144 } 145 146 $time_zn = intval($date_arr[4]) * 36; 147 $ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y); 148 $ddate_U = $ddate_U - $time_zn; 149 $post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference); 150 $post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U); 151 } 152 } 153 } 154 155 // Set $post_status based on $author_found and on author's publish_posts capability 156 if ( $author_found ) { 157 $user = new WP_User($post_author); 158 $post_status = ( $user->has_cap('publish_posts') ) ? 'publish' : 'pending'; 159 } else { 160 // Author not found in DB, set status to pending. Author already set to admin. 161 $post_status = 'pending'; 162 } 163 164 $subject = trim($subject); 165 166 if ( $content_type == 'multipart/alternative' ) { 167 $content = explode('--'.$boundary, $content); 168 $content = $content[2]; 169 // match case-insensitive content-transfer-encoding 170 if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim) ) { 171 $content = explode($delim[0], $content); 172 $content = $content[1]; 173 } 174 $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>'); 175 } 176 $content = trim($content); 177 178 //Give Post-By-Email extending plugins full access to the content 179 //Either the raw content or the content of the last quoted-printable section 180 $content = apply_filters('wp_mail_original_content', $content); 181 182 if ( false !== stripos($content_transfer_encoding, "quoted-printable") ) { 183 $content = quoted_printable_decode($content); 184 } 185 186 if ( function_exists('iconv') && ! empty( $charset ) ) { 187 $content = iconv($charset, get_option('blog_charset'), $content); 188 } 189 190 // Captures any text in the body after $phone_delim as the body 191 $content = explode($phone_delim, $content); 192 $content = empty( $content[1] ) ? $content[0] : $content[1]; 193 194 $content = trim($content); 195 196 $post_content = apply_filters('phone_content', $content); 197 198 $post_title = xmlrpc_getposttitle($content); 199 200 if ($post_title == '') $post_title = $subject; 201 202 $post_category = array(get_option('default_email_category')); 203 204 $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status'); 205 $post_data = wp_slash($post_data); 206 207 $post_ID = wp_insert_post($post_data); 208 if ( is_wp_error( $post_ID ) ) 209 echo "\n" . $post_ID->get_error_message(); 210 211 // We couldn't post, for whatever reason. Better move forward to the next email. 212 if ( empty( $post_ID ) ) 213 continue; 214 215 do_action('publish_phone', $post_ID); 216 217 echo "\n<p>" . sprintf(__('<strong>Author:</strong> %s'), esc_html($post_author)) . '</p>'; 218 echo "\n<p>" . sprintf(__('<strong>Posted title:</strong> %s'), esc_html($post_title)) . '</p>'; 219 220 if(!$pop3->delete($i)) { 221 echo '<p>' . sprintf(__('Oops: %s'), esc_html($pop3->ERROR)) . '</p>'; 222 $pop3->reset(); 223 exit; 224 } else { 225 echo '<p>' . sprintf(__('Mission complete. Message <strong>%s</strong> deleted.'), $i) . '</p>'; 226 } 227 228 } 229 230 $pop3->quit(); 21 do_action( 'wp-mail.php' ); 22 No newline at end of file