HOME


Mini Shell 1.0
DIR: /home/depancom/www/depancomblogus/wp-content/themes/beautyspot/inc/
Upload File :
Current File : /home/depancom/www/depancomblogus/wp-content/themes/beautyspot/inc/frontend-functions.php
<?php

/**
 * GENERAL
 */

	// Alert message
	if ( ! function_exists( 'lsvr_beautyspot_the_alert_message' ) ) {
		function lsvr_beautyspot_the_alert_message( $message ) {

			echo '<p class="c-alert-message">' . esc_html( $message ) . '</p>';

		}
	}

 	// Post terms
	if ( ! function_exists( 'lsvr_beautyspot_the_post_terms' ) ) {
		function lsvr_beautyspot_the_post_terms( $post_id, $taxonomy, $template = '%s', $separator = ', ', $limit = 0 ) {

			if ( 'post_tag' === $taxonomy && true === apply_filters( 'lsvr_beautyspot_the_post_terms_the_tags_enable', false ) ) {
				the_tags();
			}

			else {

				$terms = wp_get_object_terms( $post_id, $taxonomy );
				$terms_parsed = array();
				if ( ! empty( $terms ) ) {
					foreach ( $terms as $term ) {
						array_push( $terms_parsed, '<a href="' . esc_url( get_term_link( $term->term_id, $taxonomy ) ) . '" class="post__term-link">' . esc_html( $term->name ) . '</a>' );
					}
					if ( $limit > 0 && count( $terms_parsed ) > $limit ) {
						$terms_parsed = array_slice( $terms_parsed, 0, $limit );
					}
				}

				if ( ! empty( $terms_parsed ) ) { ?>

					<span class="post__terms post__terms--<?php echo esc_attr( $taxonomy ); ?>">
						<?php echo sprintf( $template, implode( $separator, $terms_parsed ) ); ?>
					</span>

				<?php }

			}

		}
	}

	// Active language label
	if ( ! function_exists( 'lsvr_beautyspot_the_active_language_label' ) ) {
		function lsvr_beautyspot_the_active_language_label() {

			$active_language = lsvr_beautyspot_get_active_language();
			echo ! empty( $active_language['label'] ) ? esc_html( $active_language['label'] ) : '';

		}
	}


/**
 * HEADER
 */

	// Header class
	if ( ! function_exists( 'lsvr_beautyspot_the_header_class' ) ) {
		function lsvr_beautyspot_the_header_class( $class = '' ) {

			$class_arr = ! empty( $class ) ? explode( ' ', $class ) : array();

			// Has languages
			if ( lsvr_beautyspot_has_languages() ) {
				array_push( $class_arr, 'header--has-languages' );
			}

			// Has search
			if ( true === get_theme_mod( 'header_search_enable', true ) ) {
				array_push( $class_arr, 'header--has-search' );
			}

			// Has CTA
			if ( lsvr_beautyspot_has_header_cta() ) {
				array_push( $class_arr, 'header--has-cta' );
			}

			// Has contact
			if ( lsvr_beautyspot_has_header_contact() ) {
				array_push( $class_arr, 'header--has-contact' );
			}

			// Has social links
			if ( lsvr_beautyspot_has_header_social_links() ) {
				array_push( $class_arr, 'header--has-social-links' );
			}

			// Has cart
			if ( lsvr_beautyspot_has_header_cart() ) {
				array_push( $class_arr, 'header--has-cart' );
			}

			// Has collapsible panel
			if ( lsvr_beautyspot_has_header_contact() && 'auto' === get_theme_mod( 'header_panel_collapsible_enable', 'auto' ) ) {
				array_push( $class_arr, 'header--has-collision-detection header--has-expanded-panel' );
			} elseif ( lsvr_beautyspot_has_header_contact() && 'expanded' === get_theme_mod( 'header_panel_collapsible_enable', 'auto' ) ) {
				array_push( $class_arr, 'header--has-collision-detection header--has-collapsible-panel header--has-expanded-panel' );
			} elseif ( lsvr_beautyspot_has_header_contact() && 'collapsed' === get_theme_mod( 'header_panel_collapsible_enable', 'auto' ) ) {
				array_push( $class_arr, 'header--has-collision-detection header--has-collapsible-panel header--has-collapsed-panel' );
			}

			// Filter
			if ( ! empty( apply_filters( 'lsvr_beautyspot_header_class', '' ) ) ) {
				array_push( $class_arr, apply_filters( 'lsvr_beautyspot_header_class', '' ) );
			}

			// Echo
			if ( ! empty( $class_arr ) ) {
				echo ' class="' . esc_attr( implode( ' ', $class_arr ) ) . '"';
			}

		}
	}

	// Header background
	if ( ! function_exists( 'lsvr_beautyspot_the_header_background' ) ) {
		function lsvr_beautyspot_the_header_background() {

			$image_url = get_theme_mod( 'header_background_image' );
			if ( ! empty( $image_url ) ) {
				echo ' style="background-image: url( \'' . esc_url( $image_url ) . '\' );"';
			}

		}
	}

	// Header background overlay
	if ( ! function_exists( 'lsvr_beautyspot_the_header_overlay' ) ) {
		function lsvr_beautyspot_the_header_overlay() {

			$overlay_opacity = (int) get_theme_mod( 'header_background_overlay_opacity', 90 );
			if ( $overlay_opacity > 0 ) {
				$opacity_css = 'opacity: ' . $overlay_opacity / 100 . ';'; // For modern browsers
				$opacity_filter_css = 'filter: alpha(opacity=' . $overlay_opacity . ');'; // For IE
				echo '<div class="header__overlay" style="' . esc_attr( $opacity_css . ' ' . $opacity_filter_css ) . '"></div>';
			}

		}
	}


/**
 * CORE
 */

	// Core class
	if ( ! function_exists( 'lsvr_beautyspot_core_class' ) ) {
		function lsvr_beautyspot_core_class( $class = '' ) {

			$class_arr = ! empty( $class ) ? explode( ' ', $class ) : array();

			// Narrow layout
			if ( true === apply_filters( 'lsvr_beautyspot_narrow_layout_enable', false )
				|| 'page-templates/narrow.php' === get_page_template_slug() || is_404() || is_search() ) {
				array_push( $class_arr, 'core--narrow' );
			}

			// Filter
			if ( ! empty( apply_filters( 'lsvr_beautyspot_core_class', '' ) ) ) {
				array_push( $class_arr, apply_filters( 'lsvr_beautyspot_core_class', '' ) );
			}

			// Echo
			if ( ! empty( $class_arr ) ) {
				echo ' class="' . esc_attr( implode( ' ', $class_arr ) ) . '"';
			}

		}
	}

	// Page title class
	if ( ! function_exists( 'lsvr_beautyspot_the_page_header_class' ) ) {
		function lsvr_beautyspot_the_page_header_class( $class = '' ) {

			$class_arr = ! empty( $class ) ? explode( ' ', $class ) : array();
			array_push( $class_arr, 'page-header' );

			// Filter
			if ( ! empty( apply_filters( 'lsvr_beautyspot_page_header_class', '' ) ) ) {
				array_push( $class_arr, apply_filters( 'lsvr_beautyspot_page_header_class', '' ) );
			}

			// Echo
			if ( ! empty( $class_arr ) ) {
				echo ' class="' . esc_attr( implode( ' ', $class_arr ) ) . '"';
			}

		}
	}

	// Blog Archive class
	if ( ! function_exists( 'lsvr_beautyspot_the_blog_post_archive_class' ) ) {
		function lsvr_beautyspot_the_blog_post_archive_class( $class = '' ) {

			// Defaults
			$class_arr = array( 'post-archive blog-post-archive' );

			// Passed
			if ( ! empty( $class ) ) {
				$class_arr = array_merge( $class_arr, explode( ' ', $class ) );
			}

			// Masonry
			if ( 'grid' === get_theme_mod( 'blog_archive_layout', 'default' ) && true === get_theme_mod( 'blog_archive_masonry_enable', false ) ) {
				array_push( $class_arr, 'blog-post-archive--is-masonry' );
			}

			// Filter
			array_push( $class_arr, apply_filters( 'lsvr_beautyspot_blog_post_archive_class', '' ) );

			// Echo
			if ( ! empty( $class_arr ) ) {
				echo ' class="' . esc_attr( implode( ' ', $class_arr ) ) . '"';
			}

		}
	}

	// Archive list class
	if ( ! function_exists( 'lsvr_beautyspot_the_blog_post_archive_list_class' ) ) {
		function lsvr_beautyspot_the_blog_post_archive_list_class( $class = '' ) {

			// Defaults
			$class_arr = array( 'post-archive__list' );

			// Passed
			if ( ! empty( $class ) ) {
				$class_arr = array_merge( $class_arr, explode( ' ', $class ) );
			}

			// Columns
			if ( 'grid' === get_theme_mod( 'blog_archive_layout', 'default' ) ) {
				$number_of_columns = ! empty( get_theme_mod( 'blog_archive_grid_columns', 3 ) ) ? (int) get_theme_mod( 'blog_archive_grid_columns', 3 ) : 3;
				$span = 12 / $number_of_columns;
				$md_cols = $span > 2 ? 2 : $span;
				$sm_cols = $span > 2 ? 2 : $span;
				array_push( $class_arr, 'lsvr-grid lsvr-grid--' . $number_of_columns . '-cols lsvr-grid--md-' . $md_cols . '-cols lsvr-grid--sm-' . $sm_cols . '-cols' );
			}

			// Masonry
			if ( 'grid' === get_theme_mod( 'blog_archive_layout', 'default' ) && true === get_theme_mod( 'blog_archive_masonry_enable', false ) ) {
				array_push( $class_arr, 'lsvr-grid--masonry' );
			}

			// Filter
			array_push( $class_arr, apply_filters( 'lsvr_beautyspot_blog_post_archive_list_class', '' ) );

			// Echo
			if ( ! empty( $class_arr ) ) {
				echo ' class="' . esc_attr( implode( ' ', $class_arr ) ) . '"';
			}

		}
	}

	// Archive grid column class
	if ( ! function_exists( 'lsvr_beautyspot_the_blog_post_archive_grid_column_class' ) ) {
		function lsvr_beautyspot_the_blog_post_archive_grid_column_class( $class = '' ) {

			// Defaults
			$class_arr = array();

			// Passed
			if ( ! empty( $class ) ) {
				$class_arr = array_merge( $class_arr, explode( ' ', $class ) );
			}

			// Columns
			$number_of_columns = (int) get_theme_mod( 'blog_archive_grid_columns', 3 ) > 0 ? (int) get_theme_mod( 'blog_archive_grid_columns', 3 ) : 3;
			$span = 12 / $number_of_columns;
			$span_md_class = 3 === $span || 4 === $span || 6 === $span ? ' lsvr-grid__col--md-span-6' : '';
			$span_sm_class = 3 === $span || 4 === $span || 6 === $span ? ' lsvr-grid__col--sm-span-6' : '';
			array_push( $class_arr, 'lsvr-grid__col lsvr-grid__col--span-' . $span . $span_md_class . $span_sm_class );

			// Filter
			array_push( $class_arr, apply_filters( 'lsvr_beautyspot_blog_post_archive_grid_column_class', '' ) );

			// Echo
			if ( ! empty( $class_arr ) ) {
				echo ' class="' . esc_attr( implode( ' ', $class_arr ) ) . '"';
			}

		}
	}


/**
 * FOOTER
 */

	// Footer widgets class
	if ( ! function_exists( 'lsvr_beautyspot_the_footer_widgets_class' ) ) {
		function lsvr_beautyspot_the_footer_widgets_class() {

			$class_arr = array( 'footer-widgets' );

			// Has background
			if ( ! empty( get_theme_mod( 'footer_widgets_background_image', '' ) ) ) {
				array_push( $class_arr, 'footer-widgets--has-background' );
			}

			// Echo
			if ( ! empty( $class_arr ) ) {
				echo ' class="' . esc_attr( implode( ' ', $class_arr ) ) . '"';
			}

		}
	}

	// Footer widgets background
	if ( ! function_exists( 'lsvr_beautyspot_the_footer_widgets_background' ) ) {
		function lsvr_beautyspot_the_footer_widgets_background() {

			$image_url = get_theme_mod( 'footer_widgets_background_image' );
			if ( ! empty( $image_url ) ) {
				echo ' style="background-image: url( \'' . esc_url( $image_url ) . '\' );"';
			}

		}
	}

	// Footer background overlay
	if ( ! function_exists( 'lsvr_beautyspot_the_footer_widgets_overlay' ) ) {
		function lsvr_beautyspot_the_footer_widgets_overlay() {

			if ( ! empty( get_theme_mod( 'footer_widgets_background_image', '' ) ) ) {
				$overlay_opacity = (int) get_theme_mod( 'footer_widgets_background_overlay_opacity', 80 );
				$opacity_css = 'opacity: ' . $overlay_opacity / 100 . ';'; // For modern browsers
				$opacity_filter_css = 'filter: alpha(opacity=' . $overlay_opacity . ');'; // For IE
				echo '<div class="footer-widgets__overlay" style="' . esc_attr( $opacity_css . ' ' . $opacity_filter_css ) . '"></div>';
			}

		}
	}

	// Footer widgets grid class
	if ( ! function_exists( 'lsvr_beautyspot_the_footer_widgets_grid_class' ) ) {
		function lsvr_beautyspot_the_footer_widgets_grid_class() {

			$classes = array( 'lsvr-grid' );
			$columns = get_theme_mod( 'footer_widgets_columns', 2 );

			// Cols
			array_push( $classes, 'lsvr-grid--' . $columns . '-cols' );

			// Cold md
			if ( $columns >= 2 ) {
				array_push( $classes, 'lsvr-grid--md-2-cols' );
			}

			if ( ! empty( $classes ) ) {
				echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"';
			}

		}
	}

?>