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

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