Skip to content

Commit 7a67778

Browse files
Hooks: Mask Shapes (#314)
1 parent deea8a0 commit 7a67778

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

src/.vuepress/sidebars/hooks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = [
1515
'php',
1616
'placeholder-image',
1717
'shapes',
18+
'masks',
1819
'frontend-content',
1920
'render-frontend-elements',
2021
'render-widget-content',

src/hooks/masks.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Mask Shapes
2+
3+
<Badge type="tip" vertical="top" text="Elementor Core" /> <Badge type="warning" vertical="top" text="Basic" />
4+
5+
Elementor offers the ability to apply overlay [masks](https://elementor.com/help/mask-option/) that create stylish designs for any element. By default Elementor offers a set of predefined masks. Additional masks can be added using a dedicated filter hook.
6+
7+
## Hook Details
8+
9+
* **Hook Type:** Filter Hook
10+
* **Hook Name:** `elementor/mask_shapes/additional_shapes`
11+
* **Affects:** Editor
12+
13+
## Hook Arguments
14+
15+
| Argument | Type | Description |
16+
|---------------------|-------------|-----------------------------------|
17+
| `additional_shapes` | _`array`_ | A list of additional mask shapes. |
18+
19+
An array of additional mask shapes that should include the following parameters:
20+
21+
```
22+
'mask-shape-id' => [
23+
'title' => (string) Mask label.
24+
'image' => (string) Mask file URI.
25+
]
26+
```
27+
28+
## Examples
29+
30+
To add new mask shapes use the following code:
31+
32+
```php
33+
/**
34+
* Add additional mask shapes to Elementor.
35+
*
36+
* @since 1.0.0
37+
*/
38+
function custom_elementor_mask_shapes() {
39+
return [
40+
'shape-id-1' => [
41+
'title' => esc_html__( 'Shape name 1', 'textdomain' ),
42+
'image' => PLUGIN_ASSETS_URL . 'mask-shapes/shape-1.svg',
43+
],
44+
'shape-id-2' => [
45+
'title' => esc_html__( 'Shape name 2', 'textdomain' ),
46+
'image' => PLUGIN_ASSETS_URL . 'mask-shapes/shape-2.svg',
47+
],
48+
];
49+
}
50+
add_filter( 'elementor/mask_shapes/additional_shapes', 'custom_elementor_mask_shapes' );
51+
```
52+
53+
To avoid conflicts with other plugins, shape IDs should be prefixed.
54+
55+
The `PLUGIN_ASSETS_URL` should be updated using `plugin_dir_path( __FILE__ )`, `get_stylesheet_directory_uri()` or any other method that retrieves the assets URL.

src/hooks/php.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Elementor's PHP hooks, both filter hooks and action hooks.
5151
* `elementor/kit/export/manifest-data`
5252
* `elementor/kit/import-export/directory/{$path}`
5353
* `elementor/maintenance_mode/is_login_page`
54+
* [elementor/mask_shapes/additional_shapes](./masks.md)
5455
* [elementor/shapes/additional_shapes](./shapes.md)
5556
* `elementor/schemes/enabled_schemes`
5657
* `elementor/settings/controls/checkbox_list_cpt/post_type_objects`

0 commit comments

Comments
 (0)