PluginProbe
Qi Blocks / 1.2
Qi Blocks v1.2
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 1.2, at helpers/helper.php

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