Plugin Directory

Changeset 616905


Ignore:
Timestamp:
10/24/2012 03:57:37 PM (13 years ago)
Author:
mikelynn
Message:

Add postal_code shortcodes

Location:
wpgeocode/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wpgeocode/trunk/readme.txt

    r616171 r616905  
    44Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GDQD948MQ3G3G
    55Tags: geocode, geocode filter, geotag, geomarketing, geomarking, geolocation, geofilter, location, local marketing, keywords
    6 Version: 1.0.5
     6Version: 1.0.7
    77Requires at least: 3.0
    88Tested up to: 3.0.1
     
    8888== Change Log ==
    8989
     90= 1.0.7 =
     91* Added support for postal code shortcodes [wpgc_postal_code],[wpgc_is_postal_code],[wpgc_is_not_postal_code postal_code="12342"],[wpgc_is_postal_code postal_code="12322"],[wpgc_is_not_postal_codes postal_codes="19232,12323"]
     92
    9093= 1.0.6 =
    9194* Fix conditional shortcode wpgc_is_not_country_codes
     
    130133= 1.0.6 =
    131134* Fixed conditional shortcode for is_not_country_codes
     135
     136= 1.0.7 =
     137* Upgrade for postal_code support
  • wpgeocode/trunk/wpgeocode.php

    r616171 r616905  
    55Tags: geocode, geotagging, geolocation, geotags, latitude, longitude, city, state, geomarketing, geolocation marketing
    66Description: Use WPGeocode to customize the content of your blog based on the location of your readers.
    7 Version: 1.0.6
     7Version: 1.0.7
    88Author: Michael Lynn
    99Author URI: http://www.mlynn.org/
     
    5252    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'city'));
    5353}
     54function wpgc_shortcode_postal_code($atts, $content="") {
     55    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'postal_code'));
     56}
    5457function wpgc_shortcode_longitude($atts, $content="") {
    5558    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'longitude'));
     
    98101    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_state_code'));
    99102}
     103function wpgc_is_not_postal_codes($atts, $content="") {
     104    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_postal_codes'));
     105}
     106function wpgc_is_not_postal_code($atts, $content="") {
     107    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_postal_code'));
     108}
    100109function wpgc_is_not_city($atts, $content="") {
    101110    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_not_city'));
     
    130139function wpgc_is_state_code($atts, $content="") {
    131140    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_state_code'));
     141}
     142function wpgc_is_postal_codes($atts, $content="") {
     143    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_postal_codes'));
     144}
     145function wpgc_is_postal_code($atts, $content="") {
     146    return do_shortcode(wpgc_conditional_shortcode($atts, $content, 'is_postal_code'));
    132147}
    133148function wpgc_is_city($atts, $content="") {
     
    165180                'state_code' => '',
    166181                'state_codes' => '',
     182                'postal_code' => '',
     183                'postal_codes' => '',
    167184                'cities' => '',
    168185                'city' => '',
     
    176193                $user_longitude = '';
    177194                $user_state_code = '';
     195                $user_postal_code = '';
    178196                $user_city = '';
    179197                $user_country_name = '';
     
    183201                $user_longitude = $loc_arr['longitude'];
    184202                $user_state_code = $loc_arr['state_code'];
     203                $user_postal_code = $loc_arr['postal_code'];
    185204                $user_city = $loc_arr['city_name'];
    186205                $user_country_name = $loc_arr['country_name'];
     
    220239        case 'state_code' :
    221240            return wpgc_case_convert($user_state_code,$options['rdo_case'],$options['txt_filter_cls']);
     241            break;
     242        case 'postal_code' :
     243            return wpgc_case_convert($user_postal_code,$options['rdo_case'],$options['txt_filter_cls']);
    222244            break;
    223245        case 'distance_miles':
     
    339361                return $content;
    340362            }
     363        case 'is_not_postal_code':
     364            if ($postal_code!=$loc_arr['postal_code']) {
     365                return $content;
     366            }
     367            break;
     368        case 'is_not_postal_codes':
     369            $found=wpgc_csv_find($postals,$loc_arr['postal_code']);
     370            if ($found==false) {
     371                return $content;
     372            }
    341373            break;
    342374        case 'is_not_country_name':
     
    383415            }
    384416            break;
    385         case 'is_state_code':
     417        case 'is_state_codes':
    386418            $found=wpgc_csv_find($state_codes,$loc_arr['state_code']);
    387419            if ($state_code==$loc_arr['state_code']) {
     420                return $content;
     421            }
     422        case 'is_postal_code':
     423            if ($postal_code==$loc_arr['state_code']) {
     424                return $content;
     425            }
     426            break;
     427        case 'is_postal_codes':
     428            $found=wpgc_csv_find($postal_codes,$loc_arr['postal_code']);
     429            if ($postal_code==$loc_arr['postal_code']) {
    388430                return $content;
    389431            }
     
    445487add_shortcode("wpgc_latitude", "wpgc_shortcode_latitude");
    446488add_shortcode("wpgc_city", "wpgc_shortcode_city");
     489add_shortcode("wpgc_postal_code", "wpgc_shortcode_postal_code");
    447490add_shortcode("wpgc_ip", "wpgc_shortcode_ip");
    448491add_shortcode("wpgc_country_name", "wpgc_shortcode_country_name");
     
    468511add_shortcode("wpgc_is_state_code", "wpgc_is_state_code");
    469512add_shortcode("wpgc_is_state_codes", "wpgc_is_state_codes");
     513add_shortcode("wpgc_is_postal_code", "wpgc_is_postal_code");
     514add_shortcode("wpgc_is_postal_codes", "wpgc_is_postal_codes");
     515add_shortcode("wpgc_is_not_postal_code", "wpgc_is_not_postal_code");
     516add_shortcode("wpgc_is_not_postal_codes", "wpgc_is_not_postal_codes");
    470517add_shortcode("wpgc_is_not_country_name", "wpgc_is_not_country_name");
    471518add_shortcode("wpgc_is_not_country_names", "wpgc_is_not_country_names");
     
    555602<li> [wpgc_ip] - IP Address of the reader</li>
    556603<li> [wpgc_city] - City of the reader
     604<li> [wpgc_postal_code] - Postal Code (zip) of the reader
    557605<li> [wpgc_state_code] - Two letter State code of the reader
    558606<li> [wpgc_country_name] - Country name of the reader
     
    566614<ul STYLE="list-style-type: square; list-style-position: inside">
    567615<li> [wpgc_is_city_and_state city="Yardley" state_code="PA"]
     616<li> [wpgc_is_postal_code postal_code="90120"]
     617<li> [wpgc_is_postal_codes postal_code="90120,19067"]
     618<li> [wpgc_is_not_postal_code postal_codes="90120"]
     619<li> [wpgc_is_not_postal_codes postal_codes="90120,19067"]
    568620<li> [wpgc_is_ip ip="xx.xx.xx.xx"]
    569621<li> [wpgc_is_ips ip="xx.xx.xx.xx"]
     
    661713                        <label><input name="wpgc_options[txt_def_state_code]" value="<?php echo $options['txt_def_state'];?>">
    662714                        <span style="color:#666666;margin-left:2px;">Use this phrase for the state code if we can't geolocate the reader (shortcode [wpgc_state_code])</span><br />
     715                    </td>
     716                </tr>
     717                <tr>
     718                    <th scope="row">Default Postal Code Phrase</th>
     719                    <td>
     720                        <label><input name="wpgc_options[txt_def_postal_code]" value="<?php echo $options['txt_def_postal'];?>">
     721                        <span style="color:#666666;margin-left:2px;">Use this phrase for the postal code if we can't geolocate the reader (shortcode [wpgc_postal_code])</span><br />
    663722                    </td>
    664723                </tr>
     
    891950    $location_info['city_name']    = (isset($record->city)) ? $record->city : '~';
    892951    $location_info['state_code']   = (isset($record->region)) ? strtoupper($record->region) : '~';
     952    $location_info['postal_code']   = (isset($record->postal_code)) ? strtoupper($record->postal_code) : '~';
    893953    $location_info['country_name'] = (isset($record->country_name)) ? $record->country_name : '~';
    894954    $location_info['country_code'] = (isset($record->country_code)) ? strtoupper($record->country_code) : '~';
Note: See TracChangeset for help on using the changeset viewer.