[ Index ]

PHP Cross Reference of PageLines DMS

title

Body

[close]

/includes/ -> class.shortcodes.php (source)

   1  <?php
   2  /**
   3   * PageLines_ShortCodes
   4   *
   5   * This file defines return functions to be used as shortcodes by users and developers
   6   *
   7   * @package     PageLines Framework
   8   * @subpackage  Sections
   9   * @since       2.2
  10   *
  11   *  SHORTCODE TABLE OF CONTENTS
  12   *  1.  Bookmark
  13   *  2.  Pagename
  14   *  3.  Theme URL
  15   *  4.  Google Maps
  16   *  5.  Google Charts
  17   *  6.  Post Feed
  18   *  7.  Dynamic Box
  19   *  8.  Container
  20   *  9.  Post Edit
  21   *  10. Post Categories
  22   *  11. Post Tags
  23   *  12. Post Type
  24   *  13. Post Comments
  25   *  14. Post Authors Archive
  26   *  15. Post Author URL
  27   *  16. Post Author Display Name
  28   *  17. Post Date
  29   *  18. Pinterest Button
  30   *      Google Plus
  31   *      Linkedin Share
  32   *  19. Tweet Button
  33   *  20. Like Button
  34   *  21. Show Authors
  35   *  22. Codebox
  36   *  23. Labels
  37   *  24. Badgets
  38   *  25. Alertbox
  39   *  26. Blockquote
  40   *  27. Button
  41   *  28. Button Group
  42   *  29. Button Dropdown
  43   *  30. Split Button Dropdown
  44   *  31. Tooltip
  45   *  32. Popover
  46   *  32. Accordion
  47   *  34. Carousel
  48   *  35. Tabs
  49   *  36. Modal Popup
  50   *  37. Post Time
  51   *  38. PageLines Buttons (orig)
  52   *  39. Enqueue jQuery
  53   *  40. Enqueue Bootstrap JS
  54   */
  55  
  56  class PageLines_ShortCodes {
  57  
  58  
  59  	function __construct() {
  60  
  61          self::register_shortcodes( $this->shortcodes_core() );
  62  
  63          // Make widgets process shortcodes
  64          add_filter( 'widget_text', 'do_shortcode' );
  65  //        add_action( 'template_redirect', array( $this, 'filters' ) );
  66          add_action('wp_footer',array( $this, 'print_carousel_js' ), 21);
  67  
  68      }
  69  
  70  	private function shortcodes_core() {
  71  
  72          $core = array(
  73  
  74              'button'                    =>    array( 'function' => 'pagelines_button_shortcode' ),
  75              'post_time'                    =>    array( 'function' => 'pagelines_post_time_shortcode' ),
  76  
  77              'pl_button'                    =>    array( 'function' => 'pl_button_shortcode' ),
  78              'pl_buttongroup'            =>  array( 'function' => 'pl_buttongroup_shortcode' ),
  79              'pl_buttondropdown'         =>    array( 'function' => 'pl_buttondropdown_shortcode' ),
  80              'pl_splitbuttondropdown'    =>  array( 'function' => 'pl_splitbuttondropdown_shortcode' ),
  81              'pl_tooltip'                =>  array( 'function' => 'pl_tooltip_shortcode' ),
  82              'pl_popover'                =>    array( 'function' => 'pl_popover_shortcode' ),
  83              'pl_accordion'              =>    array( 'function' => 'pl_accordion_shortcode' ),
  84              'pl_accordioncontent'       =>  array( 'function' => 'pl_accordioncontent_shortcode' ),
  85              'pl_carousel'               =>    array( 'function' => 'pl_carousel_shortcode' ),
  86              'pl_carouselimage'          =>    array( 'function' => 'pl_carouselimage_shortcode' ),
  87              'pl_tabs'                   =>    array( 'function' => 'pl_tabs_shortcode' ),
  88              'pl_tabtitlesection'        =>    array( 'function' => 'pl_tabtitlesection_shortcode' ),
  89              'pl_tabtitle'               =>    array( 'function' => 'pl_tabtitle_shortcode' ),
  90              'pl_tabcontentsection'      =>    array( 'function' => 'pl_tabcontentsection_shortcode' ),
  91              'pl_tabcontent'             =>    array( 'function' => 'pl_tabcontent_shortcode' ),
  92              'pl_modal'                    =>    array( 'function' => 'pl_modal_shortcode' ),
  93              'pl_blockquote'                =>    array( 'function' => 'pl_blockquote_shortcode' ),
  94              'pl_alertbox'                =>    array( 'function' => 'pl_alertbox_shortcode' ),
  95              'show_authors'                =>    array( 'function' => 'show_multiple_authors' ),
  96              'pl_codebox'                =>    array( 'function' => 'pl_codebox_shortcode' ),
  97              'pl_label'                    =>    array( 'function' => 'pl_label_shortcode' ),
  98              'pl_badge'                    =>    array( 'function' => 'pl_badge_shortcode' ),
  99              'googleplus'                =>    array( 'function' => 'pl_googleplus_button' ),
 100              'linkedin'                    =>    array( 'function' => 'pl_linkedinshare_button' ),
 101              'like_button'                =>    array( 'function' => 'pl_facebook_shortcode' ),
 102              'twitter_button'            =>    array( 'function' => 'pl_twitter_button' ),
 103              'pinterest'                    =>    array( 'function' => 'pl_pinterest_button' ),
 104              'post_date'                    =>    array( 'function' => 'pagelines_post_date_shortcode' ),
 105              'post_author'                =>    array( 'function' => 'pagelines_post_author_shortcode' ),
 106              'post_author_link'            =>    array( 'function' => 'pagelines_post_author_link_shortcode' ),
 107              'post_author_posts_link'    =>    array( 'function' => 'pagelines_post_author_posts_link_shortcode' ),
 108              'post_comments'                =>    array( 'function' => 'pagelines_post_comments_shortcode' ),
 109              'post_tags'                    =>    array( 'function' => 'pagelines_post_tags_shortcode' ),
 110              'post_categories'            =>    array( 'function' => 'pagelines_post_categories_shortcode' ),
 111              'post_type'                    =>    array( 'function' => 'pagelines_post_type_shortcode' ),
 112              'post_edit'                    =>    array( 'function' => 'pagelines_post_edit_shortcode' ),
 113              'container'                    =>    array( 'function' => 'dynamic_container' ),
 114              'cbox'                        =>    array( 'function' => 'dynamic_box' ),
 115              'post_feed'                    =>    array( 'function' => 'get_postfeed' ),
 116              'chart'                        =>    array( 'function' => 'chart_shortcode' ),
 117              'googlemap'                    =>    array( 'function' => 'googleMaps' ),
 118              'themeurl'                    =>    array( 'function' => 'get_themeurl' ),
 119              'link'                        =>    array( 'function' => 'create_pagelink' ),
 120              'bookmark'                    =>    array( 'function' => 'bookmark_link' ),
 121              'pl_raw'                    =>    array( 'function' => 'do_raw' ),
 122              'pl_video'                    =>    array( 'function' => 'pl_video_shortcode' ),
 123              'pl_child_url'                =>    array( 'function' => 'pl_child_url' ),
 124              'pl_site_url'                =>    array( 'function' => 'pl_site_url' ),
 125              'pl_parent_url'                =>    array( 'function' => 'get_themeurl' )
 126              );
 127  
 128          return $core;
 129      }
 130  
 131  	function do_raw() {
 132  
 133          global $post;
 134          $str = $post->post_content;
 135  
 136          $start = '[pl_raw]';
 137          $end = '[/pl_raw]';
 138          $stpos = strpos( $str, $start );
 139          if ( $stpos === FALSE )
 140              return '';
 141          $stpos += strlen( $start );
 142          $endpos = strpos( $str, $end, $stpos );
 143          if ( $endpos === FALSE )
 144              return '';
 145          $len = $endpos - $stpos;
 146          return do_shortcode( substr( $str, $stpos, $len ) );
 147      }
 148  
 149  
 150      // 1. Return link in page based on Bookmark
 151      // USAGE : [bookmark id="21" text="Link Text"]
 152  	function bookmark_link( $atts ) {
 153  
 154           //extract page name from the shortcode attributes
 155           extract( shortcode_atts( array( 'id' => '0', 'text' => '' ), $atts ) );
 156  
 157           //convert the page name to a page ID
 158           $bookmark = get_bookmark( $id );
 159  
 160          if( isset( $text ) ) $ltext = $text;
 161          else $ltext = $bookmark->link_name;
 162  
 163  
 164          $pagelink = "<a href=\"".$bookmark->link_url."\" target=\"".$bookmark->link_target."\">".$ltext."</a>";
 165           return $pagelink;
 166      }
 167  
 168      // 2. Function for creating a link from a page name
 169      // USAGE : [link pagename="My Example Page" linktext="Link Text"]
 170  	function create_pagelink( $atts ) {
 171  
 172           //extract page name from the shortcode attributes
 173           extract( shortcode_atts( array( 'pagename' => 'home', 'linktext' => '' ), $atts ) );
 174  
 175           //convert the page name to a page ID
 176           $page = get_page_by_title( $pagename );
 177  
 178           //use page ID to get the permalink for the page
 179           $link = get_permalink( $page );
 180  
 181           //create the link and output
 182           $pagelink = "<a href=\"".$link."\">".$linktext."</a>";
 183  
 184           return $pagelink;
 185      }
 186  
 187      // 3. Function for getting template path
 188      // USAGE: [themeurl]
 189  	function get_themeurl( $atts ) {
 190          return get_template_directory_uri();
 191      }
 192  
 193      // 4. GOOGLE MAPS //////////////////////////////////////////////////
 194  
 195          // you can use the default width and height
 196          // The only requirement is to add the address of the map
 197          // Example:
 198          // [googlemap address="san diego, ca"]
 199          // or with options
 200          // [googlemap width="200" height="200" address="San Francisco, CA 92109"]
 201  	function googleMaps( $atts, $content = null ) {
 202  
 203           extract( shortcode_atts( array(
 204  
 205           'width'    => '480',
 206           'height'    => '480',
 207           'locale'    => 'en',
 208           'address'    => ''
 209       ), $atts ) );
 210       $src = "http://maps.google.com/maps?f=q&source=s_q&hl=".$locale."&q=".$address;
 211       return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&amp;output=embed"></iframe>';
 212      }
 213  
 214      // 5. GOOGLE CHARTS  //////////////////////////////////////////////////
 215  
 216          // Gets Google charts
 217          // USAGE
 218          //        [chart data="0,12,24,26,32,64,54,24,22,20,8,2,0,0,3" bg="F7F9FA" size="200x100" type="sparkline"]
 219          //        [chart data="41.52,37.79,20.67,0.03" bg="F7F9FA" labels="Reffering+sites|Search+Engines|Direct+traffic|Other" colors="058DC7,50B432,ED561B,EDEF00" size="488x200" title="Traffic Sources" type="pie"]
 220  
 221  	function chart_shortcode( $atts ) {
 222          extract( shortcode_atts( array(
 223              'data' => '',
 224              'colors' => '',
 225              'size' => '400x200',
 226              'bg' => 'ffffff',
 227              'title' => '',
 228              'labels' => '',
 229              'advanced' => '',
 230              'type' => 'pie'
 231          ), $atts ) );
 232  
 233                  switch ( $type ) {
 234                      case 'line' :
 235                          $charttype = 'lc'; break;
 236                      case 'xyline' :
 237                          $charttype = 'lxy'; break;
 238                      case 'sparkline' :
 239                          $charttype = 'ls'; break;
 240                      case 'meter' :
 241                          $charttype = 'gom'; break;
 242                      case 'scatter' :
 243                          $charttype = 's'; break;
 244                      case 'venn' :
 245                          $charttype = 'v'; break;
 246                      case 'pie' :
 247                          $charttype = 'p3'; break;
 248                      case 'pie2d' :
 249                          $charttype = 'p'; break;
 250                      default :
 251                          $charttype = $type;
 252                      break;
 253                  }
 254                  $string = '';
 255                  if ( $title ) $string .= '&chtt='.$title.'';
 256                  if ( $labels ) $string .= '&chl='.$labels.'';
 257                  if ( $colors ) $string .= '&chco='.$colors.'';
 258                  $string .= '&chs='.$size.'';
 259                  $string .= '&chd=t:'.$data.'';
 260                  $string .= '&chf=bg,s,'.$bg.'';
 261  
 262          return '<img title="'.$title.'" src="http://chart.apis.google.com/chart?cht='.$charttype.''.$string.$advanced.'" alt="'.$title.'" />';
 263      }
 264  
 265      // 6. GET POST FIELD BY OFFSET //////////////////////////////////////////////////
 266      // Get a post based on offset from the last post published (0 for last post)
 267      // USAGE: [postfeed field="post_title"  offset="0" customfield="true" ]
 268  	function get_postfeed( $atts ) {
 269  
 270          //extract page name from the shortcode attributes
 271          extract( shortcode_atts( array( 'field' => 'post_title', 'offset' => '0', 'customfield' => "" ), $atts ) );
 272  
 273          //returns an array of objects
 274          $thepost = get_posts( 'numberposts=1&offset='.$offset );
 275  
 276          if( $customfield == 'true' ){
 277              $postfield = get_post_meta( $thepost[0]->ID, $field, true );
 278          }else{
 279              $postfield = $thepost[0]->$field;
 280          }
 281          return $postfield;
 282      }
 283  
 284      // 7. Created a container for dynamic html layout
 285      // USAGE: [cbox width="50%" leftgutter="15px" rightgutter="0px"] html box content[/cbox]
 286  	function dynamic_box( $atts, $content = null ) {
 287  
 288           //extract page name from the shortcode attributes
 289           extract( shortcode_atts( array( 'width' => '30%', 'leftgutter' => '10px', 'rightgutter' => '0px' ), $atts ) );
 290  
 291           $cbox = '<div class="cbox" style="float:left;width:'.$width.';"><div class="cbox_pad" style="margin: 0px '.$rightgutter.' 0px '.$leftgutter.'">'.do_shortcode( $content ).'</div></div>';
 292  
 293      return $cbox;
 294      }
 295  
 296      // 8. Created a container for dynamic html layout
 297      // USAGE: [container id="mycontainer" class="myclass"] 'cboxes' see shortcode below [/container]
 298  	function dynamic_container( $atts, $content = null ) {
 299  
 300           //extract page name from the shortcode attributes
 301           extract( shortcode_atts( array( 'id' => 'container', 'class' => '' ), $atts ) );
 302  
 303           $container = '<div style="width: 100%;" class="container">'.do_shortcode( $content ).'<div class="clear"></div></div>';
 304  
 305           return $container;
 306      }
 307  
 308      /**
 309       * 9. This function produces the edit post link for logged in users
 310       *
 311       * @example <code>[post_edit]</code> is the default usage
 312       * @example <code>[post_edit link="Edit", before="<b>" after="</b>"]</code>
 313       */
 314  	function pagelines_post_edit_shortcode( $atts ) {
 315  
 316          $defaults = array(
 317              'link' => __( "<span class='editpage sc'>Edit</span>", 'pagelines' ),
 318              'before' => '[',
 319              'after' => ']'
 320          );
 321          $atts = shortcode_atts( $defaults, $atts );
 322  
 323          // Prevent automatic WP Output
 324          ob_start();
 325          edit_post_link( $atts['link'], $atts['before'], $atts['after'] ); // if logged in
 326          $edit = ob_get_clean();
 327  
 328          $output = $edit;
 329  
 330          return apply_filters( 'pagelines_post_edit_shortcode', $output, $atts );
 331  
 332      }
 333  
 334      /**
 335       * 10. This function produces the category link list
 336       *
 337       * @example <code>[post_categories]</code> is the default usage
 338       * @example <code>[post_categories sep=", "]</code>
 339       */
 340  	function pagelines_post_categories_shortcode( $atts ) {
 341  
 342          $defaults = array(
 343              'sep' => ', ',
 344              'before' => '',
 345              'after' => ''
 346          );
 347          $atts = shortcode_atts( $defaults, $atts );
 348  
 349          $cats = get_the_category_list( trim( $atts['sep'] ) . ' ' );
 350  
 351          $output = sprintf( '<span class="categories sc">%2$s%1$s%3$s</span> ', $cats, $atts['before'], $atts['after'] );
 352  
 353          return apply_filters( 'pagelines_post_categories_shortcode', $output, $atts );
 354  
 355      }
 356  
 357      /**
 358       * 11. This function produces the tag link list
 359       *
 360       * @example <code>[post_tags]</code> is the default usage
 361       * @example <code>[post_tags sep=", " before="Tags: " after="bar"]</code>
 362       */
 363  	function pagelines_post_tags_shortcode( $atts ) {
 364  
 365          $defaults = array(
 366              'sep' => ', ',
 367              'before' => __( 'Tagged With: ', 'pagelines' ),
 368              'after' => ''
 369          );
 370          $atts = shortcode_atts( $defaults, $atts );
 371  
 372          $tags = get_the_tag_list( $atts['before'], trim( $atts['sep'] ) . ' ', $atts['after'] );
 373  
 374          if ( !$tags ) return;
 375  
 376          $output = sprintf( '<span class="tags sc">%s</span> ', $tags );
 377  
 378          return apply_filters( 'pagelines_post_tags_shortcode', $output, $atts );
 379  
 380      }
 381  
 382      /**
 383       * 12. This function produces a post type link.
 384       *
 385       * @example <code>[post_type]</code> is the default usage
 386       * @example <code>[post_type before="Type: " after="bar"]</code>
 387       */
 388  	function pagelines_post_type_shortcode( $atts ) {
 389  
 390          $defaults = array(
 391              'before' => __( 'Type: ', 'pagelines' ),
 392              'after' => ''
 393          );
 394          $atts = shortcode_atts( $defaults, $atts );
 395  
 396          global $post;
 397  
 398          if ( $post->post_type == 'post' )
 399              return;
 400  
 401          $t = get_post_type_object( $post->post_type );
 402  
 403          $name = $t->labels->name;
 404  
 405          $type = sprintf( '%s%s%s', $atts['before'], $name, $atts['after'] );
 406          if( $t->has_archive )
 407              $output = sprintf( '<span class="type sc"><a href="%s">%s</a></span> ', get_post_type_archive_link( $t->name ), $type );
 408          else
 409              $output = sprintf( '<span class="type sc">%s</span> ', $type );
 410          return apply_filters( 'pagelines_post_type_shortcode', $output, $atts );
 411      }
 412  
 413      /**
 414       * 13. This function produces the comment link
 415       *
 416       * @example <code>[post_comments]</code> is the default usage
 417       * @example <code>[post_comments zero="No Comments" one="1 Comment" more="% Comments"]</code>
 418       */
 419  	function pagelines_post_comments_shortcode( $atts ) {
 420  
 421          $defaults = array(
 422              'zero' => __( 'Add Comment', 'pagelines' ),
 423              'one' => __( "<span class='num'>1</span> Comment", 'pagelines' ),
 424              'more' => __( "<span class='num'>%</span> Comments", 'pagelines' ),
 425              'hide_if_off' => 'disabled',
 426              'before' => '',
 427              'after' => ''
 428          );
 429          $atts = shortcode_atts( $defaults, $atts );
 430  
 431          if ( ( !comments_open() ) && $atts['hide_if_off'] === 'enabled' )
 432              return;
 433  
 434          // Prevent automatic WP Output
 435          ob_start();
 436          comments_number( $atts['zero'], $atts['one'], $atts['more'] );
 437          $comments = ob_get_clean();
 438  
 439          $comments = sprintf( '<a href="%s">%s</a>', $this->get_comment_link(), $comments );
 440  
 441          $output = sprintf( '<span class="post-comments sc">%2$s%1$s%3$s</span>', $comments, $atts['before'], $atts['after'] );
 442  
 443          return apply_filters( 'pagelines_post_comments_shortcode', $output, $atts );
 444      }
 445  
 446  	function get_comment_link() {
 447  
 448          $comment = '#comments';
 449  
 450          if( function_exists( 'livefyre_show_comments' ) )
 451              $comment = '#lf_comment_stream';
 452  
 453          return sprintf( '%s%s', get_permalink(), $comment );
 454      }
 455  
 456      /**
 457       * 14. This function produces the author of the post (link to author archive)
 458       *
 459       * @example <code>[post_author_posts_link]</code> is the default usage
 460       * @example <code>[post_author_posts_link before="<b>" after="</b>"]</code>
 461       */
 462  	function pagelines_post_author_posts_link_shortcode( $atts ) {
 463  
 464          $defaults = array(
 465              'before' => '',
 466              'after' => ''
 467          );
 468          $atts = shortcode_atts( $defaults, $atts );
 469  
 470          // Prevent automatic WP Output
 471          ob_start();
 472          the_author_posts_link();
 473          $author = ob_get_clean();
 474  
 475          $output = sprintf( '<span class="author vcard sc">%2$s<span class="fn">%1$s</span>%3$s</span>', $author, $atts['before'], $atts['after'] );
 476  
 477          return apply_filters( 'pagelines_post_author_shortcode', $output, $atts );
 478      }
 479  
 480      /**
 481       * 15. This function produces the author of the post (link to author URL)
 482       *
 483       * @example <code>[post_author_link]</code> is the default usage
 484       * @example <code>[post_author_link before="<b>" after="</b>"]</code>
 485       */
 486  	function pagelines_post_author_link_shortcode( $atts ) {
 487  
 488          $defaults = array(
 489              'nofollow' => FALSE,
 490              'before' => '',
 491              'after' => ''
 492          );
 493          $atts = shortcode_atts( $defaults, $atts );
 494  
 495          $author = get_the_author();
 496  
 497          //    Link?
 498          if ( get_the_author_meta( 'url' ) ) {
 499  
 500              //    Build the link
 501              $author = '<a href="' . get_the_author_meta( 'url' ) . '" title="' . esc_attr( sprintf( __( 'Visit %s&#8217;s website', 'pagelines' ), $author ) ) . '" rel="external">' . $author . '</a>';
 502  
 503          }
 504  
 505          $output = sprintf( '<span class="author vcard sc">%2$s<span class="fn">%1$s</span>%3$s</span>', $author, $atts['before'], $atts['after'] );
 506  
 507          return apply_filters( 'pagelines_post_author_link_shortcode', $output, $atts );
 508  
 509      }
 510  
 511      /**
 512       * 16. This function produces the author of the post (display name)
 513       *
 514       * @example <code>[post_author]</code> is the default usage
 515       * @example <code>[post_author before="<b>" after="</b>"]</code>
 516       */
 517  	function pagelines_post_author_shortcode( $atts ) {
 518  
 519          $defaults = array(
 520              'before' => '',
 521              'after' => ''
 522          );
 523          $atts = shortcode_atts( $defaults, $atts );
 524  
 525          $output = sprintf( '<span class="author vcard sc">%2$s<span class="fn">%1$s</span>%3$s</span>',
 526                          esc_html( get_the_author() ),
 527                          $atts['before'],
 528                          $atts['after']
 529                      );
 530  
 531          return apply_filters( 'pagelines_post_author_shortcode', $output, $atts );
 532  
 533      }
 534  
 535      /**
 536       * 17. Post Date
 537       *
 538       */
 539  	function pagelines_post_date_shortcode( $atts ) {
 540  
 541          $defaults = array(
 542              'format' => get_option( 'date_format' ),
 543              'before' => '',
 544              'after' => '',
 545              'label' => ''
 546          );
 547          $atts = shortcode_atts( $defaults, $atts );
 548  
 549          $output = sprintf( '<time class="date time published updated sc" datetime="%5$s">%1$s%3$s%4$s%2$s</time> ',
 550                          $atts['before'],
 551                          $atts['after'],
 552                          $atts['label'],
 553                          get_the_time( $atts['format'] ),
 554                          get_the_time( 'c' )
 555                      );
 556  
 557          return apply_filters( 'pagelines_post_date_shortcode', $output, $atts );
 558  
 559      }
 560  
 561  
 562      /**
 563       * 18.Shortcode to display Pinterest button
 564       *
 565       * @example <code>[pinterest_button img=""]</code> is the default usage
 566       * @example <code>[pinterest_button img=""]</code>
 567       */
 568  	function pl_pinterest_button( $atts ){
 569  
 570              $defaults = array(
 571                  'url' => get_permalink(),
 572                  'img' => '',
 573                  'title' => urlencode( the_title_attribute( array( 'echo' => false ) ) ),
 574              );
 575  
 576              $atts = shortcode_atts( $defaults, $atts );
 577  
 578              $out = sprintf( '<a href="http://pinterest.com/pin/create/button/?url=%s&amp;media=%s&amp;description=%s" class="pin-it-button" count-layout="horizontal"><img style="border:0px;" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a><script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>',
 579              $atts['url'],
 580              $atts['img'],
 581              $atts['title']
 582              );
 583  
 584              return $out;
 585  
 586          }
 587  
 588      /**
 589       * 1X.Shortcode to display Google Plus 1 Button
 590       *
 591       * @example <code>[google_plus]</code> is the default usage
 592       * @example <code>[google_plus size="" count=""]</code>
 593       * @example available attributes for size include small, medium, and tall
 594       * @example avialable counts include inline, and bubble
 595       */
 596      function pl_googleplus_button ( $atts ) {
 597  
 598          $defaults = array(
 599              'size' => 'medium',
 600              'count' => 'inline',
 601              'url' => get_permalink()
 602  
 603          );
 604  
 605          $atts = shortcode_atts($defaults, $atts);
 606  
 607          ob_start();
 608  
 609          ?>
 610              <script type="text/javascript">
 611                (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 612                })();
 613              </script><?php
 614  
 615           printf( '<div class="g-plusone" style="width:190px;" data-size="%s" data-annotation="%s" data-href="%s"></div>',
 616              $atts['size'],
 617              $atts['count'],
 618              $atts['url']
 619          );
 620  
 621          return ob_get_clean();
 622      }
 623  
 624      /**
 625       * . Shortcode to display Linkedin Share Button
 626       *
 627       * @example <code>[linkedin]</code> is the default usage
 628       * @example <code>[linkedin count="vertical"]</code>
 629       */
 630      function pl_linkedinshare_button ($atts) {
 631  
 632              $defaults = array(
 633                  'url'    => get_permalink(),
 634                  'count'    => 'horizontal'
 635              );
 636  
 637              $atts = wp_parse_args( $atts, $defaults );
 638  
 639  
 640              $out = sprintf( '<script src="//platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-url="%s" data-counter="%s"></script>',
 641                      $atts['url'],
 642                      $atts['count']
 643                  );
 644  
 645             return $out;
 646  
 647      }
 648  
 649      /**
 650       * 19. Shortcode to display Tweet button
 651       *
 652       * @example <code>[twitter_button type=""]</code> is the default usage
 653       * @example <code>[twitter_button type="follow"]</code>
 654       */
 655  	function pl_twitter_button( $args ){
 656  
 657          $defaults = array(
 658              'type'      => '',
 659              'permalink'    => get_permalink(),
 660              'handle'    => ( pl_setting( 'twittername' ) ) ? pl_setting( 'twittername' ) : 'PageLines' ,
 661              'title'        => ''
 662              );
 663  
 664              $a = wp_parse_args( $args, $defaults );
 665  
 666              if ($a['type'] == 'follow') {
 667  
 668                  $out = sprintf( '<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><a href="https://twitter.com/%1$s" class="twitter-follow-button" data-show-count="true">Follow @%1$s</a>',
 669                      $a['handle']
 670                          );
 671  
 672              } else {
 673  
 674                  $out = sprintf( '<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><a href="https://twitter.com/share" class="twitter-share-button" data-url="%s" data-text="%s" data-via="%s">Tweet</a>',
 675                      $a['type'],
 676                      $a['permalink'],
 677                      $a['title'],
 678                      $a['handle']
 679                      );
 680              }
 681              return $out;
 682      }
 683  
 684      /**
 685       * 20. Shortcode to display Facebook Like button
 686       *
 687       * @example <code>[like_button]</code> is the default usage
 688       * @example <code>[like_button]</code>
 689       */
 690  	function pl_facebook_shortcode( $args ){
 691  
 692              $defaults = array(
 693                  'url'    => get_permalink(),
 694                  'width'        => '80',
 695              );
 696  
 697              $a = wp_parse_args( $args, $defaults );
 698  
 699              ob_start();
 700                  // Facebook
 701                  ?>
 702                  <script>(function(d, s, id) {
 703                          var js, fjs = d.getElementsByTagName(s)[0];
 704                          if (d.getElementById(id)) return;
 705                          js = d.createElement(s); js.id = id;
 706                          js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
 707                          fjs.parentNode.insertBefore(js, fjs);
 708                          }(document, 'script', 'facebook-jssdk'));
 709                  </script><?php
 710                  printf( '<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>',
 711                      $a['url'],
 712                      $a['width']
 713                  );
 714  
 715              return ob_get_clean();
 716  
 717          }
 718  
 719      /**
 720       * 21. This function/shortcode will show all authors on a post
 721       *
 722       * @example <code>[show_authors]</code> is the default usage
 723       * @example <code>[show_authors]</code>
 724       */
 725  	function show_multiple_authors() {
 726  
 727          if( class_exists( 'CoAuthorsIterator' ) ) {
 728  
 729              $i = new CoAuthorsIterator();
 730              $return = '';
 731              $i->iterate();
 732              $return .= '<a href="'.get_author_posts_url( get_the_author_meta( 'ID' ) ).'">'.get_the_author_meta( 'display_name' ).'</a>';
 733              while( $i->iterate() ){
 734                  $return.= $i->is_last() ? ' and ' : ', ';
 735                  $return .= '<a href="'.get_author_posts_url( get_the_author_meta( 'ID' ) ).'">'.get_the_author_meta( 'display_name' ).'</a>';
 736              }
 737  
 738              return $return;
 739  
 740          } else {
 741              //fallback
 742          }
 743      }
 744  
 745      /**
 746       * 22.Bootstrap Code Shortcode
 747       *
 748       * @example <code>[pl_codebox]...[/pl_codebox]</code> is the default usage
 749       * @example <code>[pl_codebox scrollable="yes"].box{margin:0 auto;}[/pl_codebox]</code> for lots of code
 750       */
 751  
 752  	function pl_codebox_shortcode ( $atts, $content = null ) {
 753  
 754          extract( shortcode_atts( array(
 755              'scrollable' => 'no',
 756              'linenums' => 'yes',
 757              'language'    => 'html'
 758          ), $atts ) );
 759  
 760          $scrollable = ( $scrollable == 'yes' ) ? 'pre-scrollable' : '';
 761          $linenums = ( $linenums == 'yes' ) ? 'linenums' : '';
 762          $language = 'lang-'.$language;
 763  
 764          // Grab Shortcodes
 765          $pattern = array(
 766  
 767              '#([a-z]+\=[\'|"][^\'|"]*[\'|"])#m',
 768              '#(\[[^]]*])#m',
 769  
 770          );
 771          $replace = array(
 772              '<span class="sc_var">$1</span>',
 773              '<span class="sc_code">$1</span>'
 774          );
 775  
 776          $code = preg_replace( $pattern, $replace, esc_html( $content ) );
 777  
 778          $out = sprintf( '<pre class="%s prettyprint %s %s">%s</pre>',
 779                      $scrollable,
 780                      $language,
 781                      $linenums,
 782                      $code
 783                  );
 784  
 785          return $out;
 786      }
 787  
 788      /**
 789       * 23. Bootstrap Labels Shortcode
 790       *
 791       * @example <code>[pl_label type=""]My Label[/pl_label]</code> is the default usage
 792       * @example <code>[pl_label type="info"]label[/pl_label]</code>
 793       * @example Available types include info, success, warning, error
 794       */
 795  	function pl_label_shortcode( $atts, $content = null ) {
 796  
 797          $defaults = array(
 798              'type' => 'info',
 799          );
 800  
 801          $atts = shortcode_atts( $defaults, $atts );
 802  
 803          $out = sprintf( '<span class="label label-%s">%s</span>',
 804                      $atts['type'],
 805                      do_shortcode( $content )
 806                  );
 807  
 808          return $out;
 809      }
 810  
 811      /**
 812       * 24. Bootstrap Badges Shortcode
 813       *
 814       * @example <code>[pl_badge type="info"]My badge[/pl_badge]</code> is the default usage
 815       * @example <code>[pl_badge type="info"]badge[/pl_badge]</code>
 816       * @example Available types include info, success, warning, error
 817       */
 818  	function pl_badge_shortcode( $atts, $content = null ) {
 819  
 820          $defaults = array(
 821              'type' => 'info',
 822          );
 823  
 824          $atts = shortcode_atts( $defaults, $atts );
 825  
 826          $out = sprintf( '<span class="badge badge-%s">%s</span>',
 827                      $atts['type'],
 828                      do_shortcode( $content )
 829                  );
 830  
 831          return $out;
 832      }
 833  
 834  
 835      /**
 836       * 25. Bootstrap Alertbox Shortcode
 837       *
 838       * @example <code>[pl_alertbox type="info"]My alert[/pl_alertbox]</code> is the default usage
 839       * @example <code>[pl_alertbox type="info" closable="yes"]My alert[/pl_alertbox]</code> makes an alert that can be toggled away with a close button
 840       * @example <code>[pl_alertbox type="info"]<h4 class="pl-alert-heading">Heading</h4>My alert[/pl_alertbox]</code>
 841       * @example Available types include info, success, warning, error
 842       */
 843  	function pl_alertbox_shortcode( $atts, $content = null ) {
 844  
 845          $content = str_replace( '<br />', '', str_replace( '<br>', '', $content ) );
 846  
 847          $defaults = array(
 848                      'type' => 'info',
 849                      'closable' =>'no',
 850                      );
 851  
 852          $atts = shortcode_atts( $defaults, $atts );
 853  
 854          $closed = sprintf( '<div class="alert alert-%s"><a class="close" data-dismiss="alert" href="#">×</a>%s</div>',
 855                  $atts['type'],
 856                  do_shortcode( $content )
 857          );
 858  
 859          if ( $atts['closable'] === 'yes' ) {
 860  
 861              return $closed;
 862  
 863          }
 864  
 865          $out = sprintf( '<div class="alert alert-%s alert-block">%2$s</div>',
 866                      $atts['type'],
 867                      do_shortcode( $content )
 868                  );
 869  
 870          return $out;
 871      }
 872  
 873      /**
 874       * 26. Bootstrap Blockquote Shortcode
 875       *
 876       * @example <code>[pl_blockquote pull="" cite=""]My quote[/pl_blockquote]</code> is the default usage
 877       * @example <code>[pl_blockquote pull="right" cite="Someone Famous"]My quote pulled right with source[/pl_blockquote]</code>
 878       */
 879  	function pl_blockquote_shortcode( $atts, $content = null) {
 880  
 881          $defaults = array(
 882              'pull'    => '',
 883              'cite'    => ''
 884          );
 885  
 886          $atts = shortcode_atts( $defaults, $atts );
 887  
 888          $out = sprintf( '<blockquote class="pull-%1$s"><p>%3$s<small>%2$s</small></p></blockquote>',
 889                      $atts['pull'],
 890                      $atts['cite'],
 891                      do_shortcode( $content )
 892                  );
 893  
 894          return $out;
 895  
 896      }
 897  
 898      /**
 899       * 27. Bootstrap Button Shortcode
 900       *
 901       * @example <code>[pl_button type="" size="" link="" target=""]...[/pl_button]</code> is the default usage
 902       * @example <code>[pl_button type="info" size="small" link="#" target="blank"]My Button[/pl_button]</code>
 903       * @example Available types include info, success, warning, danger, inverse
 904       * @example Available sizes include large, medium, and mini
 905       */
 906  	function pl_button_shortcode( $atts, $content = null, $target = null ) {
 907  
 908          $defaults = array(
 909              'type' => 'info',
 910              'size' => 'small',
 911              'link' => '#',
 912              'target' => '_self'
 913          );
 914  
 915          $atts = shortcode_atts( $defaults, $atts );
 916  
 917          $target = ( $target == 'blank' ) ? '_blank' : '';
 918  
 919          $out = sprintf( '<a href="%1$s" target="%2$s" class="btn btn-%3$s btn-%4$s">%5$s</a>',
 920                      $atts['link'],
 921                      $atts['target'],
 922                      $atts['type'],
 923                      $atts['size'],
 924                      do_shortcode( $content )
 925                      );
 926  
 927          return $out;
 928      }
 929  
 930  
 931      /**
 932       * 28. Bootstrap Button Group Shortcode - Builds a group of buttons as a menu
 933       *
 934       * @example <code>[pl_buttongroup]<a href="#" class="btn btn-info">...[/pl_buttongroup]</code> is the default usage
 935       * @example <code>[pl_buttongroup]<a href="#" class="btn btn-info"><a href="#" class="btn btn-info"><a href="#" class="btn btn-info">[/pl_button]</code>
 936       * @example Available types include info, success, warning, danger, inverse
 937       */
 938  	function pl_buttongroup_shortcode( $atts, $content = null ) {
 939  
 940          $content = str_replace( '<br />', '', str_replace( '<br>', '', $content ) );
 941  
 942          return sprintf( '<div class="btn-group">%s</div>', do_shortcode( $content ) );
 943  
 944      }
 945  
 946  
 947      /**
 948       * 29. Bootstrap Dropdown Button Shortcode - Builds a button with contained dropdown menu
 949       *
 950       * @example <code>[pl_buttondropdown size="" type="" label=""]<li><a href="#">...</a></li>[/pl_buttondropdown]</code> is the default usage
 951       * @example <code>[pl_buttondropdown size="large" type="info" label="button"]<li><a href="#"></li><li><a href="#"></li><li><a href="#"></li>[/pl_buttondropdown]</code>
 952       * @example Available types include info, success, warning, danger, inverse
 953       */
 954  	function pl_buttondropdown_shortcode( $atts, $content = null  ) {
 955  
 956          $defaults = array(
 957              'size' => '',
 958              'type' => '',
 959              'label' => ''
 960          );
 961  
 962          $atts = shortcode_atts( $defaults, $atts );
 963  
 964          $out = sprintf( '<div class="btn-group"><button class="btn btn-%s btn-%s dropdown-toggle" data-toggle="dropdown" href="#">%s <span class="caret"></span></button><ul  class="dropdown-menu">%s</ul></div>',
 965              $atts['size'],
 966                $atts['type'],
 967              $atts['label'],
 968              do_shortcode( $content )
 969          );
 970  
 971          return $out;
 972      }
 973  
 974  
 975      /**
 976       * 30. Bootstrap Split Button Dropdown - Builds a button with split button dropdown caret
 977       *
 978       * @example <code>[pl_splitbuttondropdown size="" type="" label=""]<li><a href="#">...</a></li>[/pl_splitbuttondropdown]</code> is the default usage
 979       * @example <code>[pl_splitbuttondropdown size="large" type="info" label="button"]<li><a href="#"></li><li><a href="#"></li><li><a href="#"></li>[/pl_splitbuttondropdown]</code>
 980       * @example Available types include info, success, warning, danger, inverse
 981       */
 982  	function pl_splitbuttondropdown_shortcode( $atts, $content = null ) {
 983  
 984          $defaults = array(
 985              'size' => '',
 986              'type' => '',
 987              'label' => ''
 988          );
 989  
 990          $atts = shortcode_atts( $defaults, $atts );
 991  
 992          $out = sprintf( '<div class="btn-group"><a class="btn btn-%1$s btn-%2$s" >%3$s</a><a class="btn btn-%1$s btn-%2$s dropdown-toggle" data-toggle="dropdown"><span  class="caret"></span></a><ul class="dropdown-menu">%4$s</ul></div>',
 993                $atts['size'],
 994              $atts['type'],
 995              $atts['label'],
 996              do_shortcode( $content )
 997          );
 998  
 999          return $out;
1000      }
1001  
1002       /**
1003       * 31. Bootstrap Tooltips
1004       *
1005       * @example <code>[pl_tooltip tip=""]...[/pl_tooltip]</code> is the default usage
1006       * @example <code>This is a [pl_tooltip tip="Cool"]tooltip[/pl_tooltip] example.</code>
1007       */
1008  	function pl_tooltip_shortcode( $atts, $content = null ) {
1009  
1010          $defaults = array(
1011              'tip' => 'Tip',
1012              'position'  => 'right'
1013          );
1014  
1015          $atts = shortcode_atts( $defaults, $atts );
1016  
1017              ob_start();
1018  
1019                  ?>
1020                  <script>
1021                      jQuery(function(){
1022                          jQuery("a[rel=tooltip]").tooltip();
1023                      });
1024                  </script><?php
1025  
1026              printf( '<a href="#" rel="tooltip" title="%s" data-placement="%s">%s</a>',
1027                  $atts['tip'],
1028                  $atts['position'],
1029                  do_shortcode( $content )
1030              );
1031  
1032              return ob_get_clean();
1033  
1034      }
1035  
1036      /**
1037       * 32. Bootstrap Popovers
1038       *
1039       * @example <code>[pl_popover title="" content=""]...[/pl_popover]</code> is the default usage
1040       * @example <code>This is a [pl_popover title="Popover Title" content="Some content that you can have inside the Popover"]popover[/pl_popover] example.</code>
1041       */
1042      function pl_popover_shortcode( $atts, $content = null ) {
1043  
1044          $defaults = array(
1045              'title' => 'Popover Title',
1046              'content' => 'Content',
1047              'position'  => 'right'
1048          );
1049  
1050          $atts = shortcode_atts( $defaults, $atts );
1051  
1052          ob_start();
1053  
1054              ?>
1055              <script>
1056                      jQuery(function(){
1057                           jQuery("a[rel=popover]")
1058                            .popover({
1059                              html:true,
1060                                trigger: 'hover'
1061                            })
1062                            .click(function(e) {
1063                              e.preventDefault()
1064                            });
1065                      });
1066              </script><?php
1067  
1068          printf( '<a href="#" rel="popover" title="%s" data-content="%s" data-placement="%s">%s</a>',
1069              $atts['title'],
1070              $atts['content'],
1071              $atts['position'],
1072              do_shortcode( $content )
1073          );
1074  
1075          return ob_get_clean();
1076  
1077      }
1078  
1079  
1080      /**
1081       * 33. Bootstrap Accordion - Collapsable Content
1082       *
1083       * @example <code>[pl_accordion name="accordion"] [accordioncontent name="accordion" number="1" heading="Tile 1"]Content 1 [/accordioncontent] [accordioncontent name="accordion" number="2" heading="Title 2"]Content 2 [/accordioncontent] [/pl_accordion]</code> is the default usage
1084       */
1085  	function pl_accordion_shortcode( $atts, $content = null ) {
1086  
1087          $defaults = array(
1088  
1089              'name' => '',
1090  
1091          );
1092  
1093          $atts = shortcode_atts( $defaults, $atts );
1094  
1095          $out = sprintf( '<div id="%s" class="accordion">%s</div>',
1096          $atts['name'],
1097          do_shortcode( $content )
1098          );
1099      return $out;
1100      }
1101  
1102      //Accordion Content
1103  	function pl_accordioncontent_shortcode( $atts, $content = null, $open = null ) {
1104  
1105          $defaults = array(
1106              'name' => '',
1107              'heading' => '',
1108              'number' => '',
1109              'open' => ''
1110          );
1111  
1112          $atts = shortcode_atts( $defaults, $atts );
1113          $open = ( $atts['open'] == 'yes' ) ? 'in' : '';
1114          $out = sprintf( '<div class="accordion-group"><div class="accordion-heading"><a class="accordion-toggle" data-toggle="collapse" data-parent="#%1$s" href="#collapse%3$s">%2$s</a></div><div id="collapse%3$s" class="accordion-body collapse %4$s"><div class="accordion-inner">%5$s</div></div></div>',
1115                $atts['name'],
1116              $atts['heading'],
1117              $atts['number'],
1118              $open,
1119              do_shortcode( $content )
1120  
1121          );
1122  
1123          return $out;
1124      }
1125  
1126      /**
1127       * 34. Bootstrap Carousel
1128       *
1129       * @example <code>[pl_carousel name=""][pl_carouselimage first="yes" title="" imageurl="" ]Caption[/pl_carouselimage][pl_carouselimage title="" imageurl="" ]Caption[/pl_carouselimage][/pl_carousel]</code> is the default usage
1130       * @example <code>[pl_carousel name="PageLinesCarousel"][pl_carouselimage first="yes" title="Feature 1" imageurl="" ]Image 1 Caption[/pl_carouselimage][pl_carouselimage title="Feature 2" imageurl=""]Image 2 Caption[/pl_carouselimage][pl_carouselimage title="Feature 3" imageurl=""]Image 3 Caption[/pl_carouselimage][/pl_carousel]</code>
1131       */
1132      function pl_carousel_shortcode( $atts, $content = null ) {
1133  
1134          global $carousel_js;
1135  
1136          if ( isset($atts['speed']) && '0' === $atts['speed'] )
1137              $atts['speed'] = 'pause'; // 0 will be striped by array_filter
1138  
1139          // remove any empty array keys that have empty values to enforce defaults (eg: name="" or speed="") that would otherwise break things
1140          $atts = array_filter($atts);
1141  
1142          $defaults = array(
1143              'name'  => 'PageLines Carousel',
1144              'speed' => 5000 // default bootstrap transition time
1145          );
1146  
1147          $atts = shortcode_atts( $defaults, $atts );
1148  
1149          $carousel_id = sanitize_title_with_dashes( $atts['name'], null, 'save' ); // convert it to a valid id attribute if it isn't.
1150          $speed = absint($atts['speed']);
1151  
1152          if ( ! isset($carousel_js) )
1153              $carousel_js = array();
1154          else {
1155              if ( array_key_exists($carousel_id, $carousel_js) )
1156                  $carousel_id = $carousel_id.'-'.count($carousel_js);
1157          }
1158  
1159          // store away the values for consolidated output in the footer
1160          $carousel_js[$carousel_id] = array(
1161              'id' => $carousel_id,
1162              'speed' => $speed
1163              );
1164  
1165          return sprintf( '<div id="%2$s" class="carousel slide"><div class="carousel-inner">%1$s</div><a class="carousel-control left" href="#%2$s" data-slide="prev">&lsaquo;</a><a class="carousel-control right" href="#%2$s" data-slide="next">&rsaquo;</a></div>',
1166          do_shortcode( $content ),
1167          $carousel_id
1168          );
1169      }
1170      //Carousel Images
1171  	function pl_carouselimage_shortcode( $atts, $content = null ) {
1172  
1173          // remove any empty string attributes to use defaults
1174          $atts = array_filter($atts);
1175  
1176          extract( shortcode_atts( array(
1177              'first' => '',
1178              'title' => '',
1179              'imageurl' => sprintf( '%s/screenshot.png', PL_PARENT_URL ), // fallback "reminder" image
1180              'caption' => '',
1181          ), $atts ) );
1182  
1183          $first = ( $first == 'yes' ) ? 'active' : '';
1184          $content = ( $content <> '' ) ? "<div class='carousel-caption'><h4>$title</h4><p>$content</p></div>" : ''; // changed to work without captions
1185  
1186          return sprintf( '<div class="item %s"><img src="%s">%s</div>', // changed to work without captions
1187                  $first,
1188                  $imageurl,
1189                  do_shortcode( $content )
1190                  );
1191      }
1192  
1193  	function print_carousel_js() {
1194  
1195          global $carousel_js;
1196  
1197          if ( ! isset($carousel_js) )
1198              return;
1199          echo "<!-- carousel_js -->\n";
1200  
1201          if ( isset($carousel_js) && is_array($carousel_js) ) : ?>
1202              <script type="text/javascript">
1203              (function($) {
1204              <?php
1205  
1206                  foreach ($carousel_js as $c) {
1207                      printf("\n$('#%s').carousel({ interval: %s })",
1208                          $c['id'],
1209                          ( 'pause' == $c['speed'] ) ? 0 : $c['speed']
1210                          );
1211                  }
1212              ?>
1213  
1214          })(jQuery);
1215  </script>
1216          <?php
1217          endif;
1218      }
1219  
1220      /**
1221       * 35. Bootstrap Tabs
1222       *
1223       * @example <code>[pl_tabs][pl_tabtitlesection type=""][pl_tabtitle active="" number="1"]...[/pl_tabtitle][pl_tabtitle number="2"]...[/pl_tabtitle][/pl_tabtitlesection][pl_tabcontentsection][pl_tabcontent active="" number="1"]...[/pl_tabcontent][pl_tabcontent number=""]...[/pl_tabcontent][/pl_tabcontentsection][/pl_tabs]</code> is the default usage
1224       * @example <code>[pl_tabs][pl_tabtitlesection type="tabs"][pl_tabtitle active="yes" number="1"]Title 1[/pl_tabtitle][pl_tabtitle number="2"]Title 2[/pl_tabtitle][/pl_tabtitlesection][pl_tabcontentsection][pl_tabcontent active="yes" number="1"]Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ac mi enim, at consectetur justo.[/pl_tabcontent][pl_tabcontent number="2"]Second content there.[/pl_tabcontent][/pl_tabcontentsection][/pl_tabs]</code>
1225       * @example Available types include tabs, pills
1226       */
1227  
1228      function pl_tabs_shortcode( $atts, $content = null ) {
1229  
1230          return sprintf( '<div class="tabs">%s</div>', do_shortcode( $content ) );
1231  
1232      }
1233  
1234      //Tab Titles Section
1235  		function pl_tabtitlesection_shortcode( $atts, $content = null ) {
1236  
1237              extract( shortcode_atts( array(
1238                  'type' => '',
1239              ), $atts ) );
1240  
1241              ob_start();
1242  
1243                  ?>
1244                      <script>
1245                          jQuery(function(){
1246                               jQuery('a[data-toggle="tab"]').on('shown', function (e) {
1247                                e.target // activated tab
1248                                e.relatedTarget // previous tab
1249                              })
1250                          });
1251                      </script><?php
1252  
1253              printf( '<ul class="nav nav-%s">%s</ul>',
1254              $type,
1255              do_shortcode( $content )
1256              );
1257  
1258              return ob_get_clean();
1259          }
1260  
1261      //Tab Titles
1262  		function pl_tabtitle_shortcode( $atts, $content = null ) {
1263  
1264              extract( shortcode_atts( array(
1265                  'active' => '',
1266                  'number' => ''
1267              ), $atts ) );
1268  
1269              $active = ( $active == 'yes' ) ? "class='active'" : '';
1270  
1271              $out = sprintf( '<li %s><a href="#%s" data-toggle="tab">%s</a></li>',
1272                      $active,
1273                      $number,
1274                      do_shortcode( $content )
1275                      );
1276  
1277              return $out;
1278          }
1279  
1280      //Tab Content Section
1281  		function pl_tabcontentsection_shortcode( $atts, $content = null ) {
1282  
1283              return '<div class="tab-content">'.do_shortcode( $content ).'</div>';
1284  
1285          }
1286  
1287      //Tab Content
1288  		function pl_tabcontent_shortcode( $atts, $content = null ) {
1289  
1290              extract( shortcode_atts( array(
1291                  'active' => '',
1292                  'number' => ''
1293              ), $atts ) );
1294  
1295              $active = ( $active == 'yes' ) ? "active" : '';
1296  
1297              return sprintf( '<div class="tab-pane %s" id="%s"><p>%s</p></div>',
1298                      $active,
1299                      $number,
1300                      do_shortcode( apply_filters( 'the_content',$content ) )
1301                      );
1302          }
1303  
1304      /**
1305       * 36. Bootstrap Modal Popup Window
1306       *
1307       * @example <code>[pl_modal title="" type="" colortype="" label=""]...[/pl_modal]</code>
1308       * @example <code>[pl_modal title="Title" type="label" colortype="info" label="Click Me!"]Some content here for the cool modal pop up. You can have all kinds of cool stuff in here.[/pl_modal]</code>
1309       * @example available types include button, label, and badge
1310       * @example available color types include default, success, warning, important, info, and inverse
1311       */
1312  	function pl_modal_shortcode( $atts, $content = null ) {
1313  
1314          extract( shortcode_atts( array(
1315              'title'        => '',
1316              'type'        => '',
1317              'colortype' => '',
1318              'label'     => '',
1319              'show'        => 'false',
1320              'hash'        => rand()
1321          ), $atts ) );
1322  
1323              ob_start();
1324  
1325                  ?>
1326                  <script>
1327                      jQuery(function(){
1328                          jQuery('#modal_<?php echo $hash; ?>').appendTo(jQuery('body')).modal({
1329                              keyboard: true
1330                              , show: <?php echo $show; ?>
1331                          });
1332                      });
1333                  </script><?php
1334  
1335                     printf( '<div id="modal_%6$s" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><a class="close" data-dismiss="modal" aria-hidden="true">×</a><h3>%s</h3></div><div class="modal-body"><p>%4$s</p></div><div class="modal-footer"><a href="#" class="btn btn-%3$s" data-dismiss="modal" aria-hidden="true">%7$s</a></div></div><a data-toggle="modal" role="button" href="#modal_%6$s" class="%2$s %2$s-%3$s">%5$s</a>',
1336                  $title,
1337                  $type,
1338                  $colortype,
1339                  do_shortcode( $content ),
1340                  $label,
1341                  $hash,
1342                  __( 'Close', 'pagelines' )
1343                  );
1344  
1345              return ob_get_clean();
1346  
1347      }
1348  
1349      /**
1350       * 37. This function produces the time of post publication
1351       *
1352       * @example <code>[post_time]</code> is the default usage</code>
1353       * @example <code>[post_time format="g:i a" before="<b>" after="</b>"]</code>
1354       */
1355  	function pagelines_post_time_shortcode( $atts ) {
1356  
1357          $defaults = array(
1358              'format' => get_option( 'time_format' ),
1359              'before' => '',
1360              'after' => '',
1361              'label' => ''
1362          );
1363          $atts = shortcode_atts( $defaults, $atts );
1364  
1365          $output = sprintf( '<span class="time published sc" title="%5$s">%1$s%3$s%4$s%2$s</span> ',
1366                          $atts['before'],
1367                          $atts['after'],
1368                          $atts['label'],
1369                          get_the_time( $atts['format'] ),
1370                          get_the_time( 'Y-m-d\TH:i:sO' )
1371                          );
1372  
1373          return apply_filters( 'pagelines_post_time_shortcode', $output, $atts );
1374  
1375      }
1376  
1377      /**
1378       * 38. Used to create general buttons and button links
1379       *
1380       * @example <code>[button]</code> is the default usage
1381       * @example <code>[button format="edit_post" before="<b>" after="</b>"]</code>
1382       */
1383  	function pagelines_button_shortcode( $atts ) {
1384  
1385          $defaults = array(
1386              'color'    => 'grey',
1387              'size'    => 'normal',
1388              'align'    => 'right',
1389              'style'    => '',
1390              'type'    => 'button',
1391              'text'    => '&nbsp;',
1392              'pid'    => 0,
1393              'class'    => null,
1394          );
1395          $atts = shortcode_atts( $defaults, $atts );
1396  
1397          $button = sprintf( '<div class="blink"><div class="blink-pad">%s</div></div>', $text );
1398  
1399          $output = sprintf( '<div class="%s %s %s blink-wrap">%s</div>', $special, $size, $color, $button );
1400  
1401          return apply_filters( 'pagelines_button_shortcode', $output, $atts );
1402  
1403      }
1404  
1405      /**
1406       * XX. Responsive Videos
1407       *
1408       * @example <code>[pl_video]</code> is the default usage
1409       * @example <code>[pl_video type="youtube" url="urltovideo"]</code>
1410       */
1411      function pl_video_shortcode ($atts) {
1412  
1413          extract( shortcode_atts( array(
1414              'type' =>'',
1415              'id' =>'',
1416              'width' => '100%',
1417              'height' => '100%',
1418              'related' => '',
1419              ), $atts ) );
1420          if ( $related )
1421              $related = '?rel=0';
1422  
1423          switch( $type ) {
1424  
1425  
1426              case 'vimeo':
1427                  $out = sprintf( '<div class="pl-video vimeo"><iframe src="http://player.vimeo.com/video/%s" width="%s" height="%s"  frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen wmode="transparent"></iframe></div>',$id, $width, $height );
1428                  break;
1429  
1430              case 'dailymotion':
1431                  $out = sprintf( '<div class="pl-video dailymotion"><iframe src="http://www.dailymotion.com/embed/video/%s" width="%s" height="%s"  frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen wmode="transparent"></iframe></div>',$id, $width, $height );
1432                  break;
1433  
1434              default:
1435                  $out = sprintf('<div class="pl-video youtube"><iframe src="http://www.youtube.com/embed/%s%s" width="%s" height="%s" frameborder="0" allowfullscreen wmode="transparent"></iframe></div>', $id, $related, $width, $height);
1436          }
1437          return $out;
1438      }
1439  
1440  	function pl_child_url() {
1441          return get_stylesheet_directory_uri();
1442      }
1443      
1444  	function pl_site_url() {
1445          return home_url();
1446      }
1447  
1448  	function filters() {
1449  
1450          /**
1451           *  Prevent AUTOP inside of shortcodes (breaking shortcodes - removed)
1452           */
1453          remove_filter( 'the_content', 'wpautop' );
1454          add_filter( 'the_content', 'wpautop' , 12);
1455          remove_filter( 'the_content', 'wptexturize' );
1456          add_filter( 'the_content', 'wptexturize' , 12);
1457      }
1458  
1459  	private function register_shortcodes( $shortcodes ) {
1460  
1461          foreach ( $shortcodes as $shortcode => $data ) {
1462              add_shortcode( $shortcode, array( $this, $data['function']) );
1463          }
1464      }
1465  //
1466  } // end of class
1467  //
1468  new PageLines_ShortCodes;


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