PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.86
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.86
51.1.86 51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 All 40 releases
king-addons / includes / widgets / TB_404_Description / TB_404_Description.php

TB_404_Description.php in King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder 51.1.86, at includes/widgets/TB_404_Description/TB_404_Description.php

288 lines 7.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Theme Builder 404 Description widget (Free).
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Controls_Manager;
11 use Elementor\Group_Control_Typography;
12 use Elementor\Widget_Base;
13
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17
18 /**
19 * Shows descriptive text on 404 pages.
20 */
21 class TB_404_Description extends Widget_Base
22 {
23 /**
24 * Widget slug.
25 *
26 * @return string
27 */
28 public function get_name(): string
29 {
30 return 'king-addons-tb-404-description';
31 }
32
33 /**
34 * Widget title.
35 *
36 * @return string
37 */
38 public function get_title(): string
39 {
40 return esc_html__('TB - 404 Description', 'king-addons');
41 }
42
43 /**
44 * Widget icon.
45 *
46 * @return string
47 */
48 public function get_icon(): string
49 {
50 return 'king-addons-icon king-addons-tb-404-description';
51 }
52
53 /**
54 * Style dependencies.
55 *
56 * @return array<int, string>
57 */
58 public function get_style_depends(): array
59 {
60 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-tb-404-description-style'];
61 }
62
63 /**
64 * Script dependencies.
65 *
66 * @return array<int, string>
67 */
68 public function get_script_depends(): array
69 {
70 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-tb-404-description-script'];
71 }
72
73 /**
74 * Categories.
75 *
76 * @return array<int, string>
77 */
78 public function get_categories(): array
79 {
80 return ['king-addons-theme-builder'];
81 }
82
83 /**
84 * Keywords.
85 *
86 * @return array<int, string>
87 */
88 public function get_keywords(): array
89 {
90 return ['404', 'description', 'error', 'king-addons'];
91 }
92
93 public function get_custom_help_url()
94 {
95 return 'mailto:[email protected]?subject=Bug Report - King Addons&body=Please describe the issue';
96 }
97
98 /**
99 * Register controls.
100 *
101 * @return void
102 */
103 public function register_controls(): void
104 {
105 $this->register_content_controls(false);
106 $this->register_style_controls(false);
107 $this->register_pro_notice_controls();
108 }
109
110 /**
111 * Render output.
112 *
113 * @return void
114 */
115 public function render(): void
116 {
117 $settings = $this->get_settings_for_display();
118 $this->render_output($settings, false);
119 }
120
121 /**
122 * Content controls.
123 *
124 * @param bool $is_pro Whether Pro is enabled.
125 *
126 * @return void
127 */
128 protected function register_content_controls(bool $is_pro): void
129 {
130 $this->start_controls_section(
131 'kng_content_section',
132 [
133 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Content', 'king-addons'),
134 'tab' => Controls_Manager::TAB_CONTENT,
135 ]
136 );
137
138 $this->add_control(
139 'kng_text',
140 [
141 'label' => esc_html__('Text', 'king-addons'),
142 'type' => Controls_Manager::TEXTAREA,
143 'dynamic' => ['active' => true],
144 'default' => esc_html__('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'king-addons'),
145 ]
146 );
147
148 $this->add_control(
149 'kng_preset',
150 [
151 'label' => $is_pro ?
152 esc_html__('Text Preset', 'king-addons') :
153 sprintf(__('Text Preset %s', 'king-addons'), '<i class="eicon-pro-icon"></i>'),
154 'type' => Controls_Manager::SELECT,
155 'options' => [
156 '' => esc_html__('None', 'king-addons'),
157 'friendly' => esc_html__('Friendly', 'king-addons'),
158 'concise' => esc_html__('Concise', 'king-addons'),
159 ],
160 'default' => '',
161 'classes' => $is_pro ? '' : 'king-addons-pro-control',
162 ]
163 );
164
165 $this->end_controls_section();
166 }
167
168 /**
169 * Style controls.
170 *
171 * @param bool $is_pro Whether Pro is enabled.
172 *
173 * @return void
174 */
175 protected function register_style_controls(bool $is_pro): void
176 {
177 $this->start_controls_section(
178 'kng_style_section',
179 [
180 'label' => esc_html__('Style', 'king-addons'),
181 'tab' => Controls_Manager::TAB_STYLE,
182 ]
183 );
184
185 $this->add_group_control(
186 Group_Control_Typography::get_type(),
187 [
188 'name' => 'kng_typography',
189 'selector' => '{{WRAPPER}} .king-addons-tb-404-description',
190 ]
191 );
192
193 $this->add_control(
194 'kng_color',
195 [
196 'label' => esc_html__('Color', 'king-addons'),
197 'type' => Controls_Manager::COLOR,
198 'selectors' => [
199 '{{WRAPPER}} .king-addons-tb-404-description' => 'color: {{VALUE}};',
200 ],
201 ]
202 );
203
204 $this->add_responsive_control(
205 'kng_alignment',
206 [
207 'label' => esc_html__('Alignment', 'king-addons'),
208 'type' => Controls_Manager::CHOOSE,
209 'options' => [
210 'left' => [
211 'title' => esc_html__('Left', 'king-addons'),
212 'icon' => 'eicon-text-align-left',
213 ],
214 'center' => [
215 'title' => esc_html__('Center', 'king-addons'),
216 'icon' => 'eicon-text-align-center',
217 ],
218 'right' => [
219 'title' => esc_html__('Right', 'king-addons'),
220 'icon' => 'eicon-text-align-right',
221 ],
222 ],
223 'selectors_dictionary' => [
224 'left' => 'text-align: left; margin-inline: 0 auto;',
225 'center' => 'text-align: center; margin-inline: auto;',
226 'right' => 'text-align: right; margin-inline: auto 0;',
227 ],
228 'selectors' => [
229 // The block carries a readable max-width and is centred by
230 // default, so text-align alone cannot move it - the author
231 // picked "left" and the paragraph stayed in the middle.
232 '{{WRAPPER}} .king-addons-tb-404-description' => '{{VALUE}}',
233 ],
234 ]
235 );
236
237 $this->end_controls_section();
238 }
239
240 /**
241 * Pro upsell.
242 *
243 * @return void
244 */
245 protected function register_pro_notice_controls(): void
246 {
247 if (king_addons_freemius()->can_use_premium_code__premium_only()) {
248 return;
249 }
250
251 Core::renderProFeaturesSection(
252 $this,
253 '',
254 Controls_Manager::RAW_HTML,
255 'tb-404-description',
256 [
257 'Preset texts and playful variants',
258 ]
259 );
260 }
261
262 /**
263 * Render output helper.
264 *
265 * @param array<string, mixed> $settings Settings.
266 * @param bool $is_pro Pro flag.
267 *
268 * @return void
269 */
270 protected function render_output(array $settings, bool $is_pro): void
271 {
272 $text = $settings['kng_text'] ?? '';
273 if ($is_pro && !empty($settings['kng_preset'])) {
274 if ('friendly' === $settings['kng_preset']) {
275 $text = esc_html__('Oops! We cannot find that page right now.', 'king-addons');
276 } elseif ('concise' === $settings['kng_preset']) {
277 $text = esc_html__('This page does not exist.', 'king-addons');
278 }
279 }
280
281 if ('' === trim((string) $text)) {
282 return;
283 }
284
285 echo '<div class="king-addons-tb-404-description">' . wp_kses_post($text) . '</div>';
286 }
287 }
288