Version Description
- When an error occurs during the Cron update of the Maxmind database, it is now shown in the backend.
- FIX: All times shown in the Admin backend now use the timezone set by Wordpress
- FIX: In the Admin Options, it was not possible to revert an hardcoded "External IP of this server" back to "automatic detection"
- FIX:
[geoip_detect2_show_if property="country.isInEuropeanUnion" property_value="true"]Products list for EU[/geoip_detect2_show_if]
now works properly (boolean values can be "true"/"yes" or "false"/"no") - FIX:
[geoip_detect2_current_flag]
now compatible with the SVG Flags version 0.9.0. See Documentation for more infos. - Minor admin improvement: If the value "IPs of trusted proxies" is set, but "The server is behind a reverse proxy" is not ticked, issue an warning
Download this release
Release Info
Developer | benjamin4 |
Plugin | GeoIP Detection |
Version | 3.0.4 |
Comparing to | |
See all releases |
Code changes from version 3.0.3.1 to 3.0.4
- admin-ui.php +23 -9
- data-sources/auto.php +9 -6
- data-sources/manual.php +2 -3
- geoip-detect-lib.php +10 -0
- geoip-detect.php +3 -2
- lib/logger.php +43 -0
- readme.txt +8 -0
- shortcode.php +24 -7
- views/options.php +20 -2
admin-ui.php
CHANGED
@@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
20 |
|
21 |
use YellowTree\GeoipDetect\DataSources\DataSourceRegistry;
|
|
|
22 |
|
23 |
function geoip_detect_menu() {
|
24 |
if (!function_exists('add_submenu_page')) {
|
@@ -89,14 +90,16 @@ function geoip_detect_sanitize_option($opt_name, $opt_value, &$message = '') {
|
|
89 |
$opt_value = sanitize_text_field($opt_value);
|
90 |
switch($opt_name) {
|
91 |
case 'external_ip':
|
92 |
-
if (
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
98 |
}
|
99 |
-
$opt_value = (string) $opt_value;
|
100 |
}
|
101 |
|
102 |
case 'trusted_proxy_ips':
|
@@ -119,6 +122,15 @@ function geoip_detect_option_page() {
|
|
119 |
}
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
$registry = DataSourceRegistry::getInstance();
|
123 |
$sources = $registry->getAllSources();
|
124 |
|
@@ -139,10 +151,12 @@ function geoip_detect_option_page() {
|
|
139 |
$s = new \YellowTree\GeoipDetect\DataSources\Auto\AutoDataSource();
|
140 |
$ret = $s->maxmindUpdate();
|
141 |
|
142 |
-
if ($ret === true)
|
143 |
$message .= __('Updated successfully.', 'geoip-detect');
|
144 |
-
else
|
|
|
145 |
$message .= __('File was not updated', 'geoip-detect') .': '. $ret;
|
|
|
146 |
|
147 |
break;
|
148 |
|
19 |
*/
|
20 |
|
21 |
use YellowTree\GeoipDetect\DataSources\DataSourceRegistry;
|
22 |
+
use YellowTree\GeoipDetect\Logger;
|
23 |
|
24 |
function geoip_detect_menu() {
|
25 |
if (!function_exists('add_submenu_page')) {
|
90 |
$opt_value = sanitize_text_field($opt_value);
|
91 |
switch($opt_name) {
|
92 |
case 'external_ip':
|
93 |
+
if ($opt_value) {
|
94 |
+
if (!geoip_detect_is_ip($opt_value)) {
|
95 |
+
$message .= 'The external IP "' . esc_html($opt_value) . '" is not a valid IP.';
|
96 |
+
return false;
|
97 |
+
} else {
|
98 |
+
if (!geoip_detect_is_public_ip($opt_value)) {
|
99 |
+
$message .= 'Warning: The external IP "' . esc_html($opt_value) . '" is not a public internet IP, so it will probably not work.';
|
100 |
+
}
|
101 |
+
$opt_value = (string) $opt_value;
|
102 |
}
|
|
|
103 |
}
|
104 |
|
105 |
case 'trusted_proxy_ips':
|
122 |
}
|
123 |
}
|
124 |
|
125 |
+
if (isset($_GET['geoip_detect_dismiss_log_notice'])) {
|
126 |
+
$category = sanitize_key($_GET['geoip_detect_dismiss_log_notice']);
|
127 |
+
if ($category == 'cron') {
|
128 |
+
Logger::reset_last_error_msg($category);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
$last_cron_error_msg = Logger::get_last_error_msg('cron');
|
133 |
+
|
134 |
$registry = DataSourceRegistry::getInstance();
|
135 |
$sources = $registry->getAllSources();
|
136 |
|
151 |
$s = new \YellowTree\GeoipDetect\DataSources\Auto\AutoDataSource();
|
152 |
$ret = $s->maxmindUpdate();
|
153 |
|
154 |
+
if ($ret === true) {
|
155 |
$message .= __('Updated successfully.', 'geoip-detect');
|
156 |
+
} else {
|
157 |
+
Logger::log($ret, Logger::CATEGORY_UPDATE);
|
158 |
$message .= __('File was not updated', 'geoip-detect') .': '. $ret;
|
159 |
+
}
|
160 |
|
161 |
break;
|
162 |
|
data-sources/auto.php
CHANGED
@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21 |
namespace YellowTree\GeoipDetect\DataSources\Auto;
|
22 |
|
23 |
use YellowTree\GeoipDetect\DataSources\Manual\ManualDataSource;
|
|
|
24 |
|
25 |
define('GEOIP_DETECT_DATA_UPDATE_FILENAME', 'GeoLite2-City.mmdb');
|
26 |
|
@@ -34,7 +35,6 @@ class AutoDataSource extends ManualDataSource
|
|
34 |
|
35 |
public function getStatusInformationHTML() {
|
36 |
$html = parent::getStatusInformationHTML();
|
37 |
-
$date_format = get_option('date_format') . ' ' . get_option('time_format');
|
38 |
|
39 |
$rescheduled = '';
|
40 |
$next_cron_update = wp_next_scheduled( 'geoipdetectupdate' );
|
@@ -43,7 +43,7 @@ class AutoDataSource extends ManualDataSource
|
|
43 |
$this->set_cron_schedule();
|
44 |
$next_cron_update = wp_next_scheduled( 'geoipdetectupdate' );
|
45 |
}
|
46 |
-
$html .= '<br />' . sprintf(__('Next update: %s', 'geoip-detect'), $next_cron_update !== false ?
|
47 |
$html .= $rescheduled;
|
48 |
|
49 |
$html .= $this->updateHTML();
|
@@ -234,7 +234,7 @@ HTML;
|
|
234 |
}
|
235 |
|
236 |
if (!is_readable($outFile)) {
|
237 |
-
return 'Something went wrong: the unpacked file cannot be found.';
|
238 |
}
|
239 |
|
240 |
update_option('geoip-detect-auto_downloaded_file', '');
|
@@ -298,10 +298,12 @@ HTML;
|
|
298 |
*/
|
299 |
$do_it = apply_filters('geoip_detect_cron_do_update', !GEOIP_DETECT_AUTO_UPDATE_DEACTIVATED, false);
|
300 |
|
301 |
-
$this->
|
302 |
|
303 |
-
if ($do_it)
|
304 |
-
$this->maxmindUpdate();
|
|
|
|
|
305 |
}
|
306 |
|
307 |
public function set_cron_schedule()
|
@@ -316,6 +318,7 @@ HTML;
|
|
316 |
// Try to update every 1-2 weeks
|
317 |
$next = time() + WEEK_IN_SECONDS;
|
318 |
$next += mt_rand(1, WEEK_IN_SECONDS);
|
|
|
319 |
wp_schedule_single_event($next, 'geoipdetectupdate');
|
320 |
}
|
321 |
|
21 |
namespace YellowTree\GeoipDetect\DataSources\Auto;
|
22 |
|
23 |
use YellowTree\GeoipDetect\DataSources\Manual\ManualDataSource;
|
24 |
+
use YellowTree\GeoipDetect\Logger;
|
25 |
|
26 |
define('GEOIP_DETECT_DATA_UPDATE_FILENAME', 'GeoLite2-City.mmdb');
|
27 |
|
35 |
|
36 |
public function getStatusInformationHTML() {
|
37 |
$html = parent::getStatusInformationHTML();
|
|
|
38 |
|
39 |
$rescheduled = '';
|
40 |
$next_cron_update = wp_next_scheduled( 'geoipdetectupdate' );
|
43 |
$this->set_cron_schedule();
|
44 |
$next_cron_update = wp_next_scheduled( 'geoipdetectupdate' );
|
45 |
}
|
46 |
+
$html .= '<br />' . sprintf(__('Next update: %s', 'geoip-detect'), $next_cron_update !== false ? geoip_detect_format_localtime($next_cron_update) : __('Never', 'geoip-detect'));
|
47 |
$html .= $rescheduled;
|
48 |
|
49 |
$html .= $this->updateHTML();
|
234 |
}
|
235 |
|
236 |
if (!is_readable($outFile)) {
|
237 |
+
return 'Error: Something went wrong: the unpacked file cannot be found.';
|
238 |
}
|
239 |
|
240 |
update_option('geoip-detect-auto_downloaded_file', '');
|
298 |
*/
|
299 |
$do_it = apply_filters('geoip_detect_cron_do_update', !GEOIP_DETECT_AUTO_UPDATE_DEACTIVATED, false);
|
300 |
|
301 |
+
$this->set_cron_schedule();
|
302 |
|
303 |
+
if ($do_it) {
|
304 |
+
$ret = $this->maxmindUpdate();
|
305 |
+
Logger::logIfError($ret, 'cron');
|
306 |
+
}
|
307 |
}
|
308 |
|
309 |
public function set_cron_schedule()
|
318 |
// Try to update every 1-2 weeks
|
319 |
$next = time() + WEEK_IN_SECONDS;
|
320 |
$next += mt_rand(1, WEEK_IN_SECONDS);
|
321 |
+
|
322 |
wp_schedule_single_event($next, 'geoipdetectupdate');
|
323 |
}
|
324 |
|
data-sources/manual.php
CHANGED
@@ -34,7 +34,6 @@ class ManualDataSource extends AbstractDataSource {
|
|
34 |
$built = $last_update = 0;
|
35 |
$html = array();
|
36 |
|
37 |
-
$date_format = get_option('date_format') . ' ' . get_option('time_format');
|
38 |
$file = $this->maxmindGetFilename();
|
39 |
|
40 |
if (!$file)
|
@@ -49,8 +48,8 @@ class ManualDataSource extends AbstractDataSource {
|
|
49 |
$metadata = $reader->metadata();
|
50 |
$built = $metadata->buildEpoch;
|
51 |
$last_update = is_readable($file) ? filemtime($file) : '';
|
52 |
-
$html[] = sprintf(__('Last updated: %s', 'geoip-detect'), $last_update ?
|
53 |
-
$html[] = sprintf(__('Database data from: %s', 'geoip-detect'),
|
54 |
}
|
55 |
|
56 |
|
34 |
$built = $last_update = 0;
|
35 |
$html = array();
|
36 |
|
|
|
37 |
$file = $this->maxmindGetFilename();
|
38 |
|
39 |
if (!$file)
|
48 |
$metadata = $reader->metadata();
|
49 |
$built = $metadata->buildEpoch;
|
50 |
$last_update = is_readable($file) ? filemtime($file) : '';
|
51 |
+
$html[] = sprintf(__('Last updated: %s', 'geoip-detect'), $last_update ? geoip_detect_format_localtime($last_update) : __('Never', 'geoip-detect'));
|
52 |
+
$html[] = sprintf(__('Database data from: %s', 'geoip-detect'), geoip_detect_format_localtime($built) );
|
53 |
}
|
54 |
|
55 |
|
geoip-detect-lib.php
CHANGED
@@ -482,4 +482,14 @@ function _geoip_dashes_to_camel_case($string, $capitalizeFirstCharacter = false)
|
|
482 |
}
|
483 |
|
484 |
return $str;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
}
|
482 |
}
|
483 |
|
484 |
return $str;
|
485 |
+
}
|
486 |
+
|
487 |
+
function geoip_detect_format_localtime($timestamp = 0) {
|
488 |
+
if ($timestamp === 0) {
|
489 |
+
$timestamp = time();
|
490 |
+
}
|
491 |
+
|
492 |
+
$format = get_option('date_format') . ' '. get_option('time_format');
|
493 |
+
|
494 |
+
return get_date_from_gmt ( date( 'Y-m-d H:i:s', $timestamp ), $format);
|
495 |
}
|
geoip-detect.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.yellowtree.de
|
|
5 |
Description: Retrieving Geo-Information using the Maxmind GeoIP (Lite) Database.
|
6 |
Author: Yellow Tree (Benjamin Pick)
|
7 |
Author URI: http://www.yellowtree.de
|
8 |
-
Version: 3.0.
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
Text Domain: geoip-detect
|
@@ -16,7 +16,7 @@ Requires WP: 4.0
|
|
16 |
Requires PHP: 5.6
|
17 |
*/
|
18 |
|
19 |
-
define('GEOIP_DETECT_VERSION', '3.0.
|
20 |
|
21 |
/*
|
22 |
Copyright 2013-2020 Yellow Tree, Siegen, Germany
|
@@ -61,6 +61,7 @@ require_once(GEOIP_PLUGIN_DIR . '/init.php');
|
|
61 |
require_once(GEOIP_PLUGIN_DIR . '/geoip-detect-lib.php');
|
62 |
require_once(GEOIP_PLUGIN_DIR . '/lib/geonames/geonames-country-info.php');
|
63 |
require_once(GEOIP_PLUGIN_DIR . '/lib/get-client-ip.php');
|
|
|
64 |
|
65 |
require_once(GEOIP_PLUGIN_DIR . '/upgrade-plugin.php');
|
66 |
require_once(GEOIP_PLUGIN_DIR . '/api.php');
|
5 |
Description: Retrieving Geo-Information using the Maxmind GeoIP (Lite) Database.
|
6 |
Author: Yellow Tree (Benjamin Pick)
|
7 |
Author URI: http://www.yellowtree.de
|
8 |
+
Version: 3.0.4
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
Text Domain: geoip-detect
|
16 |
Requires PHP: 5.6
|
17 |
*/
|
18 |
|
19 |
+
define('GEOIP_DETECT_VERSION', '3.0.4');
|
20 |
|
21 |
/*
|
22 |
Copyright 2013-2020 Yellow Tree, Siegen, Germany
|
61 |
require_once(GEOIP_PLUGIN_DIR . '/geoip-detect-lib.php');
|
62 |
require_once(GEOIP_PLUGIN_DIR . '/lib/geonames/geonames-country-info.php');
|
63 |
require_once(GEOIP_PLUGIN_DIR . '/lib/get-client-ip.php');
|
64 |
+
require_once(GEOIP_PLUGIN_DIR . '/lib/logger.php');
|
65 |
|
66 |
require_once(GEOIP_PLUGIN_DIR . '/upgrade-plugin.php');
|
67 |
require_once(GEOIP_PLUGIN_DIR . '/api.php');
|
lib/logger.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace YellowTree\GeoipDetect;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* This API is experimental and WILL change in future versions. Beware!
|
7 |
+
*/
|
8 |
+
class Logger {
|
9 |
+
const CATEGORY_CRON = 'cron';
|
10 |
+
const CATEGORY_UPDATE = 'update';
|
11 |
+
|
12 |
+
// Other errors to log: lookup, API
|
13 |
+
|
14 |
+
public static function logIfError($str, $category = '', $data = array()) {
|
15 |
+
if (is_wp_error($str)) {
|
16 |
+
$str = $str->get_error_message();
|
17 |
+
}
|
18 |
+
|
19 |
+
if (is_string($str)) {
|
20 |
+
self::log($str, $category, $data);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
public static function log($str, $category = '', $data = array()) {
|
25 |
+
$str = sanitize_text_field($str);
|
26 |
+
|
27 |
+
// For now, only log the last error
|
28 |
+
$time = geoip_detect_format_localtime();
|
29 |
+
|
30 |
+
$str = '[' . $time . '] ' . $str;
|
31 |
+
update_option('geoip-detect-logger-last-error' . $category, $str);
|
32 |
+
}
|
33 |
+
|
34 |
+
public static function get_last_error_msg($category = '') {
|
35 |
+
return get_option('geoip-detect-logger-last-error' . $category);
|
36 |
+
}
|
37 |
+
public static function reset_last_error_msg($category = '') {
|
38 |
+
update_option('geoip-detect-logger-last-error' . $category, false);
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
}
|
43 |
+
|
readme.txt
CHANGED
@@ -150,6 +150,14 @@ New: Shortcode for showing/hiding content!
|
|
150 |
|
151 |
== Changelog ==
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
= 3.0.3.1 =
|
154 |
* Hotfix: The filename specified in the manual datasource can be changed properly again.
|
155 |
|
150 |
|
151 |
== Changelog ==
|
152 |
|
153 |
+
= 3.0.4 =
|
154 |
+
* When an error occurs during the Cron update of the Maxmind database, it is now shown in the backend.
|
155 |
+
* FIX: All times shown in the Admin backend now use the timezone set by Wordpress
|
156 |
+
* FIX: In the Admin Options, it was not possible to revert an hardcoded "External IP of this server" back to "automatic detection"
|
157 |
+
* FIX: `[geoip_detect2_show_if property="country.isInEuropeanUnion" property_value="true"]Products list for EU[/geoip_detect2_show_if]` now works properly (boolean values can be "true"/"yes" or "false"/"no")
|
158 |
+
* FIX: `[geoip_detect2_current_flag]` now compatible with the [SVG Flags](https://wordpress.org/plugins/svg-flags-lite/) version 0.9.0. See [Documentation](https://github.com/yellowtree/geoip-detect/wiki/API:-Shortcodes#add-a-flag-of-the-visitors-country) for more infos.
|
159 |
+
* Minor admin improvement: If the value "IPs of trusted proxies" is set, but "The server is behind a reverse proxy" is not ticked, issue an warning
|
160 |
+
|
161 |
= 3.0.3.1 =
|
162 |
* Hotfix: The filename specified in the manual datasource can be changed properly again.
|
163 |
|
shortcode.php
CHANGED
@@ -545,6 +545,9 @@ add_shortcode('geoip_detect2_user_info', 'geoip_detect_shortcode_user_info');
|
|
545 |
*
|
546 |
* Show TEXT if the visitor is within the timezone Europe/Berlin
|
547 |
* `[geoip_detect2_show_if property="location.timeZone" property_value="Europe/Berlin"]TEXT[/geoip_detect2_show_if]`
|
|
|
|
|
|
|
548 |
*
|
549 |
* LIMITATIONS:
|
550 |
* - You cannot nest several of these shortcodes within one another. Instead, seperate them into several blocks of shortcodes.
|
@@ -554,18 +557,21 @@ add_shortcode('geoip_detect2_user_info', 'geoip_detect_shortcode_user_info');
|
|
554 |
function geoip_detect2_shortcode_show_if($attr, $content = null, $shortcodeName = '') {
|
555 |
$showContentIfMatch = ($shortcodeName == 'geoip_detect2_show_if') ? true : false;
|
556 |
|
557 |
-
/* Attribute Conditions. Order is not important, as they are combined with
|
558 |
$attributeNames = array(
|
559 |
'continent' => 'continent',
|
560 |
-
|
|
|
561 |
'country' => 'country',
|
562 |
'not_country' => 'country',
|
563 |
-
|
|
|
564 |
'region' => 'mostSpecificSubdivision',
|
565 |
'state' => 'mostSpecificSubdivision',
|
566 |
'not_most_specific_subdivision' => 'mostSpecificSubdivision',
|
567 |
'not_region' => 'mostSpecificSubdivision',
|
568 |
'not_state' => 'mostSpecificSubdivision',
|
|
|
569 |
'city' => 'city',
|
570 |
'not_city' => 'city',
|
571 |
);
|
@@ -603,7 +609,7 @@ function geoip_detect2_shortcode_show_if($attr, $content = null, $shortcodeName
|
|
603 |
|
604 |
foreach ($attributeNames as $shortcodeParamName => $maxmindName) {
|
605 |
if (!empty($attr[$shortcodeParamName])) {
|
606 |
-
// Determine
|
607 |
$actualValues = array();
|
608 |
$alternativePropertyNames = array(
|
609 |
'name',
|
@@ -659,13 +665,24 @@ function geoip_detect2_shortcode_check_subcondition($expectedValuesRaw, $actualV
|
|
659 |
$attributeValuesArray = explode(',', $expectedValuesRaw);
|
660 |
$attributeValuesArray = array_map('trim', $attributeValuesArray);
|
661 |
|
662 |
-
$actualValues
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
663 |
|
664 |
// Compare case-insensitively
|
665 |
$attributeValuesArray = array_map('mb_strtolower', $attributeValuesArray);
|
666 |
$actualValues = array_map('mb_strtolower', $actualValues);
|
667 |
|
668 |
-
|
|
|
|
|
669 |
}
|
670 |
|
671 |
|
@@ -679,7 +696,7 @@ function geoip_detect2_shortcode_check_subcondition($expectedValuesRaw, $actualV
|
|
679 |
* @param string $default Default Country in case the visitor's country cannot be determined
|
680 |
*/
|
681 |
function geoip_detect2_shortcode_current_flag($attr, $content = '', $shortcodeName = 'geoip_detect2_current_flag') {
|
682 |
-
if (!
|
683 |
return '<!-- There should be a flag here. However, the Plugin "SVG Flags" is missing.';
|
684 |
}
|
685 |
|
545 |
*
|
546 |
* Show TEXT if the visitor is within the timezone Europe/Berlin
|
547 |
* `[geoip_detect2_show_if property="location.timeZone" property_value="Europe/Berlin"]TEXT[/geoip_detect2_show_if]`
|
548 |
+
*
|
549 |
+
* Show TEXT if the visitor is in the european union
|
550 |
+
* `[geoip_detect2_show_if property="country.isInEuropeanUnion" property_value="true"]Products list for EU[/geoip_detect2_show_if]`
|
551 |
*
|
552 |
* LIMITATIONS:
|
553 |
* - You cannot nest several of these shortcodes within one another. Instead, seperate them into several blocks of shortcodes.
|
557 |
function geoip_detect2_shortcode_show_if($attr, $content = null, $shortcodeName = '') {
|
558 |
$showContentIfMatch = ($shortcodeName == 'geoip_detect2_show_if') ? true : false;
|
559 |
|
560 |
+
/* Attribute Conditions. Order is not important, as they are combined with a transitive AND condition */
|
561 |
$attributeNames = array(
|
562 |
'continent' => 'continent',
|
563 |
+
'not_continent' => 'continent',
|
564 |
+
|
565 |
'country' => 'country',
|
566 |
'not_country' => 'country',
|
567 |
+
|
568 |
+
'most_specific_subdivision' => 'mostSpecificSubdivision',
|
569 |
'region' => 'mostSpecificSubdivision',
|
570 |
'state' => 'mostSpecificSubdivision',
|
571 |
'not_most_specific_subdivision' => 'mostSpecificSubdivision',
|
572 |
'not_region' => 'mostSpecificSubdivision',
|
573 |
'not_state' => 'mostSpecificSubdivision',
|
574 |
+
|
575 |
'city' => 'city',
|
576 |
'not_city' => 'city',
|
577 |
);
|
609 |
|
610 |
foreach ($attributeNames as $shortcodeParamName => $maxmindName) {
|
611 |
if (!empty($attr[$shortcodeParamName])) {
|
612 |
+
// Determine actual MaxMind Value(s) for Attribute
|
613 |
$actualValues = array();
|
614 |
$alternativePropertyNames = array(
|
615 |
'name',
|
665 |
$attributeValuesArray = explode(',', $expectedValuesRaw);
|
666 |
$attributeValuesArray = array_map('trim', $attributeValuesArray);
|
667 |
|
668 |
+
if ($actualValues === true) {
|
669 |
+
$actualValues = array("true", "yes", "y", "1");
|
670 |
+
}
|
671 |
+
if ($actualValues === false) {
|
672 |
+
$actualValues = array("false", "no", "n", "0", "");
|
673 |
+
}
|
674 |
+
|
675 |
+
if (!is_array($actualValues)) {
|
676 |
+
$actualValues = array($actualValues);
|
677 |
+
}
|
678 |
|
679 |
// Compare case-insensitively
|
680 |
$attributeValuesArray = array_map('mb_strtolower', $attributeValuesArray);
|
681 |
$actualValues = array_map('mb_strtolower', $actualValues);
|
682 |
|
683 |
+
$intersection = array_intersect($actualValues, $attributeValuesArray);
|
684 |
+
|
685 |
+
return count($intersection) > 0;
|
686 |
}
|
687 |
|
688 |
|
696 |
* @param string $default Default Country in case the visitor's country cannot be determined
|
697 |
*/
|
698 |
function geoip_detect2_shortcode_current_flag($attr, $content = '', $shortcodeName = 'geoip_detect2_current_flag') {
|
699 |
+
if (!shortcode_exists('svg-flag')) {
|
700 |
return '<!-- There should be a flag here. However, the Plugin "SVG Flags" is missing.';
|
701 |
}
|
702 |
|
views/options.php
CHANGED
@@ -6,12 +6,25 @@ $currentSourceId = $currentSource->getId();
|
|
6 |
<div class="wrap">
|
7 |
<h1><?php _e('Geolocation IP Detection', 'geoip-detect');?></h1>
|
8 |
<p><a href="tools.php?page=<?php echo GEOIP_PLUGIN_BASENAME ?>"><?php _e('Test IP Detection Lookup', 'geoip-detect')?></a></p>
|
9 |
-
|
10 |
<p class="geoip_detect_error">
|
11 |
<?php echo $message; ?>
|
12 |
</p>
|
13 |
<?php endif; ?>
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
<p>
|
16 |
<?php printf(__('<b>Selected data source:</b> %s', 'geoip-detect'), geoip_detect2_get_current_source_description() ); ?>
|
17 |
</p>
|
@@ -93,6 +106,11 @@ $currentSourceId = $currentSource->getId();
|
|
93 |
<p>
|
94 |
<label><?php _e('IPs of trusted proxies:', 'geoip-detect'); ?><input type="text" name="options[trusted_proxy_ips]" value="<?php echo esc_attr($wp_options['trusted_proxy_ips']); ?>" placeholder="1.1.1.1, 1234::1, 2.2.2.2/24" />
|
95 |
<span class="detail-box">
|
|
|
|
|
|
|
|
|
|
|
96 |
<?php _e('If specified, only IPs in this list will be treated as proxy.', 'geoip-detect'); ?><br>
|
97 |
<?php _e('Make sure to add both IPv4 and IPv6 adresses of the proxy!', 'geoip-detect'); ?>
|
98 |
</span>
|
6 |
<div class="wrap">
|
7 |
<h1><?php _e('Geolocation IP Detection', 'geoip-detect');?></h1>
|
8 |
<p><a href="tools.php?page=<?php echo GEOIP_PLUGIN_BASENAME ?>"><?php _e('Test IP Detection Lookup', 'geoip-detect')?></a></p>
|
9 |
+
<?php if (!empty($message)): ?>
|
10 |
<p class="geoip_detect_error">
|
11 |
<?php echo $message; ?>
|
12 |
</p>
|
13 |
<?php endif; ?>
|
14 |
+
<?php if (!empty($last_cron_error_msg)): ?>
|
15 |
+
<div class="error notice is-dismissible">
|
16 |
+
<p style="float: right">
|
17 |
+
<a href="options-general.php?page=<?php echo GEOIP_PLUGIN_BASENAME ?>&geoip_detect_dismiss_log_notice=cron"><?php _e('Dismiss notice', 'geoip-detect'); ?></a>
|
18 |
+
</p>
|
19 |
+
<p>
|
20 |
+
<b><?php _e('An error occured on Cron Execution (background task):', 'geoip-detect'); ?></b><br>
|
21 |
+
<?php echo esc_html($last_cron_error_msg); ?>
|
22 |
+
<p>
|
23 |
+
<a class="button button-secondary" href="options-general.php?page=<?php echo GEOIP_PLUGIN_BASENAME ?>&geoip_detect_dismiss_log_notice=cron"><?php _e('Dismiss notice', 'geoip-detect'); ?></a>
|
24 |
+
</p>
|
25 |
+
</p>
|
26 |
+
</div>
|
27 |
+
<?php endif; ?>
|
28 |
<p>
|
29 |
<?php printf(__('<b>Selected data source:</b> %s', 'geoip-detect'), geoip_detect2_get_current_source_description() ); ?>
|
30 |
</p>
|
106 |
<p>
|
107 |
<label><?php _e('IPs of trusted proxies:', 'geoip-detect'); ?><input type="text" name="options[trusted_proxy_ips]" value="<?php echo esc_attr($wp_options['trusted_proxy_ips']); ?>" placeholder="1.1.1.1, 1234::1, 2.2.2.2/24" />
|
108 |
<span class="detail-box">
|
109 |
+
<?php if (empty($wp_options['has_reverse_proxy']) && !empty($wp_options['trusted_proxy_ips'])) : ?>
|
110 |
+
<span style="color:red">
|
111 |
+
<?php printf(__('Warning: As you didn\'t tick the option "%s" above, seting trusted IPs has no effect. This is only used for reverse proxies.', 'geoip-detect'), __('The server is behind a reverse proxy', 'geoip-detect') ); ?>
|
112 |
+
</span><br>
|
113 |
+
<?php endif; ?>
|
114 |
<?php _e('If specified, only IPs in this list will be treated as proxy.', 'geoip-detect'); ?><br>
|
115 |
<?php _e('Make sure to add both IPv4 and IPv6 adresses of the proxy!', 'geoip-detect'); ?>
|
116 |
</span>
|