From 155174bd9ca3d0172062c0ed9d4f102d82d40ef4 Mon Sep 17 00:00:00 2001 From: vishalkakadiya Date: Sun, 19 Aug 2018 18:58:06 +0530 Subject: [PATCH] Add condition for locations in geo-uniques --- wpcom-geo-uniques/wpcom-geo-uniques.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wpcom-geo-uniques/wpcom-geo-uniques.php b/wpcom-geo-uniques/wpcom-geo-uniques.php index 01fa86ec..9834d9db 100644 --- a/wpcom-geo-uniques/wpcom-geo-uniques.php +++ b/wpcom-geo-uniques/wpcom-geo-uniques.php @@ -160,7 +160,11 @@ static function get_user_location_from_global( $global_var ) { } $test = sprintf( 'if ( empty( %s ) ) { return "%s"; }', $global_var, esc_js( self::get_default_location() ) ); - $test .= sprintf( ' elseif %s', implode( ' elseif ', $checks ) ); + + if ( ! empty( $checks ) ) { + $test .= sprintf( ' elseif %s', implode( ' elseif ', $checks ) ); + } + $test .= sprintf( ' else { return "%s"; }', esc_js( self::get_default_location() ) ); $user_location = static::run_vary_cache_on_function( $test );