From 0ac256d5fb63f8f1187d37a067168132390a10ab Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Mon, 2 Sep 2024 00:11:39 +0000 Subject: [PATCH] Options, Meta APIs: Prevent mail options triggering a deprecation warning. Prevents a deprecation warning saving options when the post by email feature is turned off in code using the `enable_post_by_email_configuration` filter. Props ironprogrammer, manbo, narenin, sebastienserre, siliconforks. Fixes #61144. git-svn-id: https://develop.svn.wordpress.org/trunk@58963 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/options.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/wp-admin/options.php b/src/wp-admin/options.php index 6916e2e25c990..8348b24c8e941 100644 --- a/src/wp-admin/options.php +++ b/src/wp-admin/options.php @@ -158,7 +158,19 @@ $allowed_options['options'] = array(); $allowed_options['privacy'] = array(); -$mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass' ); +/** + * Filters whether the post-by-email functionality is enabled. + * + * @since 3.0.0 + * + * @param bool $enabled Whether post-by-email configuration is enabled. Default true. + */ +if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { + $allowed_options['writing'][] = 'mailserver_url'; + $allowed_options['writing'][] = 'mailserver_port'; + $allowed_options['writing'][] = 'mailserver_login'; + $allowed_options['writing'][] = 'mailserver_pass'; +} if ( ! is_utf8_charset() ) { $allowed_options['reading'][] = 'blog_charset'; @@ -180,7 +192,6 @@ $allowed_options['general'][] = 'users_can_register'; $allowed_options['general'][] = 'default_role'; - $allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options ); if ( '1' === get_option( 'blog_public' ) ) { $allowed_options['writing'][] = 'ping_sites'; } @@ -198,17 +209,6 @@ $allowed_options['media'][] = 'upload_path'; $allowed_options['media'][] = 'upload_url_path'; } -} else { - /** - * Filters whether the post-by-email functionality is enabled. - * - * @since 3.0.0 - * - * @param bool $enabled Whether post-by-email configuration is enabled. Default true. - */ - if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { - $allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options ); - } } /**