PluginProbe
Qi Blocks / trunk
Qi Blocks vtrunk
1.5.3 1.5.2 1.5.1 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 All 45 releases
qi-blocks / helpers / helper.php

helper.php in Qi Blocks trunk, at helpers/helper.php

1,912 lines 59.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 // Exit if accessed directly.
5 exit;
6 }
7
8 if ( ! function_exists( 'qi_blocks_extend_block_categories' ) ) {
9 /**
10 * Function that extend default array of block categories
11 *
12 * @param array $block_categories - Array of block categories
13 *
14 * @return array
15 */
16 function qi_blocks_extend_block_categories( $block_categories ) {
17
18 return array_merge(
19 array(
20 array(
21 'slug' => 'qi-blocks',
22 'title' => esc_html__( 'Qi Blocks', 'qi-blocks' ),
23 ),
24 ),
25 $block_categories
26 );
27 }
28
29 if ( version_compare( get_bloginfo( 'version' ), '5.8', '>=' ) ) {
30 add_filter( 'block_categories_all', 'qi_blocks_extend_block_categories' );
31 } else {
32 add_filter( 'block_categories', 'qi_blocks_extend_block_categories' );
33 }
34 }
35
36 if ( ! function_exists( 'qi_blocks_get_ajax_status' ) ) {
37 /**
38 * Function that return status from ajax functions
39 *
40 * @param string $status - success or error
41 * @param string $message - ajax message value
42 * @param string|array $data - returned value
43 * @param string $redirect - url address
44 */
45 function qi_blocks_get_ajax_status( $status, $message, $data = null, $redirect = '' ) {
46 $response = array(
47 'status' => esc_attr( $status ),
48 'message' => esc_html( $message ),
49 'data' => $data,
50 'redirect' => ! empty( $redirect ) ? esc_url( $redirect ) : '',
51 );
52
53 $output = wp_json_encode( $response );
54
55 exit( $output ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
56 }
57 }
58
59 if ( ! function_exists( 'qi_blocks_is_installed' ) ) {
60 /**
61 * Function check is some plugin/theme is installed
62 *
63 * @param string $plugin name
64 *
65 * @return bool
66 */
67 function qi_blocks_is_installed( $plugin ) {
68 switch ( $plugin ) :
69 case 'premium':
70 return defined( 'QI_BLOCKS_PREMIUM_VERSION' );
71 case 'qi-templates':
72 return defined( 'QI_TEMPLATES_VERSION' );
73 case 'landing':
74 return defined( 'QI_BLOCKS_LANDING_VERSION' );
75 case 'woocommerce':
76 return class_exists( 'WooCommerce' );
77 case 'contact_form_7':
78 return defined( 'WPCF7_VERSION' );
79 case 'wp_forms':
80 return defined( 'WPFORMS_VERSION' );
81 case 'full_site_editing':
82 return get_theme_support( 'block-templates' );
83 case 'wpml':
84 return defined( 'ICL_SITEPRESS_VERSION' );
85 default:
86 return apply_filters( 'qi_blocks_is_plugin_installed', false, $plugin );
87
88 endswitch;
89 }
90 }
91
92 if ( ! function_exists( 'qi_blocks_execute_template_with_params' ) ) {
93 /**
94 * Loads module template part.
95 *
96 * @param string $template path to template that is going to be included
97 * @param array $params params that are passed to template
98 *
99 * @return string - template html
100 */
101 function qi_blocks_execute_template_with_params( $template, $params ) {
102 if ( ! empty( $template ) && file_exists( $template ) ) {
103 // Extract params so they could be used in template.
104 if ( is_array( $params ) && count( $params ) ) {
105 extract( $params, EXTR_SKIP ); // @codingStandardsIgnoreLine
106 }
107
108 ob_start();
109 include $template;
110 $html = ob_get_clean();
111
112 return $html;
113 } else {
114 return '';
115 }
116 }
117 }
118
119 if ( ! function_exists( 'qi_blocks_sanitize_module_template_part' ) ) {
120 /**
121 * Sanitize module template part.
122 *
123 * @param string $template temp path to file that is being loaded
124 *
125 * @return string - string with template path
126 */
127 function qi_blocks_sanitize_module_template_part( $template ) {
128 $available_characters = '/[^A-Za-z0-9\_\-\/]/';
129
130 if ( ! empty( $template ) && is_scalar( $template ) ) {
131 $template = preg_replace( $available_characters, '', $template );
132 } else {
133 $template = '';
134 }
135
136 return $template;
137 }
138 }
139
140 if ( ! function_exists( 'qi_blocks_get_template_with_slug' ) ) {
141 /**
142 * Loads module template part.
143 *
144 * @param string $temp temp path to file that is being loaded
145 * @param string $slug slug that should be checked if exists
146 *
147 * @return string - string with template path
148 */
149 function qi_blocks_get_template_with_slug( $temp, $slug ) {
150 $template = '';
151
152 if ( ! empty( $temp ) ) {
153 $slug = qi_blocks_sanitize_module_template_part( $slug );
154
155 if ( ! empty( $slug ) ) {
156 $template = "$temp-$slug.php";
157
158 if ( ! file_exists( $template ) ) {
159 $template = $temp . '.php';
160 }
161 } else {
162 $template = $temp . '.php';
163 }
164 }
165
166 return $template;
167 }
168 }
169
170 if ( ! function_exists( 'qi_blocks_get_template_part' ) ) {
171 /**
172 * Loads module template part.
173 *
174 * @param string $module name of the module from inc folder
175 * @param string $template full path of the template to load
176 * @param string $slug
177 * @param array $params array of parameters to pass to template
178 *
179 * @return string - string containing html of template
180 */
181 function qi_blocks_get_template_part( $module, $template, $slug = '', $params = array() ) {
182 $module = qi_blocks_sanitize_module_template_part( $module );
183 $template = qi_blocks_sanitize_module_template_part( $template );
184
185 $temp = QI_BLOCKS_INC_PATH . '/' . $module . '/' . $template;
186
187 $template = qi_blocks_get_template_with_slug( $temp, $slug );
188
189 return qi_blocks_execute_template_with_params( $template, $params );
190 }
191 }
192
193 if ( ! function_exists( 'qi_blocks_template_part' ) ) {
194 /**
195 * Echo module template part.
196 *
197 * @param string $module name of the module from inc folder
198 * @param string $template full path of the template to load
199 * @param string $slug
200 * @param array $params array of parameters to pass to template
201 */
202 function qi_blocks_template_part( $module, $template, $slug = '', $params = array() ) {
203 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
204 echo qi_blocks_get_template_part( $module, $template, $slug, $params );
205 }
206 }
207
208 if ( ! function_exists( 'qi_blocks_get_block_list_template_part' ) ) {
209 /**
210 * Echo module template part.
211 *
212 * @param string $module name of the module from inc folder
213 * @param string $template full path of the template to load
214 * @param string $slug
215 * @param array $params array of parameters to pass to template
216 *
217 * @return string - string containing html of template
218 */
219 function qi_blocks_get_block_list_template_part( $module, $template, $slug = '', $params = array() ) {
220 $temp_in_variation = false;
221 $module = qi_blocks_sanitize_module_template_part( $module );
222 $template = qi_blocks_sanitize_module_template_part( $template );
223 $slug = qi_blocks_sanitize_module_template_part( $slug );
224
225 /* In order to use this way of templating, option for list item layout must be called layoyt */
226 if ( isset( $params['layout'] ) ) {
227 /* Check if folder for variation exists */
228 $variation_path = apply_filters( 'qi_blocks_filter_block_list_layout_path', QI_BLOCKS_INC_PATH . '/' . $module . '/variations/' . $params['layout'], $params );
229 if ( file_exists( $variation_path ) ) {
230 /* Check if template file in variation folder exists */
231 $temp_file = qi_blocks_get_template_with_slug( $variation_path . '/' . $template, $slug );
232
233 if ( ! empty( $temp_file ) && file_exists( $temp_file ) ) {
234 $template = $temp_file;
235 $temp_in_variation = true;
236 }
237 }
238 }
239
240 /* Template doesn't exist in variation folder, use default one */
241 if ( ! $temp_in_variation ) {
242 $temp = QI_BLOCKS_INC_PATH . '/' . $module . '/templates/' . $template;
243 $template = qi_blocks_get_template_with_slug( $temp, $slug );
244 }
245
246 return qi_blocks_execute_template_with_params( $template, $params );
247 }
248 }
249
250 if ( ! function_exists( 'qi_blocks_class_attribute' ) ) {
251 /**
252 * Function that echoes class attribute
253 *
254 * @param string|array $value - value of class attribute
255 *
256 * @see qi_blocks_get_class_attribute()
257 */
258 function qi_blocks_class_attribute( $value ) {
259 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
260 echo qi_blocks_get_class_attribute( $value );
261 }
262 }
263
264 if ( ! function_exists( 'qi_blocks_get_class_attribute' ) ) {
265 /**
266 * Function that returns generated class attribute
267 *
268 * @param string|array $value - value of class attribute
269 *
270 * @return string generated class attribute
271 *
272 * @see qi_blocks_get_inline_attr()
273 */
274 function qi_blocks_get_class_attribute( $value ) {
275 return qi_blocks_get_inline_attr( $value, 'class', ' ' );
276 }
277 }
278
279 if ( ! function_exists( 'qi_blocks_id_attribute' ) ) {
280 /**
281 * Function that echoes id attribute
282 *
283 * @param string|array $value - value of id attribute
284 *
285 * @see qi_blocks_get_id_attribute()
286 */
287 function qi_blocks_id_attribute( $value ) {
288 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
289 echo qi_blocks_get_id_attribute( $value );
290 }
291 }
292
293 if ( ! function_exists( 'qi_blocks_get_id_attribute' ) ) {
294 /**
295 * Function that returns generated id attribute
296 *
297 * @param string|array $value - value of id attribute
298 *
299 * @return string generated id attribute
300 *
301 * @see qi_blocks_get_inline_attr()
302 */
303 function qi_blocks_get_id_attribute( $value ) {
304 return qi_blocks_get_inline_attr( $value, 'id', ' ' );
305 }
306 }
307
308 if ( ! function_exists( 'qi_blocks_inline_attrs' ) ) {
309 /**
310 * Echo multiple inline attributes
311 *
312 * @param array $attrs
313 * @param bool $allow_zero_values
314 */
315 function qi_blocks_inline_attrs( $attrs, $allow_zero_values = false ) {
316 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
317 echo qi_blocks_get_inline_attrs( $attrs, $allow_zero_values );
318 }
319 }
320
321 if ( ! function_exists( 'qi_blocks_get_inline_attrs' ) ) {
322 /**
323 * Generate multiple inline attributes
324 *
325 * @param array $attrs
326 * @param bool $allow_zero_values
327 *
328 * @return string
329 */
330 function qi_blocks_get_inline_attrs( $attrs, $allow_zero_values = false ) {
331 $output = '';
332 if ( is_array( $attrs ) && count( $attrs ) ) {
333 if ( $allow_zero_values ) {
334 foreach ( $attrs as $attr => $value ) {
335 $output .= ' ' . qi_blocks_get_inline_attr( $value, $attr, '', true );
336 }
337 } else {
338 foreach ( $attrs as $attr => $value ) {
339 $output .= ' ' . qi_blocks_get_inline_attr( $value, $attr );
340 }
341 }
342 }
343
344 $output = ltrim( $output );
345
346 return $output;
347 }
348 }
349
350 if ( ! function_exists( 'qi_blocks_get_inline_attr' ) ) {
351 /**
352 * Function that generates html attribute
353 *
354 * @param string|array $value value of html attribute
355 * @param string $attr - name of html attribute to generate
356 * @param string $glue - glue with which to implode $attr. Used only when $attr is arrayed
357 * @param bool $allow_zero_values - allow data to have zero value
358 *
359 * @return string generated html attribute
360 */
361 function qi_blocks_get_inline_attr( $value, $attr, $glue = '', $allow_zero_values = false ) {
362 $properties = '';
363
364 // Leave only allowed characters in attr.
365 preg_match( '/[-_a-z0-9]+/', $attr, $attr_matches );
366
367 $single_attr_key = $attr_matches[0];
368
369 // Concatenate values in one variable and check for zero values.
370 if ( $allow_zero_values ) {
371 if ( '' !== $value ) {
372
373 if ( is_array( $value ) && count( $value ) ) {
374 $properties = implode( $glue, $value );
375 } else {
376 $properties = $value;
377 }
378 }
379 } else {
380 if ( ! empty( $value ) ) {
381
382 if ( is_array( $value ) && count( $value ) ) {
383 $properties = implode( $glue, $value );
384 } elseif ( '' !== $value ) {
385 $properties = $value;
386 } else {
387 return '';
388 }
389 }
390 }
391
392 if ( empty( $properties ) || empty( $attr_matches[0] ) ) {
393 return '';
394 }
395
396 // Remove not allowed js events.
397 if ( 'on' === substr( $single_attr_key, 0, 2 ) || 'href' === $single_attr_key || 'on' === substr( $properties, 0, 2 ) || 'href' === $properties ) {
398 return '';
399 }
400
401 $sanitized_properties = esc_attr( sanitize_text_field( html_entity_decode( $properties ) ) );
402 $clean_properties = preg_replace( '/<[^>]*>|#x3[ce];|&lt;|&gt;/i', '', $sanitized_properties );
403
404 return $attr . '="' . $clean_properties . '"';
405 }
406 }
407
408 if ( ! function_exists( 'qi_blocks_get_query_params' ) ) {
409 /**
410 * Function that return query parameters
411 *
412 * @param array $atts - options value
413 *
414 * @return array
415 */
416 function qi_blocks_get_query_params( $atts ) {
417 $post_type = isset( $atts['post_type'] ) && ! empty( $atts['post_type'] ) ? $atts['post_type'] : 'post';
418 $posts_per_page = isset( $atts['postsPerPage'] ) && ! empty( $atts['postsPerPage'] ) ? $atts['postsPerPage'] : 9;
419
420 $args = array(
421 'post_status' => 'publish',
422 'post_type' => esc_attr( $post_type ),
423 'posts_per_page' => $posts_per_page,
424 'orderby' => esc_attr( $atts['orderBy'] ),
425 'order' => esc_attr( $atts['order'] ),
426 'ignore_sticky_posts' => 1,
427 );
428
429 if ( isset( $atts['next_page'] ) && ! empty( $atts['next_page'] ) ) {
430 $args['paged'] = intval( $atts['next_page'] );
431 } elseif ( ! empty( max( 1, get_query_var( 'paged' ) ) ) ) {
432 if ( is_front_page() ) {
433 $args['paged'] = max( 1, get_query_var( 'page' ) );
434 } else {
435 $args['paged'] = max( 1, get_query_var( 'paged' ) );
436 }
437 } else {
438 $args['paged'] = 1;
439 }
440
441 if ( isset( $atts['additional_query_args'] ) && ! empty( $atts['additional_query_args'] ) ) {
442 foreach ( $atts['additional_query_args'] as $key => $value ) {
443 $args[ esc_attr( $key ) ] = $value;
444 }
445 }
446
447 return apply_filters( 'qi_blocks_filter_query_params', $args, $atts );
448 }
449 }
450
451 if ( ! function_exists( 'qi_blocks_get_svg_icon_content' ) ) {
452 /**
453 * Function that return option value
454 *
455 * @param string $icon
456 *
457 * @return string
458 */
459 function qi_blocks_get_svg_icon_content( $icon ) {
460 return $icon;
461 }
462 }
463
464 if ( ! function_exists( 'qi_blocks_get_svg_icon' ) ) {
465 /**
466 * Returns svg html
467 *
468 * @param string $name - icon name
469 * @param string $class_name - custom html tag class name
470 *
471 * @return string - that contains html content
472 */
473 function qi_blocks_get_svg_icon( $name, $class_name = '' ) {
474 $html = '';
475 $class = isset( $class_name ) && ! empty( $class_name ) ? 'class="' . esc_attr( $class_name ) . '"' : '';
476
477 switch ( $name ) {
478 case 'menu':
479 $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="13" x="0px" y="0px" viewBox="0 0 21.3 13.7" xml:space="preserve" aria-hidden="true"><rect x="10.1" y="-9.1" transform="matrix(-1.836970e-16 1 -1 -1.836970e-16 11.5 -9.75)" width="1" height="20"/><rect x="10.1" y="-3.1" transform="matrix(-1.836970e-16 1 -1 -1.836970e-16 17.5 -3.75)" width="1" height="20"/><rect x="10.1" y="2.9" transform="matrix(-1.836970e-16 1 -1 -1.836970e-16 23.5 2.25)" width="1" height="20"/></svg>';
480 break;
481 case 'menu-arrow-right':
482 $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="6.2px" height="10.8px" viewBox="0 0 6.2 10.8" xml:space="preserve" aria-hidden="true"><g><path d="M5.9,5.9l-4.7,4.7c-0.3,0.3-0.7,0.3-1,0c-0.1-0.1-0.2-0.3-0.2-0.5c0-0.2,0.1-0.4,0.2-0.5l4.1-4.2L0.3,1.2c-0.4-0.3-0.4-0.7,0-1c0.3-0.3,0.7-0.3,1,0l4.7,4.7C6.1,5,6.2,5.2,6.2,5.4C6.2,5.6,6.1,5.8,5.9,5.9z"/></g></svg>';
483 break;
484 case 'close':
485 $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 9.1 9.1" xml:space="preserve"><g><path d="M8.5,0L9,0.6L5.1,4.5L9,8.5L8.5,9L4.5,5.1L0.6,9L0,8.5L4,4.5L0,0.6L0.6,0L4.5,4L8.5,0z"/></g></svg>';
486 break;
487 case 'search':
488 $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="18.7px" height="19px" viewBox="0 0 18.7 19" xml:space="preserve"><g><path d="M11.1,15.2c-4.2,0-7.6-3.4-7.6-7.6S6.9,0,11.1,0s7.6,3.4,7.6,7.6S15.3,15.2,11.1,15.2z M11.1,1.4c-3.4,0-6.2,2.8-6.2,6.2s2.8,6.2,6.2,6.2s6.2-2.8,6.2-6.2S14.5,1.4,11.1,1.4z"/></g><g><rect x="-0.7" y="14.8" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -9.9871 6.9931)" width="8.3" height="1.4"/></g></svg>';
489 break;
490 case 'icon-arrow-left':
491 $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 34.2 32.3" xml:space="preserve" style="stroke-width: 2;"><line x1="0.5" y1="16" x2="33.5" y2="16"/><line x1="0.3" y1="16.5" x2="16.2" y2="0.7"/><line x1="0" y1="15.4" x2="16.2" y2="31.6"/></svg>';
492 break;
493 case 'icon-arrow-right':
494 $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 34.2 32.3" xml:space="preserve" style="stroke-width: 2;"><line x1="0" y1="16" x2="33" y2="16"/><line x1="17.3" y1="0.7" x2="33.2" y2="16.5"/><line x1="17.3" y1="31.6" x2="33.5" y2="15.4"/></svg>';
495 break;
496 case 'button-arrow':
497 $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="6.7px" height="11.4px" viewBox="0 0 6.7 11.4" xml:space="preserve"><path d="M6.4,5L1.7,0.3c-0.4-0.4-1-0.4-1.3,0C0.1,0.5,0,0.7,0,1s0.1,0.5,0.4,0.7l3.8,4l-3.9,4C0.1,9.8,0,10.1,0,10.4 c0,0.3,0.1,0.5,0.3,0.7c0.2,0.2,0.4,0.3,0.7,0.3c0,0,0,0,0,0c0.2,0,0.5-0.1,0.7-0.3l4.7-4.7C6.5,6.2,6.7,6,6.7,5.7 C6.7,5.4,6.6,5.1,6.4,5z"></path></svg>';
498 break;
499 case 'comment-reply':
500 $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="18.7px" height="11.6px" viewBox="0 0 18.7 11.6" xml:space="preserve"><g><path d="M0.3,4.6l4.3-4.3c0.3-0.4,0.7-0.4,1,0c0.3,0.3,0.3,0.7,0,1L2.5,4.4H13c2,0,3.4,0.6,4.4,1.9c0.9,1.3,1.4,2.8,1.4,4.6c0,0.2-0.1,0.4-0.2,0.5s-0.3,0.2-0.5,0.2c-0.2,0-0.4-0.1-0.5-0.2s-0.2-0.3-0.2-0.5c0-1.3-0.4-2.5-1.1-3.5c-0.8-1-1.8-1.5-3.2-1.5H2.5l3.1,3.1c0.4,0.3,0.4,0.7,0,1c-0.3,0.3-0.7,0.3-1,0L0.3,5.6C-0.1,5.2-0.1,4.9,0.3,4.6z"/></g></svg>';
501 break;
502 case 'comment-edit':
503 $html = '<svg ' . $class . ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="18px" height="18px" viewBox="0 0 18 18" xml:space="preserve"><g><path d="M2.5,0.4l1.5,1.5l-2,2L0.4,2.5C0.1,2.2,0,1.8,0,1.4c0-0.4,0.1-0.7,0.4-1S1,0,1.4,0C1.8,0,2.2,0.1,2.5,0.4z M8.9,10.9L3.1,5.1l2-2l5.8,5.8l1,3L8.9,10.9z M17.7,3.7C17.9,3.9,18,4.2,18,4.5v12.4c0,0.3-0.1,0.6-0.3,0.8c-0.2,0.2-0.5,0.3-0.8,0.3H4.5c-0.3,0-0.6-0.1-0.8-0.3c-0.2-0.2-0.3-0.5-0.3-0.8v-8L4.5,10v6.9h12.4V4.5H10L8.9,3.4h8C17.2,3.4,17.4,3.5,17.7,3.7z"/></g></svg>';
504 break;
505 }
506
507 return apply_filters( 'qi_blocks_filter_svg_icon', $html, $name, $class_name );
508 }
509 }
510
511 if ( ! function_exists( 'qi_blocks_get_block_option_typography_attributes' ) ) {
512 /**
513 * Function that return block option typography attributes
514 *
515 * @param string $option_name
516 *
517 * @return array
518 */
519 function qi_blocks_get_block_option_typography_attributes( $option_name ) {
520
521 if ( empty( $option_name ) ) {
522 return array();
523 }
524
525 return array(
526 esc_attr( $option_name ) . 'FontFamily' => array(
527 'type' => 'string',
528 'default' => '',
529 ),
530 esc_attr( $option_name ) . 'FontSize' => array(
531 'type' => 'number',
532 'default' => '',
533 ),
534 esc_attr( $option_name ) . 'FontSizeUnit' => array(
535 'type' => 'string',
536 'default' => 'px',
537 ),
538 esc_attr( $option_name ) . 'FontSizeDecimal' => array(
539 'type' => 'number',
540 'default' => '',
541 ),
542 esc_attr( $option_name ) . 'FontSizeTablet' => array(
543 'type' => 'number',
544 'default' => '',
545 ),
546 esc_attr( $option_name ) . 'FontSizeMobile' => array(
547 'type' => 'number',
548 'default' => '',
549 ),
550 esc_attr( $option_name ) . 'FontSizeUnitTablet' => array(
551 'type' => 'string',
552 'default' => 'px',
553 ),
554 esc_attr( $option_name ) . 'FontSizeUnitMobile' => array(
555 'type' => 'string',
556 'default' => 'px',
557 ),
558 esc_attr( $option_name ) . 'FontSizeDecimalTablet' => array(
559 'type' => 'number',
560 'default' => '',
561 ),
562 esc_attr( $option_name ) . 'FontSizeDecimalMobile' => array(
563 'type' => 'number',
564 'default' => '',
565 ),
566 esc_attr( $option_name ) . 'FontWeight' => array(
567 'type' => 'string',
568 'default' => '',
569 ),
570 esc_attr( $option_name ) . 'TextTransform' => array(
571 'type' => 'string',
572 'default' => '',
573 ),
574 esc_attr( $option_name ) . 'FontStyle' => array(
575 'type' => 'string',
576 'default' => '',
577 ),
578 esc_attr( $option_name ) . 'TextDecoration' => array(
579 'type' => 'string',
580 'default' => '',
581 ),
582 esc_attr( $option_name ) . 'LineHeight' => array(
583 'type' => 'number',
584 'default' => '',
585 ),
586 esc_attr( $option_name ) . 'LineHeightUnit' => array(
587 'type' => 'string',
588 'default' => 'px',
589 ),
590 esc_attr( $option_name ) . 'LineHeightDecimal' => array(
591 'type' => 'number',
592 'default' => '',
593 ),
594 esc_attr( $option_name ) . 'LineHeightTablet' => array(
595 'type' => 'number',
596 'default' => '',
597 ),
598 esc_attr( $option_name ) . 'LineHeightMobile' => array(
599 'type' => 'number',
600 'default' => '',
601 ),
602 esc_attr( $option_name ) . 'LineHeightUnitTablet' => array(
603 'type' => 'string',
604 'default' => 'px',
605 ),
606 esc_attr( $option_name ) . 'LineHeightUnitMobile' => array(
607 'type' => 'string',
608 'default' => 'px',
609 ),
610 esc_attr( $option_name ) . 'LineHeightDecimalTablet' => array(
611 'type' => 'number',
612 'default' => '',
613 ),
614 esc_attr( $option_name ) . 'LineHeightDecimalMobile' => array(
615 'type' => 'number',
616 'default' => '',
617 ),
618 esc_attr( $option_name ) . 'LetterSpacing' => array(
619 'type' => 'number',
620 'default' => '',
621 ),
622 esc_attr( $option_name ) . 'LetterSpacingUnit' => array(
623 'type' => 'string',
624 'default' => 'px',
625 ),
626 esc_attr( $option_name ) . 'LetterSpacingDecimal' => array(
627 'type' => 'number',
628 'default' => '',
629 ),
630 esc_attr( $option_name ) . 'LetterSpacingTablet' => array(
631 'type' => 'number',
632 'default' => '',
633 ),
634 esc_attr( $option_name ) . 'LetterSpacingMobile' => array(
635 'type' => 'number',
636 'default' => '',
637 ),
638 esc_attr( $option_name ) . 'LetterSpacingUnitTablet' => array(
639 'type' => 'string',
640 'default' => 'px',
641 ),
642 esc_attr( $option_name ) . 'LetterSpacingUnitMobile' => array(
643 'type' => 'string',
644 'default' => 'px',
645 ),
646 esc_attr( $option_name ) . 'LetterSpacingDecimalTablet' => array(
647 'type' => 'number',
648 'default' => '',
649 ),
650 esc_attr( $option_name ) . 'LetterSpacingDecimalMobile' => array(
651 'type' => 'number',
652 'default' => '',
653 ),
654 );
655 }
656 }
657
658 if ( ! function_exists( 'qi_blocks_get_block_container_attributes' ) ) {
659 /**
660 * Function that return block element container attributes
661 *
662 * @return array
663 */
664 function qi_blocks_get_block_container_attributes() {
665 return array(
666 'marginTop' => array(
667 'type' => 'number',
668 'default' => '',
669 ),
670 'marginTopTablet' => array(
671 'type' => 'number',
672 'default' => '',
673 ),
674 'marginTopMobile' => array(
675 'type' => 'number',
676 'default' => '',
677 ),
678 'marginTopDecimal' => array(
679 'type' => 'number',
680 'default' => '',
681 ),
682 'marginTopDecimalTablet' => array(
683 'type' => 'number',
684 'default' => '',
685 ),
686 'marginTopDecimalMobile' => array(
687 'type' => 'number',
688 'default' => '',
689 ),
690 'marginRight' => array(
691 'type' => 'number',
692 'default' => '',
693 ),
694 'marginRightTablet' => array(
695 'type' => 'number',
696 'default' => '',
697 ),
698 'marginRightMobile' => array(
699 'type' => 'number',
700 'default' => '',
701 ),
702 'marginRightDecimal' => array(
703 'type' => 'number',
704 'default' => '',
705 ),
706 'marginRightDecimalTablet' => array(
707 'type' => 'number',
708 'default' => '',
709 ),
710 'marginRightDecimalMobile' => array(
711 'type' => 'number',
712 'default' => '',
713 ),
714 'marginBottom' => array(
715 'type' => 'number',
716 'default' => '',
717 ),
718 'marginBottomTablet' => array(
719 'type' => 'number',
720 'default' => '',
721 ),
722 'marginBottomMobile' => array(
723 'type' => 'number',
724 'default' => '',
725 ),
726 'marginBottomDecimal' => array(
727 'type' => 'number',
728 'default' => '',
729 ),
730 'marginBottomDecimalTablet' => array(
731 'type' => 'number',
732 'default' => '',
733 ),
734 'marginBottomDecimalMobile' => array(
735 'type' => 'number',
736 'default' => '',
737 ),
738 'marginLeft' => array(
739 'type' => 'number',
740 'default' => '',
741 ),
742 'marginLeftTablet' => array(
743 'type' => 'number',
744 'default' => '',
745 ),
746 'marginLeftMobile' => array(
747 'type' => 'number',
748 'default' => '',
749 ),
750 'marginLeftDecimal' => array(
751 'type' => 'number',
752 'default' => '',
753 ),
754 'marginLeftDecimalTablet' => array(
755 'type' => 'number',
756 'default' => '',
757 ),
758 'marginLeftDecimalMobile' => array(
759 'type' => 'number',
760 'default' => '',
761 ),
762 'marginUnit' => array(
763 'type' => 'string',
764 'default' => 'px',
765 ),
766 'marginUnitTablet' => array(
767 'type' => 'string',
768 'default' => 'px',
769 ),
770 'marginUnitMobile' => array(
771 'type' => 'string',
772 'default' => 'px',
773 ),
774 'paddingTop' => array(
775 'type' => 'number',
776 'default' => '',
777 ),
778 'paddingTopTablet' => array(
779 'type' => 'number',
780 'default' => '',
781 ),
782 'paddingTopMobile' => array(
783 'type' => 'number',
784 'default' => '',
785 ),
786 'paddingTopDecimal' => array(
787 'type' => 'number',
788 'default' => '',
789 ),
790 'paddingTopDecimalTablet' => array(
791 'type' => 'number',
792 'default' => '',
793 ),
794 'paddingTopDecimalMobile' => array(
795 'type' => 'number',
796 'default' => '',
797 ),
798 'paddingRight' => array(
799 'type' => 'number',
800 'default' => '',
801 ),
802 'paddingRightTablet' => array(
803 'type' => 'number',
804 'default' => '',
805 ),
806 'paddingRightMobile' => array(
807 'type' => 'number',
808 'default' => '',
809 ),
810 'paddingRightDecimal' => array(
811 'type' => 'number',
812 'default' => '',
813 ),
814 'paddingRightDecimalTablet' => array(
815 'type' => 'number',
816 'default' => '',
817 ),
818 'paddingRightDecimalMobile' => array(
819 'type' => 'number',
820 'default' => '',
821 ),
822 'paddingBottom' => array(
823 'type' => 'number',
824 'default' => '',
825 ),
826 'paddingBottomTablet' => array(
827 'type' => 'number',
828 'default' => '',
829 ),
830 'paddingBottomMobile' => array(
831 'type' => 'number',
832 'default' => '',
833 ),
834 'paddingBottomDecimal' => array(
835 'type' => 'number',
836 'default' => '',
837 ),
838 'paddingBottomDecimalTablet' => array(
839 'type' => 'number',
840 'default' => '',
841 ),
842 'paddingBottomDecimalMobile' => array(
843 'type' => 'number',
844 'default' => '',
845 ),
846 'paddingLeft' => array(
847 'type' => 'number',
848 'default' => '',
849 ),
850 'paddingLeftTablet' => array(
851 'type' => 'number',
852 'default' => '',
853 ),
854 'paddingLeftMobile' => array(
855 'type' => 'number',
856 'default' => '',
857 ),
858 'paddingLeftDecimal' => array(
859 'type' => 'number',
860 'default' => '',
861 ),
862 'paddingLeftDecimalTablet' => array(
863 'type' => 'number',
864 'default' => '',
865 ),
866 'paddingLeftDecimalMobile' => array(
867 'type' => 'number',
868 'default' => '',
869 ),
870 'paddingUnit' => array(
871 'type' => 'string',
872 'default' => 'px',
873 ),
874 'paddingUnitTablet' => array(
875 'type' => 'string',
876 'default' => 'px',
877 ),
878 'paddingUnitMobile' => array(
879 'type' => 'string',
880 'default' => 'px',
881 ),
882 'zIndex' => array(
883 'type' => 'number',
884 'default' => '',
885 ),
886 'cssId' => array(
887 'type' => 'string',
888 'default' => '',
889 ),
890 'cssClasses' => array(
891 'type' => 'string',
892 'default' => '',
893 ),
894 'entranceAnimation' => array(
895 'type' => 'string',
896 'default' => '',
897 ),
898 'entranceAnimationDuration' => array(
899 'type' => 'string',
900 'default' => 'normal',
901 ),
902 'entranceAnimationDelay' => array(
903 'type' => 'number',
904 'default' => '',
905 ),
906 'advancedBackgroundType' => array(
907 'type' => 'string',
908 'default' => '',
909 ),
910 'advancedBackgroundColor' => array(
911 'type' => 'string',
912 'default' => '',
913 ),
914 'advancedBackgroundImage' => array(
915 'type' => 'object',
916 'default' => array(
917 'id' => null,
918 'url' => '',
919 'alt' => '',
920 ),
921 ),
922 'advancedBackgroundImageTablet' => array(
923 'type' => 'object',
924 'default' => array(
925 'id' => null,
926 'url' => '',
927 'alt' => '',
928 ),
929 ),
930 'advancedBackgroundImageMobile' => array(
931 'type' => 'object',
932 'default' => array(
933 'id' => null,
934 'url' => '',
935 'alt' => '',
936 ),
937 ),
938 'advancedBackgroundPosition' => array(
939 'type' => 'string',
940 'default' => '',
941 ),
942 'advancedBackgroundPositionTablet' => array(
943 'type' => 'string',
944 'default' => '',
945 ),
946 'advancedBackgroundPositionMobile' => array(
947 'type' => 'string',
948 'default' => '',
949 ),
950 'advancedBackgroundXPosition' => array(
951 'type' => 'number',
952 'default' => '',
953 ),
954 'advancedBackgroundXPositionUnit' => array(
955 'type' => 'string',
956 'default' => 'px',
957 ),
958 'advancedBackgroundXPositionDecimal' => array(
959 'type' => 'number',
960 'default' => '',
961 ),
962 'advancedBackgroundXPositionTablet' => array(
963 'type' => 'number',
964 'default' => '',
965 ),
966 'advancedBackgroundXPositionMobile' => array(
967 'type' => 'number',
968 'default' => '',
969 ),
970 'advancedBackgroundXPositionUnitTablet' => array(
971 'type' => 'string',
972 'default' => 'px',
973 ),
974 'advancedBackgroundXPositionUnitMobile' => array(
975 'type' => 'string',
976 'default' => 'px',
977 ),
978 'advancedBackgroundXPositionDecimalTablet' => array(
979 'type' => 'number',
980 'default' => '',
981 ),
982 'advancedBackgroundXPositionDecimalMobile' => array(
983 'type' => 'number',
984 'default' => '',
985 ),
986 'advancedBackgroundYPosition' => array(
987 'type' => 'number',
988 'default' => '',
989 ),
990 'advancedBackgroundYPositionUnit' => array(
991 'type' => 'string',
992 'default' => 'px',
993 ),
994 'advancedBackgroundYPositionDecimal' => array(
995 'type' => 'number',
996 'default' => '',
997 ),
998 'advancedBackgroundYPositionTablet' => array(
999 'type' => 'number',
1000 'default' => '',
1001 ),
1002 'advancedBackgroundYPositionMobile' => array(
1003 'type' => 'number',
1004 'default' => '',
1005 ),
1006 'advancedBackgroundYPositionUnitTablet' => array(
1007 'type' => 'string',
1008 'default' => 'px',
1009 ),
1010 'advancedBackgroundYPositionUnitMobile' => array(
1011 'type' => 'string',
1012 'default' => 'px',
1013 ),
1014 'advancedBackgroundYPositionDecimalTablet' => array(
1015 'type' => 'number',
1016 'default' => '',
1017 ),
1018 'advancedBackgroundYPositionDecimalMobile' => array(
1019 'type' => 'number',
1020 'default' => '',
1021 ),
1022 'advancedBackgroundAttachment' => array(
1023 'type' => 'string',
1024 'default' => '',
1025 ),
1026 'advancedBackgroundRepeat' => array(
1027 'type' => 'string',
1028 'default' => '',
1029 ),
1030 'advancedBackgroundRepeatTablet' => array(
1031 'type' => 'string',
1032 'default' => '',
1033 ),
1034 'advancedBackgroundRepeatMobile' => array(
1035 'type' => 'string',
1036 'default' => '',
1037 ),
1038 'advancedBackgroundSize' => array(
1039 'type' => 'string',
1040 'default' => '',
1041 ),
1042 'advancedBackgroundSizeTablet' => array(
1043 'type' => 'string',
1044 'default' => '',
1045 ),
1046 'advancedBackgroundSizeMobile' => array(
1047 'type' => 'string',
1048 'default' => '',
1049 ),
1050 'advancedBackgroundSizeWidth' => array(
1051 'type' => 'number',
1052 'default' => '',
1053 ),
1054 'advancedBackgroundSizeWidthUnit' => array(
1055 'type' => 'string',
1056 'default' => 'px',
1057 ),
1058 'advancedBackgroundSizeWidthDecimal' => array(
1059 'type' => 'number',
1060 'default' => '',
1061 ),
1062 'advancedBackgroundSizeWidthTablet' => array(
1063 'type' => 'number',
1064 'default' => '',
1065 ),
1066 'advancedBackgroundSizeWidthMobile' => array(
1067 'type' => 'number',
1068 'default' => '',
1069 ),
1070 'advancedBackgroundSizeWidthUnitTablet' => array(
1071 'type' => 'string',
1072 'default' => 'px',
1073 ),
1074 'advancedBackgroundSizeWidthUnitMobile' => array(
1075 'type' => 'string',
1076 'default' => 'px',
1077 ),
1078 'advancedBackgroundSizeWidthDecimalTablet' => array(
1079 'type' => 'number',
1080 'default' => '',
1081 ),
1082 'advancedBackgroundSizeWidthDecimalMobile' => array(
1083 'type' => 'number',
1084 'default' => '',
1085 ),
1086 'advancedBackgroundGradientColor1' => array(
1087 'type' => 'string',
1088 'default' => '',
1089 ),
1090 'advancedBackgroundGradientLocation1' => array(
1091 'type' => 'number',
1092 'default' => '',
1093 ),
1094 'advancedBackgroundGradientColor2' => array(
1095 'type' => 'string',
1096 'default' => '',
1097 ),
1098 'advancedBackgroundGradientLocation2' => array(
1099 'type' => 'number',
1100 'default' => '',
1101 ),
1102 'advancedBackgroundGradientType' => array(
1103 'type' => 'string',
1104 'default' => 'linear',
1105 ),
1106 'advancedBackgroundGradientTypeAngle' => array(
1107 'type' => 'number',
1108 'default' => '',
1109 ),
1110 'advancedBackgroundGradientTypePosition' => array(
1111 'type' => 'string',
1112 'default' => 'center center',
1113 ),
1114 'advancedBorderStyle' => array(
1115 'type' => 'string',
1116 'default' => '',
1117 ),
1118 'advancedBorderColor' => array(
1119 'type' => 'string',
1120 'default' => '',
1121 ),
1122 'advancedBorderWidthTop' => array(
1123 'type' => 'number',
1124 'default' => '',
1125 ),
1126 'advancedBorderWidthTopTablet' => array(
1127 'type' => 'number',
1128 'default' => '',
1129 ),
1130 'advancedBorderWidthTopMobile' => array(
1131 'type' => 'number',
1132 'default' => '',
1133 ),
1134 'advancedBorderWidthRight' => array(
1135 'type' => 'number',
1136 'default' => '',
1137 ),
1138 'advancedBorderWidthRightTablet' => array(
1139 'type' => 'number',
1140 'default' => '',
1141 ),
1142 'advancedBorderWidthRightMobile' => array(
1143 'type' => 'number',
1144 'default' => '',
1145 ),
1146 'advancedBorderWidthBottom' => array(
1147 'type' => 'number',
1148 'default' => '',
1149 ),
1150 'advancedBorderWidthBottomTablet' => array(
1151 'type' => 'number',
1152 'default' => '',
1153 ),
1154 'advancedBorderWidthBottomMobile' => array(
1155 'type' => 'number',
1156 'default' => '',
1157 ),
1158 'advancedBorderWidthLeft' => array(
1159 'type' => 'number',
1160 'default' => '',
1161 ),
1162 'advancedBorderWidthLeftTablet' => array(
1163 'type' => 'number',
1164 'default' => '',
1165 ),
1166 'advancedBorderWidthLeftMobile' => array(
1167 'type' => 'number',
1168 'default' => '',
1169 ),
1170 'advancedBorderWidthUnit' => array(
1171 'type' => 'string',
1172 'default' => 'px',
1173 ),
1174 'advancedBorderWidthUnitTablet' => array(
1175 'type' => 'string',
1176 'default' => 'px',
1177 ),
1178 'advancedBorderWidthUnitMobile' => array(
1179 'type' => 'string',
1180 'default' => 'px',
1181 ),
1182 'advancedBorderRadiusTop' => array(
1183 'type' => 'number',
1184 'default' => '',
1185 ),
1186 'advancedBorderRadiusTopTablet' => array(
1187 'type' => 'number',
1188 'default' => '',
1189 ),
1190 'advancedBorderRadiusTopMobile' => array(
1191 'type' => 'number',
1192 'default' => '',
1193 ),
1194 'advancedBorderRadiusTopDecimal' => array(
1195 'type' => 'number',
1196 'default' => '',
1197 ),
1198 'advancedBorderRadiusTopDecimalTablet' => array(
1199 'type' => 'number',
1200 'default' => '',
1201 ),
1202 'advancedBorderRadiusTopDecimalMobile' => array(
1203 'type' => 'number',
1204 'default' => '',
1205 ),
1206 'advancedBorderRadiusRight' => array(
1207 'type' => 'number',
1208 'default' => '',
1209 ),
1210 'advancedBorderRadiusRightTablet' => array(
1211 'type' => 'number',
1212 'default' => '',
1213 ),
1214 'advancedBorderRadiusRightMobile' => array(
1215 'type' => 'number',
1216 'default' => '',
1217 ),
1218 'advancedBorderRadiusRightDecimal' => array(
1219 'type' => 'number',
1220 'default' => '',
1221 ),
1222 'advancedBorderRadiusRightDecimalTablet' => array(
1223 'type' => 'number',
1224 'default' => '',
1225 ),
1226 'advancedBorderRadiusRightDecimalMobile' => array(
1227 'type' => 'number',
1228 'default' => '',
1229 ),
1230 'advancedBorderRadiusBottom' => array(
1231 'type' => 'number',
1232 'default' => '',
1233 ),
1234 'advancedBorderRadiusBottomTablet' => array(
1235 'type' => 'number',
1236 'default' => '',
1237 ),
1238 'advancedBorderRadiusBottomMobile' => array(
1239 'type' => 'number',
1240 'default' => '',
1241 ),
1242 'advancedBorderRadiusBottomDecimal' => array(
1243 'type' => 'number',
1244 'default' => '',
1245 ),
1246 'advancedBorderRadiusBottomDecimalTablet' => array(
1247 'type' => 'number',
1248 'default' => '',
1249 ),
1250 'advancedBorderRadiusBottomDecimalMobile' => array(
1251 'type' => 'number',
1252 'default' => '',
1253 ),
1254 'advancedBorderRadiusLeft' => array(
1255 'type' => 'number',
1256 'default' => '',
1257 ),
1258 'advancedBorderRadiusLeftTablet' => array(
1259 'type' => 'number',
1260 'default' => '',
1261 ),
1262 'advancedBorderRadiusLeftMobile' => array(
1263 'type' => 'number',
1264 'default' => '',
1265 ),
1266 'advancedBorderRadiusLeftDecimal' => array(
1267 'type' => 'number',
1268 'default' => '',
1269 ),
1270 'advancedBorderRadiusLeftDecimalTablet' => array(
1271 'type' => 'number',
1272 'default' => '',
1273 ),
1274 'advancedBorderRadiusLeftDecimalMobile' => array(
1275 'type' => 'number',
1276 'default' => '',
1277 ),
1278 'advancedBorderRadiusUnit' => array(
1279 'type' => 'string',
1280 'default' => 'px',
1281 ),
1282 'advancedBorderRadiusUnitTablet' => array(
1283 'type' => 'string',
1284 'default' => 'px',
1285 ),
1286 'advancedBorderRadiusUnitMobile' => array(
1287 'type' => 'string',
1288 'default' => 'px',
1289 ),
1290 'advancedBoxShadowColor' => array(
1291 'type' => 'string',
1292 'default' => '',
1293 ),
1294 'advancedBoxShadowHorizontal' => array(
1295 'type' => 'number',
1296 'default' => '',
1297 ),
1298 'advancedBoxShadowVertical' => array(
1299 'type' => 'number',
1300 'default' => '',
1301 ),
1302 'advancedBoxShadowBlur' => array(
1303 'type' => 'number',
1304 'default' => '',
1305 ),
1306 'advancedBoxShadowSpread' => array(
1307 'type' => 'number',
1308 'default' => '',
1309 ),
1310 'advancedBoxShadowPosition' => array(
1311 'type' => 'string',
1312 'default' => '',
1313 ),
1314 'blockWidth' => array(
1315 'type' => 'string',
1316 'default' => '',
1317 ),
1318 'blockWidthTablet' => array(
1319 'type' => 'string',
1320 'default' => '',
1321 ),
1322 'blockWidthMobile' => array(
1323 'type' => 'string',
1324 'default' => '',
1325 ),
1326 'blockCustomWidth' => array(
1327 'type' => 'number',
1328 'default' => '',
1329 ),
1330 'blockCustomWidthUnit' => array(
1331 'type' => 'string',
1332 'default' => 'px',
1333 ),
1334 'blockCustomWidthDecimal' => array(
1335 'type' => 'number',
1336 'default' => '',
1337 ),
1338 'blockCustomWidthTablet' => array(
1339 'type' => 'number',
1340 'default' => '',
1341 ),
1342 'blockCustomWidthMobile' => array(
1343 'type' => 'number',
1344 'default' => '',
1345 ),
1346 'blockCustomWidthUnitTablet' => array(
1347 'type' => 'string',
1348 'default' => 'px',
1349 ),
1350 'blockCustomWidthUnitMobile' => array(
1351 'type' => 'string',
1352 'default' => 'px',
1353 ),
1354 'blockCustomWidthDecimalTablet' => array(
1355 'type' => 'number',
1356 'default' => '',
1357 ),
1358 'blockCustomWidthDecimalMobile' => array(
1359 'type' => 'number',
1360 'default' => '',
1361 ),
1362 'blockPosition' => array(
1363 'type' => 'string',
1364 'default' => '',
1365 ),
1366 'positionHorizontalOrientation' => array(
1367 'type' => 'string',
1368 'default' => 'left',
1369 ),
1370 'positionHorizontalOffset' => array(
1371 'type' => 'number',
1372 'default' => '',
1373 ),
1374 'positionHorizontalOffsetUnit' => array(
1375 'type' => 'string',
1376 'default' => 'px',
1377 ),
1378 'positionHorizontalOffsetDecimal' => array(
1379 'type' => 'number',
1380 'default' => '',
1381 ),
1382 'positionHorizontalOffsetTablet' => array(
1383 'type' => 'number',
1384 'default' => '',
1385 ),
1386 'positionHorizontalOffsetMobile' => array(
1387 'type' => 'number',
1388 'default' => '',
1389 ),
1390 'positionHorizontalOffsetUnitTablet' => array(
1391 'type' => 'string',
1392 'default' => 'px',
1393 ),
1394 'positionHorizontalOffsetUnitMobile' => array(
1395 'type' => 'string',
1396 'default' => 'px',
1397 ),
1398 'positionHorizontalOffsetDecimalTablet' => array(
1399 'type' => 'number',
1400 'default' => '',
1401 ),
1402 'positionHorizontalOffsetDecimalMobile' => array(
1403 'type' => 'number',
1404 'default' => '',
1405 ),
1406 'positionVerticalOrientation' => array(
1407 'type' => 'string',
1408 'default' => 'top',
1409 ),
1410 'positionVerticalOffset' => array(
1411 'type' => 'number',
1412 'default' => '',
1413 ),
1414 'positionVerticalOffsetUnit' => array(
1415 'type' => 'string',
1416 'default' => 'px',
1417 ),
1418 'positionVerticalOffsetDecimal' => array(
1419 'type' => 'number',
1420 'default' => '',
1421 ),
1422 'positionVerticalOffsetTablet' => array(
1423 'type' => 'number',
1424 'default' => '',
1425 ),
1426 'positionVerticalOffsetMobile' => array(
1427 'type' => 'number',
1428 'default' => '',
1429 ),
1430 'positionVerticalOffsetUnitTablet' => array(
1431 'type' => 'string',
1432 'default' => 'px',
1433 ),
1434 'positionVerticalOffsetUnitMobile' => array(
1435 'type' => 'string',
1436 'default' => 'px',
1437 ),
1438 'positionVerticalOffsetDecimalTablet' => array(
1439 'type' => 'number',
1440 'default' => '',
1441 ),
1442 'positionVerticalOffsetDecimalMobile' => array(
1443 'type' => 'number',
1444 'default' => '',
1445 ),
1446 'hideOnDesktop' => array(
1447 'type' => 'boolean',
1448 'default' => false,
1449 ),
1450 'hideOnTablet' => array(
1451 'type' => 'boolean',
1452 'default' => false,
1453 ),
1454 'hideOnMobile' => array(
1455 'type' => 'boolean',
1456 'default' => false,
1457 ),
1458 );
1459 }
1460 }
1461
1462 if ( ! function_exists( 'qi_blocks_get_block_container_html_attributes_string' ) ) {
1463 /**
1464 * Function that return block element container html attributes
1465 *
1466 * @param array $attributes - options value
1467 *
1468 * @return string
1469 */
1470 function qi_blocks_get_block_container_html_attributes_string( $attributes ) {
1471 $container_ids = ! empty( $attributes['blockContainerIds'] ) ? $attributes['blockContainerIds'] : '';
1472 $container_classes = ! empty( $attributes['blockContainerClasses'] ) ? $attributes['blockContainerClasses'] : '';
1473 $container_data = isset( $attributes['blockContainerData'] ) && ! empty( $attributes['blockContainerData'] ) ? json_decode( $attributes['blockContainerData'], true ) : '';
1474
1475 $animation = ! empty( $container_data ) && isset( $container_data['data-animation'] ) ? sanitize_text_field( $container_data['data-animation'] ) : '';
1476
1477 $html_attributes = qi_blocks_get_id_attribute( $container_ids );
1478 $html_attributes .= ' ' . qi_blocks_get_class_attribute( $container_classes );
1479 $html_attributes .= ' ' . qi_blocks_get_inline_attr( $animation, 'data-animation' );
1480
1481 return $html_attributes;
1482 }
1483 }
1484
1485 if ( ! function_exists( 'qi_blocks_get_block_holder_classes' ) ) {
1486 /**
1487 * Function that return block element classes
1488 *
1489 * @param string $block_name
1490 * @param array $attributes - options value
1491 * @param string $additional_class
1492 *
1493 * @return array
1494 */
1495 function qi_blocks_get_block_holder_classes( $block_name, $attributes, $additional_class = '' ) {
1496 $classes = array();
1497
1498 if ( ! empty( $block_name ) ) {
1499 $classes[] = 'qi-block-' . esc_attr( $block_name );
1500 $classes[] = 'qodef-block';
1501 $classes[] = 'qodef-m';
1502 $classes[] = 'wp-block-qi-blocks-' . esc_attr( $block_name );
1503
1504 if ( isset( $attributes['className'] ) && ! empty( $attributes['className'] ) ) {
1505 $classes[] = esc_attr( $attributes['className'] );
1506 }
1507
1508 if ( ! empty( $additional_class ) ) {
1509 $classes[] = esc_attr( $additional_class );
1510 }
1511 }
1512
1513 return $classes;
1514 }
1515 }
1516
1517 if ( ! function_exists( 'qi_blocks_get_slider_classes' ) ) {
1518 /**
1519 * Function that return element slider classes
1520 *
1521 * @param array $atts - options value
1522 *
1523 * @return string
1524 */
1525 function qi_blocks_get_slider_classes( $atts ) {
1526 $classes = array(
1527 'qodef-block-swiper',
1528 );
1529 $classes[] = ! empty( $atts['sliderNavigationPosition'] ) ? 'qodef-navigation--' . $atts['sliderNavigationPosition'] : '';
1530 $classes[] = ! empty( $atts['sliderHideNavigation'] ) ? 'qodef-hide-navigation--' . $atts['sliderHideNavigation'] : '';
1531 $classes[] = ! empty( $atts['sliderPaginationPosition'] ) ? 'qodef-pagination--' . $atts['sliderPaginationPosition'] : '';
1532 $classes[] = ! empty( $atts['paginationEnableNumbers'] ) ? 'qodef-pagination-numbers' : '';
1533 $classes[] = ! empty( $atts['navigationHoverArrowMove'] ) ? 'qodef-navigation--hover-move' : '';
1534
1535 if ( ! empty( $atts['sliderNavigationAlignment'] ) && 'together' === $atts['sliderNavigationPosition'] ) {
1536 $classes[] = 'qodef-navigation-alignment--' . $atts['sliderNavigationAlignment'];
1537 }
1538 if ( ! empty( $atts['sliderNavigationVerticalPosition'] ) && 'together' === $atts['sliderNavigationPosition'] ) {
1539 $classes[] = 'qodef-navigation-together--' . $atts['sliderNavigationVerticalPosition'];
1540 }
1541
1542 return implode( ' ', $classes );
1543 }
1544 }
1545
1546 if ( ! function_exists( 'qi_blocks_get_slider_data' ) ) {
1547 /**
1548 * Function that return element slider data
1549 *
1550 * @param array $atts - options value
1551 *
1552 * @return string
1553 */
1554 function qi_blocks_get_slider_data( $atts ) {
1555 $data = array();
1556
1557 $partial_columns = isset( $atts['sliderPartialColumns'] ) && 'yes' === $atts['sliderPartialColumns'];
1558 if ( $partial_columns ) {
1559 $partial_value = isset( $atts['sliderPartialColumnsValue'] ) ? $atts['sliderPartialColumnsValue'] : 0.1;
1560 } else {
1561 $partial_value = 0;
1562 }
1563
1564 $slider_navigation_position = isset( $atts['sliderNavigationPosition'] ) ? $atts['sliderNavigationPosition'] : '';
1565 $slider_pagination_position = isset( $atts['sliderPaginationPosition'] ) ? $atts['sliderPaginationPosition'] : '';
1566
1567 if ( ( 'outside' === $slider_navigation_position || 'together' === $slider_navigation_position ) || 'outside' === $slider_pagination_position ) {
1568 $data['unique'] = isset( $atts['uniqueClass'] ) ? $atts['uniqueClass'] : '';
1569 }
1570
1571 $data['direction'] = isset( $atts['sliderDirection'] ) ? $atts['sliderDirection'] : 'horizontal';
1572 $data['slidesPerView'] = isset( $atts['sliderColumns'] ) ? $atts['sliderColumns'] : 1;
1573 $data['spaceBetween'] = isset( $atts['sliderSpace'] ) ? $atts['sliderSpace'] : 0;
1574 $data['spaceBetweenTablet'] = isset( $atts['sliderSpaceTablet'] ) ? $atts['sliderSpaceTablet'] : $data['spaceBetween'];
1575 $data['spaceBetweenMobile'] = isset( $atts['sliderSpaceMobile'] ) ? $atts['sliderSpaceMobile'] : $data['spaceBetweenTablet'];
1576 $data['effect'] = isset( $atts['sliderEffect'] ) ? $atts['sliderEffect'] : '';
1577 $data['loop'] = isset( $atts['sliderLoop'] ) ? 'no' !== $atts['sliderLoop'] : true;
1578 $data['autoplay'] = isset( $atts['sliderAutoplay'] ) ? 'no' !== $atts['sliderAutoplay'] : true;
1579 $data['centeredSlides'] = isset( $atts['sliderCentered'] ) ? 'no' !== $atts['sliderCentered'] : false;
1580 $data['speed'] = isset( $atts['sliderSpeed'] ) ? $atts['sliderSpeed'] : '';
1581 $data['speedAnimation'] = isset( $atts['sliderSpeedAnimation'] ) ? $atts['sliderSpeedAnimation'] : '';
1582 $data['outsideNavigation'] = isset( $atts['sliderNavigationPosition'] ) && ( 'outside' === $atts['sliderNavigationPosition'] || 'together' === $atts['sliderNavigationPosition'] ) ? 'yes' : 'no';
1583 $data['outsidePagination'] = isset( $atts['sliderPaginationPosition'] ) && ( 'outside' === $atts['sliderPaginationPosition'] ) ? 'yes' : 'no';
1584 $data['partialValue'] = $partial_value;
1585 $data['disablePartialValue'] = isset( $atts['sliderPartialColumnsResponsiveDisable'] ) ? $atts['sliderPartialColumnsResponsiveDisable'] : '';
1586
1587 if ( ! empty( $atts['sliderColumnsResponsive'] ) && 'custom' === $atts['sliderColumnsResponsive'] ) {
1588 $data['customStages'] = true;
1589 $data['slidesPerView1440'] = ! empty( $atts['sliderColumns1440'] ) ? $atts['sliderColumns1440'] : $atts['sliderColumns'];
1590 $data['slidesPerView1366'] = ! empty( $atts['sliderColumns1366'] ) ? $atts['sliderColumns1366'] : $atts['sliderColumns'];
1591 $data['slidesPerView1024'] = ! empty( $atts['sliderColumns1024'] ) ? $atts['sliderColumns1024'] : $atts['sliderColumns'];
1592 $data['slidesPerView768'] = ! empty( $atts['sliderColumns768'] ) ? $atts['sliderColumns768'] : $atts['sliderColumns'];
1593 $data['slidesPerView680'] = ! empty( $atts['sliderColumns680'] ) ? $atts['sliderColumns680'] : $atts['sliderColumns'];
1594 $data['slidesPerView480'] = ! empty( $atts['sliderColumns480'] ) ? $atts['sliderColumns480'] : $atts['sliderColumns'];
1595 }
1596
1597 return wp_json_encode( $data );
1598 }
1599 }
1600
1601 if ( ! function_exists( 'qi_blocks_get_additional_query_args' ) ) {
1602 /**
1603 * Function that return additional query arguments
1604 *
1605 * @param array $atts - options value
1606 *
1607 * @return array
1608 */
1609 function qi_blocks_get_additional_query_args( $atts ) {
1610 $args = array();
1611
1612 if ( ! empty( $atts['additionalParams'] ) && 'id' === $atts['additionalParams'] ) {
1613 $post_ids = explode( ',', $atts['postIds'] );
1614 $args['orderby'] = 'post__in';
1615 $args['post__in'] = $post_ids;
1616 }
1617
1618 if ( ! empty( $atts['additionalParams'] ) && 'tax' === $atts['additionalParams'] ) {
1619 $taxonomy_values = array();
1620
1621 $slug = isset( $atts['taxSlug'] ) ? $atts['taxSlug'] : '';
1622 $ids = isset( $atts['taxIn'] ) ? $atts['taxIn'] : '';
1623
1624 if ( ! empty( $ids ) && empty( $slug ) ) {
1625 $taxonomy_values['field'] = 'term_id';
1626 $taxonomy_values['terms'] = is_array( $ids ) ? array_map( 'intval', $ids ) : array_map( 'intval', explode( ',', str_replace( ' ', '', $ids ) ) );
1627 } elseif ( ! empty( $slug ) ) {
1628 $taxonomy_values['field'] = 'slug';
1629 $taxonomy_values['terms'] = $slug;
1630 }
1631
1632 if ( ! empty( $atts['tax'] ) && ! empty( $taxonomy_values ) ) {
1633 // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
1634 $args['tax_query'] = array( array_merge( array( 'taxonomy' => $atts['tax'] ), $taxonomy_values ) );
1635 }
1636 }
1637
1638 if ( ! empty( $atts['additionalParams'] ) && 'author' === $atts['additionalParams'] ) {
1639 $args['author_name'] = $atts['authorSlug'];
1640 }
1641
1642 return $args;
1643 }
1644 }
1645
1646 if ( ! function_exists( 'qi_blocks_framework_get_attachment_id_from_url' ) ) {
1647 /**
1648 * Function that retrieves attachment id for passed attachment url
1649 *
1650 * @param string $attachment_url
1651 *
1652 * @return null|string
1653 */
1654 function qi_blocks_framework_get_attachment_id_from_url( $attachment_url ) {
1655 global $wpdb;
1656 $attachment_id = '';
1657
1658 if ( '' !== $attachment_url ) {
1659 // phpcs:ignore WordPress.DB.DirectDatabaseQuery
1660 $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE guid=%s", $attachment_url ) );
1661
1662 // Additional check for undefined reason when guid is not image src.
1663 if ( empty( $attachment_id ) ) {
1664 $modified_url = substr( $attachment_url, strrpos( $attachment_url, '/' ) + 1 );
1665
1666 // get attachment id.
1667 // phpcs:ignore WordPress.DB.DirectDatabaseQuery
1668 $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_wp_attached_file' AND meta_value LIKE %s", '%' . $modified_url . '%' ) );
1669 }
1670 }
1671
1672 return $attachment_id;
1673 }
1674 }
1675
1676 if ( ! function_exists( 'qi_blocks_framework_get_image_html_from_src' ) ) {
1677 /**
1678 * Function that returns image tag from url and it's attributes.
1679 *
1680 * @param string $url
1681 * @param array $attr
1682 *
1683 * @return string
1684 */
1685 function qi_blocks_framework_get_image_html_from_src( $url, $attr = array() ) {
1686 $html = '';
1687
1688 if ( ! empty( $url ) ) {
1689 $html .= '<img src="' . esc_url( $url ) . '"';
1690 foreach ( $attr as $name => $value ) {
1691 $html .= ' ' . $name . '="' . $value . '"';
1692 }
1693 $html .= ' />';
1694 }
1695
1696 return $html;
1697 }
1698 }
1699
1700 if ( ! function_exists( 'qi_blocks_framework_resize_image' ) ) {
1701 /**
1702 * Function that generates custom thumbnail for given attachment
1703 *
1704 * @param int|string $attachment - attachment id or url of image to resize
1705 * @param int $width desired - height of custom thumbnail
1706 * @param int $height desired - width of custom thumbnail
1707 * @param bool $crop - whether to crop image or not
1708 *
1709 * @return array returns array containing img_url, width and height
1710 *
1711 * @see qi_blocks_framework_get_attachment_id_from_url()
1712 * @see get_attached_file()
1713 * @see wp_get_attachment_url()
1714 * @see wp_get_image_editor()
1715 */
1716 function qi_blocks_framework_resize_image( $attachment, $width = null, $height = null, $crop = true ) {
1717 $return_array = array();
1718
1719 if ( ! empty( $attachment ) ) {
1720 if ( is_int( $attachment ) ) {
1721 $attachment_id = $attachment;
1722 } else {
1723 $attachment_id = qi_blocks_framework_get_attachment_id_from_url( $attachment );
1724 }
1725
1726 if ( ! empty( $attachment_id ) && ( isset( $width ) && isset( $height ) ) ) {
1727
1728 // Get file path of the attachment.
1729 $img_path = get_attached_file( $attachment_id );
1730
1731 // Get attachment url.
1732 $img_url = wp_get_attachment_url( $attachment_id );
1733
1734 // Break down img path to array, so we can use its components in building thumbnail path.
1735 $img_path_array = pathinfo( $img_path );
1736
1737 // build thumbnail path.
1738 $new_img_path = $img_path_array['dirname'] . '/' . $img_path_array['filename'] . '-' . $width . 'x' . $height . '.' . $img_path_array['extension'];
1739
1740 // build thumbnail url.
1741 $new_img_url = str_replace( $img_path_array['filename'], $img_path_array['filename'] . '-' . $width . 'x' . $height, $img_url );
1742
1743 // check if thumbnail exists by its path.
1744 if ( ! file_exists( $new_img_path ) ) {
1745 // get image manipulation object.
1746 $image_object = wp_get_image_editor( $img_path );
1747
1748 if ( ! is_wp_error( $image_object ) ) {
1749 // resize image and save it new to path.
1750 $image_object->resize( $width, $height, $crop );
1751 $image_object->save( $new_img_path );
1752
1753 // get sizes of newly created thumbnail.
1754 // we don't use $width and $height because those might differ from end result based on $crop parameter.
1755 $image_sizes = $image_object->get_size();
1756
1757 $width = $image_sizes['width'];
1758 $height = $image_sizes['height'];
1759 }
1760 }
1761
1762 // generate data to be returned.
1763 $return_array = array(
1764 'img_url' => $new_img_url,
1765 'img_width' => $width,
1766 'img_height' => $height,
1767 );
1768
1769 // attachment wasn't found in gallery, but it is not empty.
1770 } elseif ( '' !== $attachment && ( isset( $width ) && isset( $height ) ) ) {
1771 // generate data to be returned.
1772 $return_array = array(
1773 'img_url' => $attachment,
1774 'img_width' => $width,
1775 'img_height' => $height,
1776 );
1777 }
1778 }
1779
1780 return $return_array;
1781 }
1782 }
1783
1784 if ( ! function_exists( 'qi_blocks_framework_generate_thumbnail' ) ) {
1785 /**
1786 * Generates thumbnail img tag. It calls qi_blocks_framework_resize_image function for resizing image
1787 *
1788 * @param int|string $attachment - attachment id or url to generate thumbnail from
1789 * @param int $width - width of thumbnail
1790 * @param int $height - height of thumbnail
1791 * @param bool $crop - whether to crop thumbnail or not
1792 *
1793 * @return string generated img tag
1794 *
1795 * @see qi_blocks_framework_resize_image()
1796 * @see qi_blocks_framework_get_attachment_id_from_url()
1797 */
1798 function qi_blocks_framework_generate_thumbnail( $attachment, $width = null, $height = null, $crop = true ) {
1799 if ( ! empty( $attachment ) ) {
1800 if ( is_int( $attachment ) ) {
1801 $attachment_id = $attachment;
1802 } else {
1803 $attachment_id = qi_blocks_framework_get_attachment_id_from_url( $attachment );
1804 }
1805 $img_info = qi_blocks_framework_resize_image( $attachment_id, $width, $height, $crop );
1806 $img_alt = ! empty( $attachment_id ) ? get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) : '';
1807
1808 if ( is_array( $img_info ) && count( $img_info ) ) {
1809 $url = esc_url( $img_info['img_url'] );
1810 $attr = array();
1811 $attr['alt'] = esc_attr( $img_alt );
1812 $attr['width'] = esc_attr( $img_info['img_width'] );
1813 $attr['height'] = esc_attr( $img_info['img_height'] );
1814
1815 return qi_blocks_framework_get_image_html_from_src( $url, $attr );
1816 }
1817 }
1818
1819 return '';
1820 }
1821 }
1822
1823 if ( ! function_exists( 'qi_blocks_get_list_block_item_image' ) ) {
1824 /**
1825 * Function that generates thumbnail img tag for list shortcodes
1826 *
1827 * @param string $image_dimension
1828 * @param int $attachment_id
1829 *
1830 * @return string generated img tag
1831 *
1832 * @see qi_blocks_framework_generate_thumbnail()
1833 */
1834 function qi_blocks_get_list_block_item_image( $image_dimension = 'full', $attachment_id = 0, $custom_image_width = 0, $custom_image_height = 0 ) {
1835 $item_id = get_the_ID();
1836 if ( 'custom' !== $image_dimension ) {
1837 if ( ! empty( $attachment_id ) ) {
1838 $html = wp_get_attachment_image( $attachment_id, $image_dimension );
1839 } else {
1840 $html = get_the_post_thumbnail( $item_id, $image_dimension );
1841 }
1842 } else {
1843 if ( ! empty( $custom_image_width ) && ! empty( $custom_image_height ) ) {
1844 if ( ! empty( $attachment_id ) ) {
1845 $html = qi_blocks_framework_generate_thumbnail( intval( $attachment_id ), $custom_image_width, $custom_image_height );
1846 } else {
1847 $html = qi_blocks_framework_generate_thumbnail( intval( get_post_thumbnail_id( $item_id ) ), $custom_image_width, $custom_image_height );
1848 }
1849 } else {
1850 $html = get_the_post_thumbnail( $item_id, $image_dimension );
1851 }
1852 }
1853
1854 return apply_filters( 'qi_blocks_filter_list_shortcode_item_image', $html, $attachment_id );
1855 }
1856 }
1857
1858 if ( ! function_exists( 'qi_blocks_main_editor_additional_dependencies' ) ) {
1859 /**
1860 * Function that adds additional dependencies for main editor script
1861 *
1862 * @param array $dependency
1863 *
1864 * @return array
1865 */
1866 function qi_blocks_main_editor_additional_dependencies( $dependency ) {
1867 global $pagenow;
1868
1869 if ( 'widgets.php' !== $pagenow ) {
1870 $dependency[] = 'wp-edit-post';
1871 }
1872
1873 return $dependency;
1874 }
1875
1876 add_filter( 'qi_blocks_filter_main_editor_dependencies', 'qi_blocks_main_editor_additional_dependencies' );
1877 }
1878
1879 if ( ! function_exists( 'qi_blocks_escape_title_tag' ) ) {
1880 /**
1881 * Function that escape title tag variable for modules
1882 *
1883 * @param string $title_tag
1884 *
1885 * @return string
1886 */
1887 function qi_blocks_escape_title_tag( $title_tag ) {
1888 $allowed_tags = array(
1889 'h1',
1890 'h2',
1891 'h3',
1892 'h4',
1893 'h5',
1894 'h6',
1895 'p',
1896 'span',
1897 'ul',
1898 'ol',
1899 'div',
1900 );
1901
1902 $escaped_title_tag = '';
1903 $title_tag = strtolower( sanitize_key( $title_tag ) );
1904
1905 if ( in_array( $title_tag, $allowed_tags, true ) ) {
1906 $escaped_title_tag = $title_tag;
1907 }
1908
1909 return $escaped_title_tag;
1910 }
1911 }
1912