Advertisement
Guest User

Untitled

a guest
Jan 20th, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.31 KB | None | 0 0
  1.     function avia_title( $args = false, $id = false )
  2.     {
  3.         global $avia_config;
  4.  
  5.         if( ! $id )
  6.         {
  7.             $id = avia_get_the_id();
  8.         }
  9.  
  10.         $header_settings = avia_header_setting();
  11.  
  12.         if( $header_settings['header_title_bar'] == 'hidden_title_bar' )
  13.         {
  14.             return '';
  15.         }
  16.  
  17.         $defaults = array(
  18.                         'title'         => get_the_title( $id ),
  19.                         'subtitle'      => '', //avia_post_meta($id, 'subtitle'),
  20.                         'link'          => get_permalink( $id ),
  21.                         'html'          => "<div class='{class} title_container'><div class='container'>{heading_html}{additions}</div></div>",
  22.                         'heading_html'  => "<{heading} class='main-title entry-title {heading_class}'>{title}</{heading}>",
  23.                         'class'         => 'stretch_full container_wrap alternate_color ' . avia_is_dark_bg( 'alternate_color', true ),
  24.                         'breadcrumb'    => true,
  25.                         'additions'     => '',
  26.                         'heading'       => 'h1', //headings are set based on this article: http://yoast.com/blog-headings-structure/
  27.                         'heading_class' => ''
  28.                     );
  29.  
  30.         if ( is_tax() || is_category() || is_tag() )
  31.         {
  32.             global $wp_query;
  33.  
  34.             $term = $wp_query->get_queried_object();
  35.             $defaults['link'] = get_term_link( $term );
  36.         }
  37.         else if( is_archive() )
  38.         {
  39.             $defaults['link'] = '';
  40.         }
  41.  
  42.  
  43.         // Parse incomming $args into an array and merge it with $defaults
  44.         $args = wp_parse_args( $args, $defaults );
  45.  
  46.         /**
  47.          * @used_by     config-woocommerce\config.php avia_title_args_woopage()             10
  48.          * @since < 4.0
  49.          * @return array
  50.          */
  51.         $args = apply_filters( 'avf_title_args', $args, $id );
  52.  
  53.         //disable breadcrumb if requested
  54.         if( $header_settings['header_title_bar'] == 'title_bar' )
  55.         {
  56.             $args['breadcrumb'] = false;
  57.         }
  58.  
  59.         //disable title if requested
  60.         if( $header_settings['header_title_bar'] == 'breadcrumbs_only' )
  61.         {
  62.             $args['title'] = '';
  63.         }
  64.  
  65.         // OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before.
  66.         extract( $args, EXTR_SKIP );
  67.  
  68.         if( empty( $title ) )
  69.         {
  70.             $class .= " empty_title ";
  71.         }
  72.  
  73.         $markup = avia_markup_helper( array( 'context' => 'avia_title', 'echo' => false ) );
  74.  
  75.         if( ! empty( $link ) && ! empty( $title ) )
  76.         {
  77.             $title = "<a href='" . $link . "' rel='bookmark' title='" . __( 'Permanent Link:', 'avia_framework' ) . " " . esc_attr( $title ) . "' $markup>" . $title . "</a>";
  78.         }
  79.  
  80.         if( ! empty( $subtitle ) )
  81.         {
  82.             $additions .= "<div class='title_meta meta-color'>" . wpautop( $subtitle ) . "</div>";
  83.         }
  84.  
  85.         if( $breadcrumb )
  86.         {
  87.             if ( function_exists('yoast_breadcrumb') ) {
  88.                 $breadcrumb = yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
  89.                 $additions .= $breadcrumb;
  90.             } else {
  91.                 $additions .= Avia_Breadcrumb_Trail()->get_trail( array( 'separator' => '/', 'richsnippet' => true ) );
  92.             }  
  93.         }
  94.  
  95.         if( ! $title )
  96.         {
  97.             $heading_html = '';
  98.         }
  99.  
  100.         $html = str_replace( '{heading_html}', $heading_html, $html );
  101.  
  102.  
  103.         $html = str_replace( '{class}', $class, $html );
  104.         $html = str_replace( '{title}', $title, $html );
  105.         $html = str_replace( '{additions}', $additions, $html );
  106.         $html = str_replace( '{heading}', $heading, $html );
  107.         $html = str_replace( '{heading_class}', $heading_class, $html );
  108.  
  109.         if( ! empty( $avia_config['slide_output'] ) && ! avia_is_dynamic_template( $id ) && ! avia_is_overview() )
  110.         {
  111.             $avia_config['small_title'] = $title;
  112.         }
  113.         else
  114.         {
  115.             return $html;
  116.         }
  117.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement