Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'toolbox_add_conditional_options' , 'add_geo_detect', 10, 1 );
- function add_geo_detect() {
- toolboxExtender::add_conditional_option(
- // filter name
- 'geo_detect',
- // option key and title
- array('key'=> 'geo_check' , 'title' => __('Geo Check', 'textdomain') ),
- // fields that are part of this options settings.
- // No toggling of subfields or forms
- array(
- 'query_parameter' => array(
- 'type' => 'text',
- 'label' => __( 'isoCode to check for', 'textdomain' ),
- 'default' => 'US',
- ),
- )
- );
- add_filter( 'geo_detect' , 'check_geo_location' , 10, 3 );
- function check_geo_location ( $is_visible, $param , $node ) {
- $record = geoip_detect2_get_info_from_current_ip();
- if ( $record->country->isoCode !== strtoupper($param['query_parameter']) ) return false;
- return $is_visible;
- }
- }
Add Comment
Please, Sign In to add comment