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


Generated: Sat Apr 6 23:00:27 2013 Cross-referenced by PHPXref 0.7.1