diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 68cdd4800a..80e0b395ff 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -688,8 +688,6 @@ function set_screen_options() { } break; default: - $screen_option = false; - if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) { /** * Filters a screen option value before it is set. @@ -710,27 +708,29 @@ function set_screen_options() { * @param string $option The option name. * @param int $value The option value. */ - $screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + $value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + } else { + /** + * Filters a screen option value before it is set. + * + * The dynamic portion of the hook, `$option`, refers to the option name. + * + * Returning false from the filter will skip saving the current option. + * + * @since 5.4.2 + * @since 5.4.3 Only applied to options not ending with '_page', + * and not the 'layout_columns' option. + * + * @see set_screen_options() + * + * @param mixed $screen_option The value to save instead of the option value. + * Default false (to skip saving the current option). + * @param string $option The option name. + * @param int $value The option value. + */ + $value = apply_filters( "set_screen_option_{$option}", false, $option, $value ); } - /** - * Filters a screen option value before it is set. - * - * The dynamic portion of the hook, `$option`, refers to the option name. - * - * Returning false from the filter will skip saving the current option. - * - * @since 5.4.2 - * - * @see set_screen_options() - * - * @param mixed $screen_option The value to save instead of the option value. - * Default false (to skip saving the current option). - * @param string $option The option name. - * @param int $value The option value. - */ - $value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value ); - if ( false === $value ) { return; } diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 47e74bc3f2..150acd6f1a 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -2188,10 +2188,19 @@ function wp_new_comment( $commentdata, $wp_error = false ) { $prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0; + if ( ! isset( $commentdata['comment_author_IP'] ) ) { + $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; + } + + if ( ! isset( $commentdata['comment_agent'] ) ) { + $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; + } + /** * Filters a comment's data before it is sanitized and inserted into the database. * * @since 1.5.0 + * @since 5.6.0 Comment data includes the `comment_agent` and `comment_author_IP` values. * * @param array $commentdata Comment data. */ @@ -2211,14 +2220,8 @@ function wp_new_comment( $commentdata, $wp_error = false ) { $commentdata['comment_parent'] = ( 'approved' === $parent_status || 'unapproved' === $parent_status ) ? $commentdata['comment_parent'] : 0; - if ( ! isset( $commentdata['comment_author_IP'] ) ) { - $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; - } $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] ); - if ( ! isset( $commentdata['comment_agent'] ) ) { - $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; - } $commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 ); if ( empty( $commentdata['comment_date'] ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 36afcd1643..8886fd83c9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-48820'; +$wp_version = '5.6-alpha-48822'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.