Plugin Directory

Changeset 951843


Ignore:
Timestamp:
07/20/2014 02:42:10 PM (12 years ago)
Author:
sutherlandboswell
Message:

Fixed bug caused by emojis

Location:
foursquare-venue
Files:
2 deleted
2 edited
6 copied

Legend:

Unmodified
Added
Removed
  • foursquare-venue/tags/3.0.2/foursquare-venue.php

    r946538 r951843  
    66Author: Sutherland Boswell
    77Author URI: http://sutherlandboswell.com
    8 Version: 3.0.1
     8Version: 3.0.2
    99License: GPL2
    1010*/
     
    2727// Define
    2828define( 'FOURSQUARE_VENUE_PATH', dirname(__FILE__) );
    29 define( 'FOURSQUARE_VENUE_VERSION', '3.0.1' );
     29define( 'FOURSQUARE_VENUE_VERSION', '3.0.2' );
    3030
    3131// Includes
     
    196196    function get_replacements( $venue ) {
    197197        $replacements = array(
    198             'id'               => $venue->id,
    199             'name'             => $venue->name,
    200             'phone'            => $venue->contact->phone,
    201             'formatted_phone'  => $venue->contact->formattedPhone,
    202             'twitter'          => $venue->contact->twitter,
    203             'address'          => $venue->location->address,
    204             'cross_street'     => $venue->location->crossStreet,
    205             'lat'              => $venue->location->lat,
    206             'lng'              => $venue->location->lng,
    207             'postal_code'      => $venue->location->postalCode,
    208             'cc'               => $venue->location->cc,
    209             'city'             => $venue->location->city,
    210             'state'            => $venue->location->state,
    211             'country'          => $venue->location->country,
    212             'foursquare_url'   => $venue->canonicalUrl,
    213             'short_url'        => $venue->shortUrl,
    214             'website_url'      => $venue->url,
    215             'checkins_count'   => $venue->stats->checkinsCount,
    216             'users_count'      => $venue->stats->usersCount,
    217             'tip_count'        => $venue->stats->tipCount,
    218             'likes_count'      => $venue->likes->count,
    219             'likes_summary'    => $venue->likes->summary,
    220             'rating'           => $venue->rating,
    221             'rating_signals'   => $venue->ratingSignals,
    222             'here_now_count'   => $venue->hereNow->count,
    223             'here_now_summary' => $venue->hereNow->summary,
    224             'description'      => $venue->description,
    225             'mayor_count'      => $venue->mayor->count,
    226             'mayor_id'         => $venue->mayor->user->id,
    227             'mayor_url'        => 'https://foursquare.com/user/' . $venue->mayor->user->id,
    228             'mayor_first_name' => $venue->mayor->user->firstName,
    229             'mayor_last_name'  => $venue->mayor->user->lastName,
    230             'mayor_gender'     => $venue->mayor->user->gender,
    231             'mayor_photo'      => $venue->mayor->user->photo->prefix . '100x100'. $venue->mayor->user->photo->suffix
     198            'id'               => ( isset( $venue->id ) ? $venue->id : '' ),
     199            'name'             => ( isset( $venue->name ) ? $venue->name : '' ),
     200            'phone'            => ( isset( $venue->contact->phone ) ? $venue->contact->phone : '' ),
     201            'formatted_phone'  => ( isset( $venue->contact->formattedPhone ) ? $venue->contact->formattedPhone : '' ),
     202            'twitter'          => ( isset( $venue->contact->twitter ) ? $venue->contact->twitter : '' ),
     203            'address'          => ( isset( $venue->location->address ) ? $venue->location->address : '' ),
     204            'cross_street'     => ( isset( $venue->location->crossStreet ) ? $venue->location->crossStreet : '' ),
     205            'lat'              => ( isset( $venue->location->lat ) ? $venue->location->lat : '' ),
     206            'lng'              => ( isset( $venue->location->lng ) ? $venue->location->lng : '' ),
     207            'postal_code'      => ( isset( $venue->location->postalCode ) ? $venue->location->postalCode : '' ),
     208            'cc'               => ( isset( $venue->location->cc ) ? $venue->location->cc : '' ),
     209            'city'             => ( isset( $venue->location->city ) ? $venue->location->city : '' ),
     210            'state'            => ( isset( $venue->location->state ) ? $venue->location->state : '' ),
     211            'country'          => ( isset( $venue->location->country ) ? $venue->location->country : '' ),
     212            'foursquare_url'   => ( isset( $venue->canonicalUrl ) ? $venue->canonicalUrl : '' ),
     213            'short_url'        => ( isset( $venue->shortUrl ) ? $venue->shortUrl : '' ),
     214            'website_url'      => ( isset( $venue->url ) ? $venue->url : '' ),
     215            'checkins_count'   => ( isset( $venue->stats->checkinsCount ) ? $venue->stats->checkinsCount : '' ),
     216            'users_count'      => ( isset( $venue->stats->usersCount ) ? $venue->stats->usersCount : '' ),
     217            'tip_count'        => ( isset( $venue->stats->tipCount ) ? $venue->stats->tipCount : '' ),
     218            'likes_count'      => ( isset( $venue->likes->count ) ? $venue->likes->count : '' ),
     219            'likes_summary'    => ( isset( $venue->likes->summary ) ? $venue->likes->summary : '' ),
     220            'rating'           => ( isset( $venue->rating ) ? $venue->rating : '' ),
     221            'rating_signals'   => ( isset( $venue->ratingSignals ) ? $venue->ratingSignals : '' ),
     222            'here_now_count'   => ( isset( $venue->hereNow->count ) ? $venue->hereNow->count : '' ),
     223            'here_now_summary' => ( isset( $venue->hereNow->summary ) ? $venue->hereNow->summary : '' ),
     224            'description'      => ( isset( $venue->description ) ? $venue->description : '' ),
     225            'mayor_count'      => ( isset( $venue->mayor->count ) ? $venue->mayor->count : '' ),
     226            'mayor_id'         => ( isset( $venue->mayor->user->id ) ? $venue->mayor->user->id : '' ),
     227            'mayor_url'        => ( isset( $venue->mayor->user->id ) ? 'https://foursquare.com/user/' . $venue->mayor->user->id : '' ),
     228            'mayor_first_name' => ( isset( $venue->mayor->user->firstName ) ? $venue->mayor->user->firstName : '' ),
     229            'mayor_last_name'  => ( isset( $venue->mayor->user->lastName ) ? $venue->mayor->user->lastName : '' ),
     230            'mayor_gender'     => ( isset( $venue->mayor->user->gender ) ? $venue->mayor->user->gender : '' ),
     231            'mayor_photo'      => ( isset( $venue->mayor->user->photo->prefix ) ? $venue->mayor->user->photo->prefix . '100x100'. $venue->mayor->user->photo->suffix : '' )
    232232        );
    233233        return apply_filters( 'foursquare_venue/replacements', $replacements, $venue );
     234    }
     235
     236    /**
     237     * Cache the venue data using WP transients
     238     * @param  string  $id   The Foursquare venue ID
     239     * @param  object  $data The venue data
     240     * @return boolean       True if data was saved, false otherwise
     241     */
     242    function save_venue_cache( $id, $data ) {
     243        // The name our transient will be stored as
     244        $transient_name = 'foursquare_venue_' . $id;
     245        // Serialize the data, then base 64 encode it to handle emoji and other characters
     246        $data = base64_encode( serialize( $data ) );
     247        // The number of seconds to store the transient
     248        $expiration = 15 * 60;
     249        // Save it
     250        return set_transient( $transient_name, $data, $expiration );
     251    }
     252
     253    /**
     254     * Get the venue data from cache if available
     255     * @param  string $id The Foursquare Venue ID
     256     * @return mixed      A Foursquare data object or false if no cache
     257     */
     258    function get_venue_cache( $id ) {
     259        // The name our transient is stored as
     260        $transient_name = 'foursquare_venue_' . $id;
     261        // Pull the data
     262        $data = get_transient( $transient_name );
     263        // If we have data, and it isn't already an object, decode and unserialize it
     264        if ( $data && !is_object( $data ) ) {
     265            $data = unserialize( base64_decode( $data ) );
     266        }
     267        // Give the data
     268        return $data;
    234269    }
    235270
     
    241276    function get_venue( $id ) {
    242277        // Check for cached data
    243         $transient_name = 'foursquare_venue_' . $id;
    244         $data = get_transient( $transient_name );
     278        $data = $this->get_venue_cache( $id );
    245279        // If we don't have data, make an API request
    246280        if ( $data === false ) {
     
    255289                } else {
    256290                    $data = $data->response->venue;
    257                     set_transient( $transient_name, $data, 15 * 60 );
     291                    $this->save_venue_cache( $id, $data );
    258292                }
    259293            }
  • foursquare-venue/tags/3.0.2/readme.txt

    r946538 r951843  
    55Requires at least: 3.5
    66Tested up to: 3.9.1
    7 Stable tag: 3.0.1
     7Stable tag: 3.0.2
    88
    99Foursquare Venue is a simple but powerful plugin for displaying any venue's Foursquare stats.
     
    4444
    4545== Changelog ==
     46
     47= 3.0.2 =
     48* Fixed bug caused by emojis in Foursquare data
     49* Fixed warnings shown when WordPress is in debugging mode
    4650
    4751= 3.0.1 =
  • foursquare-venue/trunk/foursquare-venue.php

    r946538 r951843  
    66Author: Sutherland Boswell
    77Author URI: http://sutherlandboswell.com
    8 Version: 3.0.1
     8Version: 3.0.2
    99License: GPL2
    1010*/
     
    2727// Define
    2828define( 'FOURSQUARE_VENUE_PATH', dirname(__FILE__) );
    29 define( 'FOURSQUARE_VENUE_VERSION', '3.0.1' );
     29define( 'FOURSQUARE_VENUE_VERSION', '3.0.2' );
    3030
    3131// Includes
     
    196196    function get_replacements( $venue ) {
    197197        $replacements = array(
    198             'id'               => $venue->id,
    199             'name'             => $venue->name,
    200             'phone'            => $venue->contact->phone,
    201             'formatted_phone'  => $venue->contact->formattedPhone,
    202             'twitter'          => $venue->contact->twitter,
    203             'address'          => $venue->location->address,
    204             'cross_street'     => $venue->location->crossStreet,
    205             'lat'              => $venue->location->lat,
    206             'lng'              => $venue->location->lng,
    207             'postal_code'      => $venue->location->postalCode,
    208             'cc'               => $venue->location->cc,
    209             'city'             => $venue->location->city,
    210             'state'            => $venue->location->state,
    211             'country'          => $venue->location->country,
    212             'foursquare_url'   => $venue->canonicalUrl,
    213             'short_url'        => $venue->shortUrl,
    214             'website_url'      => $venue->url,
    215             'checkins_count'   => $venue->stats->checkinsCount,
    216             'users_count'      => $venue->stats->usersCount,
    217             'tip_count'        => $venue->stats->tipCount,
    218             'likes_count'      => $venue->likes->count,
    219             'likes_summary'    => $venue->likes->summary,
    220             'rating'           => $venue->rating,
    221             'rating_signals'   => $venue->ratingSignals,
    222             'here_now_count'   => $venue->hereNow->count,
    223             'here_now_summary' => $venue->hereNow->summary,
    224             'description'      => $venue->description,
    225             'mayor_count'      => $venue->mayor->count,
    226             'mayor_id'         => $venue->mayor->user->id,
    227             'mayor_url'        => 'https://foursquare.com/user/' . $venue->mayor->user->id,
    228             'mayor_first_name' => $venue->mayor->user->firstName,
    229             'mayor_last_name'  => $venue->mayor->user->lastName,
    230             'mayor_gender'     => $venue->mayor->user->gender,
    231             'mayor_photo'      => $venue->mayor->user->photo->prefix . '100x100'. $venue->mayor->user->photo->suffix
     198            'id'               => ( isset( $venue->id ) ? $venue->id : '' ),
     199            'name'             => ( isset( $venue->name ) ? $venue->name : '' ),
     200            'phone'            => ( isset( $venue->contact->phone ) ? $venue->contact->phone : '' ),
     201            'formatted_phone'  => ( isset( $venue->contact->formattedPhone ) ? $venue->contact->formattedPhone : '' ),
     202            'twitter'          => ( isset( $venue->contact->twitter ) ? $venue->contact->twitter : '' ),
     203            'address'          => ( isset( $venue->location->address ) ? $venue->location->address : '' ),
     204            'cross_street'     => ( isset( $venue->location->crossStreet ) ? $venue->location->crossStreet : '' ),
     205            'lat'              => ( isset( $venue->location->lat ) ? $venue->location->lat : '' ),
     206            'lng'              => ( isset( $venue->location->lng ) ? $venue->location->lng : '' ),
     207            'postal_code'      => ( isset( $venue->location->postalCode ) ? $venue->location->postalCode : '' ),
     208            'cc'               => ( isset( $venue->location->cc ) ? $venue->location->cc : '' ),
     209            'city'             => ( isset( $venue->location->city ) ? $venue->location->city : '' ),
     210            'state'            => ( isset( $venue->location->state ) ? $venue->location->state : '' ),
     211            'country'          => ( isset( $venue->location->country ) ? $venue->location->country : '' ),
     212            'foursquare_url'   => ( isset( $venue->canonicalUrl ) ? $venue->canonicalUrl : '' ),
     213            'short_url'        => ( isset( $venue->shortUrl ) ? $venue->shortUrl : '' ),
     214            'website_url'      => ( isset( $venue->url ) ? $venue->url : '' ),
     215            'checkins_count'   => ( isset( $venue->stats->checkinsCount ) ? $venue->stats->checkinsCount : '' ),
     216            'users_count'      => ( isset( $venue->stats->usersCount ) ? $venue->stats->usersCount : '' ),
     217            'tip_count'        => ( isset( $venue->stats->tipCount ) ? $venue->stats->tipCount : '' ),
     218            'likes_count'      => ( isset( $venue->likes->count ) ? $venue->likes->count : '' ),
     219            'likes_summary'    => ( isset( $venue->likes->summary ) ? $venue->likes->summary : '' ),
     220            'rating'           => ( isset( $venue->rating ) ? $venue->rating : '' ),
     221            'rating_signals'   => ( isset( $venue->ratingSignals ) ? $venue->ratingSignals : '' ),
     222            'here_now_count'   => ( isset( $venue->hereNow->count ) ? $venue->hereNow->count : '' ),
     223            'here_now_summary' => ( isset( $venue->hereNow->summary ) ? $venue->hereNow->summary : '' ),
     224            'description'      => ( isset( $venue->description ) ? $venue->description : '' ),
     225            'mayor_count'      => ( isset( $venue->mayor->count ) ? $venue->mayor->count : '' ),
     226            'mayor_id'         => ( isset( $venue->mayor->user->id ) ? $venue->mayor->user->id : '' ),
     227            'mayor_url'        => ( isset( $venue->mayor->user->id ) ? 'https://foursquare.com/user/' . $venue->mayor->user->id : '' ),
     228            'mayor_first_name' => ( isset( $venue->mayor->user->firstName ) ? $venue->mayor->user->firstName : '' ),
     229            'mayor_last_name'  => ( isset( $venue->mayor->user->lastName ) ? $venue->mayor->user->lastName : '' ),
     230            'mayor_gender'     => ( isset( $venue->mayor->user->gender ) ? $venue->mayor->user->gender : '' ),
     231            'mayor_photo'      => ( isset( $venue->mayor->user->photo->prefix ) ? $venue->mayor->user->photo->prefix . '100x100'. $venue->mayor->user->photo->suffix : '' )
    232232        );
    233233        return apply_filters( 'foursquare_venue/replacements', $replacements, $venue );
     234    }
     235
     236    /**
     237     * Cache the venue data using WP transients
     238     * @param  string  $id   The Foursquare venue ID
     239     * @param  object  $data The venue data
     240     * @return boolean       True if data was saved, false otherwise
     241     */
     242    function save_venue_cache( $id, $data ) {
     243        // The name our transient will be stored as
     244        $transient_name = 'foursquare_venue_' . $id;
     245        // Serialize the data, then base 64 encode it to handle emoji and other characters
     246        $data = base64_encode( serialize( $data ) );
     247        // The number of seconds to store the transient
     248        $expiration = 15 * 60;
     249        // Save it
     250        return set_transient( $transient_name, $data, $expiration );
     251    }
     252
     253    /**
     254     * Get the venue data from cache if available
     255     * @param  string $id The Foursquare Venue ID
     256     * @return mixed      A Foursquare data object or false if no cache
     257     */
     258    function get_venue_cache( $id ) {
     259        // The name our transient is stored as
     260        $transient_name = 'foursquare_venue_' . $id;
     261        // Pull the data
     262        $data = get_transient( $transient_name );
     263        // If we have data, and it isn't already an object, decode and unserialize it
     264        if ( $data && !is_object( $data ) ) {
     265            $data = unserialize( base64_decode( $data ) );
     266        }
     267        // Give the data
     268        return $data;
    234269    }
    235270
     
    241276    function get_venue( $id ) {
    242277        // Check for cached data
    243         $transient_name = 'foursquare_venue_' . $id;
    244         $data = get_transient( $transient_name );
     278        $data = $this->get_venue_cache( $id );
    245279        // If we don't have data, make an API request
    246280        if ( $data === false ) {
     
    255289                } else {
    256290                    $data = $data->response->venue;
    257                     set_transient( $transient_name, $data, 15 * 60 );
     291                    $this->save_venue_cache( $id, $data );
    258292                }
    259293            }
  • foursquare-venue/trunk/readme.txt

    r946538 r951843  
    55Requires at least: 3.5
    66Tested up to: 3.9.1
    7 Stable tag: 3.0.1
     7Stable tag: 3.0.2
    88
    99Foursquare Venue is a simple but powerful plugin for displaying any venue's Foursquare stats.
     
    4444
    4545== Changelog ==
     46
     47= 3.0.2 =
     48* Fixed bug caused by emojis in Foursquare data
     49* Fixed warnings shown when WordPress is in debugging mode
    4650
    4751= 3.0.1 =
Note: See TracChangeset for help on using the changeset viewer.