Changeset 48575
- Timestamp:
- 07/23/2020 03:12:49 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/schema.php
r48397 r48575 533 533 534 534 // 5.5.0 535 ' blocklist_keys'=> '',535 'disallowed_keys' => '', 536 536 'comment_previously_approved' => 1, 537 537 'auto_plugin_theme_update_emails' => array(), … … 557 557 'moderation_keys', 558 558 'recently_edited', 559 ' blocklist_keys',559 'disallowed_keys', 560 560 'uninstall_plugins', 561 561 'auto_plugin_theme_update_emails', -
trunk/src/wp-admin/includes/upgrade.php
r48405 r48575 2178 2178 wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' ); 2179 2179 2180 // Use more clear and inclusive language.2181 $blocklist = get_option( 'blacklist_keys', '' );2182 update_option( 'blocklist_keys', $blocklist );2183 delete_option( 'blacklist_keys' );2184 2185 2180 $comment_previously_approved = get_option( 'comment_whitelist', '' ); 2186 2181 update_option( 'comment_previously_approved', $comment_previously_approved ); 2187 2182 delete_option( 'comment_whitelist' ); 2183 } 2184 2185 if ( $wp_current_db_version < 48572 ) { 2186 // Use more clear and inclusive language. 2187 $disallowed_list = get_option( 'blacklist_keys' ); 2188 2189 if ( false === $disallowed_list ) { 2190 $disallowed_list = get_option( 'blocklist_keys' ); 2191 } 2192 2193 update_option( 'disallowed_keys', $disallowed_list ); 2194 delete_option( 'blacklist_keys' ); 2195 delete_option( 'blocklist_keys' ); 2188 2196 } 2189 2197 } -
trunk/src/wp-admin/options-discussion.php
r48121 r48575 205 205 </tr> 206 206 <tr> 207 <th scope="row"><?php _e( ' Comment Blocklist' ); ?></th>208 <td><fieldset><legend class="screen-reader-text"><span><?php _e( ' Comment Blocklist' ); ?></span></legend>209 <p><label for=" blocklist_keys"><?php _e( 'When a comment contains any of these words in its content, author name, URL, email, IP address, or browser’s user agent string, it will be put in the Trash. One word or IP address per line. It will match inside words, so “press” will match “WordPress”.' ); ?></label></p>207 <th scope="row"><?php _e( 'Disallowed Comment Keys' ); ?></th> 208 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Disallowed Comment Keys' ); ?></span></legend> 209 <p><label for="disallowed_keys"><?php _e( 'When a comment contains any of these words in its content, author name, URL, email, IP address, or browser’s user agent string, it will be put in the Trash. One word or IP address per line. It will match inside words, so “press” will match “WordPress”.' ); ?></label></p> 210 210 <p> 211 <textarea name=" blocklist_keys" rows="10" cols="50" id="blocklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blocklist_keys' ) ); ?></textarea>211 <textarea name="disallowed_keys" rows="10" cols="50" id="disallowed_keys" class="large-text code"><?php echo esc_textarea( get_option( 'disallowed_keys' ) ); ?></textarea> 212 212 </p> 213 213 </fieldset></td> -
trunk/src/wp-admin/options.php
r48570 r48575 104 104 'comment_max_links', 105 105 'moderation_keys', 106 ' blocklist_keys',106 'disallowed_keys', 107 107 'show_avatars', 108 108 'avatar_rating', -
trunk/src/wp-includes/comment.php
r48574 r48575 821 821 } 822 822 823 if ( wp_ blocklist_check(823 if ( wp_check_comment_disallowed_list( 824 824 $commentdata['comment_author'], 825 825 $commentdata['comment_author_email'], … … 1321 1321 * @return bool True if comment contains disallowed content, false if comment does not 1322 1322 */ 1323 function wp_ blocklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) {1323 function wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent ) { 1324 1324 /** 1325 1325 * Fires before the comment is tested for disallowed characters or words. 1326 1326 * 1327 1327 * @since 1.5.0 1328 * @deprecated 5.5.0 Use {@see 'wp_ blocklist_check'} instead.1328 * @deprecated 5.5.0 Use {@see 'wp_check_comment_disallowed_list'} instead. 1329 1329 * 1330 1330 * @param string $author Comment author. … … 1339 1339 array( $author, $email, $url, $comment, $user_ip, $user_agent ), 1340 1340 '5.5.0', 1341 'wp_ blocklist_check',1341 'wp_check_comment_disallowed_list', 1342 1342 __( 'Please consider writing more inclusive code.' ) 1343 1343 ); … … 1355 1355 * @param string $user_agent Comment author's browser user agent. 1356 1356 */ 1357 do_action( 'wp_ blocklist_check', $author, $email, $url, $comment, $user_ip, $user_agent );1358 1359 $mod_keys = trim( get_option( ' blocklist_keys' ) );1357 do_action( 'wp_check_comment_disallowed_list', $author, $email, $url, $comment, $user_ip, $user_agent ); 1358 1359 $mod_keys = trim( get_option( 'disallowed_keys' ) ); 1360 1360 if ( '' === $mod_keys ) { 1361 1361 return false; // If moderation keys are empty. -
trunk/src/wp-includes/deprecated.php
r48566 r48575 4026 4026 * 4027 4027 * @since 1.5.0 4028 * @deprecated 5.5.0 Use wp_ blocklist_check() instead.4028 * @deprecated 5.5.0 Use wp_check_comment_disallowed_list() instead. 4029 4029 * Please consider writing more inclusive code. 4030 4030 * … … 4038 4038 */ 4039 4039 function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) { 4040 _deprecated_function( __FUNCTION__, '5.5.0', 'wp_ blocklist_check()' );4041 4042 return wp_ blocklist_check( $author, $email, $url, $comment, $user_ip, $user_agent );4040 _deprecated_function( __FUNCTION__, '5.5.0', 'wp_check_comment_disallowed_list()' ); 4041 4042 return wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent ); 4043 4043 } 4044 4044 -
trunk/src/wp-includes/formatting.php
r48444 r48575 4860 4860 4861 4861 case 'moderation_keys': 4862 case ' blocklist_keys':4862 case 'disallowed_keys': 4863 4863 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 4864 4864 if ( is_wp_error( $value ) ) { -
trunk/src/wp-includes/option.php
r48477 r48575 34 34 if ( empty( $option ) ) { 35 35 return false; 36 } 37 38 /* 39 * Until a proper _deprecated_option() function can be introduced, 40 * redirect requests to deprecated keys to the new, correct ones. 41 */ 42 $deprecated_keys = array( 43 'blacklist_keys' => 'disallowed_keys', 44 'comment_whitelist' => 'comment_previously_approved', 45 ); 46 47 if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) { 48 _deprecated_argument( 49 __FUNCTION__, 50 '5.5.0', 51 sprintf( 52 /* translators: 1: Deprecated option key, 2: New option key. */ 53 __( 'The "%1$s" option key has been renamed to "%2$s".' ), 54 $option, 55 $deprecated_keys[ $option ] 56 ) 57 ); 58 return get_option( $deprecated_keys[ $option ], $default ); 36 59 } 37 60 … … 314 337 } 315 338 339 /* 340 * Until a proper _deprecated_option() function can be introduced, 341 * redirect requests to deprecated keys to the new, correct ones. 342 */ 343 $deprecated_keys = array( 344 'blacklist_keys' => 'disallowed_keys', 345 'comment_whitelist' => 'comment_previously_approved', 346 ); 347 348 if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) { 349 _deprecated_argument( 350 __FUNCTION__, 351 '5.5.0', 352 sprintf( 353 /* translators: 1: Deprecated option key, 2: New option key. */ 354 __( 'The "%1$s" option key has been renamed to "%2$s".' ), 355 $option, 356 $deprecated_keys[ $option ] 357 ) 358 ); 359 return update_option( $deprecated_keys[ $option ], $value, $autoload ); 360 } 361 316 362 wp_protect_special_option( $option ); 317 363 … … 476 522 if ( empty( $option ) ) { 477 523 return false; 524 } 525 526 /* 527 * Until a proper _deprecated_option() function can be introduced, 528 * redirect requests to deprecated keys to the new, correct ones. 529 */ 530 $deprecated_keys = array( 531 'blacklist_keys' => 'disallowed_keys', 532 'comment_whitelist' => 'comment_previously_approved', 533 ); 534 535 if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) { 536 _deprecated_argument( 537 __FUNCTION__, 538 '5.5.0', 539 sprintf( 540 /* translators: 1: Deprecated option key, 2: New option key. */ 541 __( 'The "%1$s" option key has been renamed to "%2$s".' ), 542 $option, 543 $deprecated_keys[ $option ] 544 ) 545 ); 546 return add_option( $deprecated_keys[ $option ], $value, $deprecated, $autoload ); 478 547 } 479 548 -
trunk/tests/phpunit/tests/comment/wpBlacklistCheck.php
r48121 r48575 6 6 class Tests_WP_Blocklist_Check extends WP_UnitTestCase { 7 7 8 public function test_should_return_true_when_content_matches_ blocklist_keys() {8 public function test_should_return_true_when_content_matches_disallowed_keys() { 9 9 $author = 'Sting'; 10 10 $author_email = 'sting@example.com'; … … 14 14 $user_agent = ''; 15 15 16 update_option( ' blocklist_keys', "well\nfoo" );16 update_option( 'disallowed_keys', "well\nfoo" ); 17 17 18 $result = wp_ blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );18 $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent ); 19 19 20 20 $this->assertTrue( $result ); … … 24 24 * @ticket 37208 25 25 */ 26 public function test_should_return_true_when_content_with_html_matches_ blocklist_keys() {26 public function test_should_return_true_when_content_with_html_matches_disallowed_keys() { 27 27 $author = 'Sting'; 28 28 $author_email = 'sting@example.com'; … … 32 32 $user_agent = ''; 33 33 34 update_option( ' blocklist_keys', "halfway\nfoo" );34 update_option( 'disallowed_keys', "halfway\nfoo" ); 35 35 36 $result = wp_ blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );36 $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent ); 37 37 38 38 $this->assertTrue( $result ); 39 39 } 40 40 41 public function test_should_return_true_when_author_matches_ blocklist_keys() {41 public function test_should_return_true_when_author_matches_disallowed_keys() { 42 42 $author = 'Sideshow Mel'; 43 43 $author_email = 'mel@example.com'; … … 47 47 $user_agent = ''; 48 48 49 update_option( ' blocklist_keys', "sideshow\nfoo" );49 update_option( 'disallowed_keys', "sideshow\nfoo" ); 50 50 51 $result = wp_ blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );51 $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent ); 52 52 53 53 $this->assertTrue( $result ); 54 54 } 55 55 56 public function test_should_return_true_when_url_matches_ blocklist_keys() {56 public function test_should_return_true_when_url_matches_disallowed_keys() { 57 57 $author = 'Rainier Wolfcastle'; 58 58 $author_email = 'rainier@wolfcastle.com'; … … 62 62 $user_agent = ''; 63 63 64 update_option( ' blocklist_keys', "example\nfoo" );64 update_option( 'disallowed_keys', "example\nfoo" ); 65 65 66 $result = wp_ blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );66 $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent ); 67 67 68 68 $this->assertTrue( $result ); … … 72 72 * @ticket 37208 73 73 */ 74 public function test_should_return_true_when_link_matches_ blocklist_keys() {74 public function test_should_return_true_when_link_matches_disallowed_keys() { 75 75 $author = 'Rainier Wolfcastle'; 76 76 $author_email = 'rainier@wolfcastle.com'; … … 80 80 $user_agent = ''; 81 81 82 update_option( ' blocklist_keys', '/spam/' );82 update_option( 'disallowed_keys', '/spam/' ); 83 83 84 $result = wp_ blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );84 $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent ); 85 85 86 86 $this->assertTrue( $result ); … … 95 95 $user_agent = ''; 96 96 97 update_option( ' blocklist_keys', "sideshow\nfoobar" );97 update_option( 'disallowed_keys', "sideshow\nfoobar" ); 98 98 99 $result = wp_ blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );99 $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent ); 100 100 101 101 $this->assertFalse( $result );
Note: See TracChangeset
for help on using the changeset viewer.