[ Index ]

PHP Cross Reference of PageLines DMS

title

Body

[close]

/sections/sharebar/ -> section.php (source)

   1  <?php
   2  /*
   3      Section: ShareBar
   4      Author: PageLines
   5      Author URI: http://www.pagelines.com
   6      Description: Adds ways to share content on pages/single posts
   7      Class Name: PageLinesShareBar
   8      Workswith: main
   9      Failswith: pagelines_special_pages()
  10      Cloning: true
  11      Filter: social
  12  */
  13  
  14  /**
  15   * ShareBar Section
  16   *
  17   * @package PageLines DMS
  18   * @author PageLines
  19   */
  20  class PageLinesShareBar extends PageLinesSection {
  21  
  22      /**
  23       * Section template.
  24       *
  25       * @version 2.2 - added conditional check for no social sites being chosen.
  26       */
  27      function section_template() {
  28  
  29          if( ! $this->get_shares() ) {
  30              echo setup_section_notify( $this, __( 'You have no shares setup, please look at Global Options > Social & Local; or deactivate the Sharebar from the Blog Post Template.', 'pagelines' ), add_query_arg( array( 'tablink' => 'settings', 'tabsublink' => 'social_media' ), site_url() ), __( 'Social Settings', 'pagelines' ), false );
  31              return;
  32          }
  33  
  34          $text = __( 'Share &rarr;', 'pagelines' );
  35          ?>
  36  
  37          <div class="pl-sharebar">
  38              <div class="pl-sharebar-pad">
  39                  <?php echo $this->get_shares(); ?>
  40                  <div class="clear"></div>
  41              </div>
  42          </div>
  43      <?php }
  44  
  45  	function get_shares(){
  46  
  47          global $post;
  48  
  49          if( ! is_object( $post ) )
  50              return;
  51          $perm = get_permalink($post->ID);
  52          $title = wp_strip_all_tags( get_the_title( $post->ID ) );
  53          $thumb = (has_post_thumbnail($post->ID)) ? pl_the_thumbnail_url( $post->ID ) : '';
  54  
  55          $desc = wp_strip_all_tags( pl_short_excerpt($post->ID, 10, '') );
  56  
  57          $out = '';
  58  
  59          if(pl_setting('share_google'))
  60              $out .= self::google(array('permalink' => $perm));
  61  
  62          if(pl_setting('share_twitter'))
  63              $out .= self::twitter(array('permalink' => $perm, 'title' => $title));
  64  
  65          if(pl_setting('share_facebook'))
  66              $out .= self::facebook(array('permalink' => $perm));
  67  
  68          if(pl_setting('share_linkedin'))
  69              $out .= self::linkedin(array('permalink' => $perm, 'title' => $title));
  70  
  71          if(pl_setting('share_pinterest'))
  72              $out .= self::pinterest(array('permalink' => $perm, 'image' => $thumb, 'desc' => $desc));
  73  
  74          return $out;
  75      }
  76  
  77      /**
  78       *
  79       * Pinterest Button
  80       *
  81       */
  82  	function pinterest( $args ){
  83  
  84          $defaults = array(
  85              'permalink'    => '',
  86              'width'        => '80',
  87              'title'        => '',
  88              'image'        => '',
  89              'desc'        => ''
  90          );
  91  
  92          $a = wp_parse_args($args, $defaults);
  93          ob_start();
  94          ?>
  95  
  96          <div class="pin_wrap"><a href="http://pinterest.com/pin/create/button/?url=<?php echo $a['permalink'];?>&media=<?php echo urlencode($a['image']);?>&description=<?php echo urlencode($a['desc']);?>" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a></div>
  97          <script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>
  98          <?php
  99  
 100          return ob_get_clean();
 101  
 102  
 103      }
 104  
 105  
 106      /**
 107       *
 108       * LinkedIn Button
 109       *
 110       */
 111  	function linkedin( $args ){
 112  
 113          $defaults = array(
 114              'permalink'    => '',
 115              'width'        => '80',
 116              'title'        => '',
 117          );
 118  
 119          $a = wp_parse_args($args, $defaults);
 120          ob_start();
 121          ?>
 122              <script src="http://platform.linkedin.com/in.js" type="text/javascript"></script>
 123              <script width="100" type="IN/Share" data-url="<?php echo $a['permalink'];?>" data-width="<?php echo $a['width'];?>" data-counter="right"></script>
 124  
 125          <?php
 126  
 127          return ob_get_clean();
 128  
 129  
 130      }
 131  
 132  
 133      /**
 134       *
 135       * StumbleUpon Button
 136       *
 137       */
 138  	function stumbleupon( $args ){
 139  
 140          $defaults = array(
 141              'permalink'    => '',
 142              'width'        => '80',
 143              'title'        => '',
 144          );
 145  
 146          $a = wp_parse_args($args, $defaults);
 147          ob_start();
 148          ?>
 149              <su:badge layout="2" ></su:badge>
 150  
 151               <script type="text/javascript">
 152               (function() {
 153                   var li = document.createElement('script'); li.type = 'text/javascript'; li.async = true;
 154                    li.src = 'https://platform.stumbleupon.com/1/widgets.js';
 155                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(li, s);
 156               })();
 157               </script>
 158  
 159          <?php
 160  
 161          return ob_get_clean();
 162  
 163  
 164      }
 165  
 166  
 167      /**
 168      *
 169      * Buffer Social Button
 170      *
 171      */
 172  	function buffer( $args ){
 173  
 174          $defaults = array(
 175              'permalink'    => '',
 176              'width'        => '80',
 177              'title'        => '',
 178              'handle'    => pl_setting('twittername')
 179          );
 180  
 181          $a = wp_parse_args($args, $defaults);
 182  
 183  
 184          return sprintf(
 185              '<a href="http://bufferapp.com/add" class="buffer-add-button" data-text="%s" data-url="%s" data-count="horizontal" data-via="%s">Buffer</a><script type="text/javascript" src="http://static.bufferapp.com/js/button.js"></script>',
 186              $a['title'],
 187              $a['permalink'],
 188              $a['handle']
 189          );
 190  
 191  
 192      }
 193  
 194      /**
 195      *
 196      * Twitter Button
 197      *
 198      */
 199  	function twitter( $args ){
 200  
 201          $defaults = array(
 202              'permalink'    => '',
 203              'width'        => '80',
 204              'hash'        => pl_setting('site-hashtag'),
 205              'handle'    => pl_setting('twittername'),
 206              'title'        => '',
 207          );
 208  
 209          $a = wp_parse_args($args, $defaults);
 210  
 211          ob_start();
 212  
 213              // Twitter
 214              printf(
 215                  '<a href="https://twitter.com/share" class="twitter-share-button" data-url="%s" data-text="%s" data-via="%s" data-hashtags="%s">Tweet</a>',
 216                  $a['permalink'],
 217                  $a['title'],
 218                  $a['handle'],
 219                  $a['hash']
 220              );
 221  
 222          ?>
 223          <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
 224  
 225          <?php
 226  
 227          return ob_get_clean();
 228  
 229      }
 230  
 231  
 232      /**
 233      *
 234      * Google Plus Button
 235      *
 236      */
 237  	function google( $args ){
 238  
 239          $defaults = array(
 240              'permalink'    => '',
 241              'width'        => '80',
 242          );
 243  
 244          $a = wp_parse_args($args, $defaults);
 245  
 246          ob_start();
 247  
 248              // G+
 249              printf('<div class="g-plusone" data-size="medium" data-width="%s" data-href="%s"></div>', $a['width'], $a['permalink']);
 250  
 251          ?>
 252          <!-- Place this render call where appropriate -->
 253          <script type="text/javascript">
 254            (function() {
 255              var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
 256              po.src = 'https://apis.google.com/js/plusone.js';
 257              var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 258            })();
 259          </script>
 260  
 261          <?php
 262  
 263          return ob_get_clean();
 264  
 265      }
 266  
 267  
 268      /**
 269      *
 270      * @TODO document
 271      *
 272      */
 273  	function facebook( $args ){
 274  
 275          $defaults = array(
 276              'permalink'    => '',
 277              'width'        => '80',
 278          );
 279  
 280          $a = wp_parse_args($args, $defaults);
 281  
 282          $app_id = '';
 283          if( pl_setting( 'facebook_app_id' ) )
 284              $app_id = sprintf( '&appId=%s', pl_setting( 'facebook_app_id' ) );
 285  
 286          ob_start();
 287              // Facebook
 288              ?>
 289              <script>(function(d, s, id) {
 290                      var js, fjs = d.getElementsByTagName(s)[0];
 291                      if (d.getElementById(id)) return;
 292                      js = d.createElement(s); js.id = id;
 293                      js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1<?php echo $app_id; ?>";
 294                      fjs.parentNode.insertBefore(js, fjs);
 295                      }(document, 'script', 'facebook-jssdk'));
 296              </script>
 297              <?php
 298              printf(
 299                  '<div class="fb-like" data-href="%s" data-send="false" data-layout="button_count" data-width="%s" data-show-faces="false" data-font="arial" style="vertical-align: top"></div>',
 300                  $a['permalink'],
 301                  $a['width']);
 302  
 303          return ob_get_clean();
 304  
 305      }
 306  
 307  }


Generated: Sun Dec 1 19:43:16 2013 Cross-referenced by PHPXref 0.7.1