Created
July 18, 2014 00:21
-
-
Save atwellpub/be544d194b71b8434edc to your computer and use it in GitHub Desktop.
Add this code to your theme's functions.php code to enable geoplugin.com's geotargeting js script and auto-set the country dropdown to the correct country code
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 | |
/** | |
* Adds geotargeting js capabilities to javascript | |
*/ | |
add_action( 'wp_enqueue_scripts' , 'inbound_add_geotargeting_js' ); | |
function inbound_add_geotargeting_js () { | |
wp_enqueue_script( 'geoplugin' , 'http://www.geoplugin.net/javascript.gp'); | |
} | |
/** | |
* Sets Inbound Form Country Dropdown field to the correct country code. Field must be mapped to 'Country' in the Inbound Form administration area. ' | |
*/ | |
add_action( 'wp_footer' , 'inbound_set_correct_country' ); | |
function inbound_set_correct_country () { | |
?> | |
<script type='text/javascript'> | |
jQuery( document ).ready( function() { | |
jQuery( "select[name='wpleads_country_code']" ).val(geoplugin_countryCode()); | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment