Changeset 615816
- Timestamp:
- 10/22/2012 10:18:34 PM (13 years ago)
- Location:
- wpgeocode/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (6 diffs)
-
wpgeocode.php (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpgeocode/trunk/readme.txt
r606470 r615816 4 4 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GDQD948MQ3G3G 5 5 Tags: geocode, geocode filter, geotag, geomarketing, geomarking, geolocation, geofilter, location, local marketing, keywords 6 Version: 1.0. 46 Version: 1.0.5 7 7 Requires at least: 3.0 8 8 Tested up to: 3.0.1 … … 33 33 * [wpgc_is_city_and_state city="Yardley" state_code="PA"] 34 34 * [wpgc_is_ip" ip="xx.xx.xx.xx"] 35 * [wpgc_is_ips" ip="xx.xx.xx.xx,aa.bb.cc.dd"] 35 36 * [wpgc_is_not_ip" ip="xx.xx.xx.xx"] 37 * [wpgc_is_not_ips" ip="xx.xx.xx.xx,aa.bb.cc.dd"] 36 38 * [wpgc_is_city" city=""] 39 * [wpgc_is_cities" cities="city one,city two,city three"] 37 40 * [wpgc_is_not_city" city=""] 41 * [wpgc_is_not_cities" cities="city one,city two,city three"] 38 42 * [wpgc_is_nearby"] - Uses the value you specify in the Nearby Range setting from the administrative panel 39 43 * [wpgc_is_not_nearby"] … … 41 45 * [wpgc_is_within kilometers="12"] 42 46 * [wpgc_is_country_name" country_name=""] 47 * [wpgc_is_country_names" country_name="United States,Egypt,Albania"] 43 48 * [wpgc_is_country_code" country_code=""] 49 * [wpgc_is_country_codes" country_codes="US,GB,AZ"] 44 50 * [wpgc_is_state_code" state_code=""] 51 * [wpgc_is_state_codes" state_codes="PA,NJ,TX"] 45 52 * [wpgc_is_not_country_name" country_name=""] 53 * [wpgc_is_not_country_names" country_names="United States,Egypt,Albania"] 46 54 * [wpgc_is_not_country_code" country_code=""] 55 * [wpgc_is_not_country_codes" country_codes="US,GB,AZ"] 47 56 * [wpgc_is_not_state_code" state_code=""] 57 * [wpgc_is_not_state_codes" state_codes="PA,NJ,TX"] 48 58 49 59 **Examples** … … 53 63 [wpgc_is_ip ip=123.123.123.123] I used to own this IP Address [/wpgc_is_ip] - Will display the message only if the user has that specific IP Address. 54 64 [wpgc_is_city city="Yardley"] Hello Fellow Yardlian [/wpgc_is_city] - Will display the message only if the user has that specific IP Address. 65 [wpgc_is_not_cities cities="Yardley,Morrisville"] Glad you don't live in Yardley or Morrisville? [/wpgc_is_not_cities] - Will display only when visitor is not viewing the page from Yardley or Morrisville 55 66 56 67 Configurable options allow you to set a default phrase for each available shortcode in the event that the user was unable to be geo-located. … … 75 86 2. screenshot-2.png is the plugin in action. 76 87 88 == Change Log == 77 89 78 == Change Log == 90 = 1.0.5 = 91 * Add support for multiple locations (i.e. cities, states, etc.) in conditional shortcodes eg: [wpgc_is_cities cities="one,two,three"] 79 92 80 93 = 1.0.4 = … … 108 121 = 1.0.4 = 109 122 * Fix Readme 123 124 = 1.0.5 = 125 * Multiple location conditional shortcodes -
wpgeocode/trunk/wpgeocode.php
r606456 r615816 5 5 Tags: geocode, geotagging, geolocation, geotags, latitude, longitude, city, state, geomarketing, geolocation marketing 6 6 Description: Use WPGeocode to customize the content of your blog based on the location of your readers. 7 Version: 1.0. 47 Version: 1.0.5 8 8 Author: Michael Lynn 9 9 Author URI: http://www.mlynn.org/ … … 32 32 } 33 33 $log = new logfile(); 34 $log->write("test");34 // $log->write("test"); 35 35 36 36 function wpgc_shortcode_env($atts, $content="") { … … 74 74 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_ip')); 75 75 } 76 function wpgc_is_not_ips($atts, $content="") { 77 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_ips')); 78 } 76 79 function wpgc_is_not_country_code($atts, $content="") { 77 80 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_country_code')); 78 81 } 82 function wpgc_is_not_country_codes($atts, $content="") { 83 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_country_codes')); 84 } 79 85 function wpgc_is_not_country_name($atts, $content="") { 80 86 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_country_name')); 81 87 } 88 function wpgc_is_not_country_names($atts, $content="") { 89 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_country_names')); 90 } 91 function wpgc_is_not_state_codes($atts, $content="") { 92 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_state_codes')); 93 } 82 94 function wpgc_is_not_state_code($atts, $content="") { 83 95 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_state_code')); … … 86 98 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_city')); 87 99 } 100 function wpgc_is_not_cities($atts, $content="") { 101 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_cities')); 102 } 88 103 function wpgc_is_not_city_and_state($atts, $content="") { 89 104 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_city_and_state')); … … 92 107 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_ip')); 93 108 } 109 function wpgc_is_ips($atts, $content="") { 110 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_ips')); 111 } 94 112 function wpgc_is_country_code($atts, $content="") { 95 113 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_country_code')); 96 114 } 115 function wpgc_is_country_codes($atts, $content="") { 116 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_country_codes')); 117 } 97 118 function wpgc_is_country_name($atts, $content="") { 98 119 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_country_name')); 99 120 } 121 function wpgc_is_country_names($atts, $content="") { 122 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_country_names')); 123 } 124 function wpgc_is_state_codes($atts, $content="") { 125 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_state_codes')); 126 } 100 127 function wpgc_is_state_code($atts, $content="") { 101 128 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_state_code')); … … 104 131 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_city')); 105 132 } 133 function wpgc_is_cities($atts, $content="") { 134 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_cities')); 135 } 106 136 function wpgc_is_city_and_state_code($atts, $content="") { 107 137 return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_city_and_state_code')); … … 120 150 } 121 151 function wpgc_conditional_shortcode($atts, $content, $condition) { 122 $options = get_option('wpgc_options');152 $options = get_option('wpgc_options'); 123 153 extract(shortcode_atts(array( 124 154 'longitude' => '', 125 155 'latitude' => '', 126 156 'ip' => '', 157 'ips' => '', 127 158 'country_name' => '', 159 'country_names' => '', 128 160 'country_code' => '', 161 'country_codes' => '', 129 162 'state_code' => '', 163 'state_codes' => '', 164 'cities' => '', 130 165 'city' => '', 131 166 'miles' => '', 132 'kilometers' => ''167 'kilometers' => '' 133 168 ), $atts)); 134 169 $user_ip = wpgc_get_ip_address(); … … 151 186 switch( $condition ) { 152 187 case 'env': 153 return $_ENV;188 return implode('<br>',$_ENV); 154 189 break; 155 190 case 'database_date' : … … 199 234 return $user_distance_kilometers; 200 235 break; 201 case 'is_not_nearby':202 if (!$options['txt_home_latitude'] && !$options['txt_home_longitude'] && !$latitude && !$longitude) {203 return; // don't return content if we haven't specified our home base204 }236 case 'is_not_nearby': 237 if (!$options['txt_home_latitude'] && !$options['txt_home_longitude'] && !$latitude && !$longitude) { 238 return; // don't return content if we haven't specified our home base 239 } 205 240 if ($latitude && longitude) { 206 241 $compare_lat=$latitude; … … 227 262 } 228 263 } 229 break;230 case 'is_nearby':264 break; 265 case 'is_nearby': 231 266 // will assume home lat and lon if no lat and lon are specified in the shortcode atts 232 if (!$options['txt_home_latitude'] && !$options['txt_home_longitude'] && !$latitude && !$longitude) {233 return; // don't return content if we haven't specified our home base234 }267 if (!$options['txt_home_latitude'] && !$options['txt_home_longitude'] && !$latitude && !$longitude) { 268 return; // don't return content if we haven't specified our home base 269 } 235 270 if ($latitude && longitude) { 236 271 $compare_lat=$latitude; … … 257 292 } 258 293 } 259 break;294 break; 260 295 case 'is_within': 261 296 if (!$options['txt_home_latitude'] && !$options['txt_home_longitude']) { … … 279 314 } 280 315 break; 316 case 'is_not_cities': 317 $is_not_city=wpgc_csv_find($cities,$loc_arr['city_name']); 318 if ($is_not_city==false) { 319 return $content; 320 } 321 break; 281 322 case 'is_not_city': 282 if ($city!=$loc_arr['city_name']) { 323 $is_not_city=wpgc_csv_find($city,$loc_arr['city_name']); 324 if ($is_not_city==false) { 283 325 return $content; 284 326 } … … 289 331 } 290 332 break; 333 case 'is_not_state_codes': 334 $found=wpgc_csv_find($states,$loc_arr['state_code']); 335 if ($found==false) { 336 return $content; 337 } 338 break; 291 339 case 'is_not_country_name': 292 340 if ($country_name!=$loc_arr['country_name']) { … … 294 342 } 295 343 break; 344 case 'is_not_country_names': 345 $found=wpgc_csv_find($country_names,$loc_arr['country_name']); 346 if ($found==false) { 347 return $content; 348 } 349 break; 296 350 case 'is_not_country_code': 297 351 if ($country_code!=$loc_arr['country_code']) { … … 299 353 } 300 354 break; 355 case 'is_not_country_codes': 356 $found=wpgc_csv_find($country_codes,$loc_arr['country_codes']); 357 if ($found==false) { 358 return $content; 359 } 360 break; 301 361 case 'is_city_and_state_code': 302 362 if ($city==$loc_arr['city_name'] && $state_code!=$loc_arr['state_code']) { … … 309 369 } 310 370 break; 371 case 'is_cities': 372 $found=wpgc_csv_find($cities,$loc_arr['city_name']); 373 if ($found) { 374 return $content; 375 } 376 break; 311 377 case 'is_state_code': 312 378 if ($state_code==$loc_arr['state_code']) { … … 314 380 } 315 381 break; 382 case 'is_state_code': 383 $found=wpgc_csv_find($state_codes,$loc_arr['state_code']); 384 if ($state_code==$loc_arr['state_code']) { 385 return $content; 386 } 387 break; 316 388 case 'is_country_name': 317 389 if ($country_name==$loc_arr['country_name']) { … … 319 391 } 320 392 break; 393 case 'is_country_names': 394 $found=wpgc_csv_find($country_names,$loc_arr['country_name']); 395 if ($found) { 396 return $content; 397 } 398 break; 321 399 case 'is_country_code': 322 400 if ($country_code==$loc_arr['country_code']) { … … 324 402 } 325 403 break; 404 case 'is_country_code': 405 $found=wpgc_csv_find($country_codes,$loc_arr['country_code']); 406 if ($found) { 407 return $content; 408 } 409 break; 326 410 case 'is_ip': 327 if ($ip==$user_ip) { 328 return $content; 329 } 330 break; 411 if ($ip==$user_ip) { 412 return $content; 413 } 414 break; 415 case 'is_ips': 416 $found=wpgc_csv_find($ips,$user_ip); 417 if ($found) { 418 return $content; 419 } 420 break; 331 421 case 'is_not_ip': 332 if ($ip!=$user_ip) { 333 return $content; 334 } 335 break; 336 422 if ($ip!=$user_ip) { 423 return $content; 424 } 425 break; 426 case 'is_not_ip': 427 $found=wpgc_csv_find($ips,$user_ip); 428 if ($found==false) { 429 return $content; 430 } 431 break; 337 432 default: 338 433 } … … 353 448 add_shortcode("wpgc_is_city_and_state_code", "wpgc_is_city_and_state_code"); 354 449 add_shortcode("wpgc_is_ip", "wpgc_is_ip"); 450 add_shortcode("wpgc_is_ips", "wpgc_is_ips"); 355 451 add_shortcode("wpgc_is_not_ip", "wpgc_is_not_ip"); 452 add_shortcode("wpgc_is_not_ips", "wpgc_is_not_ips"); 356 453 add_shortcode("wpgc_is_city", "wpgc_is_city"); 454 add_shortcode("wpgc_is_cities", "wpgc_is_cities"); 455 add_shortcode("wpgc_is_not_cities", "wpgc_is_not_cities"); 357 456 add_shortcode("wpgc_is_not_city", "wpgc_is_not_city"); 358 457 add_shortcode("wpgc_is_nearby", "wpgc_is_nearby"); … … 360 459 add_shortcode("wpgc_is_within", "wpgc_is_within"); 361 460 add_shortcode("wpgc_is_country_name", "wpgc_is_country_name"); 461 add_shortcode("wpgc_is_country_names", "wpgc_is_country_names"); 362 462 add_shortcode("wpgc_is_country_code", "wpgc_is_country_code"); 463 add_shortcode("wpgc_is_country_codes", "wpgc_is_country_codes"); 363 464 add_shortcode("wpgc_is_state_code", "wpgc_is_state_code"); 465 add_shortcode("wpgc_is_state_codes", "wpgc_is_state_codes"); 364 466 add_shortcode("wpgc_is_not_country_name", "wpgc_is_not_country_name"); 467 add_shortcode("wpgc_is_not_country_names", "wpgc_is_not_country_names"); 365 468 add_shortcode("wpgc_is_not_country_code", "wpgc_is_not_country_code"); 469 add_shortcode("wpgc_is_not_country_codes", "wpgc_is_not_country_codes"); 366 470 add_shortcode("wpgc_is_not_state_code", "wpgc_is_not_state_code"); 471 add_shortcode("wpgc_is_not_state_codes", "wpgc_is_not_state_codes"); 367 472 368 473 // delete options table entries ONLY when plugin deactivated AND deleted … … 458 563 <li> [wpgc_is_city_and_state city="Yardley" state_code="PA"] 459 564 <li> [wpgc_is_ip ip="xx.xx.xx.xx"] 565 <li> [wpgc_is_ips ips="xx.xx.xx.xx,aa.bb.cc.dd"] 460 566 <li> [wpgc_is_not_ip ip="xx.xx.xx.xx"] 461 567 <li> [wpgc_is_city city=""] 568 <li> [wpgc_is_not_cities" city="cityone,citytwo,citythree"] 462 569 <li> [wpgc_is_not_city" city=""] 463 570 <li> [wpgc_is_nearby"] - Uses the value you specify in the Nearby Range setting from the administrative panel … … 492 599 <label for="chk_enable_plugin">Enable WP Geocode Plugin</label> 493 600 601 </td> 602 </tr> 603 <tr> 604 <th scope="row">Your Google Maps API Key</th> 605 <td> 606 <label><input size=40 name="wpgc_options[txt_gmaps_key]" value="<?php echo $options['txt_gmaps_key'];?>"> 607 <span style="color:#666666;margin-left:2px;">This is used when displaying Google Maps. See <a href=https://developers.google.com/maps/signup>https://developers.google.com/maps/signup</a> for more information.</span> 494 608 </td> 495 609 </tr> … … 713 827 714 828 function wpgc_validate_options($input) { 829 $input['txt_gmap_key'] = wp_filter_nohtml_kses($input['txt_gmap_key']); 715 830 $input['txt_def_city'] = wp_filter_nohtml_kses($input['txt_def_city']); 716 831 $input['txt_def_state_code'] = wp_filter_nohtml_kses($input['txt_def_state_code']); … … 841 956 return ($miles ? ($km * 0.621371192) : $km); 842 957 }//end function distance 958 959 function wpgc_csv_find($string1,$string2) { 960 // string1 is a csv list eg: one,two,three 961 // string2 is a static value 962 963 $strarr = explode(',',$string1); 964 foreach($strarr as $ii) { 965 if(trim(strtolower($ii)) == trim(strtolower($string2))) { 966 return true; 967 } 968 } 969 return false; 970 } // end function wpgc_find_string_in_array
Note: See TracChangeset
for help on using the changeset viewer.