Plugin Directory

Changeset 891793


Ignore:
Timestamp:
04/12/2014 09:53:40 AM (12 years ago)
Author:
shen045
Message:

Update to version 1.2.0

Location:
crafty-social-buttons/trunk
Files:
1 added
28 edited

Legend:

Unmodified
Added
Removed
  • crafty-social-buttons/trunk/README.txt

    r890035 r891793  
    9292== Changelog ==
    9393
     94= 1.2.0 =
     95* Share counts are now loaded via Ajax (so don't slow down the page loading)
     96* Custom icons can be placed under wp-content (so aren't deleted when the plugin is updated)
     97* Fixed issues with share counts not being retrieved because of API changes
     98* Improved layout of share count bubbles
     99
     100= 1.1.1 =
     101* Including page/post title in default tweet text is optional
     102
    94103= 1.1.0 =
    95104* Allows you to choose the size of share and link buttons
     
    139148== Upgrade Notice ==
    140149
     150= 1.2.0 =
     151* Share counts load faster and look better
     152
     153= 1.1.1 =
     154* Including page/post title in default tweet text is optional
     155
    141156= 1.1.0 =
    142157* Allows you to choose the size of share and link buttons
     
    174189These are the things currently in the pipeline:
    175190
    176 * Changing the post count feature to request data only after the page is loaded so it doesn't slow things down so much.
    177191* Choosing which post types the share buttons are added to
    178192* Adding more services (ebay, Xing, Vimeo)
    179 * Adding your own icons (in a way that they don't disappear after you update the plugin)
    180 * Option to diplays in archives and category listings (?)
     193* Option to display in archives and category listings (?)
    181194* (Anything else?  You tell me!)
  • crafty-social-buttons/trunk/class-SH-Crafty-Social-Buttons-Admin.php

    r890035 r891793  
    22/**
    33 * SH_Crafty_Social_Buttons_Admin Class
    4  * @author  Sarah Henderson
    5  * @date    2013-10-12
     4 * @author    Sarah Henderson
     5 * @date    2013-10-12
    66 */
    7  
    8 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
     7
     8if ( ! defined( 'ABSPATH' ) ) {
     9    exit;
     10} // Exit if accessed directly
    911
    1012class SH_Crafty_Social_Buttons_Admin {
     
    3335     * Initialize the plugin by setting localization, filters, and administration functions.
    3436     */
    35     private function __construct() {       
     37    private function __construct() {
    3638
    3739        // register settings
    38         add_action( 'admin_init', array($this, 'register_settings' ));
     40        add_action( 'admin_init', array( $this, 'register_settings' ) );
    3941
    4042        $this->load_all_services();
     
    5052            self::$instance = new self;
    5153        }
     54
    5255        return self::$instance;
    5356    }
     
    5861    public function display_plugin_admin_page() {
    5962
    60         if (!is_admin()) {
    61             wp_die(__('You cannot access this page')); 
    62         }
    63        
     63        if ( ! is_admin() ) {
     64            wp_die( __( 'You cannot access this page' ) );
     65        }
     66
    6467        // make sure they have the rights to manage options
    65         if (!current_user_can( 'manage_options' ) )  {
    66             wp_die( __('You do not have sufficient permissions to access this page.'));
    67         }
    68          $settings = $this->getSettings();
    69        
    70         include_once( plugin_dir_path(__FILE__) . 'views/admin.php' );
    71     }
    72 
    73      
    74      /**
    75       * Checks which classes are available in the services folder and registers them
    76       */
    77      function load_all_services() {
    78            
    79             include_once('services/class-SH_Social_Service.php');
    80             $this->all_services = array();
    81            
    82             $directory = plugin_dir_path(__FILE__) . 'services';
    83             foreach (scandir($directory) as $file) {
    84                 if ('.' === $file) continue;
    85                 if ('..' === $file) continue;   
    86                 if ("class-SH_Social_Service.php" === $file) { continue; }
    87                
    88                 $matches = array();
    89                 if (preg_match("/^class-SH_(.+)\.php$/", $file, $matches)) {
    90                     $this->all_services[] = $matches[1];
    91                     include_once('services/' . $file);
     68        if ( ! current_user_can( 'manage_options' ) ) {
     69            wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
     70        }
     71        $settings = $this->getSettings();
     72
     73        include_once( plugin_dir_path( __FILE__ ) . 'views/admin.php' );
     74    }
     75
     76
     77    /**
     78     * Checks which classes are available in the services folder and registers them
     79     */
     80    function load_all_services() {
     81
     82        include_once( 'services/class-SH_Social_Service.php' );
     83        $this->all_services = array();
     84
     85        $directory = plugin_dir_path( __FILE__ ) . 'services';
     86        foreach ( scandir( $directory ) as $file ) {
     87            if ( '.' === $file ) {
     88                continue;
     89            }
     90            if ( '..' === $file ) {
     91                continue;
     92            }
     93            if ( "class-SH_Social_Service.php" === $file ) {
     94                continue;
     95            }
     96
     97            $matches = array();
     98            if ( preg_match( "/^class-SH_(.+)\.php$/", $file, $matches ) ) {
     99                $this->all_services[] = $matches[1];
     100                include_once( 'services/' . $file );
     101            }
     102        }
     103    }
     104
     105    /**
     106     * Checks which folders are available in the button directory and registers them
     107     */
     108    function load_all_image_sets() {
     109        $this->all_image_sets = array();
     110
     111        $directory = plugin_dir_path( __FILE__ ) . 'buttons'; // included image sets
     112        foreach ( scandir( $directory ) as $folder ) {
     113            if ( '.' === $folder ) {
     114                continue;
     115            }
     116            if ( '..' === $folder ) {
     117                continue;
     118            }
     119
     120            if ( ! preg_match( "/\./", $folder ) ) { // no dots allowed, only folders
     121                $this->all_image_sets[] = $folder;
     122            }
     123        }
     124
     125        $directory = wp_upload_dir()['basedir'] . '/crafty-social-buttons/buttons'; // custom image sets
     126        if (is_dir($directory)) {
     127            foreach ( scandir( $directory ) as $folder ) {
     128                if ( '.' === $folder ) {
     129                    continue;
    92130                }
    93             }   
    94      }
    95      
    96      /**
    97       * Checks which folders are available in the button directory and registers them
    98       */
    99      function load_all_image_sets() {
    100             $this->all_image_sets = array();
    101            
    102             $directory = plugin_dir_path(__FILE__) . 'buttons';
    103             foreach (scandir($directory) as $folder) {
    104                 if ('.' === $folder) continue;
    105                 if ('..' === $folder) continue;
    106                
    107                 if (!preg_match("/\./", $folder)) { // no dots allowed, only folders
     131                if ( '..' === $folder ) {
     132                    continue;
     133                }
     134
     135                if ( ! preg_match( "/\./", $folder ) ) { // no dots allowed, only folders
    108136                    $this->all_image_sets[] = $folder;
    109137                }
    110             }   
    111      }
    112    
     138            }
     139        }
     140
     141    }
     142
    113143    /**
    114144     * Show admin notifications
     
    117147
    118148        $settings = $this->getSettings();
    119        
     149
    120150        // check if any buttons have been configured
    121         if (!$settings['configured']) {
    122        
     151        if ( ! $settings['configured'] ) {
     152
    123153            // output a warning that buttons need configuring and provide a link to settings
    124             echo '<div class="updated fade"><p>Thanks for installing <strong>Crafty Social Buttons!</strong>. '.
    125                  ' Your buttons need <a href="admin.php?page=' . $this->plugin_slug .
    126                 '"><strong>configuration</strong></a> before they will appear.</p></div>';
     154            echo '<div class="updated fade"><p>Thanks for installing <strong>Crafty Social Buttons!</strong>. ' .
     155                 ' Your buttons need <a href="admin.php?page=' . $this->plugin_slug .
     156                '"><strong>configuration</strong></a> before they will appear.</p></div>';
    127157        }
    128158    }
     
    132162     */
    133163    public function register_settings() {
    134        
    135         $section = 'cbs_basic_share_settings';
    136         $page = $this->plugin_slug.'-share';
    137        
    138         add_settings_section( $section, 'Display Options',
    139             array($this, 'displayShareBasicSettingsText'),  $page); 
    140        
    141         add_settings_field( 'share_image_set', 'Image Set', 
    142             array($this, 'renderImageSetSelect'), $page,  $section, array('share_image_set')  ); 
    143 
    144         add_settings_field( 'share_image_size', 'Image Size', 
    145             array($this, 'renderNumericTextbox'), $page,  $section,
    146             array('share_image_size', 'Size in pixels, between 24 and 64')  ); 
    147        
    148         add_settings_field( 'share_caption', 'Caption', 
    149             array($this, 'renderTextbox'), $page,  $section,
    150             array('share_caption', 'Displays before the set of share buttons')  ); 
    151 
    152         add_settings_field( 'share_services', 'Show these services', 
    153             array($this, 'render_service_select'), $page,  $section, array('share_services')  ); 
    154 
    155 
    156         add_settings_field( 'position', 'Above or below content', 
    157             array($this, 'renderPositionSelect'), $page,  $section, array('position')  ); 
    158 
    159         add_settings_field( 'show_on_posts', 'Show on Posts', 
    160             array($this, 'renderCheckbox'), $page,  $section,
    161             array('show_on_posts', 'Shows on post single individual pages') ); 
    162        
    163         add_settings_field( 'show_on_pages', 'Show on Pages', 
    164             array($this, 'renderCheckbox'), $page,  $section, array('show_on_pages')  ); 
    165            
    166         add_settings_field( 'show_on_home', 'Show on Home Page', 
    167             array($this, 'renderCheckbox'), $page,  $section, array('show_on_home')  ); 
    168        
    169        
    170        
    171        
    172        
     164
     165        $section = 'cbs_basic_share_settings';
     166        $page    = $this->plugin_slug . '-share';
     167
     168        add_settings_section( $section, __( 'Display Options', $this->plugin_slug ),
     169            array( $this, 'displayShareBasicSettingsText' ), $page );
     170
     171        add_settings_field( 'share_image_set', __( 'Image Set', $this->plugin_slug ),
     172            array( $this, 'renderImageSetSelect' ), $page, $section, array( 'share_image_set' ) );
     173
     174        add_settings_field( 'share_image_size', __( 'Image Size', $this->plugin_slug ),
     175            array( $this, 'renderNumericTextbox' ), $page, $section,
     176            array( 'share_image_size', __( 'Size in pixels, between 24 and 64', $this->plugin_slug ) ) );
     177
     178        add_settings_field( 'share_caption', __( 'Caption', $this->plugin_slug ),
     179            array( $this, 'renderTextbox' ), $page, $section,
     180            array( 'share_caption', __( 'Displays before the set of share buttons', $this->plugin_slug ) ) );
     181
     182        add_settings_field( 'share_services', __( 'Show these services', $this->plugin_slug ),
     183            array( $this, 'render_service_select' ), $page, $section, array( 'share_services' ) );
     184
     185
     186        add_settings_field( 'position', __( 'Above or below content', $this->plugin_slug ),
     187            array( $this, 'renderPositionSelect' ), $page, $section, array( 'position' ) );
     188
     189        add_settings_field( 'show_on_posts', __( 'Show on Posts', $this->plugin_slug ),
     190            array( $this, 'renderCheckbox' ), $page, $section,
     191            array( 'show_on_posts', __( 'Shows on post single individual pages', $this->plugin_slug ) ) );
     192
     193        add_settings_field( 'show_on_pages', __( 'Show on Pages', $this->plugin_slug ),
     194            array( $this, 'renderCheckbox' ), $page, $section, array( 'show_on_pages' ) );
     195
     196        add_settings_field( 'show_on_home', __( 'Show on Home Page', $this->plugin_slug ),
     197            array( $this, 'renderCheckbox' ), $page, $section, array( 'show_on_home' ) );
     198
     199
    173200        $section = 'cbs_advanced_share_settings';
    174         add_settings_section( $section, 'Advanced Options', null,  $page); 
    175        
    176         add_settings_field( 'new_window', 'Open in new window', 
    177             array($this, 'renderCheckbox'), $page,  $section, array('new_window')  ); 
    178        
    179         add_settings_field( 'show_count', 'Show post counts', 
    180         array($this, 'renderCheckbox'), $page,  $section,
    181             array('show_count', 'Only done if service supports it.  Calling out to the
    182             services to obtain the counts can slow down the loading of the page significantly')  ); 
    183        
    184         add_settings_field( 'email_body', 'Email text', 
    185             array($this, 'renderTextbox'), $page,  $section, array('email_body')  ); 
    186        
    187         add_settings_field( 'twitter_body', 'Twitter text', 
    188         array($this, 'renderTextbox'), $page,  $section, array('twitter_body') ); 
    189        
    190        
    191    
    192    
     201        add_settings_section( $section, __( 'Advanced Options', $this->plugin_slug ), null, $page );
     202
     203        add_settings_field( 'new_window', __( 'Open in new window', $this->plugin_slug ),
     204            array( $this, 'renderCheckbox' ), $page, $section, array( 'new_window' ) );
     205
     206        add_settings_field( 'show_count', __( 'Show post counts', $this->plugin_slug ),
     207            array( $this, 'renderCheckbox' ), $page, $section,
     208            array( 'show_count', __( 'Only done if service supports it.', $this->plugin_slug ) ) );
     209
     210        add_settings_field( 'email_body', __( 'Email text', $this->plugin_slug ),
     211            array( $this, 'renderTextbox' ), $page, $section, array( 'email_body' ) );
     212
     213        add_settings_field( 'twitter_body', __( 'Tweet text', $this->plugin_slug ),
     214            array( $this, 'renderTextbox' ), $page, $section,
     215            array( 'twitter_body', __( 'Default Tweet text (user can override this)', $this->plugin_slug ) ) );
     216
     217        add_settings_field( 'twitter_show_title', __( 'Title in Tweet text', $this->plugin_slug ),
     218            array( $this, 'renderCheckbox' ), $page, $section,
     219            array(
     220                'twitter_show_title',
     221                __( 'Include the post/page title in the default Tweet text', $this->plugin_slug )
     222            ) );
     223
     224
    193225        $section = 'cbs_link_button_settings';
    194         $page = $this->plugin_slug.'-link';
    195         add_settings_section( $section, 'Display Options', array($this, 'displayLinkSettingsText'),  $page); 
    196      
    197         add_settings_field( 'link_image_set', 'Image Set', 
    198             array($this, 'renderImageSetSelect'), $page,  $section, array('link_image_set')  ); 
    199         add_settings_field( 'link_image_size', 'Image Size', 
    200             array($this, 'renderNumericTextbox'), $page,  $section,
    201             array('link_image_size', 'Size in pixels, between 24 and 64')  ); 
    202        
    203         add_settings_field( 'link_caption', 'Caption', 
    204             array($this, 'renderTextbox'), $page,  $section,
    205             array('link_caption', 'Displays before the set of link buttons')  ); 
    206        
    207         add_settings_field( 'link_services', 'Show these services', 
    208             array($this, 'render_service_select'), $page,  $section, array('link_services')  );         
    209        
    210        
     226        $page    = $this->plugin_slug . '-link';
     227        add_settings_section( $section, __( 'Display Options', $this->plugin_slug ),
     228            array( $this, 'displayLinkSettingsText' ), $page );
     229
     230        add_settings_field( 'link_image_set', __( 'Image Set', $this->plugin_slug ),
     231            array( $this, 'renderImageSetSelect' ), $page, $section, array( 'link_image_set' ) );
     232        add_settings_field( 'link_image_size', __( 'Image Size', $this->plugin_slug ),
     233            array( $this, 'renderNumericTextbox' ), $page, $section,
     234            array( 'link_image_size', __( 'Size in pixels, between 24 and 64', $this->plugin_slug ) ) );
     235
     236        add_settings_field( 'link_caption', __( 'Caption', $this->plugin_slug ),
     237            array( $this, 'renderTextbox' ), $page, $section,
     238            array( 'link_caption', __( 'Displays before the set of link buttons', $this->plugin_slug ) ) );
     239
     240        add_settings_field( 'link_services', __( 'Show these services', $this->plugin_slug ),
     241            array( $this, 'render_service_select' ), $page, $section, array( 'link_services' ) );
     242
     243
    211244        $section = 'cbs_link_service_settings';
    212         add_settings_section( $section, 'User IDs', array($this, 'displayLinkServiceText'),  $page); 
    213      
    214         foreach($this->all_services as $service) {
     245        add_settings_section( $section, __( 'User IDs', $this->plugin_slug ), array(
     246                $this,
     247                'displayLinkServiceText'
     248            ), $page );
     249
     250        foreach ( $this->all_services as $service ) {
    215251            // we want to add a custom description for some of the fields
    216             $caption = $service;
     252            $caption     = $service;
    217253            $description = "";
    218             $description = $this->call_service_method($service, 'description');
    219            
    220             add_settings_field( 
    221                 $service, 
    222                 $caption, 
    223                 array($this, 'renderTextbox'),
    224                 $page, 
    225                 $section, 
    226                 array($service, $description) ); 
    227         }
    228        
    229         register_setting( $this->plugin_slug, $this->plugin_slug, array($this, 'validate_settings' ));
    230     }
    231    
     254            $description = $this->call_service_method( $service, 'description' );
     255
     256            add_settings_field(
     257                $service,
     258                $caption,
     259                array( $this, 'renderTextbox' ),
     260                $page,
     261                $section,
     262                array( $service, $description ) );
     263        }
     264
     265        register_setting( $this->plugin_slug, $this->plugin_slug, array( $this, 'validate_settings' ) );
     266    }
     267
    232268    /**
    233269     * Display share basic settings section text
    234270     */
    235     public function add_contextual_help($hook) {
     271    public function add_contextual_help( $hook ) {
    236272        $screen = get_current_screen();
    237        
    238         if ( $screen->id != 'settings_page_' . $this->plugin_slug ) {
    239             return;
    240         }
    241    
    242         $screen->add_help_tab( array(
    243         'id'    => 'csb-help-intro',
    244         'title' => __('Welcome'),
    245         'content'   => file_get_contents( plugin_dir_path(__FILE__). '/help/intro-tab.php' ) ) );
    246 
    247         $screen->add_help_tab( array(
    248         'id'    => 'csb-share-help',
    249         'title' => __('Share Buttons'),
    250         'content'   => file_get_contents( plugin_dir_path(__FILE__). '/help/share-tab.php' ) ) );
    251          
    252         $screen->add_help_tab( array(
    253         'id'    => 'csb-link-help',
    254         'title' => __('Link Buttons'),
    255         'content'   => file_get_contents( plugin_dir_path(__FILE__). '/help/link-tab.php' ) ) );
    256                
    257          $screen->add_help_tab( array(
    258         'id'    => 'csb-widget',
    259         'title' => __('Widget'),
    260         'content'   => file_get_contents( plugin_dir_path(__FILE__). '/help/widget-tab.php' ) ) );
    261 
    262          $screen->add_help_tab( array(
    263         'id'    => 'csb-shortcode',
    264         'title' => __('Shortcodes'),
    265         'content'   => file_get_contents( plugin_dir_path(__FILE__). '/help/shortcode-tab.php' ) ) );
    266 
    267          $screen->add_help_tab( array(
    268         'id'    => 'csb-action-hooks',
    269         'title' => __('Action Hooks'),
    270         'content'   => file_get_contents( plugin_dir_path(__FILE__). '/help/action-hook-tab.php' ) ) );
    271 
    272          $screen->add_help_tab( array(
    273         'id'    => 'csb-icons',
    274         'title' => __('Adding Icons'),
    275         'content'   => file_get_contents( plugin_dir_path(__FILE__). '/help/adding-icons-tab.php' ) ) );
    276 
    277          $screen->add_help_tab( array(
    278         'id'    => 'csb-credits',
    279         'title' => __('Credits'),
    280         'content'   => file_get_contents( plugin_dir_path(__FILE__). '/help/credits-tab.php' ) ) );
    281 
    282          $screen->add_help_tab( array(
    283         'id'    => 'csb-about',
    284         'title' => __('About Me'),
    285         'content'   => file_get_contents( plugin_dir_path(__FILE__). '/help/about-me-tab.php' ) ) );
    286      }
    287    
     273
     274        if ( $screen->id != 'settings_page_' . $this->plugin_slug ) {
     275            return;
     276        }
     277
     278        $screen->add_help_tab( array(
     279            'id'      => 'csb-help-intro',
     280            'title'   => __( 'Welcome', $this->plugin_slug ),
     281            'content' => file_get_contents( plugin_dir_path( __FILE__ ) . '/help/intro-tab.php' )
     282        ) );
     283
     284        $screen->add_help_tab( array(
     285            'id'      => 'csb-share-help',
     286            'title'   => __( 'Share Buttons', $this->plugin_slug ),
     287            'content' => file_get_contents( plugin_dir_path( __FILE__ ) . '/help/share-tab.php' )
     288        ) );
     289
     290        $screen->add_help_tab( array(
     291            'id'      => 'csb-link-help',
     292            'title'   => __( 'Link Buttons', $this->plugin_slug ),
     293            'content' => file_get_contents( plugin_dir_path( __FILE__ ) . '/help/link-tab.php' )
     294        ) );
     295
     296        $screen->add_help_tab( array(
     297            'id'      => 'csb-widget',
     298            'title'   => __( 'Widget', $this->plugin_slug ),
     299            'content' => file_get_contents( plugin_dir_path( __FILE__ ) . '/help/widget-tab.php' )
     300        ) );
     301
     302        $screen->add_help_tab( array(
     303            'id'      => 'csb-shortcode',
     304            'title'   => __( 'Shortcodes', $this->plugin_slug ),
     305            'content' => file_get_contents( plugin_dir_path( __FILE__ ) . '/help/shortcode-tab.php' )
     306        ) );
     307
     308        $screen->add_help_tab( array(
     309            'id'      => 'csb-action-hooks',
     310            'title'   => __( 'Action Hooks', $this->plugin_slug ),
     311            'content' => file_get_contents( plugin_dir_path( __FILE__ ) . '/help/action-hook-tab.php' )
     312        ) );
     313
     314        $screen->add_help_tab( array(
     315            'id'      => 'csb-icons',
     316            'title'   => __( 'Adding Icons', $this->plugin_slug ),
     317            'content' => file_get_contents( plugin_dir_path( __FILE__ ) . '/help/adding-icons-tab.php' )
     318        ) );
     319
     320        $screen->add_help_tab( array(
     321            'id'      => 'csb-credits',
     322            'title'   => __( 'Credits', $this->plugin_slug ),
     323            'content' => file_get_contents( plugin_dir_path( __FILE__ ) . '/help/credits-tab.php' )
     324        ) );
     325
     326        $screen->add_help_tab( array(
     327            'id'      => 'csb-about',
     328            'title'   => __( 'About Me', $this->plugin_slug ),
     329            'content' => file_get_contents( plugin_dir_path( __FILE__ ) . '/help/about-me-tab.php' )
     330        ) );
     331    }
     332
    288333    /**
    289334     * Display share basic settings section text
    290335     */
    291     public function displayShareBasicSettingsText() { ?>
    292         <p>Share Buttons will prompt the user to share the current post or page URL.</p>
    293         <?php
    294     }
    295    
     336    public function displayShareBasicSettingsText() {
     337        echo '<p>';
     338        _e( 'Share Buttons will prompt the user to share the current post or page URL.', $this->plugin_slug );
     339        echo '</p>';
     340
     341    }
     342
    296343    /**
    297344     * Display link settings section text
    298345     */
    299     public function displayLinkSettingsText() {?>
    300         <p>Link Buttons will link to your user profile on each site. 
    301         Enter your <strong>user id</strong> for each service you choose below to make the button link directly to your profile.</p>
    302         <?php
    303     }
    304    
     346    public function displayLinkSettingsText() {
     347        echo '<p>';
     348        _e( 'Link Buttons will link to your user profile on each site.', $this->plugin_slug );
     349        echo '</p><p>';
     350        _e( 'Enter your <strong>user id</strong> for each service you choose below to make the button link directly to your profile.', $this->plugin_slug );
     351        echo '</p>';
     352    }
     353
    305354    /**
    306355     * Display link settings section text
    307356     */
    308     public function displayLinkServiceText() {?>
    309         <p>Enter just your <strong>user id</strong> for each service, not the full URL. The bit in bold that says <strong>user-id</strong> in the hint is the part you should enter.</p>
    310         <?php
    311     }
    312    
     357    public function displayLinkServiceText() {
     358        echo '<p>';
     359        _e( 'Enter just your <strong>user id</strong> for each service, not the full URL. The bit in bold that says <strong>user-id</strong> in the hint is the part you should enter.', $this->plugin_slug );
     360        echo '</p>';
     361    }
     362
    313363    /**
    314364     * Display a settings checkbox
    315365     */
    316     public function renderCheckbox($args) {
    317         $id = $args[0];
    318         $name = $this->plugin_slug . '[' . $args[0] . ']';
    319         $description = isset($args[1]) ? $args[1] : '';
     366    public function renderCheckbox( $args ) {
     367        $id          = $args[0];
     368        $name        = $this->plugin_slug . '[' . $args[0] . ']';
     369        $description = isset( $args[1] ) ? $args[1] : '';
     370        $settings    = $this->getSettings();
     371        $value       = $settings[ $id ];
     372        ?>
     373
     374        <input type="checkbox" id="<?= $id ?>" name="<?= $name ?>" <?php echo checked( 1, $value ) ?> value="0"/>
     375        <span class="description" for="<?= $id ?>">
     376                <?= $description ?>
     377            </span>
     378
     379    <?php
     380    }
     381
     382    /**
     383     * Display a settings textbox
     384     */
     385    public function renderTextbox( $args ) {
     386        $id          = $args[0];
     387        $settings    = $this->getSettings();
     388        $value       = isset( $settings[ $id ] ) ? $settings[ $id ] : ' ';
     389        $name        = $this->plugin_slug . '[' . $args[0] . ']';
     390        $description = isset( $args[1] ) ? $args[1] : '';
     391
     392        ?>
     393
     394        <input type="text" id="<?= $id ?>" name="<?= $name ?>" value="<?= $value ?>"/>
     395        <span class="description">
     396               <?= $description ?>
     397            </span>
     398
     399    <?php
     400    }
     401
     402    /**
     403     * Display a settings textbox
     404     */
     405    public function renderNumericTextbox( $args ) {
     406        $id          = $args[0];
     407        $settings    = $this->getSettings();
     408        $value       = isset( $settings[ $id ] ) ? $settings[ $id ] : ' ';
     409        $name        = $this->plugin_slug . '[' . $args[0] . ']';
     410        $description = isset( $args[1] ) ? $args[1] : '';
     411        $min         = isset( $args[2] ) ? $args[2] : 24;
     412        $max         = isset( $args[3] ) ? $args[3] : 64;
     413
     414        ?>
     415
     416        <input type="number" id="<?= $id ?>" name="<?= $name ?>" value="<?= $value ?>" min="<?= $min ?>"
     417               max="<?= $max ?>"/>
     418        <span class="description">
     419               <?= $description ?>
     420            </span>
     421
     422    <?php
     423    }
     424
     425    /**
     426     * Display share settings section
     427     */
     428    public function renderImageSetSelect( $args ) {
     429        $id       = $args[0];
     430        $name     = $this->plugin_slug . '[' . $args[0] . ']';
    320431        $settings = $this->getSettings();
    321         $value = $settings[$id];
     432        $value    = $settings[ $id ];
     433        $base     = plugin_dir_url( __FILE__ ) . "buttons/";
    322434        ?>
    323435
    324             <input type="checkbox" id="<?=$id?>" name="<?=$name?>" <?php echo checked(1, $value) ?> value="0" />
    325             <span class="description" for="<?=$id?>">
    326                 <?=$description?>
    327             </span>
    328 
    329         <?php
    330     }
    331    
    332     /**
    333      * Display a settings textbox
    334      */
    335     public function renderTextbox($args) {
    336         $id = $args[0];
     436        <select id="<?= $id ?>" class="csb-image-set" name="<?= $name ?>">
     437
     438            <?php foreach ( $this->all_image_sets as $set ) { ?>
     439                <option value="<?= $set ?>" <?php echo selected( $set, $value );?>">
     440                    <?=$set?>
     441                </option>
     442            <?php } ?>
     443
     444        </select>
     445
     446    <?php
     447    }
     448
     449    /**
     450     * Display share settings section
     451     */
     452    public function render_service_select( $args ) {
     453        $id          = $args[0];
     454        $name        = $this->plugin_slug . '[' . $args[0] . ']';
     455        $settings    = $this->getSettings();
     456        $image_set   = ( $id == 'link_services' ) ? $settings['link_image_set'] : $settings['share_image_set'];
     457        $image_size  = ( $id == 'link_services' ) ? $settings['link_image_size'] : $settings['share_image_size'];
     458        $shareOrLink = ( $id == 'link_services' ) ? 'Link' : 'Share';
     459        $value       = $settings[ $id ];
     460        ?>
     461
     462        <div class="csb-services">
     463
     464            <div class="csb-include-list chosen">
     465                <div><span class="include-heading">Selected</span> (these will be displayed)</div>
     466                <ul id="csbsort2" class="connectedSortable data-base="<?= $image_set ?>"">
     467                    <?php echo $this->get_selected_services_html( $value, $image_set, $image_size ); ?>
     468                </ul>
     469                <input type="hidden" name="<?= $name ?>" id="<?= $id ?>" class="csb-services"/>
     470            </div>
     471
     472            <div class="csb-include-list available">
     473                <div><span class="include-heading"><?php _e( 'Available', $this->plugin_slug ) ?></span>
     474                    (<?php _e( 'these will <strong>not</strong> be displayed', $this->plugin_slug ) ?>)
     475                </div>
     476                <ul id="csbsort1" class="connectedSortable">
     477                    <?php echo $this->get_available_services_html( $value, $image_set, $image_size, $shareOrLink ); ?>
     478                </ul>
     479                </center>
     480            </div>
     481        </div>
     482    <?php
     483    }
     484
     485    /**
     486     * Display share settings section
     487     */
     488    public function renderPositionSelect( $args ) {
     489        $id       = $args[0];
     490        $name     = $this->plugin_slug . '[' . $args[0] . ']';
    337491        $settings = $this->getSettings();
    338         $value = isset($settings[$id]) ? $settings[$id] : ' ';
    339         $name = $this->plugin_slug . '[' . $args[0] . ']';
    340         $description = isset($args[1]) ? $args[1] : '';
    341        
     492        $value    = $settings[ $id ];
    342493        ?>
    343494
    344             <input type="text" id="<?=$id?>" name="<?=$name?>" value="<?=$value?>" />
    345             <span class="description">
    346                <?=$description?>
    347             </span>
    348            
    349         <?php
    350     }
    351 
    352     /**
    353      * Display a settings textbox
    354      */
    355     public function renderNumericTextbox($args) {
    356         $id = $args[0];
    357         $settings = $this->getSettings();
    358         $value = isset($settings[$id]) ? $settings[$id] : ' ';
    359         $name = $this->plugin_slug . '[' . $args[0] . ']';
    360         $description = isset($args[1]) ? $args[1] : '';
    361         $min = isset($args[2]) ? $args[2] : 24;
    362         $max = isset($args[3]) ? $args[3] : 64;
    363        
    364         ?>
    365 
    366             <input type="number" id="<?=$id?>" name="<?=$name?>" value="<?=$value?>" min="<?=$min?>" max="<?=$max?>" />
    367             <span class="description">
    368                <?=$description?>
    369             </span>
    370            
    371         <?php
    372     }
    373    
    374     /**
    375      * Display share settings section
    376      */
    377     public function renderImageSetSelect($args) {
    378         $id = $args[0];
    379         $name = $this->plugin_slug . '[' . $args[0] . ']';
    380         $settings = $this->getSettings();
    381         $value = $settings[$id];
    382         $base = plugin_dir_url(__FILE__) . "buttons/";
    383         $path = $base . $value . "/";
    384         ?>
    385        
    386         <select id="<?=$id?>" class="csb-image-set" name="<?=$name?>">
    387        
    388             <?php foreach ($this->all_image_sets as $set) { ?>
    389             <option value="<?=$set?>" <?php echo selected($set, $value);?>">
    390                 <?=$set?>
    391             </option>
    392        
    393         <?php } ?>
    394 
    395         </select>
    396 
    397 <?php
    398 }
    399    
    400     /**
    401      * Display share settings section
    402      */
    403     public function render_service_select($args) {
    404         $id = $args[0];
    405         $name = $this->plugin_slug . '[' . $args[0] . ']';
    406         $settings = $this->getSettings();
    407         $image_set = ($id == 'link_services') ? $settings['link_image_set'] : $settings['share_image_set'];
    408         $image_size = ($id == 'link_services') ? $settings['link_image_size'] : $settings['share_image_size'];
    409         $shareOrLink = ($id == 'link_services') ? 'Link' : 'Share';
    410         $value = $settings[$id];
    411         ?>
    412        
    413             <div class="csb-services">
    414 
    415                 <div class="csb-include-list chosen">
    416                     <div><span class="include-heading">Selected</span> (these will be displayed)</div>
    417                     <ul id="csbsort2" class="connectedSortable data-base="<?=$image_set?>"">
    418                         <?php echo $this->get_selected_services_html($value, $image_set, $image_size); ?>
    419                     </ul>
    420                     <input type="hidden" name="<?=$name?>" id="<?=$id?>" class="csb-services" />
    421                 </div>
    422 
    423                 <div class="csb-include-list available">
    424                     <div><span class="include-heading">Available</span> (these will <strong>not</strong> be displayed)</div>
    425                     <ul id="csbsort1" class="connectedSortable">
    426                         <?php echo $this->get_available_services_html($value, $image_set, $image_size, $shareOrLink); ?>
    427                     </ul>
    428                     </center>
    429                 </div>
    430             </div>
    431             <?php
    432     }
    433    
    434     /**
    435      * Display share settings section
    436      */
    437     public function renderPositionSelect($args) {
    438         $id = $args[0];
    439         $name = $this->plugin_slug . '[' . $args[0] . ']';
    440         $settings = $this->getSettings();
    441         $value = $settings[$id];
    442         ?>
    443        
    444             <select id="<?=$id?>" name="<?=$name?>">
    445                 <option value="above" <?php echo selected('above',$value);?> >Above</option>
    446                 <option value="below" <?php echo selected('below',$value);?> >Below</option>
    447                 <option value="both" <?php echo selected('both',$value);?> >Both</option>
    448             </select>
    449        
    450         <?php
    451     }
    452    
     495        <select id="<?= $id ?>" name="<?= $name ?>">
     496            <option
     497                value="above" <?php echo selected( 'above', $value ); ?> ><?php _e( 'Above', $this->plugin_slug ) ?></option>
     498            <option
     499                value="below" <?php echo selected( 'below', $value ); ?> ><?php _e( 'Below', $this->plugin_slug ) ?></option>
     500            <option
     501                value="both" <?php echo selected( 'both', $value ); ?> ><?php _e( 'Both', $this->plugin_slug ) ?></option>
     502        </select>
     503
     504    <?php
     505    }
     506
    453507    /**
    454508     * Validate our saved settings
    455509     */
    456     public function validate_settings($input) {
     510    public function validate_settings( $input ) {
    457511        $settings = $this->getSettings();
    458512
     
    463517        // the other data will be fine, but any checkboxes will be unset
    464518        $tab = $input['tab'];
    465        
    466         if ('share_options' == $tab) {     
     519
     520        if ( 'share_options' == $tab ) {
    467521            // first, all the checkboxes need to be set if present
    468             $settings['show_on_posts'] = isset($input['show_on_posts']);
    469             $settings['show_on_pages'] = isset($input['show_on_pages']);
    470             $settings['show_on_home'] = isset($input['show_on_home']);
    471             $settings['show_count'] = isset($input['show_count']);
    472             $settings['new_window'] = isset($input['new_window']);
    473            
     522            $settings['show_on_posts']      = isset( $input['show_on_posts'] );
     523            $settings['show_on_pages']      = isset( $input['show_on_pages'] );
     524            $settings['show_on_home']       = isset( $input['show_on_home'] );
     525            $settings['show_count']         = isset( $input['show_count'] );
     526            $settings['new_window']         = isset( $input['new_window'] );
     527            $settings['twitter_show_title'] = isset( $input['twitter_show_title'] );
     528
    474529            // our select boxes have constrained UI, so just update them
    475             $settings['share_image_set'] = isset($input['share_image_set']) ? $input['share_image_set'] : 'simple';
    476             $settings['share_services'] = isset($input['share_services']) ? $input['share_services'] : '';
    477             $settings['position'] = isset($input['position']) ? $input['position'] : 'below';
    478            
     530            $settings['share_image_set'] = isset( $input['share_image_set'] ) ? $input['share_image_set'] : 'simple';
     531            $settings['share_services']  = isset( $input['share_services'] ) ? $input['share_services'] : '';
     532            $settings['position']        = isset( $input['position'] ) ? $input['position'] : 'below';
     533
    479534            // and finally, validate our text boxes
    480             $settings['share_caption'] = sanitize_text_field ($input['share_caption']);
    481             $settings['email_body'] = sanitize_text_field ($input['email_body']);
    482             $settings['twitter_body'] = sanitize_text_field ($input['twitter_body']);
    483            
     535            $settings['share_caption'] = sanitize_text_field( $input['share_caption'] );
     536            $settings['email_body']    = sanitize_text_field( $input['email_body'] );
     537            $settings['twitter_body']  = sanitize_text_field( $input['twitter_body'] );
     538
    484539            // including numeric ones
    485             $settings['share_image_size'] = sanitize_text_field ($input['share_image_size']);
    486            
    487            
    488    
    489         } else if ('link_options' == $tab) {
     540            $settings['share_image_size'] = $this->sanitize_image_size( $input['share_image_size'] );
     541
     542
     543        } else if ( 'link_options' == $tab ) {
    490544
    491545            // our select boxes have constrained UI, so just update them
    492546            $settings['link_image_set'] = $input['link_image_set'];
    493             $settings['link_services'] = $input['link_services'];
    494            
     547            $settings['link_services']  = $input['link_services'];
     548
    495549            // and finally, validate our text boxes
    496             $settings['link_caption'] = sanitize_text_field ($input['link_caption']);
    497            
     550            $settings['link_caption'] = sanitize_text_field( $input['link_caption'] );
     551
    498552            // including numeric ones
    499             $settings['link_image_size'] = sanitize_text_field ($input['link_image_size']);
    500            
     553            $settings['link_image_size'] = $this->sanitize_image_size( $input['link_image_size'] );
     554
    501555            // and the textboxes for all our services
    502             foreach($this->all_services as $service) {
    503                 $settings[$service] = sanitize_text_field (stripslashes_deep($input[$service]));
    504             }
    505 
    506         }
    507         return $settings;
    508     }
    509        
     556            foreach ( $this->all_services as $service ) {
     557                $settings[ $service ] = sanitize_text_field( stripslashes_deep( $input[ $service ] ) );
     558            }
     559
     560        }
     561
     562        return $settings;
     563    }
     564
     565    function sanitize_image_size( $image_size_string ) {
     566        $size = sanitize_text_field( $image_size_string );
     567        if ( ! is_numeric( $size ) ) {
     568            return 48;
     569        }
     570        if ( $size < 24 ) {
     571            return 24;
     572        }
     573        if ( $size > 64 ) {
     574            return 64;
     575        }
     576
     577        return $size;
     578    }
     579
    510580    /**
    511581     * Get list item HTML for selected services from our text list
    512582     */
    513     function get_selected_services_html($selectedServicesString, $image_set, $image_size) {
    514 
    515         $htmlListItems = '';   
    516         if ($selectedServicesString != '') {
    517        
    518             $selectedServices = explode(',', $selectedServicesString); // explode string to array
    519             foreach ($selectedServices as $service) {
    520                 $url = plugin_dir_url(__FILE__) . "buttons/" . $image_set . "/" . $service . ".png";
    521                 $htmlListItems .= $this->get_service_icon_html($url, $service, $image_set, $image_size);
    522             }
    523         }
     583    function get_selected_services_html( $selectedServicesString, $image_set, $image_size ) {
     584
     585        $htmlListItems = '';
     586        if ( $selectedServicesString != '' ) {
     587
     588            $selectedServices = explode( ',', $selectedServicesString ); // explode string to array
     589            foreach ( $selectedServices as $service ) {
     590                $htmlListItems .= $this->get_service_icon_html( $service, $image_set, $image_size );
     591            }
     592        }
     593
    524594        return $htmlListItems;
    525595    }
    526    
     596
    527597    /**
    528598     * Get list item HTML for all services EXCEPT those already selected
    529599     */
    530     function get_available_services_html($selectedServicesString, $image_set, $image_size, $shareOrLink = 'Share') {
    531    
    532         $htmlListItems = '';   
     600    function get_available_services_html( $selectedServicesString, $image_set, $image_size, $shareOrLink = 'Share' ) {
     601
     602        $htmlListItems    = '';
    533603        $selectedServices = array();
    534         if ($selectedServicesString != '') {   
    535             $selectedServices = explode(',', $selectedServicesString); // explode string to array
    536         }
    537        
    538         foreach ($this->all_services as $service) {
    539             if (!$this->call_service_method($service, 'can'.$shareOrLink)) continue;
    540             if (in_array($service, $selectedServices)) continue;
    541                
    542             $url = plugin_dir_url(__FILE__) . "buttons/" . $image_set . "/" . $service . ".png";
    543             $htmlListItems .= $this->get_service_icon_html($url, $service, $image_set, $image_size);
    544        
    545         }
    546        
     604        if ( $selectedServicesString != '' ) {
     605            $selectedServices = explode( ',', $selectedServicesString ); // explode string to array
     606        }
     607
     608        foreach ( $this->all_services as $service ) {
     609            if ( ! $this->call_service_method( $service, 'can' . $shareOrLink ) ) {
     610                continue;
     611            }
     612            if ( in_array( $service, $selectedServices ) ) {
     613                continue;
     614            }
     615
     616            $htmlListItems .= $this->get_service_icon_html( $service, $image_set, $image_size );
     617
     618        }
     619
    547620        return $htmlListItems;
    548621    }
    549    
     622
     623    /**
     624     * Get html for a single service icon for selection on the admin page
     625     */
     626    function get_service_icon_html( $service, $image_set, $image_size ) {
     627        $filename = strtolower($service) . ".png";
     628        $base_url = plugin_dir_url( __FILE__ ) . "buttons/";
     629        $alt_url = wp_upload_dir()['baseurl'] . '/' . $this->plugin_slug . "/buttons/";
     630
     631        $url = $base_url . $image_set . "/" . $filename;
     632        $path = plugin_dir_path( __FILE__ ) . "buttons/" . $image_set . "/" . $filename;
     633        if (!file_exists($path)) {
     634            $url = $alt_url . $image_set . "/" . $filename;
     635        }
     636        return '<li id="' . $service
     637               . '"><img src="' . strtolower( $url )
     638               . '" data-filename="' . $filename
     639               . '" data-image-set="' . strtolower( $image_set )
     640               . '" data-alt-url="' . $alt_url
     641               . '" data-url="' . $base_url
     642               . '" alt="' . $service . '" width="' . $image_size . '" height="' . $image_size . '" /></li>';
     643
     644    }
     645
     646
    550647    /**
    551648     * Calls a static method on the given service and returns the result
    552649     */
    553     function call_service_method($service, $method) {
    554         return call_user_func(array('SH_' . $service, $method));
    555     }
    556    
    557    
    558     /**
    559      * Get html for a single service icon for selection on the admin page
    560      */
    561     function get_service_icon_html($url, $service, $image_set, $image_size) {
    562         return '<li id="' . $service
    563                 .'"><img src="' . strtolower($url)
    564                 . '" data-image-set="' . strtolower($image_set)
    565                 . '" alt="' . $service . '" width="'.$image_size.'" height="'.$image_size.'" /></li>';
    566 
    567     }
    568    
     650    function call_service_method( $service, $method ) {
     651        return call_user_func( array( 'SH_' . $service, $method ) );
     652    }
     653
    569654    /**
    570655     * Loads all the settings from the database
    571      */ 
     656     */
    572657    function getSettings() {
    573         $settings = get_option($this->plugin_slug);
     658        $settings = get_option( $this->plugin_slug );
    574659        $defaults = SH_Crafty_Social_Buttons_Plugin::get_default_settings();
    575         return wp_parse_args($settings, $defaults);
    576     }   
     660
     661        return wp_parse_args( $settings, $defaults );
     662    }
    577663
    578664}
     665
    579666?>
  • crafty-social-buttons/trunk/class-SH-Crafty-Social-Buttons-Plugin.php

    r890035 r891793  
    1313     * Plugin version, used for cache-busting of style and script file references.
    1414     */
    15     protected $version = '1.1.0';
     15    protected $version = '1.2.0';
    1616
    1717    /**
     
    6060        // Load public-facing style sheet and JavaScript.
    6161        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
    62         //add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );                       
     62        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
     63
     64        // Set up ajax callbacks for client-side loading of share counts
     65        add_action( 'wp_ajax_share_count', array($this, 'get_share_count') );
     66        add_action( 'wp_ajax_nopriv_share_count', array( $this, 'get_share_count') );
    6367       
    6468    }
     
    176180     */
    177181    public function enqueue_scripts() {
    178         wp_enqueue_script( $this->plugin_slug . '-scripts',
    179             plugins_url( 'js/public.min.js', __FILE__ ), array( 'jquery' ), $this->version );
     182
     183        $settings = get_option($this->plugin_slug);
     184
     185        // only add javascript if post counts are to be shown
     186        if ($settings['show_count']) {
     187
     188            wp_enqueue_script( $this->plugin_slug . '-scripts',
     189                plugins_url( 'js/public.min.js', __FILE__ ), array( 'jquery' ), $this->version, true );
     190        }
    180191    }
    181192
     
    215226        }
    216227    }
    217    
    218              
     228
     229    /**
     230     * Ajax callback method for those services that don't support directly getting share counts on client
     231     */
     232    function get_share_count() {
     233        $settings = get_option($this->plugin_slug);
     234        $result = new stdClass();
     235        try {
     236
     237            $nonce = isset($_GET['_wpnonce']) ? $_GET['_wpnonce'] : '';
     238
     239            if ( !wp_verify_nonce($nonce)) {
     240                $result->error = true;
     241                $result->message = __( 'You have taken too long. Please go back and retry.', $this->plugin_slug );
     242                wp_die(json_encode($result));
     243            }
     244            // get service
     245            $service = isset($_GET['service']) ? $_GET['service'] : '';
     246            if (empty($service) || strpos($settings['share_services'], $service) === false) {
     247                $result->error = true;
     248                $result->message = __( 'Service not specified.', $this->plugin_slug );
     249                wp_die(json_encode($result));
     250            }
     251
     252            // get url
     253            $url = isset($_GET['url']) ? $_GET['url'] : '';
     254            if (empty($url)) {
     255                $result->error = true;
     256                $result->message = __( 'Url not specified.', $this->plugin_slug );
     257                wp_die(json_encode($result));
     258            }
     259
     260            include_once(plugin_dir_path(__FILE__) . "services/class-SH_Social_Service.php");
     261            $class = "SH_$service";
     262
     263            if (file_exists(plugin_dir_path(__FILE__) . "services/class-$class.php")) {
     264                $file = include_once(plugin_dir_path(__FILE__) . "services/class-$class.php");
     265
     266                $service = new $class('share', $settings, '');
     267                $count = $service->shareCount($url);
     268                $result->count = $count;
     269                wp_die(json_encode($result));
     270            }
     271            exit;
     272        } catch (Exception $ex) {
     273            $result->error = true;
     274            $result->exception = $ex;
     275            $result->message = $ex.getMessage();
     276            wp_die(json_encode($result));
     277        }
     278    }
     279
     280
    219281    /**
    220282     * Get default settings (as an array)
     
    237299            'email_body'            => 'I thought you might like this: ',
    238300            'twitter_body'          => '',
     301            'twitter_show_title'    => true,
    239302                       
    240303            'link_image_set'        => 'simple',
  • crafty-social-buttons/trunk/class-SH-Crafty-Social-Buttons-Shortcode.php

    r890035 r891793  
    111111                return $content;
    112112            }
    113    
     113
    114114        }
    115115        return $content;
     
    168168        $title = get_the_title($post->ID);
    169169
     170        if ($showCount && $type == 'share') { // add url and title to JS for our scripts to access
     171            $data = array( 'url' => $url,
     172                           'callbackUrl' => wp_nonce_url(admin_url( 'admin-ajax.php' ) . '?action=share_count'),
     173                           'title' => $title,
     174                           'services' => $selectedServices,
     175                           'key' => $post->ID);
     176            wp_localize_script( $this->plugin_slug . '-scripts', 'crafty_social_buttons_data_'.$post->ID, $data );
     177        }
     178
    170179        $buttonHtml = '<div id="crafty-social-buttons" class="crafty-social-'.$type.'-buttons">';
    171180        if ($text != '') {
     
    177186        foreach ($selectedServices as $serviceName) {
    178187
    179              $button = $this->get_individual_button_html($type, $serviceName, $url, $title, $showCount, $settings);                     
     188             $button = $this->get_individual_button_html($type, $serviceName, $url, $title, $showCount, $settings, $post->ID);
    180189             if (!empty($button)) {
    181190                 $buttonHtml .= '<li>' . $button . '</li>';
     
    190199     * Generates the markup for an individual share button
    191200     */
    192     function get_individual_button_html($type, $serviceName, $url, $title, $showCount, $settings) {
     201    function get_individual_button_html($type, $serviceName, $url, $title, $showCount, $settings, $key) {
    193202           
    194203        include_once(plugin_dir_path(__FILE__) . "services/class-SH_Social_Service.php");
     
    199208            $file = include_once(plugin_dir_path(__FILE__) . "services/class-$class.php");
    200209           
    201             $service = new $class($type, $settings);
     210            $service = new $class($type, $settings, $key);
    202211           
    203212            $username = isset($settings[$serviceName]) ? $settings[$serviceName] : '';
     
    215224     * Generates the markup for an individual link button
    216225     */
    217     function get_individual_link_button_html($serviceName, $settings) {
     226    function get_individual_link_button_html($serviceName, $settings, $key = '') {
    218227           
    219228        include_once(plugin_dir_path(__FILE__) ."services/class-SH_Social_Service.php");
     
    223232       
    224233            $file = include_once(plugin_dir_path(__FILE__) ."services/class-$class.php");
    225             $service = new $class($settings['new_window'], $settings['link_image_set'], $settings);
     234            $service = new $class($settings['new_window'], $settings['link_image_set'], $settings, $key);
    226235       
    227236            return $service->linkButton();
  • crafty-social-buttons/trunk/crafty-social-buttons.php

    r890035 r891793  
    1616 * Plugin URI:  http://github.com/sarahhenderson/crafty-social-buttons
    1717 * Description: Adds social sharing buttons and links to your site, including Ravelry, Etsy, Craftsy and Pinterest
    18  * Version:     1.1.0
     18 * Version:     1.2.0
    1919 * Author:      Sarah Henderson
    2020 * Author URI:  http://sarahhenderson.info
  • crafty-social-buttons/trunk/css/admin.min.css

    r890035 r891793  
    11/*! crafty-social-buttons  (c) Sarah Henderson 2014
    2  * Version 1.1.0 (09-04-2014) */
     2 * Version 1.2.0 (12-04-2014) */
    33
    44.crafty-social-buttons .csb-include-list{border:1px solid #ddd;background:#f1f1f1;margin-right:.5em;vertical-align:top;padding:.4em}.crafty-social-buttons .include-heading{text-align:left;font-weight:700}.crafty-social-buttons .csb-include-list ul{border:1px solid #ddd;background:#fff;padding:.5em;margin:0;min-height:60px}.crafty-social-buttons .csb-include-list ul li{display:inline-block;padding:0;margin:.3em;text-align:center;font-size:1.2em;cursor:move}.crafty-social-buttons .csb-image-preview{margin-top:.5em}.crafty-social-buttons select{width:200px}.crafty-social-buttons input[type=text]{width:350px}.crafty-social-buttons span.description{font-style:normal}.crafty-social-buttons span.description strong{font-style:italic}
  • crafty-social-buttons/trunk/css/public.min.css

    r890035 r891793  
    11/*! crafty-social-buttons  (c) Sarah Henderson 2014
    2  * Version 1.1.0 (09-04-2014) */
     2 * Version 1.2.0 (12-04-2014) */
    33
    4 #crafty-social-buttons{margin:.3em 0}#crafty-social-buttons .crafty-social-caption{display:inline-block;padding-right:1em;vertical-align:top;font-size:1.2em}#crafty-social-buttons ul{display:inline-block;list-style-type:none;margin:0;padding:0}#crafty-social-buttons ul li{display:inline-block;margin:0 .2em;padding:0}#crafty-social-buttons .crafty-social-share-count:after,#crafty-social-buttons .crafty-social-share-count:before{right:100%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}#crafty-social-buttons .crafty-social-share-count:after{border-color:rgba(224,221,221,0);border-right-color:#f5f5f5;border-width:5px;top:50%;margin-top:-5px}#crafty-social-buttons .crafty-social-share-count:before{border-color:rgba(85,94,88,0);border-right-color:#e0dddd;border-width:6px;top:50%;margin-top:-6px}#crafty-social-buttons .crafty-social-share-count{font:11px Arial,Helvetica,sans-serif;color:#555e58;padding:5px;-khtml-border-radius:6px;-o-border-radius:6px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;position:relative;background:#f5f5f5;border:1px solid #e0dddd}
     4#crafty-social-buttons{margin:.3em 0}#crafty-social-buttons .crafty-social-caption{display:inline-block;padding-right:1em;vertical-align:top;font-size:1.2em}#crafty-social-buttons ul{display:inline-block;list-style-type:none;margin:0;padding:0}#crafty-social-buttons ul li{display:inline-block;margin:0 .2em;padding:0}#crafty-social-buttons .crafty-social-share-count:after,#crafty-social-buttons .crafty-social-share-count:before{right:100%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}#crafty-social-buttons .crafty-social-share-count:after{border-color:rgba(224,221,221,0);border-right-color:#f5f5f5;border-width:5px;top:50%;margin-top:-5px}#crafty-social-buttons .crafty-social-share-count:before{border-color:rgba(85,94,88,0);border-right-color:#e0dddd;border-width:6px;top:50%;margin-top:-6px}#crafty-social-buttons .crafty-social-share-count{font:18px Arial,Helvetica,sans-serif;color:#555e58;padding:5px;-khtml-border-radius:6px;-o-border-radius:6px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;position:relative;background:#f5f5f5;border:1px solid #e0dddd;display:inline-block;vertical-align:top;margin-left:2px;min-width:24px;text-align:center}
  • crafty-social-buttons/trunk/help/adding-icons-tab.php

    r801913 r891793  
    44<ol>
    55    <li>Your images are <strong>.png</strong> files</li>
    6     <li>You use the same filenames as the existing image sets (which are pretty straighforward - e.g. facebook is facebook.png, ravelry is ravelry.png)</li>
    7     <li>Your images are either 48x48px or 64x64px in size. (This isn't strictly necessary, but will give you the best results.  By default, the images are displayed at 48x48px.</li>
     6    <li>You use the same filenames as the existing image sets
     7        (which are pretty straighforward - e.g. facebook is facebook.png, ravelry is ravelry.png)</li>
     8    <li>Your images are between 24x24px or 64x64px in size. You can set the size in the options page.</li>
    89</ol>
    910
    10 <p>If you've got all that sorted, you just need to create a new folder inside the <code>wp-plugins/crafty-social-buttons/buttons</code> folder.  You'll see the folders for the existing icon sets - just add your new folder beside them.  It is best if you don't have any spaces or punctuation in the folder name.</p>
     11<p>If you've got all that sorted, you just need to create a new folder to store your icons.</p>
     12
     13<p>The plugin will look for your custom icon folders in <code>wp-content/uploads/crafty-social-buttons/buttons</code>.</p>
     14<p>For instance, if your custom icons are in a folder called <code>MyAwesomeIcons</code>, the plugin will look for the
     15    Facebook icon at <code>wp-content/uploads/crafty-social-buttons/buttons/MyAwesomeIcons/facebook.png</code>.</p>
     16<p>It is best if you don't have any spaces or punctuation in the folder name.</p>
    1117
    1218<p>Now if you refresh this options page, you will see your folder name as one of the options to choose from!</p>
  • crafty-social-buttons/trunk/js/admin.min.js

    r890035 r891793  
    11/*! crafty-social-buttons  (c) Sarah Henderson 2014
    2  * Version 1.1.0 (09-04-2014) */
    3 jQuery(document).ready(function(a){a("#csbsort1, #csbsort2").sortable({connectWith:".connectedSortable",update:function(){var b=a("#csbsort2 li").map(function(){return a(this).attr("id")}).get();a(".csb-services").val(b)}}).disableSelection(),a(".csb-services").val(a("#csbsort2 li").map(function(){return a(this).attr("id")}).get()),a(".csb-image-set").change(function(){var b=a(this).val();a(".csb-image-preview").attr("data-base"),a.each(a(".csb-services img"),function(c,d){var e=a(d).attr("src"),f=a(d).attr("data-image-set"),g=e.replace(f,b);a(d).attr("src",g),a(d).attr("data-image-set",b)})}),a("#share_image_size").bind("input",function(){var b=a(this).val();a.each(a(".csb-services img"),function(c,d){a(d).attr("width",b),a(d).attr("height",b)})}),a("#link_image_size").bind("input",function(){var b=a(this).val();a.each(a(".csb-services img"),function(c,d){a(d).attr("width",b),a(d).attr("height",b)})})});
     2 * Version 1.2.0 (12-04-2014) */
     3jQuery(document).ready(function(a){a("#csbsort1, #csbsort2").sortable({connectWith:".connectedSortable",update:function(){var b;b=a("#csbsort2 li").map(function(){return a(this).attr("id")}).get(),a(".csb-services").val(b)}}).disableSelection(),a(".csb-services").val(a("#csbsort2 li").map(function(){return a(this).attr("id")}).get()),a(".csb-image-set").change(function(){var b=a(this).val();a.each(a(".csb-services img"),function(c,d){var e=a(d).attr("data-url"),f=a(d).attr("data-alt-url"),g=a(d).attr("data-filename"),h=e+b+"/"+g,i=f+b+"/"+g;a(d).attr("src",h),a(d).attr("data-image-set",b),a.ajax(h,{method:"get",error:function(){a(d).attr("src",i)}})})}),a("#share_image_size").bind("input",function(){var b=a(this).val();a.each(a(".csb-services img"),function(c,d){a(d).attr("width",b),a(d).attr("height",b)})}),a("#link_image_size").bind("input",function(){var b=a(this).val();a.each(a(".csb-services img"),function(c,d){a(d).attr("width",b),a(d).attr("height",b)})})});
  • crafty-social-buttons/trunk/services/class-SH_Craftsy.php

    r890035 r891793  
    1111class SH_Craftsy extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Craftsy";
    1616    }
  • crafty-social-buttons/trunk/services/class-SH_Digg.php

    r890035 r891793  
    1111class SH_Digg extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Digg";
    1616    }
     
    2222            . ($this->newWindow ? 'target="_blank"' : '') . '>';
    2323   
    24         $html .= $this->buttonImage(); 
    25        
     24        $html .= $this->buttonImage();
     25
    2626        $html .= '</a>';
    2727   
     
    4545        return $html;
    4646    }
    47    
     47
    4848    public static function description() {
    4949        return "Hint: www.digg.com/<strong>user-id</strong>";   
  • crafty-social-buttons/trunk/services/class-SH_Email.php

    r890035 r891793  
    1111class SH_Email extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Email";
    1616        $this->imageUrl = $this->imagePath . "email.png";
  • crafty-social-buttons/trunk/services/class-SH_Etsy.php

    r890035 r891793  
    1111class SH_Etsy extends SH_Social_Service {
    1212   
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Etsy";
    1616        $this->imageUrl = $this->imagePath . "etsy.png";
  • crafty-social-buttons/trunk/services/class-SH_Facebook.php

    r890035 r891793  
    1111class SH_Facebook extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Facebook";
    1616        $this->imageUrl = $this->imagePath . "facebook.png";
     
    2323             . ($this->newWindow ? 'target="_blank"' : '') . '>';
    2424   
    25         $html .= $this->buttonImage(); 
    26    
    27         if ($showCount) {
    28             $html .= '<span class="crafty-social-share-count">' . $this->shareCount($url) . '</span>'; 
    29         }
     25        $html .= $this->buttonImage();
     26
     27        $html .= $this->shareCountHtml($showCount);
    3028   
    3129        $html .= '</a>';
     
    6058             if (isset($json['shares'])) {
    6159                 return $json['shares'];
     60             } elseif (isset($json['likes'])) {
     61                 return $json['likes'];
    6262             } else {
    6363                 return '0';
  • crafty-social-buttons/trunk/services/class-SH_Flickr.php

    r890035 r891793  
    1111class SH_Flickr extends SH_Social_Service {
    1212   
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Flickr";
    1616    }
  • crafty-social-buttons/trunk/services/class-SH_Google.php

    r890035 r891793  
    1111class SH_Google extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Google";
    1616        $this->imageUrl = $this->imagePath . "google.png";
     
    2424             . ($this->newWindow ? 'target="_blank"' : '') . '>';
    2525       
    26         $html .= $this->buttonImage(); 
    27        
    28         if ($showCount) {
    29             $html .= '<span class="crafty-social-share-count">' . $this->shareCount($url) . '</span>'; 
    30         }
     26        $html .= $this->buttonImage();
     27
     28        $html .= $this->shareCountHtml($showCount);
    3129   
    3230        $html .= '</a>';
     
    6462                'method' => 'pos.plusones.get',
    6563                'id' => 'p',
    66                 'method' => 'pos.plusones.get',
    6764                'jsonrpc' => '2.0',
    6865                'key' => 'p',
  • crafty-social-buttons/trunk/services/class-SH_Instagram.php

    r890035 r891793  
    1111class SH_Instagram extends SH_Social_Service {
    1212   
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Instagram";
    1616    }
  • crafty-social-buttons/trunk/services/class-SH_LinkedIn.php

    r890035 r891793  
    1111class SH_LinkedIn extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "LinkedIn";
    1616        $this->imageUrl = $this->imagePath . "linkedin.png";
     
    2424             . ($this->newWindow ? 'target="_blank"' : '') . '>';
    2525   
    26         $html .= $this->buttonImage(); 
    27        
    28         if ($showCount) {
    29             $html .= '<span class="crafty-social-share-count">' . $this->shareCount($url) . '</span>'; 
    30         }
     26        $html .= $this->buttonImage();
     27
     28        $html .= $this->shareCountHtml($showCount);
    3129
    3230        $html .= '</a>';
     
    5755    public function shareCount($url) {
    5856   
    59          $response = wp_remote_get('http://www.linkedin.com/countserv/count/share?url=' . $url);
     57         $response = wp_remote_get('http://www.linkedin.com/countserv/count/share?format=json&url=' . $url);
    6058         if (is_wp_error($response)){
    6159        // return zero if response is error                             
    6260        return "0";             
    6361         } else {
    64    
    65             $responseBody = str_replace('IN.Tags.Share.handleCount(', '', $response['body']);
    66            $responseBody = str_replace(');', '', $responseBody);
    67 
    6862             $json = json_decode($response['body'], true);
    6963             if (isset($json['count'])) {
  • crafty-social-buttons/trunk/services/class-SH_Pinterest.php

    r890035 r891793  
    1111class SH_Pinterest extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Pinterest";
    1616        $this->imageUrl = $this->imagePath . "pinterest.png";
     
    2121        $html = "<a class=\"" . $this->cssClass() . "\" href='javascript:void((function()%7Bvar%20e=document.createElement(&apos;script&apos;);e.setAttribute(&apos;type&apos;,&apos;text/javascript&apos;);e.setAttribute(&apos;charset&apos;,&apos;UTF-8&apos;);e.setAttribute(&apos;src&apos;,&apos;http://assets.pinterest.com/js/pinmarklet.js?r=&apos;+Math.random()*99999999);document.body.appendChild(e)%7D)());'>";
    2222
    23         $html .= $this->buttonImage(); 
    24        
    25         if ($showCount) {
    26             $html .= '<span class="crafty-social-share-count">' . $this->shareCount($url) . '</span>'; 
    27         }
     23        $html .= $this->buttonImage();
     24
     25        $html .= $this->shareCountHtml($showCount);
    2826
    2927        $html .= '</a>';
     
    5048   
    5149    public function shareCount($url) {
    52          $response = wp_remote_get('http://api.pinterest.com/v1/urls/count.json?callback=&url=' . $url);
     50         $response = wp_remote_get('http://api.pinterest.com/v1/urls/count.json?callback=receiveCount&url=' . $url);
    5351         if (is_wp_error($response)){
    5452        // return zero if response is error                             
    5553        return "0";             
    5654         } else {
    57              $responseBody = str_replace('(', '', $response['body']); // strip random extra parens in json
     55             $responseBody = str_replace('receiveCount(', '', $response['body']); // strip callback info from jsonp
    5856             $responseBody = str_replace(')', '', $responseBody);
    5957             $json = json_decode($responseBody, true);
  • crafty-social-buttons/trunk/services/class-SH_RSS.php

    r890035 r891793  
    1111class SH_RSS extends SH_Social_Service {
    1212   
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "RSS";
    1616    }
  • crafty-social-buttons/trunk/services/class-SH_Ravelry.php

    r890035 r891793  
    1111class SH_Ravelry extends SH_Social_Service {
    1212   
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Ravelry";
    1616        $this->imageUrl = $this->imagePath . "ravelry.png";
  • crafty-social-buttons/trunk/services/class-SH_Reddit.php

    r890035 r891793  
    1111class SH_Reddit extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Reddit";
    1616        $this->imageUrl = $this->imagePath . "reddit.png";
     
    2424            . ($this->newWindow ? 'target="_blank"' : '') . '>';
    2525   
    26         $html .= $this->buttonImage(); 
    27        
    28         if ($showCount) {
    29             $html .= '<span class="crafty-social-share-count">' . $this->shareCount($url) . '</span>'; 
    30         }
     26        $html .= $this->buttonImage();
     27
     28        $html .= $this->shareCountHtml($showCount);
    3129
    3230        $html .= '</a>';
     
    5351   
    5452    public function shareCount($url) {
    55          $response = wp_remote_get('www.reddit.com/api/info.json?url=' . $url);
     53         $response = wp_remote_get('http://www.reddit.com/api/info.json?url=' . $url);
    5654         if (is_wp_error($response)){
    5755        // return zero if response is error                             
     
    6664         }
    6765    }
     66
    6867    public static function description() {
    6968        return "Hint: www.reddit.com/user/<strong>user-id</strong>";   
  • crafty-social-buttons/trunk/services/class-SH_Social_Service.php

    r890035 r891793  
    1212
    1313    // construct the class
    14     public function __construct($type, $settings) {
     14    public function __construct($type, $settings, $key) {
    1515        $this->service = "Default"; // must be set correctly in the subclass constructors
    1616        $this->settings = $settings;
     17        $this->key = $key;
    1718
    1819        $imageSet = $settings[$type.'_image_set'];
    19         $this->imagePath = plugins_url() . "/crafty-social-buttons/buttons/$imageSet/";
     20        $this->imagePath = $this->getImageUrlPath($imageSet);
    2021
    2122        $this->imageExtension = ".png";
     
    2728    protected function cssClass() {
    2829        return "crafty-social-button csb-" . trim(strtolower($this->service));     
     30    }
     31
     32    protected function getImageUrlPath($imageSet) {
     33        $plugin_url = plugins_url() . "/crafty-social-buttons/buttons/$imageSet/";
     34        $plugin_file_path = plugin_dir_path(__FILE__) . "../buttons/$imageSet";
     35
     36        if (is_dir($plugin_file_path)) {
     37            return $plugin_url;
     38        } else {
     39            $custom_url = wp_upload_dir()['baseurl'] . "/crafty-social-buttons/buttons/$imageSet/";
     40            return $custom_url;
     41        }
    2942    }
    3043   
     
    6174        .'src="' . $imageUrl .'" />';
    6275    }
     76
     77    protected function shareCountHtml($display) {
     78        if ($display) {
     79            $slug = trim(strtolower($this->service));
     80            $key = $this->key;
     81            return '<span id="crafty-social-share-count-'.$slug.'-'.$key.'" class="crafty-social-share-count">0</span>';
     82        } else {
     83            return '';
     84        }
     85
     86    }
    6387   
    6488}
  • crafty-social-buttons/trunk/services/class-SH_StumbleUpon.php

    r890035 r891793  
    1111class SH_StumbleUpon extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "StumbleUpon";
    1616        $this->imageUrl = $this->imagePath . "stumbleupon.png";
     
    2424             . ($this->newWindow ? 'target="_blank"' : '') . '>';
    2525   
    26         $html .= $this->buttonImage(); 
    27        
    28         if ($showCount) {
    29             $html .= '<span class="crafty-social-share-count">' . $this->shareCount($url) . '</span>'; 
    30         }
     26        $html .= $this->buttonImage();
     27
     28        $html .= $this->shareCountHtml($showCount);
    3129
    3230        $html .= '</a>';
  • crafty-social-buttons/trunk/services/class-SH_Tumblr.php

    r890035 r891793  
    1111class SH_Tumblr extends SH_Social_Service {
    1212
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Tumblr";
    1616        $this->imageUrl = $this->imagePath . "tumblr.png";
  • crafty-social-buttons/trunk/services/class-SH_Twitter.php

    r890035 r891793  
    1111class SH_Twitter extends SH_Social_Service {
    1212   
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "Twitter";
    16         $this->text = isset($settings['twitter_body']) ? $settings['twitter_body'] : '';
     16        $this->text = isset($settings['twitter_body']) ? $settings['twitter_body'] : '';
     17        $this->show_title = isset($settings['twitter_show_title']) && $settings['twitter_show_title'];
    1718    }
    1819
     
    2021    public function shareButton($url, $title = '', $showCount = false) {
    2122
     23        if ($this->show_title) {
     24            $this->text .= ' '.$title;
     25        }
     26
    2227        $html = '<a class="' . $this->cssClass() . '" href="http://twitter.com/share?'
    2328            . 'url=' . $url
    24             . '&text=' . htmlspecialchars(urlencode(html_entity_decode(trim($this->text . ' ' . $title), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8')
     29            . '&text=' . htmlspecialchars(urlencode(html_entity_decode(trim($this->text), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8')
    2530            . '" '
    2631            . ($this->newWindow ? 'target="_blank"' : '') . '>';
    2732   
    2833        $html .= $this->buttonImage();
    29    
    30         if ($showCount) {
    31             $html .= '<span class="crafty-social-share-count">' . $this->shareCount($url) . '</span>'; 
    32         }
    33    
     34
     35        $html .= $this->shareCountHtml($showCount);
     36
    3437        $html .= '</a>';
    3538   
  • crafty-social-buttons/trunk/services/class-SH_YouTube.php

    r890035 r891793  
    1111class SH_YouTube extends SH_Social_Service {
    1212   
    13     public function __construct($type, $settings) {
    14         parent::__construct($type, $settings);
     13    public function __construct($type, $settings, $key) {
     14        parent::__construct($type, $settings, $key);
    1515        $this->service = "YouTube";
    1616    }
  • crafty-social-buttons/trunk/views/admin.php

    r801913 r891793  
    11            <div class="wrap <?php echo $this->plugin_slug; ?>">
    2                 <?php screen_icon(); ?>
    32                <h2>Crafty Social Buttons</h2>
    43
     
    1211                       Link Button Options</a>
    1312                </h2>
    14                
    15                 <? settings_errors(); ?>
    16        
     13                       
    1714                <form method="post" action="options.php">
    1815                    <?php 
Note: See TracChangeset for help on using the changeset viewer.