diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php
index d9e9d468a0..79886491c3 100644
--- a/src/wp-admin/includes/schema.php
+++ b/src/wp-admin/includes/schema.php
@@ -532,7 +532,7 @@ function populate_options( array $options = array() ) {
'admin_email_lifespan' => ( time() + 6 * MONTH_IN_SECONDS ),
// 5.5.0
- 'blocklist_keys' => '',
+ 'disallowed_keys' => '',
'comment_previously_approved' => 1,
'auto_plugin_theme_update_emails' => array(),
);
@@ -556,7 +556,7 @@ function populate_options( array $options = array() ) {
$fat_options = array(
'moderation_keys',
'recently_edited',
- 'blocklist_keys',
+ 'disallowed_keys',
'uninstall_plugins',
'auto_plugin_theme_update_emails',
);
diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php
index 6b47228755..d9ec48632f 100644
--- a/src/wp-admin/includes/upgrade.php
+++ b/src/wp-admin/includes/upgrade.php
@@ -2177,15 +2177,23 @@ function upgrade_550() {
update_option( 'finished_updating_comment_type', 0 );
wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
- // Use more clear and inclusive language.
- $blocklist = get_option( 'blacklist_keys', '' );
- update_option( 'blocklist_keys', $blocklist );
- delete_option( 'blacklist_keys' );
-
$comment_previously_approved = get_option( 'comment_whitelist', '' );
update_option( 'comment_previously_approved', $comment_previously_approved );
delete_option( 'comment_whitelist' );
}
+
+ if ( $wp_current_db_version < 48572 ) {
+ // Use more clear and inclusive language.
+ $disallowed_list = get_option( 'blacklist_keys' );
+
+ if ( false === $disallowed_list ) {
+ $disallowed_list = get_option( 'blocklist_keys' );
+ }
+
+ update_option( 'disallowed_keys', $disallowed_list );
+ delete_option( 'blacklist_keys' );
+ delete_option( 'blocklist_keys' );
+ }
}
/**
diff --git a/src/wp-admin/options-discussion.php b/src/wp-admin/options-discussion.php
index 7727e70106..dbe37e720b 100644
--- a/src/wp-admin/options-discussion.php
+++ b/src/wp-admin/options-discussion.php
@@ -204,11 +204,11 @@ printf(
- |
- |
diff --git a/src/wp-admin/options.php b/src/wp-admin/options.php
index 0b4a5e874a..7bf45b5e81 100644
--- a/src/wp-admin/options.php
+++ b/src/wp-admin/options.php
@@ -103,7 +103,7 @@ $allowed_options = array(
'comment_previously_approved',
'comment_max_links',
'moderation_keys',
- 'blocklist_keys',
+ 'disallowed_keys',
'show_avatars',
'avatar_rating',
'avatar_default',
diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php
index 16327b7ce0..1f33868cfc 100644
--- a/src/wp-includes/comment.php
+++ b/src/wp-includes/comment.php
@@ -820,7 +820,7 @@ function wp_allow_comment( $commentdata, $wp_error = false ) {
$approved = 0;
}
- if ( wp_blocklist_check(
+ if ( wp_check_comment_disallowed_list(
$commentdata['comment_author'],
$commentdata['comment_author_email'],
$commentdata['comment_author_url'],
@@ -1320,12 +1320,12 @@ function wp_check_comment_data_max_lengths( $comment_data ) {
* @param string $user_agent The author's browser user agent
* @return bool True if comment contains disallowed content, false if comment does not
*/
-function wp_blocklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) {
+function wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent ) {
/**
* Fires before the comment is tested for disallowed characters or words.
*
* @since 1.5.0
- * @deprecated 5.5.0 Use {@see 'wp_blocklist_check'} instead.
+ * @deprecated 5.5.0 Use {@see 'wp_check_comment_disallowed_list'} instead.
*
* @param string $author Comment author.
* @param string $email Comment author's email.
@@ -1338,7 +1338,7 @@ function wp_blocklist_check( $author, $email, $url, $comment, $user_ip, $user_ag
'wp_blacklist_check',
array( $author, $email, $url, $comment, $user_ip, $user_agent ),
'5.5.0',
- 'wp_blocklist_check',
+ 'wp_check_comment_disallowed_list',
__( 'Please consider writing more inclusive code.' )
);
@@ -1354,9 +1354,9 @@ function wp_blocklist_check( $author, $email, $url, $comment, $user_ip, $user_ag
* @param string $user_ip Comment author's IP address.
* @param string $user_agent Comment author's browser user agent.
*/
- do_action( 'wp_blocklist_check', $author, $email, $url, $comment, $user_ip, $user_agent );
+ do_action( 'wp_check_comment_disallowed_list', $author, $email, $url, $comment, $user_ip, $user_agent );
- $mod_keys = trim( get_option( 'blocklist_keys' ) );
+ $mod_keys = trim( get_option( 'disallowed_keys' ) );
if ( '' === $mod_keys ) {
return false; // If moderation keys are empty.
}
diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php
index 5cae9d514a..f5b5e6348e 100644
--- a/src/wp-includes/deprecated.php
+++ b/src/wp-includes/deprecated.php
@@ -4025,7 +4025,7 @@ function wp_unregister_GLOBALS() { // phpcs:ignore WordPress.NamingConventions.
* Does comment contain disallowed characters or words.
*
* @since 1.5.0
- * @deprecated 5.5.0 Use wp_blocklist_check() instead.
+ * @deprecated 5.5.0 Use wp_check_comment_disallowed_list() instead.
* Please consider writing more inclusive code.
*
* @param string $author The author of the comment
@@ -4037,9 +4037,9 @@ function wp_unregister_GLOBALS() { // phpcs:ignore WordPress.NamingConventions.
* @return bool True if comment contains disallowed content, false if comment does not
*/
function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) {
- _deprecated_function( __FUNCTION__, '5.5.0', 'wp_blocklist_check()' );
+ _deprecated_function( __FUNCTION__, '5.5.0', 'wp_check_comment_disallowed_list()' );
- return wp_blocklist_check( $author, $email, $url, $comment, $user_ip, $user_agent );
+ return wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent );
}
/**
diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index e1dbf85a36..bee762a1cc 100644
--- a/src/wp-includes/formatting.php
+++ b/src/wp-includes/formatting.php
@@ -4859,7 +4859,7 @@ function sanitize_option( $option, $value ) {
break;
case 'moderation_keys':
- case 'blocklist_keys':
+ case 'disallowed_keys':
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php
index 256795acd9..79025dc8a2 100644
--- a/src/wp-includes/option.php
+++ b/src/wp-includes/option.php
@@ -35,6 +35,29 @@ function get_option( $option, $default = false ) {
return false;
}
+ /*
+ * Until a proper _deprecated_option() function can be introduced,
+ * redirect requests to deprecated keys to the new, correct ones.
+ */
+ $deprecated_keys = array(
+ 'blacklist_keys' => 'disallowed_keys',
+ 'comment_whitelist' => 'comment_previously_approved',
+ );
+
+ if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
+ _deprecated_argument(
+ __FUNCTION__,
+ '5.5.0',
+ sprintf(
+ /* translators: 1: Deprecated option key, 2: New option key. */
+ __( 'The "%1$s" option key has been renamed to "%2$s".' ),
+ $option,
+ $deprecated_keys[ $option ]
+ )
+ );
+ return get_option( $deprecated_keys[ $option ], $default );
+ }
+
/**
* Filters the value of an existing option before it is retrieved.
*
@@ -313,6 +336,29 @@ function update_option( $option, $value, $autoload = null ) {
return false;
}
+ /*
+ * Until a proper _deprecated_option() function can be introduced,
+ * redirect requests to deprecated keys to the new, correct ones.
+ */
+ $deprecated_keys = array(
+ 'blacklist_keys' => 'disallowed_keys',
+ 'comment_whitelist' => 'comment_previously_approved',
+ );
+
+ if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
+ _deprecated_argument(
+ __FUNCTION__,
+ '5.5.0',
+ sprintf(
+ /* translators: 1: Deprecated option key, 2: New option key. */
+ __( 'The "%1$s" option key has been renamed to "%2$s".' ),
+ $option,
+ $deprecated_keys[ $option ]
+ )
+ );
+ return update_option( $deprecated_keys[ $option ], $value, $autoload );
+ }
+
wp_protect_special_option( $option );
if ( is_object( $value ) ) {
@@ -477,6 +523,29 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
return false;
}
+ /*
+ * Until a proper _deprecated_option() function can be introduced,
+ * redirect requests to deprecated keys to the new, correct ones.
+ */
+ $deprecated_keys = array(
+ 'blacklist_keys' => 'disallowed_keys',
+ 'comment_whitelist' => 'comment_previously_approved',
+ );
+
+ if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
+ _deprecated_argument(
+ __FUNCTION__,
+ '5.5.0',
+ sprintf(
+ /* translators: 1: Deprecated option key, 2: New option key. */
+ __( 'The "%1$s" option key has been renamed to "%2$s".' ),
+ $option,
+ $deprecated_keys[ $option ]
+ )
+ );
+ return add_option( $deprecated_keys[ $option ], $value, $deprecated, $autoload );
+ }
+
wp_protect_special_option( $option );
if ( is_object( $value ) ) {
diff --git a/tests/phpunit/tests/comment/wpBlacklistCheck.php b/tests/phpunit/tests/comment/wpBlacklistCheck.php
index e0dd951b85..86a449825d 100644
--- a/tests/phpunit/tests/comment/wpBlacklistCheck.php
+++ b/tests/phpunit/tests/comment/wpBlacklistCheck.php
@@ -5,7 +5,7 @@
*/
class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
- public function test_should_return_true_when_content_matches_blocklist_keys() {
+ public function test_should_return_true_when_content_matches_disallowed_keys() {
$author = 'Sting';
$author_email = 'sting@example.com';
$author_url = 'http://example.com';
@@ -13,9 +13,9 @@ class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
$author_ip = '192.168.0.1';
$user_agent = '';
- update_option( 'blocklist_keys', "well\nfoo" );
+ update_option( 'disallowed_keys', "well\nfoo" );
- $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
+ $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
$this->assertTrue( $result );
}
@@ -23,7 +23,7 @@ class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
/**
* @ticket 37208
*/
- public function test_should_return_true_when_content_with_html_matches_blocklist_keys() {
+ public function test_should_return_true_when_content_with_html_matches_disallowed_keys() {
$author = 'Sting';
$author_email = 'sting@example.com';
$author_url = 'http://example.com';
@@ -31,14 +31,14 @@ class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
$author_ip = '192.168.0.1';
$user_agent = '';
- update_option( 'blocklist_keys', "halfway\nfoo" );
+ update_option( 'disallowed_keys', "halfway\nfoo" );
- $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
+ $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
$this->assertTrue( $result );
}
- public function test_should_return_true_when_author_matches_blocklist_keys() {
+ public function test_should_return_true_when_author_matches_disallowed_keys() {
$author = 'Sideshow Mel';
$author_email = 'mel@example.com';
$author_url = 'http://example.com';
@@ -46,14 +46,14 @@ class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
$author_ip = '192.168.0.1';
$user_agent = '';
- update_option( 'blocklist_keys', "sideshow\nfoo" );
+ update_option( 'disallowed_keys', "sideshow\nfoo" );
- $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
+ $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
$this->assertTrue( $result );
}
- public function test_should_return_true_when_url_matches_blocklist_keys() {
+ public function test_should_return_true_when_url_matches_disallowed_keys() {
$author = 'Rainier Wolfcastle';
$author_email = 'rainier@wolfcastle.com';
$author_url = 'http://example.com';
@@ -61,9 +61,9 @@ class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
$author_ip = '192.168.0.1';
$user_agent = '';
- update_option( 'blocklist_keys', "example\nfoo" );
+ update_option( 'disallowed_keys', "example\nfoo" );
- $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
+ $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
$this->assertTrue( $result );
}
@@ -71,7 +71,7 @@ class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
/**
* @ticket 37208
*/
- public function test_should_return_true_when_link_matches_blocklist_keys() {
+ public function test_should_return_true_when_link_matches_disallowed_keys() {
$author = 'Rainier Wolfcastle';
$author_email = 'rainier@wolfcastle.com';
$author_url = 'http://example.com';
@@ -79,9 +79,9 @@ class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
$author_ip = '192.168.0.1';
$user_agent = '';
- update_option( 'blocklist_keys', '/spam/' );
+ update_option( 'disallowed_keys', '/spam/' );
- $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
+ $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
$this->assertTrue( $result );
}
@@ -94,9 +94,9 @@ class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
$author_ip = '192.168.0.1';
$user_agent = '';
- update_option( 'blocklist_keys', "sideshow\nfoobar" );
+ update_option( 'disallowed_keys', "sideshow\nfoobar" );
- $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
+ $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
$this->assertFalse( $result );
}