Advertisement
rdusnr

Untitled

Jul 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1.  
  2. if ( ! function_exists( 'kleo_title_section' ) ) {
  3. /**
  4. * Return the breadcrumb area
  5. * @global object $wp_query
  6. *
  7. * @param array $args
  8. *
  9. * @return string
  10. */
  11. function kleo_title_section( $args = false ) {
  12. $defaults = array(
  13. 'title' => get_the_title(),
  14. 'show_title' => true,
  15. 'show_breadcrumb' => true,
  16. 'link' => '',
  17. 'output' => "<section class='{class} border-bottom breadcrumbs-container'><div class='container'>{title_data}<div class='breadcrumb-extra'>{breadcrumb_data}{extra}</div></div></section>",
  18. 'class' => 'container-wrap main-title alternate-color ',
  19. 'extra' => '<p class="page-info">' . do_shortcode( sq_option( 'title_info', '' ) ) . '</p>',
  20. 'heading' => 'h1'
  21. );
  22.  
  23. // Parse incoming $args into an array and merge it with $defaults
  24. $args = wp_parse_args( $args, $defaults );
  25. $args = apply_filters( 'kleo_title_args', $args );
  26.  
  27. // OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before.
  28. extract( $args, EXTR_SKIP );
  29.  
  30. if ( ! empty( $link ) ) {
  31. $title = "<a href='" . $link . "' rel='bookmark' title='" . __( 'Permanent Link:', 'kleo_framework' ) . " " . esc_attr( $title ) . "'>" . $title . "</a>";
  32. }
  33.  
  34. $breadcrumb_data = '';
  35. if ( $show_breadcrumb ) {
  36. $breadcrumb_data = kleo_breadcrumb( array(
  37. 'show_browse' => false,
  38. 'separator' => ' ',
  39. 'show_home' => __( 'Home', 'kleo_framework' ),
  40. 'echo' => false
  41. ) );
  42. }
  43.  
  44. $title_data = '';
  45. if ( $show_title ) {
  46. $title_data = '<{heading} class="page-title">{title}</{heading}>';
  47. }
  48.  
  49. if ( ! $show_breadcrumb && $extra == '' ) {
  50. $class .= ' title-single';
  51. }
  52.  
  53. $title_layout = sq_option( 'title_layout', 'normal' );
  54. if ( is_singular() && get_cfield( 'title_layout' ) && get_cfield( 'title_layout' ) != '' ) {
  55. $title_layout = get_cfield( 'title_layout' );
  56. }
  57. if ( $title_layout == 'center' ) {
  58. $class .= ' main-center-title';
  59. } elseif ( $title_layout == 'right_breadcrumb' ) {
  60. $class .= ' main-right-breadcrumb';
  61. }
  62.  
  63. $current_title = get_the_title();
  64.  
  65. $output = str_replace( '{title_data}', $title_data, $output );
  66. $output = str_replace( '{class}', $class, $output );
  67. if(class_exists('WooCommerce') && is_woocommerce() ) {
  68. $output = str_replace('{title}', $current_title, $output);
  69. } else {
  70. $output = str_replace( '{title}', $title, $output );
  71. }
  72. $output = str_replace( '{breadcrumb_data}', $breadcrumb_data, $output );
  73. $output = str_replace( '{extra}', $extra, $output );
  74. $output = str_replace( '{heading}', $heading, $output );
  75.  
  76. return $output;
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement