PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.87
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.87
51.1.87 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 All 41 releases
← All changes | includes/widgets/Woo_Archive_Banner/Woo_Archive_Banner.php +38 -7 51.1.44 → 51.1.87 View file →
@@ -32,9 +32,9 @@
32 32 }
33 33
34 34 public function get_icon(): string
35 35 {
36 - return 'eicon-banner';
36 + return 'king-addons-icon king-addons-woo-archive-banner';
37 37 }
38 38
39 39 public function get_categories(): array
40 40 {
@@ -60,8 +60,9 @@
60 60 'image',
61 61 [
62 62 'label' => esc_html__('Image', 'king-addons'),
63 63 'type' => Controls_Manager::MEDIA,
64 + 'dynamic' => ['active' => true],
64 65 'default' => [
65 66 'url' => Utils::get_placeholder_image_src(),
66 67 ],
67 68 ]
@@ -79,8 +80,9 @@
79 80 'title',
80 81 [
81 82 'label' => esc_html__('Title', 'king-addons'),
82 83 'type' => Controls_Manager::TEXT,
84 + 'dynamic' => ['active' => true],
83 85 'default' => esc_html__('Archive Banner', 'king-addons'),
84 86 ]
85 87 );
86 88
@@ -88,8 +90,9 @@
88 90 'description',
89 91 [
90 92 'label' => esc_html__('Description', 'king-addons'),
91 93 'type' => Controls_Manager::TEXTAREA,
94 + 'dynamic' => ['active' => true],
92 95 'default' => esc_html__('Highlight your category or shop with a banner.', 'king-addons'),
93 96 ]
94 97 );
95 98
@@ -97,8 +100,9 @@
97 100 'button_text',
98 101 [
99 102 'label' => esc_html__('Button Text', 'king-addons'),
100 103 'type' => Controls_Manager::TEXT,
104 + 'dynamic' => ['active' => true],
101 105 'default' => '',
102 106 ]
103 107 );
104 108
@@ -106,8 +110,9 @@
106 110 'button_url',
107 111 [
108 112 'label' => esc_html__('Button URL', 'king-addons'),
109 113 'type' => Controls_Manager::URL,
114 + 'dynamic' => ['active' => true],
110 115 'placeholder' => 'https://',
111 116 ]
112 117 );
113 118
@@ -202,9 +207,13 @@
202 207 }
203 208
204 209 protected function render(): void
205 210 {
206 - if (!is_shop() && !is_product_taxonomy()) {
211 + if (!class_exists('WooCommerce') || !function_exists('is_shop') || !function_exists('is_product_taxonomy')) {
212 + return;
213 + }
214 +
215 + if (!$this->should_render()) {
207 216 $this->render_missing_archive_notice();
208 217 return;
209 218 }
210 219
@@ -220,9 +229,18 @@
220 229 $term_img_id = get_term_meta($term->term_id, 'banner_image', true);
221 230 $term_title = get_term_meta($term->term_id, 'banner_title', true);
222 231 $term_desc = get_term_meta($term->term_id, 'banner_desc', true);
223 232 if ($term_img_id) {
224 - $img_html = Group_Control_Image_Size::get_attachment_image_html($settings, 'image_size', $term_img_id);
233 + // The third argument is the name of a settings key, not an
234 + // attachment id - passing the id made Elementor look up
235 + // $settings[128], warn, and return nothing. Feed it a synthetic
236 + // key so the chosen image size still applies.
237 + $img_settings = $settings;
238 + $img_settings['ka_term_banner_image'] = [
239 + 'id' => (int) $term_img_id,
240 + 'url' => wp_get_attachment_image_url((int) $term_img_id, 'full') ?: '',
241 + ];
242 + $img_html = Group_Control_Image_Size::get_attachment_image_html($img_settings, 'image_size', 'ka_term_banner_image');
225 243 }
226 244 if ($term_title) {
227 245 $title = $term_title;
228 246 }
@@ -250,11 +268,23 @@
250 268 }
251 269 }
252 270
253 271 if (empty($img_html) && !empty($settings['image']['id'])) {
254 - $img_html = Group_Control_Image_Size::get_attachment_image_html($settings, 'image_size', $settings['image']['id']);
272 + $img_html = Group_Control_Image_Size::get_attachment_image_html($settings, 'image_size', 'image');
255 273 }
256 274
275 + // With no image, title, description or button there is nothing but an
276 + // empty shell - which in the editor looks like the widget failed.
277 + $has_button = !empty($settings['button_text']) && !empty($settings['button_url']['url']);
278 + if (!$img_html && '' === trim((string) $title) && '' === trim((string) $desc) && !$has_button) {
279 + if (\Elementor\Plugin::$instance->editor->is_edit_mode()) {
280 + echo '<div class="king-addons-woo-builder-notice">'
281 + . esc_html__('Set a title, description, image or button for the banner.', 'king-addons')
282 + . '</div>';
283 + }
284 + return;
285 + }
286 +
257 287 echo '<div class="ka-woo-archive-banner">';
258 288 if ($img_html) {
259 289 echo '<div class="ka-woo-archive-banner__image">' . $img_html . '</div>';
260 290 }
@@ -264,10 +294,12 @@
264 294 }
265 295 if ($desc) {
266 296 echo '<div class="ka-woo-archive-banner__desc">' . wp_kses_post($desc) . '</div>';
267 297 }
268 - if (!empty($settings['button_text']) && !empty($settings['button_url']['url'])) {
269 - $target = $settings['button_url']['is_external'] ? ' target="_blank" rel="noopener noreferrer"' : '';
298 + if ($has_button) {
299 + // is_external is absent until the author opens the link options, so
300 + // reading it directly warned on a plain URL.
301 + $target = !empty($settings['button_url']['is_external']) ? ' target="_blank" rel="noopener noreferrer"' : '';
270 302 echo '<a class="ka-woo-archive-banner__btn" href="' . esc_url($settings['button_url']['url']) . '"' . $target . '>' . esc_html($settings['button_text']) . '</a>';
271 303 }
272 304 echo '</div>';
273 305 echo '</div>';
@@ -272,9 +304,8 @@
272 304 echo '</div>';
273 305 echo '</div>';
274 306 }
275 307 }
276 -
277 308
278 309
279 310
280 311