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
← All changes | includes/widgets/Woo_Archive_Description/Woo_Archive_Description.php +46 -7 51.1.44 → 51.1.86 View file →
@@ -30,9 +30,9 @@
30 30 }
31 31
32 32 public function get_icon(): string
33 33 {
34 - return 'eicon-editor-paragraph';
34 + return 'king-addons-icon king-addons-woo-archive-description';
35 35 }
36 36
37 37 public function get_categories(): array
38 38 {
@@ -38,8 +38,22 @@
38 38 {
39 39 return ['king-addons-woo-builder'];
40 40 }
41 41
42 + /**
43 + * Script handles.
44 + *
45 + * ModulesMap registers this file, but without declaring the dependency here
46 + * Elementor never enqueues it - the "Read more" toggle had no script behind
47 + * it on the page.
48 + *
49 + * @return array<int,string>
50 + */
51 + public function get_script_depends(): array
52 + {
53 + return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-archive-description-script'];
54 + }
55 +
42 56 public function get_style_depends(): array
43 57 {
44 58 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-archive-description-style'];
45 59 }
@@ -67,8 +81,9 @@
67 81 'read_more_text',
68 82 [
69 83 'label' => esc_html__('Read more text (Pro)', 'king-addons'),
70 84 'type' => Controls_Manager::TEXT,
85 + 'dynamic' => ['active' => true],
71 86 'default' => esc_html__('Read more', 'king-addons'),
72 87 ]
73 88 );
74 89
@@ -99,8 +114,9 @@
99 114 'custom_text',
100 115 [
101 116 'label' => esc_html__('Custom text', 'king-addons'),
102 117 'type' => Controls_Manager::TEXTAREA,
118 + 'dynamic' => ['active' => true],
103 119 'rows' => 4,
104 120 'condition' => [
105 121 'source' => 'custom',
106 122 ],
@@ -152,9 +168,13 @@
152 168 }
153 169
154 170 protected function render(): void
155 171 {
156 - if (!is_shop() && !is_product_taxonomy()) {
172 + if (!class_exists('WooCommerce') || !function_exists('is_shop') || !function_exists('is_product_taxonomy')) {
173 + return;
174 + }
175 +
176 + if (!$this->should_render()) {
157 177 $this->render_missing_archive_notice();
158 178 return;
159 179 }
160 180
@@ -173,11 +193,20 @@
173 193 }
174 194 }
175 195
176 196 if (empty($desc)) {
197 + // Nothing to show is a legitimate state, but a blank widget in the
198 + // editor reads as a fault.
199 + if (\Elementor\Plugin::$instance->editor->is_edit_mode()) {
200 + echo '<div class="king-addons-woo-builder-notice">'
201 + . esc_html__('The description comes from the shop page or the category being viewed.', 'king-addons')
202 + . '</div>';
203 + }
177 204 return;
178 205 }
179 206
207 + $full_desc = $desc;
208 +
180 209 $trim = !empty($settings['trim_words']) && $can_pro ? (int) $settings['trim_words'] : 0;
181 210 $trimmed = false;
182 211 if ($trim > 0) {
183 212 $trimmed = true;
@@ -194,17 +223,27 @@
194 223 $settings['format']
195 224 );
196 225 }
197 226
198 - echo '<div class="ka-woo-archive-description">';
199 - echo wp_kses_post($desc);
200 - if ($trimmed && !empty($settings['read_more_text']) && $can_pro) {
201 - echo '<a class="ka-woo-archive-description__readmore" href="#">' . esc_html($settings['read_more_text']) . '</a>';
227 + $has_more = $trimmed && !empty($settings['read_more_text']) && $can_pro;
228 +
229 + echo '<div class="ka-woo-archive-description"' . ($has_more ? ' data-ka-expandable="1"' : '') . '>';
230 + echo '<div class="ka-woo-archive-description__short">' . wp_kses_post($desc) . '</div>';
231 +
232 + if ($has_more) {
233 + // The link was an href="#" with no behaviour behind it: clicking
234 + // "Read more" jumped to the top of the page and never revealed
235 + // anything. The full text ships alongside, hidden until asked for -
236 + // and only when the toggle exists, so the page never carries the
237 + // same paragraph twice for nothing.
238 + echo '<div class="ka-woo-archive-description__full" hidden>' . wp_kses_post($full_desc) . '</div>';
239 + echo '<button type="button" class="ka-woo-archive-description__readmore" aria-expanded="false">'
240 + . esc_html($settings['read_more_text']) . '</button>';
202 241 }
242 +
203 243 echo '</div>';
204 244 }
205 245 }
206 -
207 246
208 247
209 248
210 249