PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.2.0
GenerateBlocks v1.2.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / includes / functions.php
generateblocks / includes Last commit date
class-do-css.php 5 years ago class-enqueue-css.php 5 years ago class-plugin-update.php 5 years ago class-render-blocks.php 5 years ago class-rest.php 5 years ago class-settings.php 5 years ago dashboard.php 5 years ago defaults.php 5 years ago functions.php 5 years ago general.php 5 years ago generate-css.php 5 years ago
functions.php
746 lines
1 <?php
2 /**
3 * Functions used throughout the plugin.
4 *
5 * @package GenerateBlocks
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Retrive attributes from our blocks.
14 *
15 * @since 0.1
16 * @param array $content The content of our page.
17 * @param array $data Data used to loop through the function as needed.
18 * @param int $depth Keep track of how deep we are in nested blocks.
19 *
20 * @return array
21 */
22 function generateblocks_get_block_data( $content, $data = array(), $depth = 0 ) {
23 if ( ! is_array( $content ) || empty( $content ) ) {
24 return;
25 }
26
27 foreach ( $content as $index => $block ) {
28 if ( ! is_object( $block ) && is_array( $block ) && isset( $block['blockName'] ) ) {
29 if ( 'generateblocks/grid' === $block['blockName'] ) {
30 $data['grid'][] = $block['attrs'];
31 $depth++;
32 $data[ 'tempGridId-' . $depth ] = $block['attrs']['uniqueId'];
33 }
34
35 if ( 'generateblocks/container' === $block['blockName'] ) {
36 if ( isset( $block['attrs']['isGrid'] ) && $block['attrs']['isGrid'] && isset( $data[ 'tempGridId-' . $depth ] ) ) {
37 $block['attrs']['gridId'] = $data[ 'tempGridId-' . $depth ];
38 }
39
40 $data['container'][] = $block['attrs'];
41 }
42
43 if ( 'generateblocks/headline' === $block['blockName'] ) {
44 if ( isset( $block['innerHTML'] ) ) {
45 if ( strpos( trim( $block['innerHTML'] ), '<div class="gb-headline-wrapper' ) === 0 ) {
46 $block['attrs']['hasWrapper'] = true;
47 }
48 }
49
50 $data['headline'][] = $block['attrs'];
51 }
52
53 if ( 'generateblocks/button-container' === $block['blockName'] ) {
54 $data['button-container'][] = $block['attrs'];
55 }
56
57 if ( 'generateblocks/button' === $block['blockName'] ) {
58 if ( ! isset( $block['attrs']['hasUrl'] ) && isset( $block['innerHTML'] ) ) {
59 if ( strpos( trim( $block['innerHTML'] ), '<a' ) === 0 ) {
60 $block['attrs']['hasUrl'] = true;
61 }
62 }
63
64 $data['button'][] = $block['attrs'];
65 }
66
67 if ( 'core/block' === $block['blockName'] ) {
68 if ( isset( $block['attrs'] ) && is_array( $block['attrs'] ) ) {
69 $atts = $block['attrs'];
70
71 if ( isset( $atts['ref'] ) ) {
72 $reusable_block = get_post( $atts['ref'] );
73
74 if ( $reusable_block && 'wp_block' === $reusable_block->post_type ) {
75 $reuse_data_block = parse_blocks( $reusable_block->post_content );
76 $data = generateblocks_get_block_data( $reuse_data_block, $data );
77 }
78 }
79 }
80 }
81
82 if ( isset( $block['innerBlocks'] ) && ! empty( $block['innerBlocks'] ) && is_array( $block['innerBlocks'] ) ) {
83 $data = generateblocks_get_block_data( $block['innerBlocks'], $data, $depth );
84 }
85 }
86 }
87
88 return $data;
89 }
90
91 /**
92 * Parse our content for blocks.
93 *
94 * @param string $content Optional content to parse.
95 * @since 1.1
96 */
97 function generateblocks_get_parsed_content( $content = '' ) {
98 if ( ! function_exists( 'has_blocks' ) ) {
99 return;
100 }
101
102 if ( ! $content && has_blocks( get_the_ID() ) ) {
103 global $post;
104
105 if ( ! is_object( $post ) ) {
106 return;
107 }
108
109 $content = $post->post_content;
110 }
111
112 $content = apply_filters( 'generateblocks_do_content', $content );
113
114 if ( ! function_exists( 'parse_blocks' ) ) {
115 return;
116 }
117
118 $content = parse_blocks( $content );
119
120 return $content;
121 }
122
123 /**
124 * Shorthand CSS values (padding, margin, border etc..).
125 *
126 * @since 0.1
127 *
128 * @param int $top The first value.
129 * @param int $right The second value.
130 * @param int $bottom The third value.
131 * @param int $left The fourth value.
132 * @param string $unit The unit we're adding.
133 *
134 * @return string The shorthand value.
135 */
136 function generateblocks_get_shorthand_css( $top, $right, $bottom, $left, $unit ) {
137 if ( '' === $top && '' === $right && '' === $bottom && '' === $left ) {
138 return;
139 }
140
141 $top = ( floatval( $top ) <> 0 ) ? floatval( $top ) . $unit . ' ' : '0 '; // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
142 $right = ( floatval( $right ) <> 0 ) ? floatval( $right ) . $unit . ' ' : '0 '; // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
143 $bottom = ( floatval( $bottom ) <> 0 ) ? floatval( $bottom ) . $unit . ' ' : '0 '; // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
144 $left = ( floatval( $left ) <> 0 ) ? floatval( $left ) . $unit . ' ' : '0 '; // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
145
146 if ( $right === $left ) {
147 $left = '';
148
149 if ( $top === $bottom ) {
150 $bottom = '';
151
152 if ( $top === $right ) {
153 $right = '';
154 }
155 }
156 }
157
158 return trim( $top . $right . $bottom . $left );
159 }
160
161 /**
162 * Get our media query.
163 *
164 * @since 0.1
165 * @param string $type The media query we're getting.
166 *
167 * @return string
168 */
169 function generateblocks_get_media_query( $type ) {
170 $queries = apply_filters(
171 'generateblocks_media_query',
172 array(
173 'desktop' => '(min-width: 1025px)',
174 'tablet' => '(max-width: 1024px)',
175 'tablet_only' => '(max-width: 1024px) and (min-width: 768px)',
176 'mobile' => '(max-width: 767px)',
177 )
178 );
179
180 return $queries[ $type ];
181 }
182
183 /**
184 * Build our list of Google fonts on this page.
185 *
186 * @since 0.1
187 * @param string $content Optional content to parse.
188 * @return array
189 */
190 function generateblocks_get_google_fonts( $content = '' ) {
191 $content = generateblocks_get_parsed_content( $content );
192
193 if ( ! $content ) {
194 return;
195 }
196
197 $data = generateblocks_get_block_data( $content );
198
199 $defaults = generateblocks_get_block_defaults();
200 $font_data = array();
201
202 if ( ! empty( $data ) ) {
203 foreach ( $data as $name => $blockData ) {
204 if ( 'button' === $name ) {
205 foreach ( $blockData as $atts ) {
206 $button_settings = wp_parse_args(
207 $atts,
208 $defaults['button']
209 );
210
211 if ( $button_settings['googleFont'] ) {
212 $id = $atts['uniqueId'];
213
214 $variants = $button_settings['googleFontVariants'];
215
216 if ( $variants ) {
217 $variants = str_replace( ' ', '', $variants );
218 $variants = explode( ',', $variants );
219 }
220
221 $font_data[ $id ] = array(
222 'name' => $button_settings['fontFamily'],
223 'variants' => $variants,
224 );
225 }
226 }
227 }
228
229 if ( 'headline' === $name ) {
230 foreach ( $blockData as $atts ) {
231 $headline_settings = wp_parse_args(
232 $atts,
233 $defaults['headline']
234 );
235
236 if ( $headline_settings['googleFont'] ) {
237 $id = $atts['uniqueId'];
238 $variants = $headline_settings['googleFontVariants'];
239
240 if ( $variants ) {
241 $variants = str_replace( ' ', '', $variants );
242 $variants = explode( ',', $variants );
243 }
244
245 $font_data[ $id ] = array(
246 'name' => $headline_settings['fontFamily'],
247 'variants' => $variants,
248 );
249 }
250 }
251 }
252
253 if ( 'container' === $name ) {
254 foreach ( $blockData as $atts ) {
255 $container_settings = wp_parse_args(
256 $atts,
257 $defaults['container']
258 );
259
260 if ( $container_settings['googleFont'] ) {
261 $id = $atts['uniqueId'];
262 $variants = $container_settings['googleFontVariants'];
263
264 if ( $variants ) {
265 $variants = str_replace( ' ', '', $variants );
266 $variants = explode( ',', $variants );
267 }
268
269 $font_data[ $id ] = array(
270 'name' => $container_settings['fontFamily'],
271 'variants' => $variants,
272 );
273 }
274 }
275 }
276 }
277 }
278
279 $fonts = array();
280
281 foreach ( (array) $font_data as $font ) {
282 $id = str_replace( ' ', '', strtolower( $font['name'] ) );
283
284 $fonts[ $id ]['name'] = $font['name'];
285
286 if ( ! empty( $font['variants'] ) ) {
287 foreach ( $font['variants'] as $variant ) {
288 if ( isset( $fonts[ $id ]['variants'] ) ) {
289 if ( in_array( $variant, (array) $fonts[ $id ]['variants'] ) ) {
290 continue;
291 }
292 }
293
294 $fonts[ $id ]['variants'][] = $variant;
295 }
296 }
297 }
298
299 return apply_filters( 'generateblocks_google_fonts', $fonts );
300 }
301
302 /**
303 * Build the Google Font request URI.
304 *
305 * @since 0.1
306 *
307 * @return string The request URI to Google Fonts.
308 */
309 function generateblocks_get_google_fonts_uri() {
310 $google_fonts = generateblocks_get_google_fonts();
311
312 if ( ! $google_fonts ) {
313 return;
314 }
315
316 $data = array();
317
318 foreach ( $google_fonts as $font ) {
319 $variants = array();
320
321 if ( ! empty( $font['variants'] ) ) {
322 foreach ( $font['variants'] as $variant ) {
323 $variants[] = $variant;
324 }
325 }
326
327 $variants = apply_filters( 'generateblocks_google_font_variants', $variants, $font['name'] );
328
329 $name = str_replace( ' ', '+', $font['name'] );
330
331 if ( $variants ) {
332 $data[] = $name . ':' . implode( ',', $variants );
333 } else {
334 $data[] = $name;
335 }
336 }
337
338 $font_args = apply_filters(
339 'generateblocks_google_font_args',
340 array(
341 'family' => implode( '|', $data ),
342 'subset' => null,
343 'display' => 'swap',
344 )
345 );
346
347 return add_query_arg( $font_args, '//fonts.googleapis.com/css' );
348 }
349
350 /**
351 * Convert hex to RGBA
352 *
353 * @since 0.1
354 * @param string $hex The hex value.
355 * @param int $alpha The opacity value.
356 *
357 * @return string The RGBA value.
358 */
359 function generateblocks_hex2rgba( $hex, $alpha ) {
360 if ( ! $hex ) {
361 return;
362 }
363
364 if ( 1 === $alpha ) {
365 return $hex;
366 }
367
368 $hex = str_replace( '#', '', $hex );
369
370 if ( strlen( $hex ) == 3 ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
371 $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
372 $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
373 $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
374 } else {
375 $r = hexdec( substr( $hex, 0, 2 ) );
376 $g = hexdec( substr( $hex, 2, 2 ) );
377 $b = hexdec( substr( $hex, 4, 2 ) );
378 }
379
380 $rgba = 'rgba(' . $r . ', ' . $g . ', ' . $b . ', ' . $alpha . ')';
381
382 return $rgba;
383 }
384
385 /**
386 * Return old flexblocks values for old browsers.
387 *
388 * @since 0.1
389 * @param string $value The value to convert.
390 *
391 * @return string The old browser value.
392 */
393 function generateblocks_get_vendor_prefix( $value ) {
394 if ( 'flex-start' === $value || 'left' === $value ) {
395 return 'start';
396 }
397
398 if ( 'flex-end' === $value || 'right' === $value ) {
399 return 'end';
400 }
401
402 return $value;
403 }
404
405 /**
406 * Return flexbox alignment values from left/right.
407 *
408 * @since 0.1
409 * @param string $value The value to convert.
410 *
411 * @return string The flexbox alignment value.
412 */
413 function generateblocks_get_flexbox_alignment( $value ) {
414 if ( 'left' === $value || 'top' === $value ) {
415 return 'flex-start';
416 }
417
418 if ( 'right' === $value || 'bottom' === $value ) {
419 return 'flex-end';
420 }
421
422 return $value;
423 }
424
425 /**
426 * Get an option from the database.
427 *
428 * @param string $option The option to get.
429 * @since 0.1
430 */
431 function generateblocks_get_option( $option ) {
432 $defaults = generateblocks_get_option_defaults();
433
434 if ( ! isset( $defaults[ $option ] ) ) {
435 return;
436 }
437
438 $options = wp_parse_args(
439 get_option( 'generateblocks', array() ),
440 $defaults
441 );
442
443 return $options[ $option ];
444 }
445
446 /**
447 * Checks whether a value exists, even if it's a 0.
448 *
449 * @param int|string $value The value to check.
450 * @since 1.0
451 */
452 function generateblocks_has_number_value( $value ) {
453 if ( $value || 0 === $value || '0' === $value ) {
454 return true;
455 }
456
457 return false;
458 }
459
460 /**
461 * Get the background-image value for our Container block.
462 *
463 * @param string $type Gradient or background image.
464 * @param array $settings Our background image settings.
465 */
466 function generateblocks_get_background_image_css( $type, $settings ) {
467 $gradient = '';
468
469 if ( $settings['gradient'] ) {
470 $gradientColorStopOneValue = '';
471 $gradientColorStopTwoValue = '';
472 $gradientColorOneValue = generateblocks_hex2rgba( $settings['gradientColorOne'], $settings['gradientColorOneOpacity'] );
473 $gradientColorTwoValue = generateblocks_hex2rgba( $settings['gradientColorTwo'], $settings['gradientColorTwoOpacity'] );
474
475 if ( $settings['gradientColorOne'] && '' !== $settings['gradientColorStopOne'] ) {
476 $gradientColorStopOneValue = ' ' . $settings['gradientColorStopOne'] . '%';
477 }
478
479 if ( $settings['gradientColorTwo'] && '' !== $settings['gradientColorStopTwo'] ) {
480 $gradientColorStopTwoValue = ' ' . $settings['gradientColorStopTwo'] . '%';
481 }
482
483 $gradient = 'linear-gradient(' . $settings['gradientDirection'] . 'deg, ' . $gradientColorOneValue . $gradientColorStopOneValue . ', ' . $gradientColorTwoValue . $gradientColorStopTwoValue . ')';
484 }
485
486 if ( 'gradient' === $type ) {
487 return $gradient;
488 }
489
490 $backgroundImage = '';
491
492 if ( $settings['bgImage'] ) {
493 $url = '';
494
495 if ( isset( $settings['bgImage']['id'] ) ) {
496 $image_src = wp_get_attachment_image_src( $settings['bgImage']['id'], $settings['bgImageSize'] );
497
498 if ( is_array( $image_src ) ) {
499 $url = $image_src[0];
500 } else {
501 $url = $settings['bgImage']['image']['url'];
502 }
503 } else {
504 $url = $settings['bgImage']['image']['url'];
505 }
506
507 $url = apply_filters( 'generateblocks_background_image_url', $url, $settings );
508
509 // Old background image overlays mixed with our gradients.
510 if (
511 'element' === $settings['bgOptions']['selector'] &&
512 ( $settings['backgroundColor'] || $settings['gradient'] ) &&
513 isset( $settings['bgOptions']['overlay'] ) &&
514 $settings['bgOptions']['overlay']
515 ) {
516 if ( $settings['gradient'] ) {
517 $backgroundImage = $gradient . ', url(' . esc_url( $url ) . ')';
518 } elseif ( $settings['backgroundColor'] ) {
519 $settings['backgroundColor'] = generateblocks_hex2rgba( $settings['backgroundColor'], $settings['backgroundColorOpacity'] );
520 $backgroundImage = 'linear-gradient(0deg, ' . $settings['backgroundColor'] . ', ' . $settings['backgroundColor'] . '), url(' . esc_url( $url ) . ')';
521 }
522 } else {
523 $backgroundImage = 'url(' . esc_url( $url ) . ')';
524 }
525 }
526
527 return $backgroundImage;
528 }
529
530 /**
531 * Build list of attributes into a string and apply contextual filter on string.
532 *
533 * The contextual filter is of the form `generateblocks_attr_{context}_output`.
534 *
535 * @since 1.2.0
536 *
537 * @param string $context The context, to build filter name.
538 * @param array $attributes Optional. Extra attributes to merge with defaults.
539 * @param array $settings Optional. Custom data to pass to filter.
540 * @return string String of HTML attributes and values.
541 */
542 function generateblocks_attr( $context, $attributes = array(), $settings = array() ) {
543 $attributes = generateblocks_parse_attr( $context, $attributes, $settings );
544
545 $output = '';
546
547 // Cycle through attributes, build tag attribute string.
548 foreach ( $attributes as $key => $value ) {
549
550 if ( ! $value ) {
551 continue;
552 }
553
554 if ( true === $value ) {
555 $output .= esc_html( $key ) . ' ';
556 } else {
557 $output .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
558 }
559 }
560
561 $output = apply_filters( "generateblocks_attr_{$context}_output", $output, $attributes, $settings, $context );
562
563 return trim( $output );
564 }
565
566 /**
567 * Merge array of attributes with defaults, and apply contextual filter on array.
568 *
569 * The contextual filter is of the form `generateblocks_attr_{context}`.
570 *
571 * @since 1.2.0
572 *
573 * @param string $context The context, to build filter name.
574 * @param array $attributes Optional. Extra attributes to merge with defaults.
575 * @param array $settings Optional. Custom data to pass to filter.
576 * @return array Merged and filtered attributes.
577 */
578 function generateblocks_parse_attr( $context, $attributes = array(), $settings = array() ) {
579 $defaults = array(
580 'class' => sanitize_html_class( $context ),
581 );
582
583 $attributes = wp_parse_args( $attributes, $defaults );
584
585 // Contextual filter.
586 return apply_filters( "generateblocks_attr_{$context}", $attributes, $settings, $context );
587 }
588
589 /**
590 * Generate our SVG shape dividers.
591 *
592 * @since 1.2.0
593 */
594 function generateblocks_get_svg_shapes() {
595 return apply_filters(
596 'generateblocks_svg_shapes',
597 array(
598 'gb-waves' => array(
599 'group' => esc_attr__( 'Waves', 'generateblocks' ),
600 'svgs' => array(
601 'gb-waves-1' => array(
602 /* translators: Shape number */
603 'label' => sprintf( __( 'Wave %s', 'generateblocks' ), '1' ),
604 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 194.3" preserveAspectRatio="none"><path d="M1200 133.3l-50 8.9c-50 8.6-150 26.9-250 31.1-100 4.2-200-4.2-300-26.7S400 89.2 300 62.2C200 35.8 100 17.5 50 8.9L0 0v194.3h1200v-61z"/></svg>',
605 ),
606 'gb-waves-2' => array(
607 /* translators: Shape number */
608 'label' => sprintf( __( 'Wave %s', 'generateblocks' ), '2' ),
609 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 137.6" preserveAspectRatio="none"><path d="M0 137.6h1200V21.9l-66.7 26.7c-66.7 26.7-200 80-333.3 66.7S533.3 21.9 400 4.2C266.7-13.9 133.3 31.1 66.7 53L0 75.3v62.3z"/></svg>',
610 ),
611 'gb-waves-3' => array(
612 /* translators: Shape number */
613 'label' => sprintf( __( 'Wave %s', 'generateblocks' ), '3' ),
614 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 96.2" preserveAspectRatio="none"><path d="M0 96.2h1200V72.9l-50-8.9c-50-8.6-150-26.9-250-22.2C800 46.2 700 72.9 600 64 500 55.4 400 10.4 300 1.8 200-7.1 100 19.5 50 32.9L0 46.2v50z"/></svg>',
615 ),
616 'gb-waves-4' => array(
617 /* translators: Shape number */
618 'label' => sprintf( __( 'Wave %s', 'generateblocks' ), '4' ),
619 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 130.3" preserveAspectRatio="none"><path d="M0 107.9l40-22.2c40-21.9 120-66.9 200-62.2 80 4.4 160 57.8 240 53.3C560 72 640 10.4 720 1.2S880 37 960 59c80 22.3 160 22.3 200 22.3h40v49H0v-22.4z"/></svg>',
620 ),
621 'gb-waves-5' => array(
622 /* translators: Shape number */
623 'label' => sprintf( __( 'Wave %s', 'generateblocks' ), '5' ),
624 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 218" preserveAspectRatio="none"><path d="M0 218h1200v-31.3l-40 4.4c-40 4.8-120 13.1-200 0-80-13.6-160-48.6-240-66.7-80-17.8-160-17.8-240-8.8-80 8.6-160 26.9-240 8.8-80-17.7-160-71.1-200-97.7L0 0v218z"/></svg>',
625 ),
626 'gb-waves-6' => array(
627 /* translators: Shape number */
628 'label' => sprintf( __( 'Wave %s', 'generateblocks' ), '6' ),
629 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 234" preserveAspectRatio="none"><path d="M0 0l40 40c40 40 120 120 200 115.6 80-4.8 160-93.1 240-111.2C560 26.7 640 80 720 88.9c80 8.6 160-26.4 240-13.3 80 13.6 160 75.2 200 106.7l40 31.1V234H0V0z"/></svg>',
630 ),
631 'gb-waves-7' => array(
632 /* translators: Shape number */
633 'label' => sprintf( __( 'Wave %s', 'generateblocks' ), '7' ),
634 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 217.3" preserveAspectRatio="none"><path d="M1200 195.6l-25-22.2c-25-21.9-75-66.9-125-75.5-50-8.9-100 17.8-150 26.7-50 8.6-100 .2-150-13.3-50-13.1-100-31.4-150-26.7-50 4.4-100 31.1-150 26.7-50-4.8-100-39.8-150-66.7C250 18.1 200-.2 150 0 100-.2 50 18.1 25 26.7L0 35.6v181.7h1200v-21.7z"/></svg>',
635 ),
636 'gb-waves-8' => array(
637 /* translators: Shape number */
638 'label' => sprintf( __( 'Wave %s', 'generateblocks' ), '8' ),
639 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 230.8" preserveAspectRatio="none"><path d="M1200 179.5l-22.2-26.7c-22.2-26.7-66.9-80-111.1-75.6-44.4 4.8-89.2 66.4-133.3 102.2-44.4 35.8-89.2 44.2-133.3 8.9-44.4-35.6-89.2-115.6-133.3-155.6-44.4-40-89.2-40-133.3-17.8C488.9 37 444.2 82 400 81.7c-44.4.2-89.2-44.8-133.3-57.8-44.4-13.6-89.2 4.8-133.3 26.7-44.5 22.2-89.2 48.9-110.9 62.2L0 126.1v104.7H1199.7l.3-51.3z"/></svg>',
640 ),
641 ),
642 ),
643 'gb-angles' => array(
644 'group' => esc_attr__( 'Angles', 'generateblocks' ),
645 'svgs' => array(
646 'gb-angle-1' => array(
647 /* translators: Shape number */
648 'label' => sprintf( __( 'Angle %s', 'generateblocks' ), '1' ),
649 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 360" preserveAspectRatio="none"><path d="M1200 360H0V0l1200 348z"/></svg>',
650 ),
651 ),
652 ),
653 'gb-curves' => array(
654 'group' => esc_attr__( 'Curves', 'generateblocks' ),
655 'svgs' => array(
656 'gb-curve-1' => array(
657 /* translators: Shape number */
658 'label' => sprintf( __( 'Curve %s', 'generateblocks' ), '1' ),
659 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 350" preserveAspectRatio="none"><path d="M1200 336.7V350H0V0s22.4 276.4 1200 336.7z"/></svg>',
660 ),
661 'gb-curve-2' => array(
662 /* translators: Shape number */
663 'label' => sprintf( __( 'Curve %s', 'generateblocks' ), '2' ),
664 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 350" preserveAspectRatio="none"><path d="M1200 350V0C22.4 60.3 0 336.7 0 336.7V350h1200z"/></svg>',
665 ),
666 'gb-curve-3' => array(
667 /* translators: Shape number */
668 'label' => sprintf( __( 'Curve %s', 'generateblocks' ), '3' ),
669 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 211.2" preserveAspectRatio="none"><path d="M600 188.4C321.1 188.4 84.3 109.5 0 0v211.2h1200V0c-84.3 109.5-321.1 188.4-600 188.4z"/></svg>',
670 ),
671 'gb-curve-4' => array(
672 /* translators: Shape number */
673 'label' => sprintf( __( 'Curve %s', 'generateblocks' ), '4' ),
674 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 211.2" preserveAspectRatio="none"><path d="M1200 188.4v22.8H0v-22.8C84.3 78.9 321.1 0 600 0s515.7 78.9 600 188.4z"/></svg>',
675 ),
676 ),
677 ),
678 'gb-triangles' => array(
679 'group' => esc_attr__( 'Triangles', 'generateblocks' ),
680 'svgs' => array(
681 'gb-triangle-1' => array(
682 /* translators: Shape number */
683 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '1' ),
684 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 100" preserveAspectRatio="none"><path d="M1200 100H0V0l400 77.2L1200 0z"/></svg>',
685 ),
686 'gb-triangle-2' => array(
687 /* translators: Shape number */
688 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '2' ),
689 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 100" preserveAspectRatio="none"><path d="M1200 77.2L400 0 0 77.2V100h1200z"/></svg>',
690 ),
691 'gb-triangle-3' => array(
692 /* translators: Shape number */
693 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '3' ),
694 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 70" preserveAspectRatio="none"><path d="M1200 0v70H0V0h530l70 50 70-50z"/></svg>',
695 ),
696 'gb-triangle-4' => array(
697 /* translators: Shape number */
698 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '4' ),
699 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 70" preserveAspectRatio="none"><path d="M670 50L600 0l-70 50H0v20h1200V50z"/></svg>',
700 ),
701 'gb-triangle-5' => array(
702 /* translators: Shape number */
703 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '5' ),
704 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 50" preserveAspectRatio="none"><path d="M1200 0v50H0V0h560l40 30 40-30z"/></svg>',
705 ),
706 'gb-triangle-6' => array(
707 /* translators: Shape number */
708 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '6' ),
709 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 50" preserveAspectRatio="none"><path d="M640 30L600 0l-40 30H0v20h1200V30z"/></svg>',
710 ),
711 'gb-triangle-7' => array(
712 /* translators: Shape number */
713 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '7' ),
714 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 230" preserveAspectRatio="none"><path d="M1200 230H0V0l600 207.2L1200 0z"/></svg>',
715 ),
716 'gb-triangle-8' => array(
717 /* translators: Shape number */
718 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '8' ),
719 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 230" preserveAspectRatio="none"><path d="M1200 207.2L600 0 0 207.2V230h1200z"/></svg>',
720 ),
721 'gb-triangle-9' => array(
722 /* translators: Shape number */
723 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '9' ),
724 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 131" preserveAspectRatio="none"><path d="M1200 131H0V40l154.8 50L410 35l277 69L899 0l301 110z"/></svg>',
725 ),
726 'gb-triangle-10' => array(
727 /* translators: Shape number */
728 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '10' ),
729 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 131" preserveAspectRatio="none"><path d="M1200 0L899 110 687 6 410 75 154.8 20 0 70v61h1200z"/></svg>',
730 ),
731 'gb-triangle-11' => array(
732 /* translators: Shape number */
733 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '11' ),
734 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 176" preserveAspectRatio="none"><path d="M0 0l400 156 400-88 400 74v34H0z"/></svg>',
735 ),
736 'gb-triangle-12' => array(
737 /* translators: Shape number */
738 'label' => sprintf( __( 'Triangle %s', 'generateblocks' ), '12' ),
739 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 176" preserveAspectRatio="none"><path d="M0 176h1200V14L800 88 400 0 0 156z"/></svg>',
740 ),
741 ),
742 ),
743 )
744 );
745 }
746