Plugin Directory

Changeset 946349


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

Total rewrite for version 3.0

Location:
foursquare-venue
Files:
13 added
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • foursquare-venue/trunk/foursquare-venue.php

    r850120 r946349  
    66Author: Sutherland Boswell
    77Author URI: http://sutherlandboswell.com
    8 Version: 2.2.2
     8Version: 3.0
    99License: GPL2
    1010*/
    11 /*  Copyright 2010 Sutherland Boswell  (email : [email protected])
     11/*  Copyright 2014 Sutherland Boswell  (email : [email protected])
    1212
    1313    This program is free software; you can redistribute it and/or modify
     
    2525*/
    2626
    27 // Set Default Options
    28 
    29 register_activation_hook(__FILE__,'foursquare_venue_activate');
    30 register_deactivation_hook(__FILE__,'foursquare_venue_deactivate');
    31 
    32 function foursquare_venue_activate() {
    33     add_option('foursquare_venue_client_id','');
    34     add_option('foursquare_venue_client_secret','');
    35     add_option('foursquare_venue_show_title','');
    36     add_option('foursquare_venue_stats_title','Foursquare Stats');
    37     add_option('foursquare_show_venue_name','');
    38     add_option('foursquare_show_venue_icon','');
    39     add_option('foursquare_show_here_now','1');
    40     add_option('foursquare_show_here_now_text','');
    41     add_option('foursquare_show_total','1');
    42     add_option('foursquare_show_total_text','');
    43     add_option('foursquare_show_mayor','1');
    44     add_option('foursquare_show_mayor_text','');
    45     add_option('foursquare_link_mayor','1');
    46     add_option('foursquare_show_mayor_photo','1');
    47     add_option('foursquare_mayor_photo_size','32');
    48     add_option('foursquare_venue_stats_width','');
    49     add_option('foursquare_venue_stats_align','');
     27// Define
     28define( 'FOURSQUARE_VENUE_PATH', dirname(__FILE__) );
     29define( 'FOURSQUARE_VENUE_VERSION', '3.0' );
     30
     31// Includes
     32require_once( FOURSQUARE_VENUE_PATH . '/php/class-refactored-settings.php' );
     33require_once( FOURSQUARE_VENUE_PATH . '/php/widget.php' );
     34
     35// Plugin Class
     36class Foursquare_Venue_Plugin {
     37   
     38    function __construct() {
     39        /**
     40         * Settings
     41         */
     42        $settings_args = array(
     43            'file'    => __FILE__,
     44            'version' => FOURSQUARE_VENUE_VERSION,
     45            'name'    => 'Foursquare Venue',
     46            'slug'    => 'foursquare_venue',
     47            'options' => array(
     48                'api_key' => array(
     49                    'name'        => 'API Key',
     50                    'description' => '<a href="https://foursquare.com/developers/apps">Register your app</a> and enter your keys below.',
     51                    'fields'      => array(
     52                        'client_id' => array(
     53                            'name'        => 'Client ID',
     54                            'type'        => 'text',
     55                            'default'     => '',
     56                            'description' => ''
     57                        ),
     58                        'client_secret' => array(
     59                            'name'        => 'Client Secret',
     60                            'type'        => 'text',
     61                            'default'     => '',
     62                            'description' => ''
     63                        )
     64                    )
     65                ),
     66                'display' => array(
     67                    'name'        => 'Display',
     68                    'description' => 'These settings control how the widget and <code>[venue]</code> shortcode are displayed.',
     69                    'fields'      => array(
     70                        'template' => array(
     71                            'name'        => 'Template',
     72                            'type'        => 'textarea',
     73                            'class'       => 'code',
     74                            'default'     => '<a href="%%foursquare_url%%">%%name%%</a><br>' . PHP_EOL . '%%checkins_count%% check-ins<br>' . PHP_EOL . 'Rating: %%rating%%<br>' . PHP_EOL . '%%here_now_summary%%',
     75                            'description' => 'To view available placeholders, open the <a href="#" id="open-help-tab">Help</a> tab in the top right.<table class="foursquare-venue-template-preview-table"><tr><th>Preview</th></tr><tr><td><div id="foursquare-venue-template-preview"></div></td></tr></table>'
     76                        )
     77                    )
     78                ),
     79            )
     80        );
     81        $this->settings = new Refactored_Settings_0_4( $settings_args );
     82        /**
     83         * Add scripts and styles to settings page
     84         */
     85        add_action( 'admin_init', array( &$this, 'settings_scripts' ), 20 );
     86        /**
     87         * Add AJAX preview callback for settings page
     88         */
     89        add_action( 'wp_ajax_foursquare_venue_template_preview', array( &$this, 'template_preview_callback' ) );
     90        /**
     91         * Add Help tab
     92         */
     93        add_action( 'load-settings_page_foursquare_venue', array( &$this, 'add_help_tab' ) );
     94        /**
     95         * Register shortcode
     96         */
     97        add_shortcode( 'venue', array( &$this, 'venue_shortcode' ) );
     98        /**
     99         * Delete old settings
     100         */
     101        $this->delete_old_settings();
     102    }
     103
     104    /**
     105     * Deletes pre-3.0 settings
     106     */
     107    function delete_old_settings() {
     108        delete_option('foursquare_venue_client_id');
     109        delete_option('foursquare_venue_client_secret');
     110        delete_option('foursquare_venue_show_title');
     111        delete_option('foursquare_venue_stats_title');
     112        delete_option('foursquare_show_venue_name');
     113        delete_option('foursquare_show_venue_icon');
     114        delete_option('foursquare_show_here_now');
     115        delete_option('foursquare_show_here_now_text');
     116        delete_option('foursquare_show_total');
     117        delete_option('foursquare_show_total_text');
     118        delete_option('foursquare_show_mayor');
     119        delete_option('foursquare_show_mayor_text');
     120        delete_option('foursquare_link_mayor');
     121        delete_option('foursquare_show_mayor_photo');
     122        delete_option('foursquare_mayor_photo_size');
     123        delete_option('foursquare_venue_stats_width');
     124        delete_option('foursquare_venue_stats_align');
     125    }
     126
     127    /**
     128     * Adds javascript and CSS to the settings page
     129     * @return void
     130     */
     131    function settings_scripts() {
     132        wp_enqueue_script( 'foursquare-venue-settings-js', plugins_url( '/js/settings.js' , __FILE__ ), array( 'jquery' ), FOURSQUARE_VENUE_VERSION );
     133        wp_enqueue_style( 'foursquare-venue-admin-css', plugins_url( '/css/admin.css', __FILE__ ), false, FOURSQUARE_VENUE_VERSION );
     134    }
     135
     136    /**
     137     * The venue shortcode's callback function
     138     * @param  array  $atts Shortcode attributes
     139     * @return string       The shortcode's HTML
     140     */
     141    function venue_shortcode( $atts ) {
     142        extract(shortcode_atts(array(
     143            'id' => '',
     144        ), $atts));
     145        return $this->render_venue( $id );
     146    }
     147
     148    /**
     149     * Renders a venue's info as an HTML string
     150     * @param  string $id The Foursquare venue ID
     151     * @return string     An HTML string
     152     */
     153    function render_venue( $id ) {
     154        $venue = $this->get_venue( $id );
     155        return $this->fill_template( $venue, $this->settings->options['display']['template'] );
     156    }
     157
     158    /**
     159     * Callback function for the AJAX call that displays a preview of the venue template
     160     */
     161    function template_preview_callback() {
     162        // Security checks
     163        if ( !current_user_can( 'manage_options' ) ) die();
     164
     165        $template = $_POST['template'];
     166        $venue = $this->get_venue( '3fd66200f964a520d6f01ee3' );
     167
     168        echo $this->fill_template( $venue, $template );
     169        die();
     170    }
     171
     172    /**
     173     * Fills a template with venue data
     174     * @param  object $venue    The venue data retrieved from Foursquare
     175     * @param  string $template A template containing placeholders to be filled
     176     * @return string           The HTML containing filled in data
     177     */
     178    function fill_template( $venue, $template ) {
     179        if ( is_wp_error( $venue ) ) {
     180            $result = $venue->get_error_message();
     181        } else {
     182            $result = $template;
     183            $replacements = $this->get_replacements( $venue );
     184            foreach ( $replacements as $key => $value) {
     185                $result = str_replace( '%%' . $key . '%%', $value, $result );
     186            }
     187        }
     188        return $result;
     189    }
     190
     191    /**
     192     * Gets an array of values available for use in venue templates
     193     * @param  object $venue The venue data retrieved from foursquare
     194     * @return array         An array of keys available for replacement with real data as the value
     195     */
     196    function get_replacements( $venue ) {
     197        $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
     232        );
     233        return apply_filters( 'foursquare_venue/replacements', $replacements, $venue );
     234    }
     235
     236    /**
     237     * Get a venue's data from the Foursquare API or local cache
     238     * @param  string $id The Foursquare venue ID
     239     * @return object     The venue data
     240     */
     241    function get_venue( $id ) {
     242        // Check for cached data
     243        $transient_name = 'foursquare_venue_' . $id;
     244        $data = get_transient( $transient_name );
     245        // If we don't have data, make an API request
     246        if ( $data === false ) {
     247            $request_url = 'https://api.foursquare.com/v2/venues/' . $id . '?client_id=' . $this->settings->options['api_key']['client_id'] . '&client_secret=' . $this->settings->options['api_key']['client_secret'] . '&v=20140702';
     248            $response = wp_remote_get( $request_url, array( 'sslverify' => false ) );
     249            if( is_wp_error( $response ) ) {
     250                $data = $response;
     251            } else {
     252                $data = json_decode( $response['body'] );
     253                $data = $data->response->venue;
     254                set_transient( $transient_name, $data, 15 * 60 );
     255            }
     256        }
     257        // Give up the data
     258        return $data;
     259    }
     260
     261    /**
     262     * This callback adds the help tab's content to the settings page
     263     */
     264    function add_help_tab() {
     265        $screen = get_current_screen();
     266
     267        $venue = $this->get_venue( '3fd66200f964a520d6f01ee3' );
     268        if ( is_wp_error( $venue ) ) {
     269            $table = '<p><strong>' . __( 'Error:' ) . '</strong> ' . $venue->get_error_message() . '</p>';
     270        } else {
     271            $table = '<table class="foursquare-venue-replacements"><thead><tr><th>' . __( 'Placeholder' ) . '</th><td>' . __( 'Example Value' ) . '</td></tr></thead><tbody>';
     272            $replacements = $this->get_replacements( $venue );
     273            foreach ( $replacements as $key => $value ) {
     274                $table .= '<tr><th>%%' . $key . '%%</th><td>' . $value . '</td></tr>';
     275            }
     276            $table .= '</tbody></table>';
     277        }
     278
     279        // Add placeholder help tab
     280        $screen->add_help_tab( array(
     281            'id'    => 'foursquare_venue_placeholder_help_tab',
     282            'title' => __('Venue Placeholders'),
     283            'content'   => '<h2>' . __( 'Venue Placeholders' ) . '</h2><p>' . __( 'These placeholders will be replaced with the appropriate data in your display template.' ) . '</p>' . $table,
     284        ) );
     285        // Add shortcode help tab
     286        $screen->add_help_tab( array(
     287            'id'    => 'foursquare_venue_shortcode_help_tab',
     288            'title' => __('Venue Shortcode'),
     289            'content'   => '<h2>' . __( 'Venue Shortcode' ) . '</h2><p>' . __( 'The <code>[venue]</code> shortcode can be used to display venue information and stats from Foursquare.' ) . '</p><p>' . __( 'To use the shortcode you will need the venue\'s Foursquare ID. The ID is found at the end of the venue\'s Foursquare URL. For example, The White House\'s venue URL is <code>https://foursquare.com/v/the-white-house/3fd66200f964a520d6f01ee3</code>, which means the ID is <code>3fd66200f964a520d6f01ee3</code>.' ) . '</p>' . __( 'Once you have the venue ID, you can insert the shortcode with the venue ID included. Example: <code>[venue id="3fd66200f964a520d6f01ee3"]</code>' ) . '</p>'
     290        ) );
     291
     292        $screen->set_help_sidebar( '<p>' . __( 'For support, please visit the <a href="http://wordpress.org/support/plugin/foursquare-venue">WordPress forums</a>.' ) . '</p>' );
     293    }
     294
    50295}
    51296
    52 function foursquare_venue_deactivate() {
    53     delete_option('foursquare_venue_client_id');
    54     delete_option('foursquare_venue_client_secret');
    55     delete_option('foursquare_venue_show_title');
    56     delete_option('foursquare_venue_stats_title');
    57     delete_option('foursquare_show_venue_name');
    58     delete_option('foursquare_show_venue_icon');
    59     delete_option('foursquare_show_here_now');
    60     delete_option('foursquare_show_here_now_text');
    61     delete_option('foursquare_show_total');
    62     delete_option('foursquare_show_total_text');
    63     delete_option('foursquare_show_mayor');
    64     delete_option('foursquare_show_mayor_text');
    65     delete_option('foursquare_link_mayor');
    66     delete_option('foursquare_show_mayor_photo');
    67     delete_option('foursquare_mayor_photo_size');
    68     delete_option('foursquare_venue_stats_width');
    69     delete_option('foursquare_venue_stats_align');
    70 }
    71 
    72 function getVenueInfo($id) {
    73     // Check for cached data
    74     $transient = "foursquare_venue_$id";
    75     $data = get_transient( $transient );
    76     // Fetch and cache data if needed
    77     if( false === $data )
    78     {
    79         $client_id = get_option('foursquare_venue_client_id');
    80         $client_secret = get_option('foursquare_venue_client_secret');
    81         $request = "https://api.foursquare.com/v2/venues/$id?client_id=$client_id&client_secret=$client_secret&v=20111113";
    82         $response = wp_remote_get( $request, array( 'sslverify' => false ) );
    83         if( is_wp_error( $response ) ) {
    84             $error_string = $response->get_error_message();
    85             echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
    86         } else {
    87             $data = json_decode($response['body']);
    88             set_transient( $transient, $data, 15 * 60 );
    89         }
    90     }
    91     // Return the data
    92     return $data;
    93 }
    94 
    95 function renderVenueInfo($venue) {
    96     $venueName = $venue->response->venue->name;
    97     $venueIcon = $venue->response->venue->categories[0]->icon;
    98     $venueURL = $venue->response->venue->shortUrl;
    99    
    100     $stats_title = get_option('foursquare_venue_stats_title');
    101 
    102     if(get_option('foursquare_venue_show_title')==1) {
    103         $rendered_html .= '<h3>';
    104         $rendered_html .= $stats_title;
    105         $rendered_html .= '</h3>';
    106     }
    107     if(get_option('foursquare_show_venue_name')==1) {
    108         $rendered_html .= '<h4>';
    109         if(get_option('foursquare_show_venue_icon')==1) $rendered_html .= '<img src="' . $venueIcon . '" style="border: 0; margin: 0;" /> ';
    110         $rendered_html .= '<a href="' . $venueURL . '">';
    111         $rendered_html .= $venueName;
    112         $rendered_html .= '</a>';
    113         $rendered_html .= '</h4>';
    114     }
    115     return $rendered_html;
    116 }
    117 
    118 function renderVenueStats($venue) {
    119     $mayor = $venue->response->venue->mayor->user->firstName . ' ' . $venue->response->venue->mayor->user->lastName;
    120     $mayorURL = 'http://foursquare.com/user/' . $venue->response->venue->mayor->user->id;
    121     $mayorPic = $venue->response->venue->mayor->user->photo;
    122     $mayorCount = $venue->response->venue->mayor->count;
    123     $hereNow = $venue->response->venue->hereNow->count;
    124     $totalCheckins = $venue->response->venue->stats->checkinsCount;
    125    
    126     $here_now_text = get_option('foursquare_show_here_now_text');
    127     if($here_now_text=='') $here_now_text = 'People here now:';
    128     $total_text = get_option('foursquare_show_total_text');
    129     if($total_text=='') $total_text = 'Total check-ins:';
    130     $mayor_text = get_option('foursquare_show_mayor_text');
    131     if($mayor_text=='') $mayor_text = 'Mayor:';
    132 
    133     $rendered_html .= '<ul>';
    134     if(get_option('foursquare_show_here_now')==1) $rendered_html .= '<li>' . $here_now_text . ' ' . $hereNow . '</li>';
    135     if(get_option('foursquare_show_total')==1) $rendered_html .= '<li>' . $total_text . ' ' . $totalCheckins . '</li>';
    136     if(get_option('foursquare_show_mayor')==1) {
    137         $rendered_html .= '<li>' . $mayor_text . ' ';
    138         if(get_option('foursquare_link_mayor')==1) $rendered_html .= '<a href="' . $mayorURL . '" title="' . $mayorCount . ' check-ins in the past 2 months" >';
    139         $rendered_html .= $mayor;
    140         if(get_option('foursquare_link_mayor')==1) $rendered_html .= '</a>';
    141         if(get_option('foursquare_show_mayor_photo')==1) $rendered_html .=  ' <img src="' . $mayorPic . '" height="' . get_option('foursquare_mayor_photo_size') . '" width="' . get_option('foursquare_mayor_photo_size') . '" style="border:0;margin:0;" />';
    142         $rendered_html .= '</li>';
    143     }
    144     $rendered_html .= '</ul>';
    145     return $rendered_html;
    146 }
    147 
    148 class Foursquare_Venue extends WP_Widget
    149 {
    150 
    151     function Foursquare_Venue()
    152     {
    153         $widget_ops = array('classname' => 'foursquare_venue_widget', 'description' => 'Foursquare Venue');
    154         $this->WP_Widget('foursquare_venue', 'Foursquare Venue', $widget_ops);
    155     }
    156 
    157     function widget($args, $instance)
    158     {
    159         extract($args);
    160        
    161         $id=str_replace("https://foursquare.com/venue/", "", $instance['venue_id']);
    162         $id=str_replace("http://foursquare.com/venue/", "", $id);
    163         $venue = getVenueInfo($id);
    164 
    165         echo $before_widget;
    166         $title = strip_tags($instance['title']);
    167         echo $before_title . $title . $after_title;
    168 
    169         echo renderVenueStats($venue);
    170 
    171         echo $after_widget;
    172     }
    173 
    174     function update($new_instance, $old_instance)
    175     {
    176         $instance = $old_instance;
    177         $instance['title'] = strip_tags($new_instance['title']);
    178         $instance['venue_id'] = trim(strip_tags($new_instance['venue_id']));
    179 
    180         return $instance;
    181     }
    182 
    183     function form($instance)
    184     {
    185         $instance = wp_parse_args((array)$instance, array('title' => 'Foursquare', 'venue_id' => 3945));
    186         $title = strip_tags($instance['title']);
    187         $venue_id = strip_tags($instance['venue_id']);
     297$foursquare_venue_plugin = new Foursquare_Venue_Plugin();
     298
    188299?>
    189             <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
    190             <p><label for="<?php echo $this->get_field_id('venue_id'); ?>">Venue ID: <input class="widefat" id="<?php echo $this->get_field_id('venue_id'); ?>" name="<?php echo $this->get_field_name('venue_id'); ?>" type="text" value="<?php echo attribute_escape($venue_id); ?>" /></label></p>
    191 <?php
    192     }
    193 }
    194 
    195 add_action('widgets_init', 'RegisterFoursquareVenueWidget');
    196 
    197 function RegisterFoursquareVenueWidget() {
    198     register_widget('Foursquare_Venue');
    199 }
    200 
    201 // Shortcode
    202 
    203 function show_foursquare_venue($atts) {
    204     extract(shortcode_atts(array(
    205         'id' => '',
    206     ), $atts));
    207    
    208 $id=str_replace("https://foursquare.com/venue/", "", $id);
    209 $id=str_replace("http://foursquare.com/venue/", "", $id);
    210 
    211         $venue = getVenueInfo($id);
    212        
    213         if ($venue->meta->code==200) {
    214 
    215         $widget_html = '<div class="venue-stats';
    216         if(get_option('foursquare_venue_stats_align')=='left') $widget_html .= ' alignleft';
    217         if(get_option('foursquare_venue_stats_align')=='right') $widget_html .= ' alignright';
    218         $widget_html .= '"';
    219         if(get_option('foursquare_venue_stats_width')!='') $widget_html .= ' style="width:' . get_option('foursquare_venue_stats_width') . ';"';
    220         $widget_html .= '>';
    221 
    222         // Display Venue's Info
    223         $widget_html .= renderVenueInfo($venue);
    224 
    225         // Display Venue's Statistics
    226         $widget_html .= renderVenueStats($venue);
    227 
    228         $widget_html .= '</div>';
    229        
    230         return $widget_html;
    231        
    232         } else {
    233             return '[<strong>Error: '.$venue->meta->errorDetail.'</strong>]';
    234         }
    235 }
    236 
    237 add_shortcode('venue', 'show_foursquare_venue');
    238 
    239 // Admin Page
    240 
    241 add_action('admin_menu', 'foursquare_venue_menu');
    242 
    243 function foursquare_venue_menu() {
    244 
    245   add_options_page('Foursquare Venue Options', 'Foursquare Venue', 'manage_options', 'foursquare-venue-options', 'foursquare_venue_options');
    246 
    247 }
    248 
    249 function foursquare_venue_options() {
    250 
    251   if (!current_user_can('manage_options'))  {
    252     wp_die( __('You do not have sufficient permissions to access this page.') );
    253   }
    254 
    255 ?>
    256 
    257 <div class="wrap">
    258 
    259     <div id="icon-plugins" class="icon32"></div><h2>Foursquare Venue</h2>
    260    
    261     <h3>Getting Started</h3>
    262    
    263     <p>Before using this plugin, you'll have to set up a free Foursquare API key. Visit <a href="https://foursquare.com/oauth/">foursquare.com/oauth</a>, click "Register a new consumer," then enter the name of your site, your site's address, and for "Callback URL" just enter your site's address again. You'll be given two keys, "Client ID" and "Client Secret," which need to be copied and pasted into the matching fields on this page.</p>
    264     <p>After saving your API key you'll be able to start using the widget or shortcode. To use the widget simply add it to your sidebar and set the venue's ID. To use the shortcode just insert <code>[venue id=23647]</code> (replacing the '23647' with the desired venue's ID) into any post or page, and the plugin do the rest.</p>
    265     <p>The venue's ID can be found by taking the number from the end of the venue's page on the Foursquare website. For example, if the venue's URL is <code>https://foursquare.com/venue/<span style="color:green;">1278862</span></code>, the id is <code>1278862</code>.</p>
    266    
    267     <div id="icon-options-general" class="icon32"></div><h2>Options</h2>
    268 
    269     <form method="post" action="options.php">
    270     <?php wp_nonce_field('update-options'); ?>
    271 
    272     <h3>API Key</h3>
    273    
    274     <table class="form-table">
    275    
    276     <tr valign="top">
    277     <th scope="row">Client ID</th>
    278     <td><fieldset><legend class="screen-reader-text"><span>Client ID</span></legend>
    279     <input name="foursquare_venue_client_id" type="text" id="foursquare_venue_client_id" value="<?php echo get_option('foursquare_venue_client_id'); ?>" />
    280     </fieldset></td>
    281     </tr>
    282    
    283     <tr valign="top">
    284     <th scope="row">Client Secret</th>
    285     <td><fieldset><legend class="screen-reader-text"><span>Client Secret</span></legend>
    286     <input name="foursquare_venue_client_secret" type="text" id="foursquare_venue_client_secret" value="<?php echo get_option('foursquare_venue_client_secret'); ?>" />
    287     </fieldset></td>
    288     </tr>
    289    
    290     </table>
    291 
    292     <h3>Check-ins</h3>
    293    
    294     <table class="form-table">
    295    
    296     <tr valign="top">
    297     <th scope="row">Show Current Check-ins</th>
    298     <td><fieldset><legend class="screen-reader-text"><span>Show the number of people currently checked-in</span></legend>
    299     <label for="foursquare_show_here_now"><input name="foursquare_show_here_now" type="checkbox" id="foursquare_show_here_now" value="1" <?php if(get_option('foursquare_show_here_now')==1) echo "checked='checked'"; ?>/> Show the number of people currently checked-in</label>
    300     </fieldset></td>
    301     </tr>
    302    
    303     <tr valign="top">
    304     <th scope="row">Current Check-ins Text</th>
    305     <td><fieldset><legend class="screen-reader-text"><span>Customize the text for the current number of check-ins</span></legend>
    306     <label for="foursquare_show_here_now_text"><input name="foursquare_show_here_now_text" type="text" id="foursquare_show_here_now_text" value="<?php if(($here_now_text=get_option('foursquare_show_here_now_text'))!='') echo $here_now_text; else echo 'People here now:'; ?>" /> Customize the text for the current number of check-ins</label>
    307     </fieldset></td>
    308     </tr>
    309 
    310     <tr valign="top">
    311     <th scope="row">Show Total Check-ins</th>
    312     <td><fieldset><legend class="screen-reader-text"><span>Show the total number of check-ins</span></legend>
    313     <label for="foursquare_show_total"><input name="foursquare_show_total" type="checkbox" id="foursquare_show_total" value="1" <?php if(get_option('foursquare_show_total')==1) echo "checked='checked'"; ?>/> Show the total number of check-ins</label>
    314     </fieldset></td>
    315     </tr>
    316    
    317     <tr valign="top">
    318     <th scope="row">Total Check-ins Text</th>
    319     <td><fieldset><legend class="screen-reader-text"><span>Customize the text for the total number of check-ins</span></legend>
    320     <label for="foursquare_show_total_text"><input name="foursquare_show_total_text" type="text" id="foursquare_show_total_text" value="<?php if(($total_text=get_option('foursquare_show_total_text'))!='') echo $total_text; else echo 'Total check-ins:'; ?>" /> Customize the text for the total number of check-ins</label>
    321     </fieldset></td>
    322     </tr>
    323    
    324     </table>
    325    
    326     <h3>Mayor</h3>
    327    
    328     <table class="form-table">
    329    
    330     <tr valign="top">
    331     <th scope="row">Show Mayor</th>
    332     <td><fieldset><legend class="screen-reader-text"><span>Show the current mayor</span></legend>
    333     <label for="foursquare_show_mayor"><input name="foursquare_show_mayor" type="checkbox" id="foursquare_show_mayor" value="1" <?php if(get_option('foursquare_show_mayor')==1) echo "checked='checked'"; ?>/> Show the current mayor</label>
    334     </fieldset></td>
    335     </tr>
    336    
    337     <tr valign="top">
    338     <th scope="row">Mayor Text</th>
    339     <td><fieldset><legend class="screen-reader-text"><span>Customize the text for the mayor</span></legend>
    340     <label for="foursquare_show_mayor_text"><input name="foursquare_show_mayor_text" type="text" id="foursquare_show_mayor_text" value="<?php if(($mayor_text=get_option('foursquare_show_mayor_text'))!='') echo $mayor_text; else echo 'Mayor:'; ?>" /> Customize the text for the mayor</label>
    341     </fieldset></td>
    342     </tr>
    343    
    344     <tr valign="top">
    345     <th scope="row">Link to Mayor</th>
    346     <td><fieldset><legend class="screen-reader-text"><span>Link to the current mayor</span></legend>
    347     <label for="foursquare_link_mayor"><input name="foursquare_link_mayor" type="checkbox" id="foursquare_link_mayor" value="1" <?php if(get_option('foursquare_link_mayor')==1) echo "checked='checked'"; ?>/> Link to the current mayor</label>
    348     </fieldset></td>
    349     </tr>
    350    
    351     <tr valign="top">
    352     <th scope="row">Show Mayor's Photo</th>
    353     <td><fieldset><legend class="screen-reader-text"><span>Show a photo of the current mayor next to their name</span></legend>
    354     <label for="foursquare_show_mayor_photo"><input name="foursquare_show_mayor_photo" type="checkbox" id="foursquare_show_mayor_photo" value="1" <?php if(get_option('foursquare_show_mayor_photo')==1) echo "checked='checked'"; ?>/> Show a photo of the current mayor next to their name</label>
    355     </fieldset></td>
    356     </tr>
    357 
    358     <tr valign="top">
    359     <th scope="row">Mayor Photo Size</th>
    360     <td><fieldset><legend class="screen-reader-text"><span>Choose what size to display the mayor's photo</span></legend>
    361     <label for="foursquare_mayor_photo_size"><input name="foursquare_mayor_photo_size" type="text" id="foursquare_mayor_photo_size" value="<?php echo get_option('foursquare_mayor_photo_size'); ?>" size="3" />px (ex: 32 will create a 32x32 photo)</label>
    362     </fieldset></td>
    363     </tr>
    364    
    365     </table>
    366    
    367     <h3>Style</h3>
    368    
    369     <p>Note: These settings do not affect the Foursquare Venue widget, only the shortcode. Advanced users can style their Foursquare stats using CSS. Ex: <code>.venue-stats { width: 300px; float: right; }</code></p>
    370    
    371     <table class="form-table">
    372    
    373     <tr valign="top">
    374     <th scope="row">Show Shortcode Title</th>
    375     <td><fieldset><legend class="screen-reader-text"><span>Show the current mayor</span></legend>
    376     <label for="foursquare_venue_show_title"><input name="foursquare_venue_show_title" type="checkbox" id="foursquare_venue_show_title" value="1" <?php if(get_option('foursquare_venue_show_title')==1) echo "checked='checked'"; ?>/> Show a title above the Foursquare stats</label>
    377     </fieldset></td>
    378     </tr>
    379    
    380     <tr valign="top">
    381     <th scope="row">Shortcode Title Text</th>
    382     <td><fieldset><legend class="screen-reader-text"><span>Customize the text for the mayor</span></legend>
    383     <label for="foursquare_venue_stats_title"><input name="foursquare_venue_stats_title" type="text" id="foursquare_venue_stats_title" value="<?php if(($mayor_text=get_option('foursquare_venue_stats_title'))!='') echo $mayor_text; else echo 'Mayor:'; ?>" /> Customize the title above the stats</label>
    384     </fieldset></td>
    385     </tr>
    386    
    387     <tr valign="top">
    388     <th scope="row">Show Venue Name</th>
    389     <td><fieldset><legend class="screen-reader-text"><span>Show the venue name</span></legend>
    390     <label for="foursquare_show_venue_name"><input name="foursquare_show_venue_name" type="checkbox" id="foursquare_show_venue_name" value="1" <?php if(get_option('foursquare_show_venue_name')==1) echo "checked='checked'"; ?>/> Show name and link to the venue</label>
    391     </fieldset></td>
    392     </tr>
    393    
    394     <tr valign="top">
    395     <th scope="row">Show Venue Icon</th>
    396     <td><fieldset><legend class="screen-reader-text"><span>Show venue icon</span></legend>
    397     <label for="foursquare_show_venue_icon"><input name="foursquare_show_venue_icon" type="checkbox" id="foursquare_show_venue_icon" value="1" <?php if(get_option('foursquare_show_venue_icon')==1) echo "checked='checked'"; ?>/> Show an icon for the venue's category</label>
    398     </fieldset></td>
    399     </tr>
    400    
    401     <tr valign="top">
    402     <th scope="row">Width</th>
    403     <td><fieldset>
    404     <label for="foursquare_venue_stats_width"><input name="foursquare_venue_stats_width" type="text" id="foursquare_venue_stats_width" value="<?php echo get_option('foursquare_venue_stats_width'); ?>" size="3" />px</label>
    405     </fieldset></td>
    406     </tr>
    407    
    408     <tr valign="top">
    409     <th scope="row">Align</th>
    410     <td><fieldset>
    411     <label for="foursquare_venue_stats_alignleft"><input type="radio" name="foursquare_venue_stats_align" id="foursquare_venue_stats_alignleft" value="left" <?php if(get_option('foursquare_venue_stats_align')=='left') echo 'checked="checked" '; ?>/> Left</label> <label for="foursquare_venue_stats_alignright"><input type="radio" name="foursquare_venue_stats_align" id="foursquare_venue_stats_alignright" value="right" <?php if(get_option('foursquare_venue_stats_align')=='right') echo 'checked="checked" '; ?>/> Right</label> <label for="foursquare_venue_stats_alignnone"><input type="radio" name="foursquare_venue_stats_align" id="foursquare_venue_stats_alignnone" value="" <?php if(get_option('foursquare_venue_stats_align')=='') echo 'checked="checked" '; ?>/> None</label>
    412     </fieldset></td>
    413     </tr>
    414    
    415     </table>
    416    
    417     <input type="hidden" name="action" value="update" />
    418     <input type="hidden" name="page_options" value="foursquare_venue_client_id,foursquare_venue_client_secret,foursquare_venue_show_title,foursquare_venue_stats_title,foursquare_show_venue_name,foursquare_show_venue_icon,foursquare_show_here_now,foursquare_show_here_now_text,foursquare_show_total,foursquare_show_total_text,foursquare_show_mayor,foursquare_show_mayor_text,foursquare_link_mayor,foursquare_show_mayor_photo,foursquare_mayor_photo_size,foursquare_venue_stats_width,foursquare_venue_stats_align" />
    419    
    420     <p class="submit">
    421     <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
    422     </p>
    423    
    424     </form>
    425 
    426 </div>
    427 
    428 <?php
    429 
    430 }
    431 
    432 ?>
  • foursquare-venue/trunk/readme.txt

    r850120 r946349  
    33Donate link: http://wie.ly/u/donate
    44Tags: foursquare, venue, widget, social networking, location
    5 Requires at least: 3.0
    6 Tested up to: 3.8.1
    7 Stable tag: 2.2.2
     5Requires at least: 3.5
     6Tested up to: 3.9.1
     7Stable tag: 3.0
    88
    99Foursquare Venue is a simple but powerful plugin for displaying any venue's Foursquare stats.
     
    1111== Description ==
    1212
    13 Foursquare Venue gives you the ability to display any venue's latest stats on your WordPress site. Using either the widget or shortcode, you will be able to display:
     13Foursquare Venue gives you the ability to display any venue's latest stats on your WordPress site. Using either the widget or shortcode, you will be able to display everything from a venue's address, to average rating, to mayor, and more!
    1414
    15 *   People here now
    16 *   Total check-ins
    17 *   Current mayor (along with their picture and number of check-ins)
     15**New!** Foursquare Venue 3.0 has been entirely rewritten to support the latest Foursquare API and give users more control over how data is displayed. Note: If you are already running Foursquare Venue, you will need to reconfigure the plugin.
    1816
    19 I'm open to any feedback and suggestions.
     17= Our Other Plugins =
     18
     19[Video Thumbnails](https://refactored.co/plugins/video-thumbnails) | [Video Importer](https://refactored.co/plugins/video-importer) | [Retinamatic](http://retinamatic.com/)
    2020
    2121== Installation ==
     
    2727
    2828* On the 'Widgets' page listed under 'Appearance,' drag the Foursquare Venue widget to your desired widget area and set the venue ID.
    29 * On any post or page, add the shortcode `[venue id=3945]`, replacing the '3945' with the venue's ID.
     29* On any post or page, add the shortcode `[venue id=abc123]`, replacing the 'abc123' with the venue's ID.
    3030
    31 The venue's ID can be found as a number at the end of the venue's URL on Foursquare.
     31The venue's ID can be found as a string of random numbers and letters at the end of the venue's URL on Foursquare.
    3232
    3333== Frequently Asked Questions ==
     
    3535= The stats are wrong or I'm getting an error, what did I do wrong? =
    3636
    37 The most likely problem is that you haven't set a proper venue ID. This is the number from the end of the venue's URL (ex: `3945`).
     37The most likely problem is that you haven't set a proper venue ID. This is the number from the end of the venue's URL (ex: `3fd66200f964a520d6f01ee3`).
    3838
    3939== Screenshots ==
    4040
    41 1. The full set of options
    42 2. Shortcode in use with custom settings applied
     411. The shortcode in action
     422. Settings page
     433. Help tab on settings page
    4344
    4445== Changelog ==
     46
     47= 3.0 =
     48* Rewritten from the ground up to give users more control
     49* Uses the latest Foursquare API
     50* If you are already using the plugin, you will need to reconfigure the settings.
    4551
    4652= 2.2.2 =
Note: See TracChangeset for help on using the changeset viewer.