Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/bdthemes-element-pack/modules/hash-link/module.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
namespace ElementPack\Modules\HashLink;
4
+
5
+
use Elementor\Controls_Manager;
6
+
use Elementor\Plugin;
7
+
use ElementPack\Base\Element_Pack_Module_Base;
8
+
9
+
if (!defined('ABSPATH')) exit; // Exit if accessed directly
10
+
11
+
class Module extends Element_Pack_Module_Base {
12
+
13
+
public function __construct() {
14
+
parent::__construct();
15
+
$this->add_actions();
16
+
}
17
+
18
+
public function get_name() {
19
+
return 'bdt-hash-link';
20
+
}
21
+
22
+
public function register_controls($page) {
23
+
$pro_lock = bdt_get_widget_badge( str_replace( 'bdt-', '', $this->get_name() ) );
24
+
25
+
$page->start_controls_section(
26
+
'element_pack_hash_link_section',
27
+
[
28
+
'tab' => Controls_Manager::TAB_SETTINGS,
29
+
'label' => BDTEP_CP . esc_html__('Hash Link', 'bdthemes-element-pack') . $pro_lock,
30
+
]
31
+
);
32
+
33
+
$page->add_control(
34
+
'ep_hash_link_enable',
35
+
[
36
+
'label' => esc_html__('Hash Link?', 'bdthemes-element-pack'),
37
+
'type' => Controls_Manager::SWITCHER,
38
+
'render_type' => 'template',
39
+
]
40
+
);
41
+
42
+
$page->add_control(
43
+
'ep_hash_link_notes',
44
+
[
45
+
'type' => Controls_Manager::RAW_HTML,
46
+
'raw' => esc_html__('Note: This feature will not work on Editor Mode. Please check on the Preview Page.', 'bdthemes-element-pack'),
47
+
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
48
+
'condition' => [
49
+
'ep_hash_link_enable' => 'yes'
50
+
],
51
+
]
52
+
);
53
+
54
+
$page->add_control(
55
+
'ep_hash_link_container',
56
+
[
57
+
'label' => esc_html__('Container Class', 'bdthemes-element-pack'),
58
+
'type' => Controls_Manager::TEXT,
59
+
'dynamic' => [
60
+
'active' => true,
61
+
],
62
+
'placeholder' => '.elementor',
63
+
'label_block' => true,
64
+
'condition' => [
65
+
'ep_hash_link_enable' => 'yes'
66
+
],
67
+
]
68
+
);
69
+
70
+
$page->add_control(
71
+
'ep_hash_link_selector',
72
+
[
73
+
'label' => esc_html__('Selector', 'bdthemes-element-pack'),
74
+
'type' => Controls_Manager::SELECT2,
75
+
'multiple' => true,
76
+
'options' => [
77
+
'h1' => esc_html__('h1', 'bdthemes-element-pack'),
78
+
'h2' => esc_html__('h2', 'bdthemes-element-pack'),
79
+
'h3' => esc_html__('h3', 'bdthemes-element-pack'),
80
+
'h4' => esc_html__('h4', 'bdthemes-element-pack'),
81
+
'h5' => esc_html__('h5', 'bdthemes-element-pack'),
82
+
'h6' => esc_html__('h6', 'bdthemes-element-pack'),
83
+
],
84
+
'condition' => [
85
+
'ep_hash_link_enable' => 'yes'
86
+
],
87
+
]
88
+
);
89
+
90
+
$page->add_control(
91
+
'ep_hash_link_color',
92
+
[
93
+
'label' => esc_html__('Color', 'bdthemes-element-pack'),
94
+
'type' => Controls_Manager::COLOR,
95
+
'selectors' => [
96
+
'.ep-hash-link .ep-hash-link-inner-el' => 'color: {{VALUE}} !important;',
97
+
],
98
+
'condition' => [
99
+
'ep_hash_link_enable' => 'yes'
100
+
],
101
+
]
102
+
);
103
+
104
+
$page->add_control(
105
+
'ep_hash_link_color_hover',
106
+
[
107
+
'label' => esc_html__('Color Hover', 'bdthemes-element-pack'),
108
+
'type' => Controls_Manager::COLOR,
109
+
'selectors' => [
110
+
'.ep-hash-link:hover .ep-hash-link-inner-el' => 'color: {{VALUE}} !important;',
111
+
],
112
+
'condition' => [
113
+
'ep_hash_link_enable' => 'yes'
114
+
],
115
+
]
116
+
);
117
+
118
+
$page->end_controls_section();
119
+
}
120
+
121
+
public function should_script_enqueue() {
122
+
123
+
if (Plugin::instance()->editor->is_edit_mode() || Plugin::instance()->preview->is_preview_mode()) {
124
+
return;
125
+
}
126
+
127
+
$document = Plugin::instance()->documents->get(get_the_ID());
128
+
129
+
if (!$document) {
130
+
return;
131
+
}
132
+
133
+
$hash_link_enable = $document->get_settings('ep_hash_link_enable');
134
+
135
+
if ('yes' !== $hash_link_enable) {
136
+
return;
137
+
}
138
+
139
+
$container = $document->get_settings('ep_hash_link_container');
140
+
141
+
if (empty($container)) {
142
+
$container = '.elementor';
143
+
}
144
+
145
+
$selector = $document->get_settings('ep_hash_link_selector');
146
+
147
+
if (empty($selector)) {
148
+
return;
149
+
}
150
+
151
+
$selector = implode(", ", $selector);
152
+
153
+
$data = [
154
+
'container' => $container,
155
+
'selector' => $selector,
156
+
'new_tab' => 'yes',
157
+
];
158
+
159
+
?>
160
+
<div id="ep-hash-link" data-settings='<?php echo wp_json_encode($data); ?>' style="display:none;"></div>
161
+
<?php
162
+
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
163
+
wp_enqueue_script('ep-hash-link', BDTEP_ASSETS_URL . '/js/modules/ep-hash-link' . $suffix . '.js', ['jquery'], BDTEP_VER, true);
164
+
}
165
+
166
+
protected function add_actions() {
167
+
add_action('elementor/documents/register_controls', [$this, 'register_controls'], 1, 1);
168
+
add_action('wp_body_open', [$this, 'should_script_enqueue']);
169
+
}
170
+
}
171
+