PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.63
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.63
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.63, at includes/widgets/TB_404_Description/TB_404_Description.php

279 lines 7.2 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 'eicon-editor-paragraph';
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'];
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 'default' => esc_html__('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'king-addons'),
144 ]
145 );
146
147 $this->add_control(
148 'kng_preset',
149 [
150 'label' => $is_pro ?
151 esc_html__('Text Preset', 'king-addons') :
152 sprintf(__('Text Preset %s', 'king-addons'), '<i class="eicon-pro-icon"></i>'),
153 'type' => Controls_Manager::SELECT,
154 'options' => [
155 '' => esc_html__('None', 'king-addons'),
156 'friendly' => esc_html__('Friendly', 'king-addons'),
157 'concise' => esc_html__('Concise', 'king-addons'),
158 ],
159 'default' => '',
160 'classes' => $is_pro ? '' : 'king-addons-pro-control',
161 ]
162 );
163
164 $this->end_controls_section();
165 }
166
167 /**
168 * Style controls.
169 *
170 * @param bool $is_pro Whether Pro is enabled.
171 *
172 * @return void
173 */
174 protected function register_style_controls(bool $is_pro): void
175 {
176 $this->start_controls_section(
177 'kng_style_section',
178 [
179 'label' => esc_html__('Style', 'king-addons'),
180 'tab' => Controls_Manager::TAB_STYLE,
181 ]
182 );
183
184 $this->add_group_control(
185 Group_Control_Typography::get_type(),
186 [
187 'name' => 'kng_typography',
188 'selector' => '{{WRAPPER}} .king-addons-tb-404-description',
189 ]
190 );
191
192 $this->add_control(
193 'kng_color',
194 [
195 'label' => esc_html__('Color', 'king-addons'),
196 'type' => Controls_Manager::COLOR,
197 'selectors' => [
198 '{{WRAPPER}} .king-addons-tb-404-description' => 'color: {{VALUE}};',
199 ],
200 ]
201 );
202
203 $this->add_responsive_control(
204 'kng_alignment',
205 [
206 'label' => esc_html__('Alignment', 'king-addons'),
207 'type' => Controls_Manager::CHOOSE,
208 'options' => [
209 'left' => [
210 'title' => esc_html__('Left', 'king-addons'),
211 'icon' => 'eicon-text-align-left',
212 ],
213 'center' => [
214 'title' => esc_html__('Center', 'king-addons'),
215 'icon' => 'eicon-text-align-center',
216 ],
217 'right' => [
218 'title' => esc_html__('Right', 'king-addons'),
219 'icon' => 'eicon-text-align-right',
220 ],
221 ],
222 'selectors' => [
223 '{{WRAPPER}} .king-addons-tb-404-description' => 'text-align: {{VALUE}};',
224 ],
225 ]
226 );
227
228 $this->end_controls_section();
229 }
230
231 /**
232 * Pro upsell.
233 *
234 * @return void
235 */
236 protected function register_pro_notice_controls(): void
237 {
238 if (king_addons_freemius()->can_use_premium_code__premium_only()) {
239 return;
240 }
241
242 Core::renderProFeaturesSection(
243 $this,
244 '',
245 Controls_Manager::RAW_HTML,
246 'tb-404-description',
247 [
248 'Preset texts and playful variants',
249 ]
250 );
251 }
252
253 /**
254 * Render output helper.
255 *
256 * @param array<string, mixed> $settings Settings.
257 * @param bool $is_pro Pro flag.
258 *
259 * @return void
260 */
261 protected function render_output(array $settings, bool $is_pro): void
262 {
263 $text = $settings['kng_text'] ?? '';
264 if ($is_pro && !empty($settings['kng_preset'])) {
265 if ('friendly' === $settings['kng_preset']) {
266 $text = esc_html__('Oops! We cannot find that page right now.', 'king-addons');
267 } elseif ('concise' === $settings['kng_preset']) {
268 $text = esc_html__('This page does not exist.', 'king-addons');
269 }
270 }
271
272 if ('' === trim((string) $text)) {
273 return;
274 }
275
276 echo '<div class="king-addons-tb-404-description">' . wp_kses_post($text) . '</div>';
277 }
278 }
279