This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class GeotWP_Url_Location { | |
public $data_url; | |
public function __construct() { | |
add_filter( 'geot/cancel_query', [ $this, 'set_custom_data' ],11 ); | |
add_action('init', [$this , 'rocket_cookies'],21); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('geot/dropdown_widget/countries', function($countries) { | |
foreach( $countries as $i => $c ) { | |
if( $c->iso_code == 'US' ) { | |
$countries[$i]->country = 'USA'; | |
} | |
if( $c->iso_code == 'GB' ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add this file in the wp-content/mu-plugins/ folder. If the folder doesn't exist simply create it. | |
* Uncomment the line for you builder and comment out the rest | |
**/ | |
add_filter( 'geot/deactivate_divi_integration', '__return_true' ); | |
//add_filter( 'geot/deactivate_beaver_integration', '__return_true' ); | |
//add_filter( 'geot/deactivate_elementor_integration', '__return_true' ); | |
//add_filter( 'geot/deactivate_fusion_integration', '__return_true' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* The following code serves as an example and could be copied over to your theme's functions.php file | |
* Ideally you want to separate your javascript files and load them separatly. | |
* This example it's based on the following HTML structure: | |
* <a href="#" data-iso="US" class="geot-countries">United States</a> - <a href="#" data-iso="AR" class="geot-countries">Argentina</a> | |
*/ | |
add_action('wp_footer', 'my_custom_geot_widget' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class GeotWP_Url_Location { | |
public function __construct() { | |
add_filter( 'geot/cancel_query', [ $this, 'set_custom_data' ] ); | |
} | |
/** | |
* Check if url is set and modify data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wpse159536_override_mofile_path( $mofile, $domain ){ | |
if( 'geot' == $domain ){ | |
$mofile = WP_LANG_DIR . '/plugins/' . basename( $mofile ); | |
} | |
return $mofile; | |
} | |
add_filter( 'load_textdomain_mofile', 'wpse159536_override_mofile_path', 10, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Allow users to change location with query string like this | |
* https://yourdomain.com?geot_country=US | |
**/ | |
add_action( 'init', 'change_geolocation_with_url' ); | |
function change_geolocation_with_url(){ | |
if( ! isset( $_GET['geot_country'] ) ) { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('geotwp_ajax_success', function(e, data) { | |
if( typeof data.geo != 'undefined') { | |
// create a custom cookie with zip value and 999 days duration | |
GeotCreateCookie('geot_switcher', data.geo.city.data.zip, 999); | |
// Add a marker in a custom google map | |
if( data.geo.geolocation.data.latitude && data.geo.geolocation.data.longitude && jQuery('#geot-map').length != 0 ) { | |
var stanton = {lat: parseFloat(data.geo.geolocation.data.latitude), lng: parseFloat(data.geo.geolocation.data.longitude)}; | |
add_marker(stanton); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Practical example on how to use ajax php functions | |
**/ | |
$html = '<p>This is your HTML you want to apply geotargeting, if you have complex and large content you could use ob_start() and ob_get_clean() to fill this variable with the HTML</p>'; | |
$html_world = '<p>Some other HTML for everyone except US and CA</p>'; | |
// We echo the part for and US,CA. Javascript will take care of hide or show the $html | |
echo ajax_geotwp_filter( ['country' => 'US,CA'],$html); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// geot_user_country | |
// Return object of current user country details | |
$country = geot_user_country(); | |
echo $country->name; | |
echo $country->isoCode; | |
//geot_country_code | |
// return current user country code |
NewerOlder