cipher87

Avia Title Tweak

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