Path : /home/vishqocm/vishalwebtech.in/blog/wp-content/themes/katerio/functions/
File Upload :
Current File : /home/vishqocm/vishalwebtech.in///blog/wp-content/themes/katerio/functions/heading.php

<?php
/**
 * Heading functions
 *
 * @package Katerio
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

/*
--------------------------------------------------------------------------------
* Block Heading
* ------------------------------------------------------------------------------
*/
if ( ! function_exists( 'th90_heading_block' ) ) {
	function th90_heading_block( $atts = array() ) {
		$output = '';
		$heading_attributes = $wrapper_attributes = array();

		$atts = wp_parse_args( $atts, array(
			'_heading'           => '',
			'_heading_align'     => 'left',
			'_heading_style'     => '1',
			'_heading_size'      => '',
			'_heading_tag'       => 'h3',
			'is_base'            => true,
			'subheading'         => '',
			'subheading_pos'     => 'bottom',

			'_heading_more'      => false,
			'_heading_more_text' => '',
			'_heading_more_link' => array(),

			'_filters'           => false,
			'tags'               => array(),
			'categories'         => array(),
			'posts'              => array(),

			'_sort'              => false,
			'orderby'            => '',

			'_slider_arrow'      => false,
			'slider_id'          => '',

			'pagi'               => false,
			'_pagi_show_text'    => esc_html__( 'Show More', 'katerio' ),
		));

		if ( empty( $atts['_heading'] ) ) {
			return;
		}

		if ( empty( $atts['_heading_size'] ) ) {
			$atts['_heading_size'] = $atts['_heading_tag'];
		}

		$head_style = '';
		if ( '10' == $atts['_heading_style'] ) {
			$head_style = 'heading-style2';
		}

		$wrapper_classes = array(
			'heading-wrap',
			$head_style,
			$atts['_heading_style'] ? 'heading-style' . $atts['_heading_style'] : '',
			$atts['_heading_align'] ? 'heading-' . $atts['_heading_align'] : '',
			$atts['is_base'] ? 'heading-widget' : '',
		);
		if ( ! empty( $wrapper_classes ) ) {
			$wrapper_attributes[] = 'class="' . esc_attr( implode( ' ', array_filter( $wrapper_classes ) ) ) . '"';
		}

		$heading_classes = array(
			'heading-main',
			$atts['_heading_size'],
		);
		if ( ! empty( $heading_classes ) ) {
			$heading_attributes[] = 'class="' . esc_attr( implode( ' ', array_filter( $heading_classes ) ) ) . '"';
		}

		$output .= '<div ' . implode( ' ', $wrapper_attributes )  . '>';

		/* Sub Heading - Top */
		if ( ! empty( $atts['subheading'] ) && 'top' == $atts['subheading_pos'] ) {
			$output .= '<p class="subheading">' . do_shortcode( $atts['subheading'] ) . '</p>';
		}

		/* Heading */
		$output .= '<' . esc_attr( $atts['_heading_tag'] ) . ' ' . implode( ' ', $heading_attributes ) . '>';
		$output .= '<span class="heading-text">';
		$output .= $atts['_heading'];
		$output .= '</span>';
		$output .= '</' . esc_attr( $atts['_heading_tag'] ) . '>';

		/* More & Filters */
		if ( ( 'yes' == $atts['_filters'] && ( ! empty( $atts['tags'] ) || ! empty( $atts['categories'] ) ) && empty( $atts['posts'] ) ) || 'yes' == $atts['_sort'] || 'yes' == $atts['_heading_more'] || 'yes' == $atts['_slider_arrow'] || 'heading-show-more' == $atts['pagi'] || 'heading-next-prev' == $atts['pagi'] ) {
			$output .= '<div class="heading-more">';
				ob_start();
				?>
				<?php if( 'yes' == $atts['_filters'] && ( ! empty( $atts['tags'] ) || ! empty( $atts['categories'] ) ) && empty( $atts['posts'] ) ): ?>
					<div class="module-filters">
						<ul>
							<li><a href="#" class="module-term active"><?php esc_html_e( 'All', 'katerio' ); ?></a></li>
							<?php
							if ( ! empty( $atts['tags'] ) ) {
								$tags = explode( ',', $atts['tags'] );
								foreach ( $tags as $tag ) {
									$get_tag = _th90_get_term_by( 'slug', $tag, 'post_tag' );
									if ( ! empty( $get_tag ) && ! empty( $get_tag->count ) ) {
										echo '<li><a href="#" data-term="' . $get_tag->slug . '" class="module-term">' . $get_tag->name . '</a></li>';
									}
								}
							} elseif ( ! empty( $atts['categories'] ) ) {
								$categories = explode( ',', $atts['categories'] );
								foreach ( $categories as $cat ) {
									$get_category = _th90_get_term_by( 'slug', $cat, 'category' );
									if ( ! empty( $get_category ) && ! empty( $get_category->count ) ) {
										echo '<li><a href="#" data-term="' . $get_category->slug . '" class="module-term">' . $get_category->name . '</a></li>';
									}
								}
							}
							?>
						</ul>
					</div>
				<?php endif; ?>

				<?php if( 'yes' == $atts['_sort'] ): ?>
					<div class="module-sorts dropdown-click">
						<a href="#" class="dropdown-trigger"><?php echo esc_html( th90_default_options()['post_sort'][$atts['orderby']] );?></a>
						<ul class="dropdown-container">
							<?php
							foreach ( th90_default_options()['post_sort'] as $key => $value ) {
								?>
								<li><a href="#" data-sort="<?php echo esc_attr( $key ); ?>" class="module-sort"><?php echo esc_html( $value ); ?></a></li>
								<?php
							}
							?>
						</ul>
					</div>
				<?php endif; ?>

				<?php if( 'yes' == $atts['_heading_more'] ): ?>
					<span class="heading-more-text">
						<?php echo wp_kses_post( th90_text_link( $atts['_heading_more_text'], $atts['_heading_more_link'] ) ); ?>
					</span>
				<?php endif; ?>

				<?php if( 'heading-show-more' == $atts['pagi'] ): ?>
					<?php
					$btn_classes = array(
						'is-link',
						'module-pagi',
						'show-more',
						'next-posts',
						'heading-pagi',
					);
					?>
					<div class="<?php echo esc_attr( implode( ' ', array_filter( $btn_classes ) ) ); ?>" data-text="<?php echo esc_attr( $atts['_pagi_show_text'] ); ?>">
						<span class="heading-pagi-text"><?php echo esc_html( $atts['_pagi_show_text'] ); ?></span>
					</div>
				<?php endif; ?>

				<?php if( 'heading-next-prev' == $atts['pagi'] ): ?>
					<?php
					$btn_classes = array(
						'module-pagi',
						'show-more',
						'nextprev-more',
					);
					?>
					<div class="nextprev-pagi">
						<div class="<?php echo esc_attr( implode( ' ', array_filter( $btn_classes ) ) ); ?> prev-posts btn-disabled" data-text="Prev"></div>
						<div class="<?php echo esc_attr( implode( ' ', array_filter( $btn_classes ) ) ); ?> next-posts" data-text="Next"></div>
					</div>
				<?php endif; ?>

				<?php if( 'yes' == $atts['_slider_arrow'] ): ?>
					<div class="swiper-nav-heading">
						<div class="swiper-arrow swiper-prev swiper-prev-slider-<?php echo absint( $atts['slider_id'] ); ?>"></div>
						<div class="swiper-arrow swiper-next swiper-next-slider-<?php echo absint( $atts['slider_id'] ); ?>"></div>
					</div>
				<?php endif; ?>

				<?php
				$output .= ob_get_clean();
			$output .= '</div>';
		}

		/* Sub Heading - Bottom */
		if ( ! empty( $atts['subheading'] ) && 'bottom' == $atts['subheading_pos'] ) {
			$output .= '<p class="subheading">' . do_shortcode( $atts['subheading'] ) . '</p>';
		}

		$output .= '</div>';

		return $output;
	}
}

/*
--------------------------------------------------------------------------------
* Text Link
* ------------------------------------------------------------------------------
*/
if ( ! function_exists( 'th90_text_link' ) ) {
	function th90_text_link( $text = '', $link = array() ) {
		$link_before = $link_after = '';
		$link_attr = array();

		if ( ! empty( $link ) ) {
			if ( isset( $link['url'] ) && strlen( $link['url'] ) > 0 && $text ) {
				$link_attr[] = 'class="text-link"';
				$link_attr[] = 'href="' . esc_url( trim( $link['url'] ) ) . '"';
				$link_attr[] = 'title="' . esc_attr( trim( $text ) ) . '"';

				if ( ! empty( $link['is_external'] ) && $link['is_external'] ) {
					$link_attr[] = 'target="_blank"';
				}

				if ( ! empty( $link['nofollow'] ) && $link['nofollow'] ) {
					$link_attr[] = 'rel="nofollow';
				}

				$link_before = '<a ' . implode( ' ', $link_attr ) . '>';
				$link_after = '</a>';
			}
		}
		return $link_before . $text . $link_after;
	}
}