summaryrefslogtreecommitdiff
path: root/inc/core/markup/class-astra-markup.php
blob: d9d6e9c1d73739295ad8e013d5e75177678f314a (plain) (blame)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
/**
 * Astra Generate Markup Class.
 *
 * @package     Astra
 * @author      Astra
 * @copyright   Copyright (c) 2021, Astra
 * @link        https://wpastra.com/
 * @since       Astra 3.3.0
 */

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

/**
 * Class Astra_Attr
 */
class Astra_Markup {

	/**
	 * Initialuze the Class.
	 *
	 * @since 3.3.0
	 */
	public function __construct() {

		if ( ! Astra_Builder_Helper::apply_flex_based_css() ) {
			// Add filters here.
			add_filter( 'astra_markup_footer-widget-div_open', array( $this, 'footer_widget_div_open' ) );
			add_filter( 'astra_markup_footer-widget-div_close', array( $this, 'footer_widget_div_close' ) );
			add_filter( 'astra_markup_header-widget-div_open', array( $this, 'header_widget_div_open' ) );
			add_filter( 'astra_markup_header-widget-div_close', array( $this, 'footer_widget_div_close' ) );                        
			add_filter( 'astra_markup_comment-count-wrapper_open', array( $this, 'comment_count_wrapper_open' ) );
			add_filter( 'astra_markup_comment-count-wrapper_close', array( $this, 'comment_count_wrapper_close' ) );
			add_filter( 'astra_markup_ast-comment-data-wrap_open', array( $this, 'ast_comment_data_wrap_open' ) );
			add_filter( 'astra_markup_ast-comment-data-wrap_close', array( $this, 'ast_comment_data_wrap_close' ) );
			add_filter( 'astra_markup_ast-comment-meta-wrap_open', array( $this, 'ast_comment_meta_wrap_open' ) );
			add_filter( 'astra_markup_ast-comment-meta-wrap_close', array( $this, 'ast_comment_meta_wrap_close' ) );                                
			add_filter( 'astra_attr_ast-comment-time_output', array( $this, 'ast_comment_time_attr' ) );
			add_filter( 'astra_attr_ast-comment-cite-wrap_output', array( $this, 'ast_comment_cite_wrap_attr' ) );
		}
		add_filter( 'astra_attr_comment-form-grid-class_output', array( $this, 'comment_form_grid_class' ) );
		add_filter( 'astra_attr_header-widget-area-inner', array( $this, 'header_widget_area_inner' ) );
		add_filter( 'astra_attr_footer-widget-area-inner', array( $this, 'footer_widget_area_inner' ) );
		add_filter( 'astra_attr_ast-grid-lg-12_output', array( $this, 'ast_grid_lg_12' ) );
		add_filter( 'astra_attr_ast-grid-common-col_output', array( $this, 'ast_grid_common_css' ) );
		add_filter( 'astra_attr_ast-grid-blog-col_output', array( $this, 'ast_grid_blog_col' ) );
		add_filter( 'astra_attr_ast-blog-col_output', array( $this, 'ast_blog_common_css' ) );
		add_filter( 'astra_attr_ast-grid-col-6_output', array( $this, 'ast_grid_col_6' ) );
		add_filter( 'astra_attr_ast-layout-4-grid_output', array( $this, 'ast_layout_4_grid' ) );
		add_filter( 'astra_attr_ast-layout-1-grid_output', array( $this, 'ast_layout_1_grid' ) );
		add_filter( 'astra_attr_ast-layout-2-grid_output', array( $this, 'ast_layout_2_grid' ) );
		add_filter( 'astra_attr_ast-layout-3-grid_output', array( $this, 'ast_layout_3_grid' ) );
		add_filter( 'astra_attr_ast-layout-5-grid_output', array( $this, 'ast_layout_5_grid' ) );
		add_filter( 'astra_attr_ast-layout-6-grid_output', array( $this, 'ast_layout_6_grid' ) ); 
			
	}

	/** 
	 * Comment count wrapper opening div.
	 *
	 * @param array $args markup arguments.
	 * @since 3.3.0
	 * @return array.
	 */
	public function comment_count_wrapper_open( $args ) {
		$args['open']  = '<div %s>';
		$args['attrs'] = array( 'class' => 'comments-count-wrapper' );           
		return $args;
	}

	/** 
	 * Comment count wrapper closing div.
	 *
	 * @param array $args markup arguments.
	 * @since 3.3.0
	 * @return array.
	 */
	public function comment_count_wrapper_close( $args ) {
		$args['close'] = '</div>';
		return $args;
	}

	/** 
	 * Comment data wrapper opening div.
	 *
	 * @param array $args markup arguments.
	 * @since 3.3.0
	 * @return array.
	 */
	public function ast_comment_data_wrap_open( $args ) {
		$args['open']  = '<div %s>';
		$args['attrs'] = array( 'class' => 'ast-comment-data-wrap' );           
		return $args;
	}

	/** 
	 * Comment data wrapper closing div.
	 *
	 * @param array $args markup arguments.
	 * @since 3.3.0
	 * @return array.
	 */
	public function ast_comment_data_wrap_close( $args ) {
		$args['close'] = '</div>';
		return $args;
	}

	/** 
	 * Comment meta wrapper opening div.
	 *
	 * @param array $args markup arguments.
	 * @since 3.3.0
	 * @return array.
	 */
	public function ast_comment_meta_wrap_open( $args ) {
		$args['open']  = '<div %s>';
		$args['attrs'] = array( 'class' => 'ast-comment-meta-wrap' );           
		return $args;
	}

	/** 
	 * Comment meta wrapper closing div.
	 *
	 * @param array $args markup arguments.
	 * @since 3.3.0
	 * @return array.
	 */
	public function ast_comment_meta_wrap_close( $args ) {
		$args['close'] = '</div>';
		return $args;
	}

	/** 
	 * Comment time div attributes.
	 *
	 * @since 3.3.0
	 * @return string.
	 */
	public function ast_comment_time_attr() {
		return 'class = "ast-comment-time ast-col-lg-12" ';
	}

	/** 
	 * Comment cite wrapper div attributes.
	 *
	 * @since 3.3.0
	 * @return string.
	 */
	public function ast_comment_cite_wrap_attr() {
		return 'class = "ast-comment-cite-wrap ast-col-lg-12" ';
	}

	/**
	 * We have removed grid css and make common css for grid style.
	 *
	 * @since 3.3.0
	 * @return string.
	 */
	public function ast_grid_common_css() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col' : 'ast-col-md-12'; 
	}

	/**
	 * Blog content Grid CSS.
	 *
	 * @since 3.3.0
	 * @return string.
	 */
	public function ast_grid_blog_col() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col ast-float' : 'ast-col-md-12'; 
	}

	/**
	 * We have removed grid css and make common css for grid style.
	 *
	 * @since 3.3.0
	 * @return string.
	 */
	public function ast_blog_common_css() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col ast-full-width' : 'ast-col-sm-12'; 
	}

	/**
	 * Removed grid layout classes and make common class for same style.
	 *
	 * @since 3.3.0
	 * @return string.
	 */
	public function ast_grid_col_6() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-width-md-6' : 'ast-col-md-6'; 
	}

	/** 
	 * Comment form grid classes.
	 *
	 * @since 3.3.0 
	 * @return string.
	 */
	public function comment_form_grid_class() {
		return ( Astra_Builder_Helper::apply_flex_based_css() ) ? 'ast-grid-common-col ast-width-lg-33 ast-width-md-4 ast-float' : 'ast-col-xs-12 ast-col-sm-12 ast-col-md-4 ast-col-lg-4';
	}

	/** 
	 * Removed grid layout classes and make common class for same style
	 *
	 * @since 3.3.0
	 * @return string.
	 */
	public function ast_grid_lg_12() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col' : 'ast-col-lg-12'; 
	}

	/** 
	 * Layout-4 grid css backward comaptibility.
	 *
	 * @return string.
	 */
	public function ast_layout_4_grid() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col ast-width-sm-25 ast-width-md-3 ast-float ast-full-width' : 'ast-col-lg-3 ast-col-md-3 ast-col-sm-12 ast-col-xs-12'; 
	}

	/** 
	 * Layout-2 grid css backward comaptibility.
	 *
	 * @return string.
	 */
	public function ast_layout_2_grid() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col ast-width-md-6 ast-full-width' : 'ast-col-lg-6 ast-col-md-6 ast-col-sm-12 ast-col-xs-12'; 
	}

	/** 
	 * Layout-1 grid css backward comaptibility.
	 *
	 * @return string.
	 */
	public function ast_layout_1_grid() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col' : 'ast-col-lg-12 ast-col-md-12 ast-col-sm-12 ast-col-xs-12'; 
	}

	/** 
	 * Layout-3 grid css backward comaptibility.
	 *
	 * @return string.
	 */
	public function ast_layout_3_grid() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col ast-width-md-4 ast-float ast-full-width' : 'ast-col-lg-4 ast-col-md-4 ast-col-sm-12 ast-col-xs-12'; 
	}

	/** 
	 * Layout-5 grid css backward comaptibility.
	 *
	 * @return string.
	 */
	public function ast_layout_5_grid() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col ast-width-md-16 ast-width-md-20 ast-float ast-full-width' : 'ast-col-lg-2 ast-col-md-2 ast-col-sm-12 ast-col-xs-12'; 
	}

	/** 
	 * Layout-6 grid css backward comaptibility.
	 *
	 * @return string.
	 */
	public function ast_layout_6_grid() {
		return Astra_Builder_Helper::apply_flex_based_css() ? 'ast-grid-common-col ast-width-md-6 ast-width-lg-50 ast-float ast-full-width' : 'ast-col-lg-6 ast-col-md-6 ast-col-sm-12 ast-col-xs-12';
	}

	/**
	 * Footer widget opening div.
	 * 
	 * @since 3.3.0
	 * @param array $args div attributes.
	 * @return array.
	 */
	public function footer_widget_div_open( $args ) {
		$args['open']  = '<div %s>';
		$args['attrs'] = array( 'class' => 'footer-widget-area-inner site-info-inner' );
		return $args;
	}

	/**
	 * Footer widget closing div.
	 * 
	 * @since 3.3.0
	 * @param array $args div attributes.
	 * @return array.
	 */
	public function footer_widget_div_close( $args ) {
		$args['close'] = '</div>';
		return $args;
	}

	/**
	 * Footer widget inner class.
	 *
	 * @param array $args attributes.
	 * @since 3.3.0
	 * @return string.
	 */
	public function footer_widget_area_inner( $args ) {
		if ( Astra_Builder_Helper::apply_flex_based_css() ) {
			$args['class'] = $args['class'] . ' footer-widget-area-inner';
		}
		return $args;
	}

	/**
	 * Header widget inner class.
	 *
	 * @param array $args Attributes.
	 * @since 3.3.0
	 * @return string.
	 */
	public function header_widget_area_inner( $args ) {
		if ( Astra_Builder_Helper::apply_flex_based_css() ) {
			$args['class'] = $args['class'] . ' header-widget-area-inner';
		}
		return $args;
	}

	/**
	 * Footer widget opening div.
	 * 
	 * @since 3.3.0
	 * @param array $args div attributes.
	 * @return array.
	 */
	public function header_widget_div_open( $args ) {
		$args['open']  = '<div %s>';
		$args['attrs'] = array( 'class' => 'header-widget-area-inner site-info-inner' );
		return $args;   
	}

}

/**
 * Kicking this off by calling 'get_instance()' method
 */
new Astra_Markup();