PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.1.2
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.1.2
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 / dynamic / wrapper-link / wrapper-link.php

wrapper-link.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.1.2, at inc/modules/dynamic/wrapper-link/wrapper-link.php

94 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Modules\Dynamic;
4
5 use \Elementor\Controls_Manager;
6 use \Elementor\Element_Base;
7
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 if (!class_exists('MasterAddons\Modules\Dynamic\WrapperLink')) {
13 class WrapperLink
14 {
15 private static $instance = null;
16
17 private function __construct()
18 {
19 add_action('elementor/element/container/section_layout/after_section_end', [$this, 'add_controls_section'], 1);
20 add_action('elementor/element/column/section_advanced/after_section_end', [$this, 'add_controls_section'], 1);
21 add_action('elementor/element/section/section_advanced/after_section_end', [$this, 'add_controls_section'], 1);
22 add_action('elementor/element/common/_section_style/after_section_end', [$this, 'add_controls_section'], 1);
23
24 add_action('elementor/frontend/before_render', [$this, 'before_render'], 1);
25 }
26
27 public function add_controls_section(Element_Base $element)
28 {
29 $tabs = Controls_Manager::TAB_CONTENT;
30
31 if (in_array($element->get_name(), ['section', 'column', 'container'])) {
32 $tabs = Controls_Manager::TAB_LAYOUT;
33 }
34
35 $element->start_controls_section(
36 'jltma_section_wrapper_link',
37 [
38 'label' => esc_html__('Wrapper Link', 'master-addons') . JLTMA_EXTENSION_BADGE,
39 'tab' => $tabs,
40 ]
41 );
42
43 $element->add_control(
44 'jltma_section_element_link',
45 [
46 'label' => esc_html__('Link', 'master-addons'),
47 'type' => Controls_Manager::URL,
48 'dynamic' => [
49 'active' => true,
50 ],
51 'placeholder' => 'https://example.com',
52 ]
53 );
54
55 $element->end_controls_section();
56 }
57
58 public function before_render(Element_Base $element)
59 {
60 $link_settings = $element->get_settings_for_display('jltma_section_element_link');
61
62 if (empty($link_settings['url'])) {
63 return;
64 }
65
66 $link_settings['url'] = esc_url($link_settings['url'] ?? '');
67 unset($link_settings['custom_attributes']);
68
69 if ($link_settings && !empty($link_settings['url'])) {
70 $element->add_render_attribute(
71 '_wrapper',
72 [
73 'data-jltma-wrapper-link' => wp_json_encode($link_settings),
74 'style' => 'cursor: pointer'
75 ]
76 );
77
78 // Enqueue module script when wrapper link is used
79 wp_enqueue_script('master-addons-wrapper-link');
80 }
81 }
82
83 public static function get_instance()
84 {
85 if (!self::$instance) {
86 self::$instance = new self;
87 }
88 return self::$instance;
89 }
90 }
91 }
92
93 WrapperLink::get_instance();
94