Skip to content

Commit cd4d2c8

Browse files
Hooks: Shape Dividers (#315)
1 parent 7a67778 commit cd4d2c8

File tree

1 file changed

+18
-50
lines changed

1 file changed

+18
-50
lines changed

src/hooks/shapes.md

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To support negative variations, you should include two files:
3636

3737
The first is the original design, the other is the same design but with negative colors.
3838

39-
## Examples
39+
## Example
4040

4141
To add new shape dividers in your theme, use the following code:
4242

@@ -48,58 +48,26 @@ To add new shape dividers in your theme, use the following code:
4848
* @param array $additional_shapes Additional Elementor shape dividers.
4949
*/
5050
function custom_elementor_shape_dividers( $additional_shapes ) {
51-
52-
$additional_shapes['shape-divider-1'] = [
53-
'title' => esc_html__( 'Shape divider 1', 'textdomain' ),
54-
'url' => get_stylesheet_directory_uri() . '/assets/shapes/shape-1.svg',
55-
'path' => get_stylesheet_directory() . '/assets/shapes/shape-1.svg',
56-
'height_only' => true,
57-
];
58-
59-
$additional_shapes['shape-divider-2'] = [
60-
'title' => esc_html__( 'Shape divider 2', 'textdomain' ),
61-
'url' => get_stylesheet_directory_uri() . '/assets/shapes/shape-2.svg',
62-
'path' => get_stylesheet_directory() . '/assets/shapes/shape-2.svg',
63-
'has_flip' => true,
64-
'has_negative' => true,
65-
'height_only' => true,
51+
return [
52+
'shape-divider-1' => [
53+
'title' => esc_html__( 'Shape divider 1', 'textdomain' ),
54+
'url' => PLUGIN_ASSETS_URL . 'assets/shapes/shape-1.svg',
55+
'path' => PLUGIN_ASSETS_PATH . 'assets/shapes/shape-1.svg',
56+
'height_only' => true,
57+
],
58+
'shape-divider-1' => [
59+
'title' => esc_html__( 'Shape divider 2', 'textdomain' ),
60+
'url' => PLUGIN_ASSETS_URL . 'assets/shapes/shape-2.svg',
61+
'path' => PLUGIN_ASSETS_PATH . 'assets/shapes/shape-2.svg',
62+
'has_flip' => true,
63+
'has_negative' => true,
64+
'height_only' => true,
65+
],
6666
];
67-
68-
return $additional_shapes;
69-
7067
}
7168
add_filter( 'elementor/shapes/additional_shapes', 'custom_elementor_shape_dividers' );
7269
```
7370

74-
To add new shape dividers in your plugin, use the following code:
75-
76-
```php
77-
/**
78-
* Add additional shape dividers to Elementor.
79-
*
80-
* @since 1.0.0
81-
* @param array $additional_shapes Additional Elementor shape dividers.
82-
*/
83-
function custom_elementor_shape_dividers( $additional_shapes ) {
84-
85-
$additional_shapes['shape-divider-1'] = [
86-
'title' => esc_html__( 'Shape divider 1', 'textdomain' ),
87-
'url' => plugins_url( __FILE__ ) . 'assets/shapes/shape-1.svg',
88-
'path' => plugin_dir_path( __FILE__ ) . 'assets/shapes/shape-1.svg',
89-
'height_only' => true,
90-
];
71+
To avoid conflicts with other plugins, shape IDs should be prefixed.
9172

92-
$additional_shapes['shape-divider-2'] = [
93-
'title' => esc_html__( 'Shape divider 2', 'textdomain' ),
94-
'url' => plugins_url( __FILE__ ) . 'assets/shapes/shape-2.svg',
95-
'path' => plugin_dir_path( __FILE__ ) . 'assets/shapes/shape-2.svg',
96-
'has_flip' => true,
97-
'has_negative' => true,
98-
'height_only' => true,
99-
];
100-
101-
return $additional_shapes;
102-
103-
}
104-
add_filter( 'elementor/shapes/additional_shapes', 'custom_elementor_shape_dividers' );
105-
```
73+
The `PLUGIN_ASSETS_URL` should be updated using functions like `plugin_dir_path( __FILE__ )` or `get_stylesheet_directory_uri()`. and `PLUGIN_ASSETS_PATH` should be updated using functions like `plugin_dir_path( __FILE__ )` or `get_stylesheet_directory()`.

0 commit comments

Comments
 (0)