get_unsafe_client_ip example


    protected function get_request_args( $search = '', $timezone = '' ) {
        $args = array(
            'number' => 5, // Get more than three in case some get trimmed out.             'ip'     => self::get_unsafe_client_ip(),
        );

        /* * Include the minimal set of necessary arguments, in order to increase the * chances of a cache-hit on the API side. */
        if ( empty( $search ) && isset( $this->user_location['latitude']$this->user_location['longitude'] ) ) {
            $args['latitude']  = $this->user_location['latitude'];
            $args['longitude'] = $this->user_location['longitude'];
        } else {
            $args['locale'] = get_user_locale( $this->user_id );

            

function wp_localize_community_events() {
    if ( ! wp_script_is( 'dashboard' ) ) {
        return;
    }

    require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php';

    $user_id            = get_current_user_id();
    $saved_location     = get_user_option( 'community-events-location', $user_id );
    $saved_ip_address   = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false;
    $current_ip_address = WP_Community_Events::get_unsafe_client_ip();

    /* * If the user's location is based on their IP address, then update their * location when their IP address changes. This allows them to see events * in their current city when travelling. Otherwise, they would always be * shown events in the city where they were when they first loaded the * Dashboard, which could have been months or years ago. */
    if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) {
        $saved_location['ip'] = $current_ip_address;
        update_user_meta( $user_id, 'community-events-location', $saved_location );
    }
Home | Imprint | This part of the site doesn't use cookies.