Skip to content

Commit 8b9ca55

Browse files
author
Benjamin Pick
committed
update docs [ci skip]
1 parent 9c6ffce commit 8b9ca55

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed

docs/API-Usage-Examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,4 +409,4 @@ Content for other countries
409409
<p>(Debug: Current saved country is: <b>[geoip_detect2 property="country"]</b> / ISO: <b>[geoip_detect2 property="country.isoCode"] </b>)</p>
410410
<p>Override (from Autosave or manual) active? <b>[geoip_detect2_show_if property="extra.override" property_value="1"]Yes[else]No[/geoip_detect2_show_if]</b></p>
411411
<p><a href="#" onclick="geoip_detect.remove_override(); return false;">Reset override</a></p>
412-
```
412+
```

docs/API:-AJAX.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ add_filter('geoip_detect2_ajax_localize_script_data', function($data) {
101101
return $data;
102102
});
103103
```
104+
### JS Variants
105+
(Since 5.3.0)
106+
107+
If you are only using the method geoip_detect.get_info(), then you can opt in to a smaller JS file variant.
108+
109+
```php
110+
define('GEOIP_DETECT_JS_VARIANT', 'base');
111+
```
112+
113+
There are three possible variants:
114+
115+
* `full`: All features (default)
116+
* `base`: Only get_info, no shortcodes, no body_class, no overrides ...
117+
* `minimal`: Only get_info, but without the Record class (get_info is returning raw json data instead)
104118

105119
### Storing data that overrides detected data
106120
(Since 4.0.0)
@@ -179,3 +193,22 @@ Execute this shortcode as AJAX even if the option `Resolve shortcodes (via AJAX)
179193
`[geoip_detect2_countries name="mycountry" ajax="0"]`
180194

181195
Generate a countries select with the current country selected in the HTML (no AJAX), even if the option `Resolve shortcodes (via AJAX)` is enabled.
196+
197+
# Events
198+
199+
(Since 5.4.1)
200+
201+
* `geoip-detect-shortcodes-done` - Fired after the shortcode values have been set or updated
202+
* `geoip-detect-body-classes-done` - Fired after the body classes have been set or updated
203+
204+
Example:
205+
206+
```js
207+
document.getElementsByTagName('body')[0].addEventListener('geoip-detect-body-classes-done', function() { console.log('body class done') });
208+
document.getElementsByTagName('body')[0].addEventListener('geoip-detect-shortcodes-done', function() { console.log('shortcodes done') });
209+
```
210+
211+
Note that:
212+
213+
* Both events get fired only if the corresponding feature is enabled in the backend options
214+
* Both events potentially get fired more than once, e.g. after a call to [set_override](./API:-AJAX#storing-data-that-overrides-detected-data) or when used in combination with [autosave](./API:-Shortcodes).
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
These shortcodes you can use in forms created with [WP Forms Lite / WP Forms Pro](https://wordpress.org/plugins/wpforms-lite/):
2+
3+
4+
### Insert the geoinfos of the user into the email text
5+
(since 5.4.0)
6+
7+
Just use `{geoip_detect2_user_info}` in the email body. The result will me like this:
8+
9+
```
10+
IP of the user: 88.64.140.3
11+
Country: Germany
12+
State or region: Hesse
13+
City: Eschborn
14+
15+
Data from: GeoLite2 City database
16+
```
17+
18+
If you want to customize the labels or formatting ... use this text in the email body as starting point (since 2.9.1):
19+
20+
```
21+
IP of the user: {geoip_detect2_get_client_ip}
22+
Country: {geoip_detect2_property_country}
23+
State or region: {geoip_detect2_property_region}
24+
City: {geoip_detect2_property_city}
25+
26+
Data from: {geoip_detect2_get_current_source_description}
27+
```
28+
29+
Result: same as above.
30+
31+
Actually, you can print any property name that your data source allows, e.g.
32+
```
33+
Country Flag: {geoip_detect2_property_extra__flag}
34+
Country Iso Code: {geoip_detect2_property_country__iso_code}
35+
Country Iso 3 Code: {geoip_detect2_property_extra__country_iso_code_3}
36+
3-letter currency code: {geoip_detect2_property_extra__currency_code}
37+
```
38+
39+
As you might have guessed, you can use the [property names](https://github.com/yellowtree/geoip-detect/wiki/Record-Properties) by:
40+
41+
* Replacing `.` by 2 underscores
42+
* Reformatting `geonameId` (pascalCase) to `geoname_id` (underscore_case)

docs/API:-Shortcodes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,4 @@ Check the HTML to see error messages that are commented out (`<!-- ... -->`).
235235

236236
## WP ContactForm7 Shortcodes
237237

238-
See [https://github.com/yellowtree/geoip-detect/wiki/API:-Shortcodes-for-Contact-Form-7](CF7 Shortcodes API Documentation)
238+
See [CF7 Shortcodes API Documentation](./API:-Shortcodes-for-Contact-Form-7)

0 commit comments

Comments
 (0)