summaryrefslogtreecommitdiff
path: root/inc/builder/type/header/above-header
diff options
context:
space:
mode:
Diffstat (limited to 'inc/builder/type/header/above-header')
-rw-r--r--inc/builder/type/header/above-header/assets/js/minified/customizer-preview.min.js1
-rw-r--r--inc/builder/type/header/above-header/assets/js/unminified/customizer-preview.js81
-rw-r--r--inc/builder/type/header/above-header/class-astra-above-header-loader.php53
-rw-r--r--inc/builder/type/header/above-header/class-astra-above-header.php44
-rw-r--r--inc/builder/type/header/above-header/dynamic-css/dynamic.css.php153
5 files changed, 332 insertions, 0 deletions
diff --git a/inc/builder/type/header/above-header/assets/js/minified/customizer-preview.min.js b/inc/builder/type/header/above-header/assets/js/minified/customizer-preview.min.js
new file mode 100644
index 0000000..0a24c24
--- /dev/null
+++ b/inc/builder/type/header/above-header/assets/js/minified/customizer-preview.min.js
@@ -0,0 +1 @@
+!function(){var r=astraBuilderPreview.tablet_break_point||768,t=astraBuilderPreview.mobile_break_point||544;wp.customize("astra-settings[hba-header-height]",function(a){a.bind(function(a){var e;""==a.desktop&&""==a.tablet&&""==a.mobile||(e="",e+=".ast-above-header-bar .site-above-header-wrap, .ast-mobile-header-wrap .ast-above-header-bar{",e+="min-height: "+a.desktop+"px;",e+="} ",e+=".ast-desktop .ast-above-header-bar .main-header-menu > .menu-item {",e+="line-height: "+a.desktop+"px;",e+="} ",e+="@media (max-width: "+r+"px) {",e+=".ast-above-header-bar .site-above-header-wrap, .ast-mobile-header-wrap .ast-above-header-bar{",e+="min-height: "+a.tablet+"px;",e+="} ",e+="} ",e+="@media (max-width: "+t+"px) {",e+=".ast-above-header-bar .site-above-header-wrap, .ast-mobile-header-wrap .ast-above-header-bar{",e+="min-height: "+a.mobile+"px;",e+="} ",e+="} ",astra_add_dynamic_css("hba-header-height",e))})}),wp.customize("astra-settings[hba-header-separator]",function(a){a.bind(function(a){var e="";e+=".ast-above-header.ast-above-header-bar, .ast-above-header-bar {",e+="border-bottom-width: "+a+"px;",e+="border-bottom-style: solid;",e+="border-color:"+wp.customize("astra-settings[hba-header-bottom-border-color]").get()+";",e+="}",astra_add_dynamic_css("hba-header-separator",e)})}),astra_css("astra-settings[hba-header-bottom-border-color]","border-color",".ast-above-header.ast-above-header-bar, .ast-above-header-bar"),astra_apply_responsive_background_css("astra-settings[hba-header-bg-obj-responsive]",".ast-above-header.ast-above-header-bar","desktop"),astra_apply_responsive_background_css("astra-settings[hba-header-bg-obj-responsive]",".ast-above-header.ast-above-header-bar","tablet"),astra_apply_responsive_background_css("astra-settings[hba-header-bg-obj-responsive]",".ast-above-header.ast-above-header-bar","mobile"),astra_builder_advanced_css("section-above-header-builder",".ast-above-header.ast-above-header-bar"),astra_builder_visibility_css("section-above-header-builder",".ast-above-header-bar","grid")}(jQuery); \ No newline at end of file
diff --git a/inc/builder/type/header/above-header/assets/js/unminified/customizer-preview.js b/inc/builder/type/header/above-header/assets/js/unminified/customizer-preview.js
new file mode 100644
index 0000000..1f7d82d
--- /dev/null
+++ b/inc/builder/type/header/above-header/assets/js/unminified/customizer-preview.js
@@ -0,0 +1,81 @@
+/**
+ * This file adds some LIVE to the Customizer live preview. To leverage
+ * this, set your custom settings to 'postMessage' and then add your handling
+ * here. Your javascript should grab settings from customizer controls, and
+ * then make any necessary changes to the page using jQuery.
+ *
+ * @package Astra
+ * @since 3.0.0
+ */
+
+( function( $ ) {
+
+ var tablet_break_point = astraBuilderPreview.tablet_break_point || 768,
+ mobile_break_point = astraBuilderPreview.mobile_break_point || 544;
+
+ wp.customize( 'astra-settings[hba-header-height]', function( value ) {
+ value.bind( function( size ) {
+
+ if( size.desktop != '' || size.tablet != '' || size.mobile != '' ) {
+ var dynamicStyle = '';
+ dynamicStyle += '.ast-above-header-bar .site-above-header-wrap, .ast-mobile-header-wrap .ast-above-header-bar{';
+ dynamicStyle += 'min-height: ' + size.desktop + 'px;';
+ dynamicStyle += '} ';
+ dynamicStyle += '.ast-desktop .ast-above-header-bar .main-header-menu > .menu-item {';
+ dynamicStyle += 'line-height: ' + size.desktop + 'px;';
+ dynamicStyle += '} ';
+
+ dynamicStyle += '@media (max-width: ' + tablet_break_point + 'px) {';
+ dynamicStyle += '.ast-above-header-bar .site-above-header-wrap, .ast-mobile-header-wrap .ast-above-header-bar{';
+ dynamicStyle += 'min-height: ' + size.tablet + 'px;';
+ dynamicStyle += '} ';
+ dynamicStyle += '} ';
+
+ dynamicStyle += '@media (max-width: ' + mobile_break_point + 'px) {';
+ dynamicStyle += '.ast-above-header-bar .site-above-header-wrap, .ast-mobile-header-wrap .ast-above-header-bar{';
+ dynamicStyle += 'min-height: ' + size.mobile + 'px;';
+ dynamicStyle += '} ';
+ dynamicStyle += '} ';
+
+ astra_add_dynamic_css( 'hba-header-height', dynamicStyle );
+ }
+ } );
+ } );
+
+ // Border Bottom width.
+ wp.customize( 'astra-settings[hba-header-separator]', function( value ) {
+ value.bind( function( border ) {
+
+ var color = wp.customize( 'astra-settings[hba-header-bottom-border-color]' ).get(),
+ dynamicStyle = '';
+
+ dynamicStyle += '.ast-above-header.ast-above-header-bar, .ast-above-header-bar {';
+ dynamicStyle += 'border-bottom-width: ' + border + 'px;';
+ dynamicStyle += 'border-bottom-style: solid;';
+ dynamicStyle += 'border-color:' + color + ';';
+ dynamicStyle += '}';
+
+ astra_add_dynamic_css( 'hba-header-separator', dynamicStyle );
+
+ } );
+ } );
+
+ // Border Color.
+ astra_css(
+ 'astra-settings[hba-header-bottom-border-color]',
+ 'border-color',
+ '.ast-above-header.ast-above-header-bar, .ast-above-header-bar'
+ );
+
+ // Responsive BG styles > Below Header Row.
+ astra_apply_responsive_background_css( 'astra-settings[hba-header-bg-obj-responsive]', '.ast-above-header.ast-above-header-bar', 'desktop' );
+ astra_apply_responsive_background_css( 'astra-settings[hba-header-bg-obj-responsive]', '.ast-above-header.ast-above-header-bar', 'tablet' );
+ astra_apply_responsive_background_css( 'astra-settings[hba-header-bg-obj-responsive]', '.ast-above-header.ast-above-header-bar', 'mobile' );
+
+ // Advanced CSS Generation.
+ astra_builder_advanced_css( 'section-above-header-builder', '.ast-above-header.ast-above-header-bar' );
+
+ // Advanced Visibility CSS Generation.
+ astra_builder_visibility_css( 'section-above-header-builder', '.ast-above-header-bar', 'grid' );
+
+} )( jQuery );
diff --git a/inc/builder/type/header/above-header/class-astra-above-header-loader.php b/inc/builder/type/header/above-header/class-astra-above-header-loader.php
new file mode 100644
index 0000000..41dd14a
--- /dev/null
+++ b/inc/builder/type/header/above-header/class-astra-above-header-loader.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Above Header Loader.
+ *
+ * @package astra-builder
+ * @author Brainstorm Force
+ * @copyright Copyright (c) 2020, Brainstorm Force
+ * @link https://www.brainstormforce.com
+ * @since 3.0.0
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+/**
+ * Class Astra_Above_Header_Loader
+ *
+ * Loads config files.
+ *
+ * @since 3.0.0
+ */
+class Astra_Above_Header_Loader {
+
+ /**
+ * Constructor
+ *
+ * @since 3.0.0
+ */
+ public function __construct() {
+ add_action( 'customize_preview_init', array( $this, 'preview_scripts' ), 110 );
+ }
+
+ /**
+ * Customizer Preview
+ *
+ * @since 3.0.0
+ */
+ public function preview_scripts() {
+ /**
+ * Load unminified if SCRIPT_DEBUG is true.
+ */
+ /* Directory and Extension */
+ $dir_name = ( SCRIPT_DEBUG ) ? 'unminified' : 'minified';
+ $file_prefix = ( SCRIPT_DEBUG ) ? '' : '.min';
+ wp_enqueue_script( 'astra-heading-above-customizer-preview-js', ASTRA_ABOVE_HEADER_URI . '/assets/js/' . $dir_name . '/customizer-preview' . $file_prefix . '.js', array( 'customize-preview', 'astra-customizer-preview-js' ), ASTRA_THEME_VERSION, true );
+ }
+}
+
+/**
+* Kicking this off by creating the object of the class.
+*/
+new Astra_Above_Header_Loader();
diff --git a/inc/builder/type/header/above-header/class-astra-above-header.php b/inc/builder/type/header/above-header/class-astra-above-header.php
new file mode 100644
index 0000000..d42ce54
--- /dev/null
+++ b/inc/builder/type/header/above-header/class-astra-above-header.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Above Header.
+ *
+ * @package astra-builder
+ * @author Brainstorm Force
+ * @copyright Copyright (c) 2020, Brainstorm Force
+ * @link https://www.brainstormforce.com
+ * @since 3.0.0
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+define( 'ASTRA_ABOVE_HEADER_DIR', ASTRA_THEME_DIR . 'inc/builder/type/header/above-header' );
+define( 'ASTRA_ABOVE_HEADER_URI', ASTRA_THEME_URI . 'inc/builder/type/header/above-header' );
+
+/**
+ * Above Header Initial Setup
+ *
+ * @since 3.0.0
+ */
+class Astra_Above_Header {
+
+ /**
+ * Constructor function that initializes required actions and hooks.
+ */
+ public function __construct() {
+ // @codingStandardsIgnoreStart WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
+ require_once ASTRA_ABOVE_HEADER_DIR . '/class-astra-above-header-loader.php';
+
+ // Include front end files.
+ if ( ! is_admin() ) {
+ require_once ASTRA_ABOVE_HEADER_DIR . '/dynamic-css/dynamic.css.php';
+ }
+ // @codingStandardsIgnoreEnd WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
+ }
+}
+
+/**
+ * Kicking this off by creating an object.
+ */
+new Astra_Above_Header();
diff --git a/inc/builder/type/header/above-header/dynamic-css/dynamic.css.php b/inc/builder/type/header/above-header/dynamic-css/dynamic.css.php
new file mode 100644
index 0000000..618d9aa
--- /dev/null
+++ b/inc/builder/type/header/above-header/dynamic-css/dynamic.css.php
@@ -0,0 +1,153 @@
+<?php
+/**
+ * Above Header - Dynamic CSS
+ *
+ * @package astra-builder
+ * @since 3.0.0
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+/**
+ * Above Header Row.
+ */
+add_filter( 'astra_dynamic_theme_css', 'astra_above_header_row_setting', 11 );
+
+/**
+ * Above Header Row - Dynamic CSS
+ *
+ * @param string $dynamic_css Astra Dynamic CSS.
+ * @param string $dynamic_css_filtered Astra Dynamic CSS Filters.
+ * @return String Generated dynamic CSS for Heading Colors.
+ *
+ * @since 3.0.0
+ */
+function astra_above_header_row_setting( $dynamic_css, $dynamic_css_filtered = '' ) {
+
+ if ( ! is_customize_preview() && ( ! Astra_Builder_helper::is_row_empty( 'above', 'header', 'desktop' ) && ! Astra_Builder_helper::is_row_empty( 'above', 'header', 'mobile' ) ) ) {
+ return $dynamic_css;
+ }
+
+ $parse_css = '';
+
+ // Common CSS options.
+ $hba_header_height = astra_get_option( 'hba-header-height' );
+ $hba_header_divider = absint( astra_get_option( 'hba-header-separator' ) );
+ $hba_border_color = astra_get_option( 'hba-header-bottom-border-color' );
+
+ // Background CSS options.
+ $hba_header_bg_obj = astra_get_option( 'hba-header-bg-obj-responsive' );
+ $desktop_background = isset( $hba_header_bg_obj['desktop']['background-color'] ) ? $hba_header_bg_obj['desktop']['background-color'] : '';
+ $tablet_background = isset( $hba_header_bg_obj['tablet']['background-color'] ) ? $hba_header_bg_obj['tablet']['background-color'] : '';
+ $mobile_background = isset( $hba_header_bg_obj['mobile']['background-color'] ) ? $hba_header_bg_obj['mobile']['background-color'] : '';
+
+ // Header Height.
+ $hba_header_height_desktop = ( isset( $hba_header_height['desktop'] ) && ! empty( $hba_header_height['desktop'] ) ) ? $hba_header_height['desktop'] : '';
+ $hba_header_height_tablet = ( isset( $hba_header_height['tablet'] ) && ! empty( $hba_header_height['tablet'] ) ) ? $hba_header_height['tablet'] : '';
+ $hba_header_height_mobile = ( isset( $hba_header_height['mobile'] ) && ! empty( $hba_header_height['mobile'] ) ) ? $hba_header_height['mobile'] : '';
+
+ // Spacing CSS options.
+ $hba_header_spacing = astra_get_option( 'hba-header-spacing' );
+
+ /**
+ * Above Header General options
+ */
+ $common_css_output = array(
+ '.ast-above-header .main-header-bar-navigation' => array(
+ 'height' => '100%',
+ ),
+ '.ast-header-break-point .ast-mobile-header-wrap .ast-above-header-wrap .main-header-bar-navigation .inline-on-mobile .menu-item .menu-link' => array(
+ 'border' => 'none',
+ ),
+ '.ast-header-break-point .ast-mobile-header-wrap .ast-above-header-wrap .main-header-bar-navigation .inline-on-mobile .menu-item-has-children > .ast-menu-toggle::before' => array(
+ 'font-size' => '.6rem',
+ ),
+ '.ast-header-break-point .ast-mobile-header-wrap .ast-above-header-wrap .main-header-bar-navigation .ast-submenu-expanded > .ast-menu-toggle::before' => array(
+ 'transform' => 'rotateX(180deg)',
+ ),
+ '.ast-mobile-header-wrap .ast-above-header-bar , .ast-above-header-bar .site-above-header-wrap' => array(
+ 'min-height' => astra_get_css_value( $hba_header_height_desktop, 'px' ),
+ ),
+ '.ast-desktop .ast-above-header-bar .main-header-menu > .menu-item' => array(
+ 'line-height' => astra_get_css_value( $hba_header_height_desktop, 'px' ),
+ ),
+ '.ast-desktop .ast-above-header-bar .ast-header-woo-cart, .ast-desktop .ast-above-header-bar .ast-header-edd-cart' => array(
+ 'line-height' => astra_get_css_value( $hba_header_height_desktop, 'px' ),
+ ),
+ );
+
+ // Apply border only when it has positive value.
+ if ( $hba_header_divider ) {
+ $common_css_output['.ast-above-header-bar'] = array(
+ 'border-bottom-width' => astra_get_css_value( $hba_header_divider, 'px' ),
+ 'border-bottom-color' => esc_attr( $hba_border_color ),
+ 'border-bottom-style' => 'solid',
+ );
+ } else {
+ $common_css_output['.ast-above-header-bar'] = array(
+ 'border-bottom-style' => 'none',
+ );
+ }
+
+ if ( is_astra_addon_3_5_0_version() ) {
+ $common_css_output['.ast-above-header-bar.ast-header-sticked'] = array(
+ 'z-index' => 9,
+ );
+ }
+
+ $parse_css .= astra_parse_css( $common_css_output );
+
+ // Above Header Background Responsive - Desktop.
+ $desktop_bg = array(
+ '.ast-above-header.ast-above-header-bar' => astra_get_responsive_background_obj( $hba_header_bg_obj, 'desktop' ),
+ '.ast-header-break-point .ast-above-header-bar' => array(
+ 'background-color' => esc_attr( $desktop_background ),
+ ),
+ );
+ $parse_css .= astra_parse_css( $desktop_bg );
+
+ // Above Header Background Responsive - Tablet.
+ $tablet_bg = array(
+ '.ast-above-header.ast-above-header-bar' => astra_get_responsive_background_obj( $hba_header_bg_obj, 'tablet' ),
+ '.ast-header-break-point .ast-above-header-bar' => array(
+ 'background-color' => esc_attr( $tablet_background ),
+ ),
+ '.ast-mobile-header-wrap .ast-above-header-bar , .ast-above-header-bar .site-above-header-wrap' => array(
+ 'min-height' => astra_get_css_value( $hba_header_height_tablet, 'px' ),
+ ),
+ '#masthead .ast-mobile-header-wrap .ast-above-header-bar' => array(
+ 'padding-left' => '20px',
+ 'padding-right' => '20px',
+ ),
+ );
+ $parse_css .= astra_parse_css( $tablet_bg, '', astra_get_tablet_breakpoint() );
+
+ // Above Header Background Responsive - Mobile.
+ $mobile_bg = array(
+ '.ast-above-header.ast-above-header-bar' => astra_get_responsive_background_obj( $hba_header_bg_obj, 'mobile' ),
+ '.ast-header-break-point .ast-above-header-bar' => array(
+ 'background-color' => esc_attr( $mobile_background ),
+ ),
+ '.ast-mobile-header-wrap .ast-above-header-bar , .ast-above-header-bar .site-above-header-wrap' => array(
+ 'min-height' => astra_get_css_value( $hba_header_height_mobile, 'px' ),
+ ),
+ );
+ $parse_css .= astra_parse_css( $mobile_bg, '', astra_get_mobile_breakpoint() );
+
+ // Trim white space for faster page loading.
+ $dynamic_css .= Astra_Enqueue_Scripts::trim_css( $parse_css );
+
+ $_section = 'section-above-header-builder';
+
+ $selector = '.site-above-header-wrap[data-section="ast_header_above"]';
+
+ $parent_selector = '.ast-above-header.ast-above-header-bar';
+
+ $dynamic_css .= Astra_Builder_Base_Dynamic_CSS::prepare_advanced_margin_padding_css( $_section, $parent_selector );
+
+ $dynamic_css .= Astra_Builder_Base_Dynamic_CSS::prepare_visibility_css( $_section, '.ast-above-header-bar', 'block', $mobile_tablet_default_display = 'grid' );
+
+ return $dynamic_css;
+}