|
| 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. |
0 commit comments