PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / trunk
Block Animations, Motion & Scroll Effects – Ghost Kit vtrunk
3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / classes / class-shapes.php

class-shapes.php in Block Animations, Motion & Scroll Effects – Ghost Kit trunk, at classes/class-shapes.php

145 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shapes for Shape Divider block
4 *
5 * @package ghostkit
6 */
7
8 /**
9 * GhostKit_Shapes_List
10 */
11 class GhostKit_Shapes_List {
12 /**
13 * GhostKit_Shapes_List constructor.
14 */
15 public function __construct() {
16 add_filter( 'gkt_shapes_list', array( $this, 'add_default_shapes' ), 9 );
17 add_filter( 'gkt_shapes_list', array( $this, 'prepare_shapes_data' ), 99999 );
18 }
19
20 /**
21 * Add default set of shapes.
22 *
23 * @param array $shapes - shapes list.
24 *
25 * @return array
26 */
27 public static function add_default_shapes( $shapes = array() ) {
28 $shapes['default'] = array(
29 'name' => esc_html__( 'Default', 'ghostkit' ),
30 'shapes' => array(
31 array(
32 'label' => esc_html__( 'Wave', 'ghostkit' ),
33 'name' => 'wave',
34 'allow_flip_vertical' => true,
35 'allow_flip_horizontal' => true,
36 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/wave.svg',
37 ),
38 array(
39 'label' => esc_html__( 'Waves', 'ghostkit' ),
40 'name' => 'waves',
41 'allow_flip_vertical' => true,
42 'allow_flip_horizontal' => true,
43 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/waves.svg',
44 ),
45 array(
46 'label' => esc_html__( 'Tilt', 'ghostkit' ),
47 'name' => 'tilt',
48 'allow_flip_vertical' => true,
49 'allow_flip_horizontal' => true,
50 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/tilt.svg',
51 ),
52 array(
53 'label' => esc_html__( 'Tilts', 'ghostkit' ),
54 'name' => 'tilts',
55 'allow_flip_vertical' => true,
56 'allow_flip_horizontal' => true,
57 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/tilts.svg',
58 ),
59 array(
60 'label' => esc_html__( 'Triangle', 'ghostkit' ),
61 'name' => 'triangle',
62 'allow_flip_vertical' => true,
63 'allow_flip_horizontal' => false,
64 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/triangle.svg',
65 ),
66 array(
67 'label' => esc_html__( 'Triangles', 'ghostkit' ),
68 'name' => 'triangles',
69 'allow_flip_vertical' => true,
70 'allow_flip_horizontal' => false,
71 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/triangles.svg',
72 ),
73 array(
74 'label' => esc_html__( 'Triangle Asymm', 'ghostkit' ),
75 'name' => 'triangle-asymmetrical',
76 'allow_flip_vertical' => true,
77 'allow_flip_horizontal' => true,
78 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/triangle-asymmetrical.svg',
79 ),
80 array(
81 'label' => esc_html__( 'Triangles Asymm', 'ghostkit' ),
82 'name' => 'triangles-asymmetrical',
83 'allow_flip_vertical' => true,
84 'allow_flip_horizontal' => true,
85 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/triangles-asymmetrical.svg',
86 ),
87 array(
88 'label' => esc_html__( 'Ellipse', 'ghostkit' ),
89 'name' => 'ellipse',
90 'allow_flip_vertical' => true,
91 'allow_flip_horizontal' => false,
92 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/ellipse.svg',
93 ),
94 array(
95 'label' => esc_html__( 'Ellipses', 'ghostkit' ),
96 'name' => 'ellipses',
97 'allow_flip_vertical' => true,
98 'allow_flip_horizontal' => false,
99 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/ellipses.svg',
100 ),
101 array(
102 'label' => esc_html__( 'Arrow', 'ghostkit' ),
103 'name' => 'arrow',
104 'allow_flip_vertical' => true,
105 'allow_flip_horizontal' => false,
106 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/arrow.svg',
107 ),
108 array(
109 'label' => esc_html__( 'Arrow Curve', 'ghostkit' ),
110 'name' => 'arrow-curve',
111 'allow_flip_vertical' => true,
112 'allow_flip_horizontal' => false,
113 'path' => ghostkit()->plugin_path . '/gutenberg/shapes/arrow-curve.svg',
114 ),
115 ),
116 );
117
118 return $shapes;
119 }
120
121 /**
122 * Prepare shapes data (get SVG string).
123 *
124 * @param array $shapes - shapes list.
125 *
126 * @return array
127 */
128 public static function prepare_shapes_data( $shapes = array() ) {
129 foreach ( $shapes as $k => $shape_cat ) {
130 if ( ! isset( $shape_cat['shapes'] ) ) {
131 continue;
132 }
133
134 foreach ( $shape_cat['shapes'] as $i => $shape ) {
135 // phpcs:ignore
136 $shapes[ $k ]['shapes'][ $i ]['svg'] = file_get_contents( $shape['path'] );
137 }
138 }
139
140 return $shapes;
141 }
142 }
143
144 new GhostKit_Shapes_List();
145