File: /home/carrerup/.trash/techland/vc_templates/vc_custom_heading.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Shortcode attributes
* @var $atts
* @var $source
* @var $text
* @var $link
* @var $google_fonts
* @var $font_container
* @var $el_class
* @var $el_id
* @var $css
* @var $css_animation
* @var $font_container_data - returned from $this->getAttributes
* @var $google_fonts_data - returned from $this->getAttributes
* Shortcode class
* @var $this WPBakeryShortCode_VC_Custom_heading
*/
$source = $text = $link = $google_fonts = $font_container = $el_id = $el_class = $css = $css_animation = $font_container_data = $google_fonts_data = array();
// This is needed to extract $font_container_data and $google_fonts_data
extract( $this->getAttributes( $atts ) );
$techland_heading = '';
$htag = 'h2';
//extra vc_heading atts
$heading_fw = $heading_trans = $heading_lts = $heading_clr = $custom_clr = $bold_clr = '';
$def_lh = $md_lh = $sm_lh = $xs_lh = '';
$techland_premartop = $techland_premarbot = $techland_row_prepad = '';
//extra vc_heading atts
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );
/**
* @var $css_class
*/
extract( $this->getStyles( $el_class . $this->getCSSAnimation( $css_animation ), $css, $google_fonts_data, $font_container_data, $atts ) );
if ($techland_heading != 'vc') {
$uniq = 'nt-ch-1'.mt_rand(5, 1000);
//
$techland_css_class = preg_replace('/vc_custom_heading/', 'nt-custom-heading', $css_class );
$heading_class = array(
$techland_css_class,
$techland_row_prepad,
$techland_premartop,
$techland_premarbot,
);
if ('yes' !== $atts['use_theme_fonts'] && $atts['heading_fw'] != '' ) {
$heading_class[] = $atts['heading_fw'];
}
if ($atts['heading_trans'] != '') {
$heading_class[] = $atts['heading_trans'];
}
if ($atts['def_align'] != '') {
$heading_class[] = $atts['def_align'];
}
if ($atts['md_align'] != '') {
$heading_class[] = $atts['md_align'];
}
if ($atts['sm_align'] != '') {
$heading_class[] = $atts['sm_align'];
}
if ($atts['xs_align'] != '') {
$heading_class[] = $atts['xs_align'];
}
if ($atts['heading_clr'] != 'custom' && $atts['heading_clr'] != '') {
$heading_class[] = $atts['heading_clr'];
}
// custom css
$heading_css = array();
$settings = get_option( 'wpb_js_google_fonts_subsets' );
if ( is_array( $settings ) && ! empty( $settings ) ) {
$subsets = '&subset=' . implode( ',', $settings );
} else {
$subsets = '';
}
if ( ( ! isset( $atts['use_theme_fonts'] ) || 'yes' !== $atts['use_theme_fonts'] ) && isset( $google_fonts_data['values']['font_family'] ) ) {
wp_enqueue_style( 'vc_google_fonts_' . vc_build_safe_css_class( $google_fonts_data['values']['font_family'] ), 'https://fonts.googleapis.com/css?family=' . $google_fonts_data['values']['font_family'] . $subsets );
}
if ( ! empty( $styles ) ) {
$heading_css[] = esc_attr( implode( ';', $styles ) ).';';
}
if ($atts['heading_lts'] != '') {
$heading_css[] = 'letter-spacing:'.esc_attr($atts['heading_lts']).';';
}
if ($atts['heading_clr'] == 'custom' && $atts['custom_clr'] != '') {
$heading_css[] = 'color:'.esc_attr($atts['custom_clr']).';';
}
if ($atts['def_fs'] != '') {
$heading_css[] = 'font-size: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $atts['def_fs'] ) ? esc_attr($atts['def_fs']) : esc_attr($atts['def_fs']) . 'px' ) . ';';
}
if ($atts['def_lh'] != '') {
$heading_css[] = 'line-height: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $atts['def_lh'] ) ? esc_attr($atts['def_lh']) : esc_attr($atts['def_lh']) . 'px' ) . ';';
}
$techland_ch_extra = '';
if (!empty($heading_css)) {
$techland_ch_extra .= '.'.$uniq.'.nt-custom-heading{'.implode( ' ', array_filter( $heading_css ) ).'}';
}
// responsive css
$heading_rescss = array();
if ($md_fs != '') {
$heading_rescss[] = '@media(max-width:992px){.'.$uniq.'{font-size: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $md_fs ) ? esc_attr($md_fs) : esc_attr($md_fs) . 'px' ) . ';}}';
}
if ($sm_fs != '') {
$heading_rescss[] = '@media(max-width:768px){.'.$uniq.'{font-size: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $sm_fs ) ? esc_attr($sm_fs) : esc_attr($sm_fs) . 'px' ) . ';}}';
}
if ($xs_fs != '') {
$heading_rescss[] = '@media(max-width:576px){.'.$uniq.'{font-size: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $xs_fs ) ? esc_attr($xs_fs) : esc_attr($xs_fs) . 'px' ) . ';}}';
}
if ($md_lh != '') {
$heading_rescss[] = '@media(max-width:992px){.'.$uniq.'{line-height: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $md_lh ) ? esc_attr($md_lh) : esc_attr($md_lh) . 'px' ) . ';}}';
}
if ($sm_lh != '') {
$heading_rescss[] = '@media(max-width:768px){.'.$uniq.'{line-height: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $sm_lh ) ? esc_attr($sm_lh) : esc_attr($sm_lh) . 'px' ) . ';}}';
}
if ($xs_lh != '') {
$heading_rescss[] = '@media(max-width:576px){.'.$uniq.'{line-height: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $xs_lh ) ? esc_attr($xs_lh) : esc_attr($xs_lh) . 'px' ) . ';}}';
}
if (!empty($heading_rescss)) {
$techland_ch_extra .= implode( ' ', array_filter( $heading_rescss ) );
}
if ( 'post_title' === $source ) {
$text = get_the_title( get_the_ID() );
}
$wrapper_attributes = array();
// attributes id
if ( ! empty( $el_id ) ) {
$wrapper_attributes[] = 'id="' . esc_attr( $el_id ) . '"';
}
if ( $techland_heading == 'heading') {
$heading_class[] = '__title';
}
if ( $techland_heading == 'subheading' ) {
$htag = 'h6';
$heading_class[] = '__subtitle';
}
if ( $techland_heading == 'description' || $techland_heading == 'description-strong' ) {
$htag = 'p';
$heading_class[] = 'section-description';
if ( $techland_heading == 'description-strong' ) {
$heading_class[] = 'strong';
}
}
// add to custom css function
if (function_exists('techland_vc_extra_css')) {
$wrapper_attributes[] = techland_vc_extra_css( $atts, $uniq, $techland_ch_extra, $bg_options=false );
$heading_class[] = techland_vc_extra_css( $atts, $uniq, $techland_ch_extra, $bg_options=false ) ? $uniq : '';
}
$wrapper_attributes[] = 'class="'.trim(implode(' ', array_filter($heading_class))).'"';
if ( apply_filters( 'vc_custom_heading_template_use_wrapper', false ) ) { ?>
<div <?php echo implode( ' ', $wrapper_attributes ) ?>>
<<?php echo esc_attr($htag); ?>><?php echo wp_kses($text, techland_allowed_html() ); ?></<?php echo esc_attr($htag); ?>>
</div>
<?php
} else { ?>
<<?php echo esc_attr($htag); ?>
<?php echo implode( ' ', $wrapper_attributes ) ?>>
<?php echo wp_kses($text, techland_allowed_html()); ?></<?php echo esc_attr($htag); ?>>
<?php
}
} else {
$settings = get_option( 'wpb_js_google_fonts_subsets' );
if ( is_array( $settings ) && ! empty( $settings ) ) {
$subsets = '&subset=' . implode( ',', $settings );
} else {
$subsets = '';
}
if ( ( ! isset( $atts['use_theme_fonts'] ) || 'yes' !== $atts['use_theme_fonts'] ) && isset( $google_fonts_data['values']['font_family'] ) ) {
wp_enqueue_style( 'vc_google_fonts_' . vc_build_safe_css_class( $google_fonts_data['values']['font_family'] ), 'https://fonts.googleapis.com/css?family=' . $google_fonts_data['values']['font_family'] . $subsets );
}
if ( ! empty( $styles ) ) {
$style = 'style="' . esc_attr( implode( ';', $styles ) ) . '"';
} else {
$style = '';
}
if ( 'post_title' === $source ) {
$text = get_the_title( get_the_ID() );
}
if ( ! empty( $link ) ) {
$link = vc_build_link( $link );
$text = '<a href="' . esc_attr( $link['url'] ) . '"' . ( $link['target'] ? ' target="' . esc_attr( $link['target'] ) . '"' : '' ) . ( $link['rel'] ? ' rel="' . esc_attr( $link['rel'] ) . '"' : '' ) . ( $link['title'] ? ' title="' . esc_attr( $link['title'] ) . '"' : '' ) . '>' . $text . '</a>';
}
$wrapper_attributes = array();
if ( ! empty( $el_id ) ) {
$wrapper_attributes[] = 'id="' . esc_attr( $el_id ) . '"';
}
$output = '';
if ( apply_filters( 'vc_custom_heading_template_use_wrapper', false ) ) {
$output .= '<div class="' . esc_attr( $css_class ) . '" ' . implode( ' ', $wrapper_attributes ) . '>';
$output .= '<' . $font_container_data['values']['tag'] . ' ' . $style . ' >';
$output .= $text;
$output .= '</' . $font_container_data['values']['tag'] . '>';
$output .= '</div>';
} else {
$output .= '<' . $font_container_data['values']['tag'] . ' ' . $style . ' class="' . esc_attr( $css_class ) . '" ' . implode( ' ', $wrapper_attributes ) . '>';
$output .= $text;
$output .= '</' . $font_container_data['values']['tag'] . '>';
}
echo techland_vc_sanitize_data($output);
}