Comments: Make sure the comment data passed to the preprocess_comment
filter includes the comment_agent
and comment_author_IP
values.
Props zodiac1978, SergeyBiryukov. Fixes #51044. git-svn-id: https://develop.svn.wordpress.org/trunk@48822 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c65973e0f5
commit
5f861293e6
@ -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,9 +708,8 @@ 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.
|
||||
*
|
||||
@ -721,6 +718,8 @@ function set_screen_options() {
|
||||
* 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()
|
||||
*
|
||||
@ -729,7 +728,8 @@ function set_screen_options() {
|
||||
* @param string $option The option name.
|
||||
* @param int $value The option value.
|
||||
*/
|
||||
$value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
|
||||
$value = apply_filters( "set_screen_option_{$option}", false, $option, $value );
|
||||
}
|
||||
|
||||
if ( false === $value ) {
|
||||
return;
|
||||
|
@ -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'] ) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user