Skip to content

Commit 854829d

Browse files
committed
Merge pull request #19 from ryanshoover/master
fix(logic): error in negated logic
2 parents eb97b48 + 2d94dc9 commit 854829d

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: wpengine, markkelnar, stevenkword, stephenlin, ryanshoover, taylor
33
Tags: wpe, wpengine, geoip, localization, geolocation
44
Requires at least: 3.0.1
55
Tested up to: 4.2.2
6-
Stable tag: 1.1.0
6+
Stable tag: 1.1.1
77
License: GPLv2 or later
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

@@ -153,6 +153,10 @@ Please contact the WP Engine [Support Team](https://my.wpengine.com/support#gene
153153

154154
== Changelog ==
155155

156+
= 1.1.1 =
157+
- Fixes logic for negated parameters in content shortcake
158+
- Allows the plugin to run on development sites
159+
156160
= 1.1.0 =
157161
- Adds continent shortcode
158162
- Adds content shortcode for localized geographic content

wpengine-geoip.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/*
33
Plugin Name: WP Engine GeoIP
4-
Version: 1.1.0
4+
Version: 1.1.1
55
Description: Create a personalized user experienced based on location.
66
Author: WP Engine
77
Author URI: http://wpengine.com
@@ -94,16 +94,16 @@ public function setup() {
9494

9595
$this->geoip_path = plugin_dir_path( __FILE__ );
9696

97+
// Get our array of countries and continents
98+
require_once( $this->geoip_path . '/inc/country-list.php' );
99+
100+
$this->countries = apply_filters( 'geoip_country_list', geoip_country_list() );
101+
97102
$this->geos = $this->get_actuals();
98103

99104
$this->geos = $this->get_test_parameters( $this->geos );
100105

101106
$this->geos = apply_filters( 'geoip_location_values', $this->geos );
102-
103-
// Get our array of countries and continents
104-
require_once( $this->geoip_path . '/inc/country-list.php' );
105-
106-
$this->countries = apply_filters( 'geoip_country_list', geoip_country_list() );
107107
}
108108

109109
/**
@@ -449,6 +449,11 @@ function do_shortcode_content( $atts, $content = null ) {
449449
// find out if the value is comma delimited
450450
$test_values = (array) explode( ',', $value );
451451

452+
// If we're checking for a negative, we need to start with TRUE
453+
if( $negate ) {
454+
$keep = TRUE;
455+
}
456+
452457
// Let's run through the test values and see if we get a match
453458
foreach( $test_values as $test_value ) {
454459

@@ -459,8 +464,8 @@ function do_shortcode_content( $atts, $content = null ) {
459464
$keep = TRUE;
460465
}
461466

462-
if( $negate && $match_value != $test_value ) {
463-
$keep = TRUE;
467+
if( $negate && $match_value == $test_value ) {
468+
$keep = FALSE;
464469
}
465470
}
466471
}
@@ -477,9 +482,11 @@ function do_shortcode_content( $atts, $content = null ) {
477482
* @since 0.5.0
478483
*/
479484
public function action_admin_init_check_plugin_dependencies() {
480-
// Check to see if the environment variables are present
485+
// Check to see if we're in a development environment or the environment variables are present
481486
$is_wpe = getenv( 'HTTP_GEOIP_COUNTRY_CODE' );
482-
if( ! isset( $is_wpe ) || empty( $is_wpe ) ) {
487+
$is_dev = preg_match( '/^(.*)(\.dev)$|^(.*)(staging.wpengine.com)$/', get_site_url() );
488+
489+
if( 1 != $is_dev && ( ! isset( $is_wpe ) || empty( $is_wpe ) ) ) {
483490
$this->admin_notices[] = __( 'Please note - this plugin will only function on your <a href="http://wpengine.com/plans/?utm_source=' . self::TEXT_DOMAIN . '">WP Engine account</a>. This will not function outside of the WP Engine environment. Plugin <b>deactivated.</b>', self::TEXT_DOMAIN );
484491
}
485492
unset( $is_wpe );

0 commit comments

Comments
 (0)