Skip to content

Commit 8585382

Browse files
update
1 parent 48b2280 commit 8585382

File tree

2 files changed

+49
-25
lines changed

2 files changed

+49
-25
lines changed

inc/helper.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,14 @@ function aae_addon_breadcrumbs($tag = 'div', $separator = ' » ')
465465
{
466466
global $post;
467467

468-
echo '<' . $tag . ' class="aae-breadcrumbs"><a href="' . esc_url(home_url()) . '">' . esc_html__('Home', 'animation-addons-for-elementor') . '</a>';
468+
// Fallback for separator
469+
$separator = $separator ?? ' &raquo; ';
470+
471+
echo '<' . esc_html($tag) . ' class="aae-breadcrumbs">';
472+
echo '<a href="' . esc_url(home_url()) . '">' . esc_html__('Home', 'animation-addons-for-elementor') . '</a>';
469473

470474
if (is_front_page()) {
471-
echo '</div>';
475+
echo '</' . esc_html($tag) . '>';
472476
return;
473477
}
474478

@@ -478,7 +482,8 @@ function aae_addon_breadcrumbs($tag = 'div', $separator = ' &raquo; ')
478482
$cat = get_the_category();
479483
if (!empty($cat)) {
480484
$category = $cat[0];
481-
$parents = get_category_parents($category, true, $separator);
485+
// Avoid deprecated warning
486+
$parents = get_category_parents($category, true, wp_kses_post($separator));
482487
echo wp_kses_post($parents);
483488
}
484489

@@ -492,11 +497,17 @@ function aae_addon_breadcrumbs($tag = 'div', $separator = ' &raquo; ')
492497

493498
while ($parent_id) {
494499
$page = get_post($parent_id);
495-
$breadcrumbs[] = '<a href="' . esc_url(get_permalink($page->ID)) . '">' . esc_html(get_the_title($page->ID)) . '</a>';
496-
$parent_id = $page->post_parent;
500+
if ($page) {
501+
$breadcrumbs[] = '<a href="' . esc_url(get_permalink($page->ID)) . '">' . esc_html(get_the_title($page->ID)) . '</a>';
502+
$parent_id = $page->post_parent;
503+
} else {
504+
break;
505+
}
497506
}
498507

499-
echo wp_kses_post(implode($separator, array_reverse($breadcrumbs)) . $separator);
508+
if (!empty($breadcrumbs)) {
509+
echo wp_kses_post(implode(wp_kses_post($separator), array_reverse($breadcrumbs)) . wp_kses_post($separator));
510+
}
500511
}
501512

502513
echo esc_html(get_the_title());
@@ -523,11 +534,15 @@ function aae_addon_breadcrumbs($tag = 'div', $separator = ' &raquo; ')
523534
echo esc_html(post_type_archive_title('', false));
524535
} elseif (is_tax() || is_tag() || is_category()) {
525536
$term = get_queried_object();
526-
if ($term->parent) {
537+
if (!empty($term) && property_exists($term, 'parent') && $term->parent) {
527538
$parent_term = get_term($term->parent, $term->taxonomy);
528-
echo '<a href="' . esc_url(get_term_link($parent_term)) . '">' . esc_html($parent_term->name) . '</a>' . wp_kses_post($separator);
539+
if (!is_wp_error($parent_term)) {
540+
echo '<a href="' . esc_url(get_term_link($parent_term)) . '">' . esc_html($parent_term->name) . '</a>' . wp_kses_post($separator);
541+
}
542+
}
543+
if (!empty($term) && property_exists($term, 'name')) {
544+
echo esc_html($term->name);
529545
}
530-
echo esc_html($term->name);
531546
} elseif (is_day()) {
532547
echo esc_html(get_the_date('F j, Y'));
533548
} elseif (is_month()) {
@@ -545,6 +560,6 @@ function aae_addon_breadcrumbs($tag = 'div', $separator = ' &raquo; ')
545560
echo esc_html__('404 - Page not found', 'animation-addons-for-elementor');
546561
}
547562

548-
echo '</' . $tag . '>';
563+
echo '</' . esc_html($tag) . '>';
549564
}
550565
}

widgets/breadcrumbs.php

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function get_keywords()
4848

4949
protected function register_controls()
5050
{
51-
51+
// Content Section
5252
$this->start_controls_section(
5353
'section_breadcrumbs_content',
5454
[
@@ -69,7 +69,6 @@ protected function register_controls()
6969
);
7070

7171
if (! class_exists('\WPSEO_Breadcrumbs')) {
72-
7372
$this->add_control(
7473
'warning_text',
7574
[
@@ -79,7 +78,8 @@ protected function register_controls()
7978
]
8079
);
8180

82-
$this->end_controls_section();
81+
$this->end_controls_section(); // Ends section early if Yoast is not active
82+
return; // Prevent further controls from being registered
8383
}
8484

8585
$this->add_responsive_control(
@@ -125,7 +125,6 @@ protected function register_controls()
125125
'html_description',
126126
[
127127
'raw' => sprintf(
128-
/* translators: 1: Link opening tag, 2: Link closing tag. */
129128
esc_html__('Additional settings are available in the Yoast SEO %1$sBreadcrumbs Panel%2$s', 'animation-addons-for-elementor'),
130129
sprintf('<a href="%s" target="_blank">', admin_url('admin.php?page=wpseo_titles#top#breadcrumbs')),
131130
'</a>'
@@ -138,11 +137,11 @@ protected function register_controls()
138137
$this->add_control(
139138
'br_separator',
140139
[
141-
'label' => esc_html__('Seprator Text', 'animation-addons-for-elementor'),
142-
'type' => Controls_Manager::TEXT,
143-
'default' => ' &raquo; ',
144-
'placeholder' => esc_html__('Seprator text', 'animation-addons-for-elementor'),
145-
'condition' => [
140+
'label' => esc_html__('Separator Text', 'animation-addons-for-elementor'),
141+
'type' => Controls_Manager::TEXT,
142+
'default' => ' &raquo; ',
143+
'placeholder' => esc_html__('Separator text', 'animation-addons-for-elementor'),
144+
'condition' => [
146145
'yoast_seo!' => 'yes'
147146
]
148147
]
@@ -152,22 +151,22 @@ protected function register_controls()
152151
'sep_description',
153152
[
154153
'raw' => sprintf(
155-
/* translators: 1: Link opening tag, 2: Link closing tag. */
156154
esc_html__('You can use HTML entities as separators. Check out %1$sHTML Symbols%2$s for examples.', 'animation-addons-for-elementor'),
157155
sprintf('<a href="%s" target="_blank">', 'https://www.toptal.com/designers/htmlarrows/symbols/'),
158156
'</a>'
159157
),
160158
'type' => Controls_Manager::RAW_HTML,
161159
'content_classes' => 'elementor-descriptor',
162-
'condition' => [
160+
'condition' => [
163161
'yoast_seo!' => 'yes'
164162
]
165163
]
166164
);
167165

166+
$this->end_controls_section(); // END CONTENT SECTION
168167

169-
$this->end_controls_section();
170168

169+
// Style Section
171170
$this->start_controls_section(
172171
'section_style',
173172
[
@@ -201,6 +200,7 @@ protected function register_controls()
201200

202201
$this->start_controls_tabs('tabs_breadcrumbs_style');
203202

203+
// Normal Tab
204204
$this->start_controls_tab(
205205
'tab_color_normal',
206206
[
@@ -222,6 +222,7 @@ protected function register_controls()
222222

223223
$this->end_controls_tab();
224224

225+
// Hover Tab
225226
$this->start_controls_tab(
226227
'tab_color_hover',
227228
[
@@ -240,9 +241,15 @@ protected function register_controls()
240241
]
241242
);
242243

243-
$this->end_controls_section();
244+
$this->end_controls_tab();
245+
246+
// ✅ THIS WAS MISSING!
247+
$this->end_controls_tabs();
248+
249+
$this->end_controls_section(); // END STYLE SECTION
244250
}
245251

252+
246253
private function get_html_tag()
247254
{
248255
$html_tag = $this->get_settings('html_tag');
@@ -258,10 +265,12 @@ protected function render()
258265
{
259266
$settings = $this->get_settings_for_display();
260267
$html_tag = $this->get_html_tag();
261-
if (class_exists('\WPSEO_Breadcrumbs') && $settings['yoast_seo'] == 'yes') {
268+
269+
if (class_exists('\WPSEO_Breadcrumbs') && $settings['yoast_seo'] === 'yes') {
262270
WPSEO_Breadcrumbs::breadcrumb('<' . $html_tag . ' id="breadcrumbs">', '</' . $html_tag . '>');
263271
} else {
264-
aae_addon_breadcrumbs($html_tag, $settings['br_separator']);
272+
$separator = isset($settings['br_separator']) ? $settings['br_separator'] : ' &raquo; ';
273+
aae_addon_breadcrumbs($html_tag, $separator);
265274
}
266275
}
267276
}

0 commit comments

Comments
 (0)