1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<?php
/**
* Button Styling Loader for Astra theme.
*
* @package Astra
* @author Brainstorm Force
* @copyright Copyright (c) 2020, Brainstorm Force
* @link https://www.brainstormforce.com
* @since Astra 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Customizer Initialization
*
* @since 3.0.0
*/
class Astra_Primary_Header_Loader {
/**
* Constructor
*
* @since 3.0.0
*/
public function __construct() {
add_action( 'customize_preview_init', array( $this, 'preview_scripts' ), 110 );
// Markup.
remove_filter( 'body_class', 'astra_body_classes' );
add_filter( 'body_class', array( $this, 'astra_body_header_classes' ) );
}
/**
* Adds custom classes to the array of body classes.
*
* @since 1.0.0
* @param array $classes Classes for the body element.
* @return array
*/
public function astra_body_header_classes( $classes ) {
if ( wp_is_mobile() ) {
$classes[] = 'ast-header-break-point';
} else {
$classes[] = 'ast-desktop';
}
if ( astra_is_amp_endpoint() ) {
$classes[] = 'ast-amp';
}
// Apply separate container class to the body.
$content_layout = astra_get_content_layout();
if ( 'content-boxed-container' == $content_layout ) {
$classes[] = 'ast-separate-container';
} elseif ( 'boxed-container' == $content_layout ) {
$classes[] = 'ast-separate-container ast-two-container';
} elseif ( 'page-builder' == $content_layout ) {
$classes[] = 'ast-page-builder-template';
} elseif ( 'plain-container' == $content_layout ) {
$classes[] = 'ast-plain-container';
}
// Sidebar location.
$page_layout = 'ast-' . astra_page_layout();
$classes[] = esc_attr( $page_layout );
// Current Astra verion.
$classes[] = esc_attr( 'astra-' . ASTRA_THEME_VERSION );
/**
* Add class for header width
*/
$header_content_layout = astra_get_option( 'hb-header-main-layout-width' );
if ( 'full' == $header_content_layout ) {
$classes[] = 'ast-full-width-primary-header';
}
return $classes;
}
/**
* 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-primary-customizer-preview-js', ASTRA_PRIMARY_HEADER_URI . '/assets/js/' . $dir_name . '/customizer-preview' . $file_prefix . '.js', array( 'customize-preview', 'astra-customizer-preview-js' ), ASTRA_THEME_VERSION, true );
// Localize variables for Button JS.
wp_localize_script(
'astra-heading-primary-customizer-preview-js',
'AstraBuilderPrimaryHeaderData',
array(
'header_break_point' => astra_header_break_point(),
'tablet_break_point' => astra_get_tablet_breakpoint(),
'mobile_break_point' => astra_get_mobile_breakpoint(),
)
);
}
}
/**
* Kicking this off by creating the object of the class.
*/
new Astra_Primary_Header_Loader();
|