[ Index ]

PHP Cross Reference of PageLines Framework

title

Body

[close]

/includes/ -> library.templates.php (source)

   1  <?php
   2  /**
   3   * This file contains a library of common templates accessed by functions
   4   *
   5   * @package PageLines DMS
   6   *
   7   **/
   8  
   9  
  10  /**
  11   * Special content wrap is for plugins that operate outside of pagelines
  12   * We started doing things manually, so there are legacy extensions still using manual methodology
  13   *
  14   * @uses $pagelines_render // this is set in the main pagelines setup_pagelines_template(); function
  15   **/
  16  function do_special_content_wrap(){
  17      global $pagelines_render;
  18      if(
  19          isset($pagelines_render)
  20          || class_exists('SkinPageLinesWiki')
  21          || function_exists('vanilla_dcss')
  22      //    || (function_exists('is_jigoshop') && is_jigoshop() && class_exists('PageLinesJigoShop'))
  23      )
  24          return false;
  25      else
  26          return true;
  27  }
  28  
  29  function pagelines_special_content_wrap_top(){
  30  
  31      if(do_special_content_wrap()):
  32          
  33          if(pl_has_editor()){
  34              
  35              $integration = new PageLinesIntegrationHandler;
  36              
  37              $integration->start_new_integration();
  38              
  39          } else {
  40              
  41              add_action('pagelines_after_sidebar_wrap', 'pagelines_special_content_wrap_finish_after_sidebar');
  42              add_action('pagelines_before_sidebar_wrap', 'pagelines_special_content_wrap_finish_before_sidebar');
  43              add_action('pagelines_start_footer', 'pagelines_special_content_wrap_finish_after_content');
  44      ?>
  45          <section id="content" class="container fix">
  46                  <div class="content">
  47                      <div class="content-pad">
  48                          <div id="pagelines_content" class="fix">
  49  
  50                              <div id="column-wrap" class="fix">
  51                                  <div id="column-main" class="mcolumn fix">
  52                                      <div class="mcolumn-pad">
  53      <?php 
  54          }
  55      endif;
  56  
  57  
  58  }
  59  
  60  function pagelines_special_content_wrap_finish_before_sidebar_left() {
  61  
  62      if ( 'two-sidebar-center' === pl_layout_mode() ) {
  63          ?><div id="sidebar1" class="scolumn fix">
  64              <div class="scolumn-pad">
  65                  <section id="sb_primary" class="copy no_clone section-sb_primary">
  66                      <div class="copy-pad">
  67          <?php pagelines_draw_sidebar('sb_primary', 'Primary Sidebar', 'includes/widgets.default'); ?>
  68                      </div>
  69                  </section>
  70              </div>
  71          </div>
  72          <?php
  73      }
  74  }
  75  
  76  /**
  77   * If the extension runs the sidebar, close down some markup before
  78   *
  79   **/
  80  function pagelines_special_content_wrap_finish_before_sidebar(){
  81  
  82                                  ?></div>
  83                              </div>
  84                          <?php pagelines_special_content_wrap_finish_before_sidebar_left(); ?>
  85                      </div>
  86  <?php
  87  }
  88  
  89  /**
  90   * If the extension runs the sidebar, close down some markup after
  91   *
  92   **/
  93  function pagelines_special_content_wrap_finish_after_sidebar(){
  94      ?>
  95                  </div>
  96              </div>
  97          </div>
  98      </section>
  99      <?php
 100  }
 101  /**
 102   * If the sidebar wasn't run, then finish the markup
 103   *
 104   */
 105  function pagelines_special_content_wrap_finish_after_content(){
 106      global $sidebar_was_run;
 107  
 108      if(!isset($sidebar_was_run)):?>
 109                          </div>
 110                      </div>
 111                  </div>
 112              </div>
 113          </div>
 114      </div>
 115  </section>
 116      <?php endif;
 117  }
 118  
 119  
 120  
 121  
 122  // ======================================
 123  // = Sidebar Setup & Template Functions =
 124  // ======================================
 125  
 126  /**
 127   * PageLines Draw Sidebar
 128   *
 129   * Writes sidebar markup.
 130   * If no dynamic sidebar (widget) exists it calls the default widget
 131   *
 132   * @since   ...
 133   *
 134   * @param   $id - Sidebar ID
 135   * @param   $name - Sidebar name
 136   * @param   null $default
 137   * @param   string $element - CSS wrapper element, default is `ul`
 138   *
 139   * @uses    pagelines_default_widget
 140   */
 141  function pagelines_draw_sidebar($id, $name = '', $default = null, $element = 'ul'){
 142  
 143      printf('<%s id="%s" class="sidebar_widgets fix">', $element, 'list_'.$id);
 144  
 145      if ( !dynamic_sidebar($id) )
 146          pagelines_default_widget( $id, $default);
 147  
 148      printf('</%s>', $element);
 149  
 150  }
 151  
 152  /**
 153   * PageLines Default Widget
 154   *
 155   * Calls default sidebar widget, or allows user with 'edit_themes' capability to adds widgets
 156   *
 157   * @since   ...
 158   *
 159   * @param   $id - widget area ID
 160   * @param   $name - name of sidebar widget area
 161   * @param   $default - ...
 162   *
 163   * @uses    pagelines
 164   * @todo Finish paramater definitions
 165   */
 166  function pagelines_default_widget($id, $default){
 167  
 168      global $wp_registered_sidebars;
 169      if( isset($wp_registered_sidebars[ $id ]) && isset($wp_registered_sidebars[ $id ]['name']) )
 170          $name = $wp_registered_sidebars[ $id ]['name'];
 171      else
 172          $name = 'Widgetized Area';
 173  
 174      if(isset($default) && !pagelines('sidebar_no_default')):
 175  
 176          get_template_part( $default );
 177  
 178      elseif( current_user_can('edit_themes') ):
 179      ?>
 180  
 181      <li class="widget widget-default setup_area no_<?php echo $id;?>">
 182          <div class="widget-pad">
 183              <h3 class="widget-title">Add Widgets (<?php echo $name;?>)</h3>
 184              <p class="fix">This is your <?php echo $name;?> but it needs some widgets!<br/> Easy! Just add some content to it in your <a href="<?php echo admin_url('widgets.php');?>">widgets panel</a>.
 185              </p>
 186              <p>
 187                  <a href="<?php echo admin_url('widgets.php');?>" class="btn"><i class="icon-retweet"></i> <?php _e('Add Widgets &rarr;', 'pagelines');?></a>
 188              </p>
 189  
 190          </div>
 191      </li>
 192  
 193  <?php endif;
 194      }
 195  
 196  /**
 197   * PageLines Standard Sidebar
 198   *
 199   * Defines standard sidebar parameters
 200   *
 201   * @since   ...
 202   *
 203   * @param   string $name - Name of sidebar area
 204   * @param   string $description - Description of sidebar area
 205   *
 206   * @internal    @param  before_widget - markup that wraps the widget area
 207   * @internal    @param  after_widget - closing tags of markup added in `before_widget`
 208   * @internal    @param  before_title - markup that wraps the widget title text
 209   * @internal    @param  after_title - closing tags of markup added in `before_title`
 210   *
 211   * @return  array - all sidebar parameters
 212   */
 213  function pagelines_standard_sidebar($name, $description){
 214      return array(
 215          'name'=> $name,
 216          'description' => $description,
 217          'before_widget' => '<li id="%1$s" class="%2$s widget fix"><div class="widget-pad">',
 218          'after_widget' => '</div></li>',
 219          'before_title' => '<h3 class="widget-title">',
 220          'after_title' => '</h3>'
 221      );
 222  }
 223  
 224  
 225  /**
 226   * Javascript Confirmation
 227   *
 228   * @param string $name Function name, to be used in the input
 229   * @param string $text The text of the confirmation
 230   */
 231  function pl_action_confirm($name, $text){
 232      ?>
 233      <script language="jscript" type="text/javascript"> function <?php echo $name;?>(){
 234              var a = confirm ("<?php echo esc_js( $text );?>");
 235              if(a) {
 236                  jQuery("#input-full-submit").val(1);
 237                  return true;
 238              } else return false;
 239          }
 240      </script>
 241  <?php }
 242  
 243  /**
 244   * PageLines Search Form
 245   *
 246   * Writes the default "Search" text to the search form's input field.
 247   * Allows the $searchform to be filtered via the pagelines_search_form hook
 248   *
 249   * @since   ...
 250   *
 251   * @param   bool $echo - defaults to true, outputs $searchform
 252   *
 253   * @return  mixed|void - if $echo is false, returns $searchform
 254   */
 255  function pagelines_search_form( $echo = true ){
 256  
 257      $searchfield = sprintf('<input type="text" value="" name="s" class="searchfield" placeholder="%s" />', __('Search', 'pagelines'));
 258  
 259      $searchform = sprintf('<form method="get" class="searchform" onsubmit="this.submit();return false;" action="%s/" ><fieldset>%s</fieldset></form>', home_url(), $searchfield);
 260  
 261      if ( $echo )
 262          echo apply_filters('pagelines_search_form', $searchform);
 263      else
 264          return apply_filters('pagelines_search_form', $searchform);
 265  }
 266  
 267  
 268  /**
 269   * PageLines <head> Includes
 270   *
 271   */
 272  function pagelines_head_common(){
 273      global $pagelines_ID;
 274      $oset = array('post_id' => $pagelines_ID);
 275  
 276      pagelines_register_hook('pagelines_code_before_head'); // Hook
 277  
 278      printf('<meta http-equiv="Content-Type" content="%s; charset=%s" />',  get_bloginfo('html_type'),  get_bloginfo('charset'));
 279  
 280      pagelines_source_attribution();
 281  
 282      echo pl_source_comment('Title');
 283  
 284      // Draw Page <title> Tag. We use a filter to apply the actual titles.
 285  
 286      printf( '<title>%s</title>', wp_title( '',false ) );
 287  
 288      // Allow for extension deactivation of all css
 289      if(!has_action('override_pagelines_css_output')){
 290  
 291          // RTL Language Support
 292  
 293          // wordpress autoloads from child theme so if child theme has no rtl we need to load ours.
 294          if( 
 295              ( is_rtl() 
 296                  && is_child_theme() 
 297                  && ! is_file( sprintf( '%s/rtl.css', get_stylesheet_directory() ) ) 
 298              ) || ( is_rtl() && ! is_child_theme() ) 
 299          ){
 300              add_action( 'wp_print_styles', create_function( '', 'pagelines_load_css_relative( "rtl.css", "pagelines-rtl" );' ), 99 );
 301          }
 302              
 303      }
 304  
 305      if ( ploption( 'facebook_headers' ) && ! has_action( 'disable_facebook_headers' ) && VPRO )
 306          pagelines_facebook_header();
 307  
 308      // Fix IE and special handling
 309      if ( pl_detect_ie() )
 310          pagelines_fix_ie();
 311  
 312      // Cufon replacement
 313      pagelines_font_replacement();
 314  
 315      if(ploption('load_prettify_libs'))
 316          load_prettify();
 317  
 318      add_action( 'wp_head', create_function( '',  'echo pl_source_comment("Start >> Meta Tags and Inline Scripts", 2);' ), 0 );
 319  
 320      add_action( 'wp_print_styles', create_function( '',  'echo pl_source_comment("Styles");' ), 0 );
 321  
 322      add_action( 'wp_print_scripts', create_function( '',  'echo pl_source_comment("Scripts");' ), 0 );
 323  
 324      add_action( 'wp_print_footer_scripts', create_function( '',  'echo pl_source_comment("Footer Scripts");' ), 0 );
 325  
 326      add_action( 'admin_bar_menu', create_function( '',  'echo pl_source_comment("WordPress Admin Bar");' ), 0 );
 327  
 328      add_action( 'wp_head', 'pagelines_meta_tags', 9 );
 329  
 330      add_action( 'wp_head', 'pl_scripts_on_ready', 10 );
 331  
 332      // Headerscripts option > custom code
 333      if ( ploption( 'headerscripts' ) && ploption( 'headerscripts' ) != default_headerscript() )
 334          add_action( 'wp_head', create_function( '',  'print_pagelines_option("headerscripts");' ), 25 );
 335  
 336      if( ploption('asynch_analytics'))
 337          add_action( 'pagelines_head_last', create_function( '',  'echo ploption("asynch_analytics");' ), 25 );
 338  }
 339  
 340  function load_prettify(){
 341      pagelines_add_bodyclass( 'prettify-on' );
 342      wp_enqueue_script( 'prettify', PL_JS . '/prettify/prettify.js' );
 343      wp_enqueue_style( 'prettify', PL_JS . '/prettify/prettify.css' );
 344      add_action( 'wp_head', create_function( '',  'echo pl_js_wrap("prettyPrint()");' ), 14 );
 345  
 346  }
 347  
 348  function pl_scripts_on_ready(){
 349  
 350  echo pl_source_comment("On Ready"); ?>
 351  <script> /* <![CDATA[ */
 352  !function ($) {
 353  jQuery(document).ready(function() {
 354  <?php pagelines_register_hook('pl_scripts_on_ready'); // Hook ?>
 355  })
 356  }(window.jQuery);
 357  /* ]]> */
 358  </script>
 359  
 360  <?php
 361  }
 362  
 363  function pagelines_meta_tags(){
 364  
 365      global $pagelines_ID;
 366      $oset = array('post_id' => $pagelines_ID);
 367  
 368      // Meta Images
 369      if(ploption('pagelines_favicon') && VPRO)
 370          printf('<link rel="shortcut icon" href="%s" type="image/x-icon" />%s', ploption('pagelines_favicon'), "\n");
 371  
 372      if(ploption('pagelines_touchicon'))
 373          printf('<link rel="apple-touch-icon" href="%s" />%s', ploption('pagelines_touchicon'), "\n");
 374  
 375      // Meta Data Profiles
 376      if(!apply_filters( 'pagelines_xfn', '' ))
 377          echo '<link rel="profile" href="http://gmpg.org/xfn/11" />'."\n";
 378  
 379      // Removes viewport scaling on Phones, Tablets, etc.
 380      if(!ploption('disable_mobile_view', $oset) && !apply_filters( 'disable_mobile_view', '' ))
 381          echo '<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />';
 382  
 383  }
 384  
 385  function pagelines_source_attribution() {
 386  
 387      echo "\n\n<!-- ";
 388      printf ( "Site Crafted Using PageLines v%s - WordPress - HTML5 ( %s ) - www.PageLines.com ", PL_CORE_VERSION, get_pagelines_credentials( 'licence' ) );
 389  
 390      echo "-->\n";
 391  }
 392  
 393  function pl_source_comment( $text, $spacing = 1 ) {
 394  
 395      $newline = ($spacing) ? "\n" : '';
 396  
 397      $double = ($spacing == 2) ? "\n\n" : $newline;
 398  
 399      return sprintf( '%s<!-- %s -->%s', $double, $text, $newline);
 400  
 401  }
 402  
 403  
 404  /**
 405  *
 406  * @TODO do
 407  *
 408  */
 409  function pagelines_facebook_header() {
 410  
 411      if ( is_home() || is_archive() )
 412          return;
 413  
 414      if ( function_exists( 'is_bbpress' ) && is_bbpress() )
 415          return;
 416  
 417      global $pagelines_ID;
 418  
 419      if ( ! $pagelines_ID )
 420          return;
 421  
 422      $fb_img = apply_filters('pl_opengraph_image', pl_the_thumbnail_url( $pagelines_ID, 'full' ) );
 423  
 424      echo pl_source_comment('Facebook Open Graph');
 425  
 426      printf( "<meta property='og:title' content='%s' />\n", get_the_title($pagelines_ID));
 427      printf( "<meta property='og:url' content='%s' />\n", get_permalink($pagelines_ID));
 428      printf( "<meta property='og:site_name' content='%s' />\n", get_bloginfo( 'name' ));
 429      $fb_content = get_post( $pagelines_ID );
 430      if ( ! function_exists( 'sharing_plugin_settings' ) )
 431          printf( "<meta property='og:description' content='%s' />\n", pl_short_excerpt( $fb_content, 15 ) );
 432      printf( "<meta property='og:type' content='%s' />", (is_home()) ? 'website' : 'article');
 433      if($fb_img)
 434          printf( "\n<meta property='og:image' content='%s' />", $fb_img);
 435  }
 436  
 437  /**
 438  *
 439  * @TODO do
 440  *
 441  */
 442  function pagelines_supersize_bg(){
 443  
 444      global $pagelines_ID;
 445      $oset = array('post_id' => $pagelines_ID);
 446      $url = ploption('page_background_image_url', $oset);
 447  
 448      if(ploption('supersize_bg') && $url && !pl_is_disabled('color_control') && !pl_deprecate_v2()){
 449  
 450          wp_enqueue_script('pagelines-supersize' );
 451          add_action('wp_head', 'pagelines_runtime_supersize', 20);
 452      }
 453  }
 454  
 455  /**
 456  *
 457  * @TODO do
 458  *
 459  */
 460  function pagelines_runtime_supersize(){
 461  
 462      if ( has_action( 'pl_no_supersize' ) )
 463      return;
 464  
 465      global $pagelines_ID;
 466      $oset = array('post_id' => $pagelines_ID);
 467      $url = ploption('page_background_image_url', $oset);
 468      ?>
 469  
 470      <script type="text/javascript"> /* <![CDATA[ */
 471      jQuery(document).ready(function(){
 472          jQuery.supersized({ slides  :      [ { image : '<?php echo $url; ?>' } ] });
 473      });/* ]]> */
 474      </script>
 475  
 476  <?php
 477  }
 478  
 479  
 480  
 481  /**
 482   * PageLines Title Tag ( deprecated )
 483   *
 484   * Checks for AIO or WPSEO functionality, if they both do not exist then this will define the HTML <title> tag for the theme.
 485   *
 486   * @TODO deleteme
 487   *
 488   * @internal filter pagelines_meta_title provided for over-writing the default title text.
 489   */
 490  function pagelines_title_tag(){
 491      echo "<title>";
 492  
 493      if ( !function_exists( 'aiosp_meta' ) && !function_exists( 'wpseo_get_value' ) ) {
 494      // Pagelines seo titles.
 495          global $page, $paged;
 496          $title = wp_title( '|', false, 'right' );
 497  
 498          // Add the blog name.
 499          $title .= get_bloginfo( 'name' );
 500  
 501          // Add the blog description for the home/front page.
 502          $title .= ( ( is_home() || is_front_page() ) && get_bloginfo( 'description', 'display' ) ) ? ' | ' . get_bloginfo( 'description', 'display' ) : '';
 503  
 504          // Add a page number if necessary:
 505          $title .= ( $paged >= 2 || $page >= 2 ) ? ' | ' . sprintf( __( 'Page %s', 'pagelines' ), max( $paged, $page ) ) : '';
 506      } else
 507          $title = trim( wp_title( '', false ) );
 508  
 509      // Print the title.
 510      echo apply_filters( 'pagelines_meta_title', $title );
 511  
 512      echo "</title>";
 513  }
 514  
 515  /**
 516   * PageLines Title Tag Filter
 517   *
 518   * Filters wp_title so SEO plugins can override.
 519   *
 520   * @since 2.2.2
 521   *
 522   * @internal filter pagelines_meta_title provided for over-writing the default title text.
 523   */
 524  function pagelines_filter_wp_title( $title ) {
 525      global $wp_query, $s, $paged, $page;
 526      $sep = __( '|','pagelines' );
 527      $new_title = get_bloginfo( 'name' ) . ' ';
 528      $bloginfo_description = get_bloginfo( 'description' );
 529      if( is_feed() ) {
 530          $new_title = $title;
 531      } elseif ( ( is_home () || is_front_page() ) && ! empty( $bloginfo_description ) ) {
 532          $new_title .= $sep . ' ' . $bloginfo_description;
 533      } elseif ( is_category() ) {
 534          $new_title .= $sep . ' ' . single_cat_title( '', false );
 535      } elseif ( is_single() || is_page() ) {
 536          $new_title .= $sep . ' ' . single_post_title( '', false );
 537      } elseif ( is_search() ) {
 538          $new_title .= $sep . ' ' . sprintf( __( 'Search Results: %s','pagelines' ), esc_html( $s ) );
 539      } else
 540          $new_title .= $sep . ' ' . $title;
 541      if ( $paged >= 2 || $page >= 2 ) {
 542          $new_title .= ' ' . $sep . ' ' . sprintf( __( 'Page: %s', 'pagelines' ), max( $paged, $page ) );
 543      }
 544      return apply_filters( 'pagelines_meta_title', $new_title );
 545  }
 546  add_filter( 'wp_title', 'pagelines_filter_wp_title' );
 547  
 548  /**
 549   *
 550   *  Fix IE to the extent possible
 551   *
 552   *  @package PageLines DMS
 553   *  @subpackage Functions Library
 554   *  @since 1.3.3
 555   *
 556   */
 557  function pagelines_fix_ie( ){
 558  
 559      $ie_ver = pl_detect_ie();
 560      if( ploption('google_ie') && ( $ie_ver < 9 ) ) {
 561          $compat = sprintf( '//ie7-js.googlecode.com/svn/version/2.1(beta4)/IE%1$s.js', $ie_ver +1 );
 562          $shiv = '//html5shim.googlecode.com/svn/trunk/html5.js';
 563          wp_enqueue_script( 'ie-compat', $compat );
 564          wp_enqueue_script( 'html5shiv', $shiv );
 565      }
 566  
 567      // If IE7 add the Internet Explorer 7 specific stylesheet
 568      if ( $ie_ver == 7 )
 569          wp_enqueue_style('ie7-style', PL_CSS  . '/ie7.css', array(), PL_CORE_VERSION);
 570  }
 571  
 572  /**
 573   *
 574   *  Cufon Font Replacement
 575   *
 576   *  @package PageLines DMS
 577   *  @subpackage Functions Library
 578   *  @since 1.3.3
 579   *
 580   */
 581  function pagelines_font_replacement( $default_font = ''){
 582  
 583      if(ploption('typekit_script')){
 584          echo pagelines_option('typekit_script');
 585      }
 586  
 587      if(ploption('fontreplacement')){
 588          global $cufon_font_path;
 589  
 590          if(ploption('font_file')) $cufon_font_path = ploption('font_file');
 591          elseif($default_font) $cufon_font_path = PL_JS.'/'.$default_font;
 592          else $cufon_font_path = null;
 593  
 594          // ===============================
 595          // = Hook JS Libraries to Footer =
 596          // ===============================
 597          add_action('wp_footer', 'font_replacement_scripts');
 598  
 599          /**
 600          *
 601          * @TODO document
 602          *
 603          */
 604  		function font_replacement_scripts(){
 605  
 606              global $cufon_font_path;
 607  
 608              wp_register_script('cufon', PL_ADMIN_JS.'/type.cufon.js', 'jquery', '1.09i', true);
 609              wp_print_scripts('cufon');
 610  
 611              if(isset($cufon_font_path)){
 612                  wp_register_script('cufon_font', $cufon_font_path, 'cufon');
 613                  wp_print_scripts('cufon_font');
 614              }
 615  
 616          }
 617  
 618          add_action('wp_head', 'cufon_inline_script');
 619  
 620          /**
 621          *
 622          * @TODO document
 623          *
 624          */
 625  		function cufon_inline_script(){
 626              ?><script type="text/javascript"><?php
 627              if(pagelines('replace_font')):
 628                  ?>jQuery(document).ready(function () { Cufon.replace('<?php echo ploption("replace_font"); ?>', {hover: true}); });<?php
 629              endif;
 630              ?></script><?php
 631           }
 632       }
 633  }
 634  
 635  /**
 636   *
 637   *  Pagination Function
 638   *
 639   *  @package PageLines DMS
 640   *  @subpackage Functions Library
 641   *  @since 2.0.b12 moved
 642   *
 643   */
 644  function pagelines_pagination() {
 645      if(function_exists('wp_pagenavi') && show_posts_nav() && VPRO):
 646  
 647          $args = array(
 648              'before' => '<div class="pagination pagenavi">',
 649              'after' => '</div>',
 650          );
 651          wp_pagenavi( $args );
 652  
 653      elseif (show_posts_nav()) : ?>
 654          <ul class="pager page-nav-default fix">
 655              <li class="previous previous-entries">
 656                  <?php next_posts_link(__('&larr; Previous Entries','pagelines')) ?>
 657              </li>
 658              <li class="next next-entries">
 659              <?php previous_posts_link(__('Next Entries &rarr;','pagelines')) ?>
 660              </li>
 661          </ul>
 662  <?php endif;
 663  }
 664  
 665  // As a callback with nav args associated
 666  function pl_nav_callback( $args ){
 667      pl_nav_fallback( $args['menu_class'] );
 668  }
 669  
 670  function pl_nav_fallback($class = '', $limit = 6){
 671  
 672      $pages = wp_list_pages('echo=0&title_li=&sort_column=menu_order&depth=1');
 673  
 674      $pages_arr = explode("\n", $pages);
 675  
 676      $pages_out = '';
 677      for($i=0; $i < $limit; $i++){
 678  
 679          if(isset($pages_arr[$i]))
 680              $pages_out .= $pages_arr[$i];
 681  
 682      }
 683  
 684      printf('<ul class="%s">%s</ul>', $class, $pages_out);
 685  }
 686  
 687  /**
 688   *
 689   *  Fallback for navigation, if it isn't set up
 690   *
 691   *  @package PageLines DMS
 692   *  @subpackage Functions Library
 693   *  @since 1.1.0
 694   *
 695   */
 696  
 697  // DEPRECATED for pl_nav_fallback
 698  function pagelines_nav_fallback() {
 699      global $post; ?>
 700  
 701      <ul id="menu-nav" class="main-nav<?php echo pagelines_nav_classes();?>">
 702          <?php wp_list_pages( 'title_li=&sort_column=menu_order&depth=3'); ?>
 703      </ul><?php
 704  }
 705  
 706  
 707  /**
 708   *
 709   *  Blank Nav Fallback
 710   *
 711   */
 712  function blank_nav_fallback() {
 713  
 714      if(current_user_can('edit_themes'))
 715          printf( __( "<ul class='inline-list'>Please select a nav menu for this area in the <a href='%s'>WordPress menu admin</a>.</ul>", 'pagelines' ), admin_url('nav-menus.php') );
 716  }
 717  
 718  /**
 719   *
 720   *  Returns child pages for subnav, setup in hierarchy
 721   *
 722   *  @package PageLines DMS
 723   *  @subpackage Functions Library
 724   *  @since 1.1.0
 725   *
 726   */
 727  function pagelines_page_subnav(){
 728      global $post;
 729      if(!is_404() && isset($post) && is_object($post) && !pagelines_option('hide_sub_header') && ($post->post_parent || wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0'))):?>
 730      <ul class="secondnav_menu lcolor3">
 731          <?php
 732              if(count($post->ancestors)>=2){
 733                  $reverse_ancestors = array_reverse($post->ancestors);
 734                  $children = wp_list_pages('title_li=&depth=1&child_of='.$reverse_ancestors[0].'&echo=0&sort_column=menu_order');
 735              }elseif($post->post_parent){ $children = wp_list_pages('title_li=&depth=1&child_of='.$post->post_parent.'&echo=0&sort_column=menu_order');
 736              }else{    $children = wp_list_pages('title_li=&depth=1&child_of='.$post->ID.'&echo=0&sort_column=menu_order');}
 737  
 738              if ($children) { echo $children;}
 739          ?>
 740      </ul>
 741      <?php endif;
 742  }
 743  
 744  /**
 745   * PageLines Main Logo
 746   *
 747   * The main site logo template
 748   *
 749   * @package     PageLines Framework
 750   * @subpackage  Functions Library
 751   *
 752   * @since       1.1.0
 753   *
 754   * @param       null $location
 755   *
 756   * @uses        (global) $pagelines_ID
 757   * @uses        ploption - pagelines_custom_logo, pagelines_custom_logo_url
 758   * @uses        (filters) pagelines_logo_url, pagelines_site_logo, pagelines_custom_logo_url, pagelines_site_title
 759   *
 760   */
 761  function pagelines_main_logo( $location = null ){
 762  
 763      global $pagelines_ID;
 764  
 765      if ( is_pagelines_special() )
 766          $pagelines_ID = false;
 767  
 768      $oset = array( 'post_id' => $pagelines_ID );
 769  
 770      if(ploption('pagelines_custom_logo', $oset) || apply_filters('pagelines_site_logo', '') || apply_filters('pagelines_logo_url', '')){
 771  
 772          $logo = apply_filters('pagelines_logo_url', esc_url(ploption('pagelines_custom_logo', $oset) ), $location);
 773  
 774  
 775          $logo_url = ( esc_url(ploption('pagelines_custom_logo_url', $oset) ) ) ? esc_url(ploption('pagelines_custom_logo_url', $oset) ) : home_url();
 776  
 777          $site_logo = sprintf(
 778              '<a class="plbrand mainlogo-link" href="%s" title="%s"><img class="mainlogo-img" src="%s" alt="%s" /></a>',
 779              $logo_url,
 780              get_bloginfo('name'),
 781              $logo,
 782              get_bloginfo('name')
 783          );
 784  
 785          echo apply_filters('pagelines_site_logo', $site_logo, $location);
 786  
 787      } else {
 788  
 789          $site_title = sprintf( '<div class="title-container"><a class="home site-title" href="%s" title="%s">%s</a><h6 class="site-description subhead">%s</h6></div>', esc_url(home_url()), __('Home','pagelines'), get_bloginfo('name'), get_bloginfo('description'));
 790  
 791          echo apply_filters('pagelines_site_title', $site_title, $location);
 792      }
 793  }
 794  
 795  /**
 796   *
 797   * Wraps in standard js on ready format
 798   *
 799   * @since 2.0.0
 800   */
 801  function pl_js_wrap( $js ){
 802  
 803      return sprintf('<script type="text/javascript">/*<![CDATA[*/ jQuery(document).ready(function(){ %s }); /*]]>*/</script>', $js);
 804  
 805  }
 806  
 807  /**
 808   *
 809   *  Adds PageLines to Admin Bar
 810   *
 811   *  @package PageLines DMS
 812   *  @subpackage Functions Library
 813   *  @since 1.3.0
 814   *
 815   */
 816  function pagelines_settings_menu_link(  ){
 817      global $wp_admin_bar;
 818  
 819      global $pagelines_template;
 820  
 821  
 822      if ( !current_user_can('edit_theme_options') || pl_deprecate_v2())
 823          return;
 824  
 825      $wp_admin_bar->add_menu( array( 'id' => 'pl_settings', 'title' => __('PageLines', 'pagelines'), 'href' => admin_url( PL_DASH_URL ) ) );
 826      $wp_admin_bar->add_menu( array( 'id' => 'pl_dashboard', 'parent' => 'pl_settings', 'title' => __( 'Dashboard', 'pagelines' ), 'href' => admin_url( PL_DASH_URL ) ) );
 827      $wp_admin_bar->add_menu( array( 'id' => 'pl_main_settings', 'parent' => 'pl_settings', 'title' => __( 'Site Options', 'pagelines' ), 'href' => admin_url( PL_SETTINGS_URL ) ) );
 828      $wp_admin_bar->add_menu( array( 'id' => 'pl_special', 'parent' => 'pl_settings', 'title' => __( 'Page Options', 'pagelines' ), 'href' => admin_url( PL_SPECIAL_OPTS_URL ) ) );
 829      $wp_admin_bar->add_menu( array( 'id' => 'pl_templates', 'parent' => 'pl_settings', 'title' =>  __( 'Drag &amp; Drop', 'pagelines' ), 'href' => admin_url( PL_TEMPLATE_SETUP_URL ) ) );
 830      $wp_admin_bar->add_menu( array( 'id' => 'pl_extend', 'parent' => 'pl_settings', 'title' => __('Store', 'pagelines'), 'href' => admin_url( PL_ADMIN_STORE_URL ) ) );
 831  
 832      $template_name = (isset($pagelines_template->template_name)) ? $pagelines_template->template_name : false;
 833  
 834      if( $template_name ){
 835          $page_type = __('Template: ', 'pagelines') . ucfirst($template_name );
 836          $wp_admin_bar->add_menu( array( 'id' => 'template_type', 'title' => $page_type, 'href' => admin_url( PL_TEMPLATE_SETUP_URL ) ) );
 837      }
 838  
 839      $spurl = pl_special_url( $template_name );
 840  
 841      if( $template_name && is_pagelines_special() && $spurl){
 842          $wp_admin_bar->add_menu( array( 'id' => 'special_settings', 'title' => __('Edit Meta', 'pagelines'), 'href' => $spurl ) );
 843      }
 844  
 845      if ( is_pl_debug() && ! is_admin() ) {
 846  
 847          $wp_admin_bar->add_menu(
 848              array(
 849                  'id'    => 'pl_flush',
 850                  'title' => __('Flush LESS', 'pagelines'),
 851                  'href'  => get_pl_reset_less_url()
 852                  ) );
 853      }
 854  }
 855  
 856  function get_pl_reset_less_url() {
 857  
 858      $flush = array( 'pl_reset_less' => 1 );
 859  
 860      $request = explode( '?', $_SERVER['REQUEST_URI'] );
 861  
 862      $page = $request[0];
 863  
 864      $query = array();
 865  
 866      if ( isset( $request[1] ) )
 867          wp_parse_str( $request[1], $query );
 868  
 869      $query = wp_parse_args( $flush, $query );
 870  
 871      $url = sprintf( '%s://%s%s?%s',
 872          is_ssl() ? 'https' : 'http',
 873          $_SERVER['HTTP_HOST'],
 874          $page,
 875          http_build_query( $query )
 876          );
 877  
 878      return $url;
 879  }
 880  
 881  /**
 882  *
 883  * @TODO do
 884  *
 885  */
 886  function pl_special_url( $t ){
 887  
 888      $t = strtolower( trim($t) );
 889  
 890      if($t == 'blog')
 891          $slug = 'blog_page';
 892      elseif($t == 'category')
 893          $slug = 'category_page';
 894      elseif($t == 'archive')
 895          $slug = 'archive_page';
 896      elseif($t == 'search')
 897          $slug = 'search_results';
 898      elseif($t == 'tag')
 899          $slug = 'tag_listing';
 900      elseif($t == '404_error')
 901          $slug = '404_page';
 902      elseif($t == 'author')
 903          $slug = 'author_posts';
 904      else
 905          return false;
 906  
 907      $rurl = sprintf(PL_SPECIAL_OPTS_URL.'%s', '#'.$slug);
 908  
 909      return admin_url( $rurl );
 910  
 911  }
 912  
 913  /**
 914   *
 915   *  PageLines Attribution
 916   *
 917   *  @package PageLines DMS
 918   *  @subpackage Functions Library
 919   *  @since 1.3.3
 920   *
 921   */
 922  function pagelines_cred(){
 923  
 924      if ( VPRO && ploption( 'watermark_hide' ) && ! has_action( 'show_pagelines_leaf' ) )
 925          return;
 926  
 927      $image = (VPRO && ploption('watermark_image')) ? ploption('watermark_image') : PL_IMAGES.'/pagelines.png';
 928  
 929      $alt = (VPRO) ? ploption( 'watermark_alt' ) : 'Build a website with PageLines';
 930  
 931      $url = ploption('watermark_link');
 932  
 933      if ( ! VPRO )
 934          $url = 'http://www.pagelines.com';
 935  
 936      $img     = sprintf('<img src="%s" alt="%s" />', $image, $alt);
 937  
 938      $link = ( '' != $url && ! apply_filters('no_leaf_link', '') ) ? sprintf('<a class="plimage" target="_blank" href="%s" title="%s">%s</a>', $url, $alt, $img ) : $img;
 939  
 940      $cred = sprintf('<div id="cred" class="pagelines" style="display: block; visibility: visible;">%s</div><div class="clear"></div>', $link);
 941  
 942      echo apply_filters('pagelines_leaf', $cred);
 943  }
 944  
 945  /**
 946  *
 947  * @TODO do
 948  *
 949  */
 950  function pagelines_get_childcss() {
 951      if ( ! is_admin() && is_child_theme() )
 952          pagelines_load_css(  get_bloginfo('stylesheet_url'), 'pagelines-child-stylesheet', pagelines_get_style_ver());
 953  }
 954  
 955  function pl_social_button( $type = 'facebook', $args) {
 956  
 957      if($type == 'twitter')
 958          PageLinesShareBar::twitter( $args );
 959      else
 960          PageLinesShareBar::facebook( $args );
 961  
 962  }


Generated: Fri Aug 30 18:26:24 2013 Cross-referenced by PHPXref 0.7.1