Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/23/2023 04:08:04 AM (3 years ago)
Author:
imath
Message:

Avoid a PHP warning in bp_core_current_user_ip()

Props slaFFik

Fixes #9028
See #9002
Closes https://github.com/buddypress/buddypress/pull/195

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-moderation.php

    r13370 r13649  
    331331 */
    332332function bp_core_current_user_ip() {
    333         $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
     333        $retval = '';
     334        if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
     335                $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
     336        }
    334337
    335338        /**
Note: See TracChangeset for help on using the changeset viewer.