PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.1.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.1.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / inc / modules / display / image-masking / image-masking.php

image-masking.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.1.9, at inc/modules/display/image-masking/image-masking.php

100 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Add image masking support to some specific widgets
5 *
6 * @package Master_Addons
7 */
8
9 namespace MasterAddons\Modules\Display;
10
11 use Elementor\Widget_Base;
12 use MasterAddons\Inc\Controls\Group_Control_Mask_Image;
13
14 defined('ABSPATH') || die();
15
16 if (!class_exists('MasterAddons\Modules\Display\Image_Masking')) {
17 class Image_Masking
18 {
19
20 public static function init()
21 {
22 add_action('elementor/element/image/section_image/before_section_end', [__CLASS__, 'add_controls']);
23 add_action('elementor/element/image-box/section_image/before_section_end', [__CLASS__, 'add_controls']);
24 add_action('elementor/element/ha-card/_section_image/before_section_end', [__CLASS__, 'add_controls']);
25 add_action('elementor/element/ha-infobox/_section_media/before_section_end', [__CLASS__, 'add_controls']);
26 add_action('elementor/element/ha-promo-box/_section_title/before_section_end', [__CLASS__, 'add_controls']);
27 add_action('elementor/element/ha-member/_section_info/before_section_end', [__CLASS__, 'add_controls']);
28 }
29
30 /**
31 * @param Widget_Base $element
32 */
33 public static function add_controls(Widget_Base $element)
34 {
35
36 $args = self::widget_to_args_map($element->get_name());
37
38 $element->start_injection([
39 'type' => 'control',
40 'at' => 'after',
41 'of' => $args['of'],
42 ]);
43
44 $element->add_group_control(
45 Group_Control_Mask_Image::get_type(),
46 [
47 'name' => 'image_masking',
48 'selector' => '{{WRAPPER}} ' . $args['selector'],
49 'condition' => $args['condition'],
50 ]
51 );
52
53 $element->end_injection();
54 }
55
56 /**
57 * @param string $widget_name
58 * @return mixed
59 */
60 public static function widget_to_args_map($widget_name = '')
61 {
62 $map = [
63 'image' => [
64 'of' => 'image',
65 'selector' => '.elementor-image',
66 'condition' => []
67 ],
68 'image-box' => [
69 'of' => 'image',
70 'selector' => '.elementor-image-box-img',
71 'condition' => []
72 ],
73 'ha-card' => [
74 'of' => 'image',
75 'selector' => '.ha-card-figure img',
76 'condition' => []
77 ],
78 'ha-infobox' => [
79 'of' => 'image',
80 'selector' => '.ha-infobox-figure.ha-infobox-figure--image',
81 'condition' => [
82 'type' => 'image'
83 ]
84 ],
85 'ha-promo-box' => [
86 'of' => 'image',
87 'selector' => '.ha-promo-box-thumb',
88 'condition' => []
89 ],
90 'ha-member' => [
91 'of' => 'image',
92 'selector' => '.ha-member-figure',
93 'condition' => []
94 ]
95 ];
96
97 return $map[$widget_name];
98 }
99 }
100 }