Skip to content

Commit

Permalink
Fixing the breadcrumbs - BH 62,72,55
Browse files Browse the repository at this point in the history
  • Loading branch information
krugazul committed Nov 14, 2024
1 parent 6640812 commit be40920
Showing 1 changed file with 48 additions and 40 deletions.
88 changes: 48 additions & 40 deletions includes/classes/legacy/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,41 +424,34 @@ public function accommodation_breadcrumb_links( $crumbs ) {
'url' => get_post_type_archive_link( 'accommodation' ),
),
);
$current_destinations = get_post_meta( get_the_ID(), 'destination_to_accommodation', true );

Check warning on line 427 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L427

Whitespace found at end of line. (Squiz.WhiteSpace.SuperfluousWhitespace-[fixable])
// Get the primary travel style

Check warning on line 428 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L428

Inline comments must end in full-stops, exclamation marks, or question marks. (Squiz.Commenting.InlineComment)
$primary = get_post_meta( get_the_ID(), '_yoast_wpseo_primary_accommodation-type', true );
$primary_term = get_term( $primary, 'accommodation-type' );

$all_destinations = array();
if ( false !== $current_destinations && ! empty( $current_destinations ) ) {

$country = false;
$regions = array();

foreach ( $current_destinations as $current_destination ) {
$all_destinations[] = get_post( $current_destination );
}
if ( ! is_wp_error( $primary_term ) && null !== $primary_term ) {

Check warning on line 432 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L432

Expected 0 spaces after opening bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])

Check warning on line 432 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L432

Expected 0 spaces before closing bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])
$new_crumbs[] = array(
'text' => $primary_term->name,
'url' => get_term_link( $primary_term, 'accommodation-type' ),
);
} else {
$counter = 0;
$terms = wp_get_object_terms( get_the_ID(), 'accommodation-type' );

Check notice on line 439 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L439

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space. (Generic.Formatting.MultipleStatementAlignment-[fixable])
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {

Check warning on line 440 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L440

Expected 0 spaces before closing bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])

Check warning on line 440 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L440

Expected 0 spaces after opening bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])
foreach ( $terms as $term ) {

Check warning on line 441 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L441

Expected 0 spaces after opening bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])

Check warning on line 441 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L441

Expected 0 spaces before closing bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])
if ( 0 < $counter ) {

Check warning on line 442 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L442

Expected 0 spaces before closing bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])

Check warning on line 442 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L442

Expected 0 spaces after opening bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])
continue;
}

//Find the country
foreach ( $all_destinations as $destination_index => $destination ) {
if ( ( 0 === $destination->post_parent || '0' === $destination->post_parent ) && 'publish' === $destination->post_status ) {
$new_crumbs[] = array(
'text' => $destination->post_title,
'url' => get_permalink( $destination->ID ),
'text' => $term->name,
'url' => get_term_link( $term ),
);
unset( $all_destinations[ $destination_index ] );
}
}

//Find the region
if ( ! empty( $all_destinations ) ) {
foreach ( $all_destinations as $destination_index => $destination ) {
if ( 'publish' === $destination->post_status ) {
$new_crumbs[] = array(
'text' => $destination->post_title,
'url' => get_permalink( $destination->ID ),
);
}
$counter++;

Check notice on line 450 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L450

Stand-alone post-increment statement found. Use pre-increment instead: ++$counter. (Universal.Operators.DisallowStandalonePostIncrementDecrement-[fixable])
}
}
}

Check warning on line 454 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L454

Whitespace found at end of line. (Squiz.WhiteSpace.SuperfluousWhitespace-[fixable])
$new_crumbs[] = array(
'text' => get_the_title(),
'url' => get_permalink(),
Expand All @@ -480,29 +473,44 @@ public function tour_breadcrumb_links( $crumbs ) {
'url' => home_url(),
),
array(
'text' => esc_attr__( 'Tour', 'tour-operator' ),
'text' => esc_attr__( 'Tours', 'tour-operator' ),
'url' => get_post_type_archive_link( 'tour' ),
),
);
$region = get_post_meta( get_the_ID(), 'departs_from', true );
if ( false !== $region && isset( $region[0] ) ) {
$country = wp_get_post_parent_id( $region[0] );
if ( false !== $country && '' !== $country ) {
$new_crumbs[] = array(
'text' => get_the_title( $country ),
'url' => get_permalink( $country ),
);
}

// Get the primary travel style

Check warning on line 481 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L481

Inline comments must end in full-stops, exclamation marks, or question marks. (Squiz.Commenting.InlineComment)
$primary = get_post_meta( get_the_ID(), '_yoast_wpseo_primary_travel-style', true );
$primary_term = get_term( $primary, 'travel-style' );

if ( ! is_wp_error( $primary_term ) && null !== $primary_term ) {

Check warning on line 485 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L485

Expected 0 spaces after opening bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])

Check warning on line 485 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L485

Expected 0 spaces before closing bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])
$new_crumbs[] = array(
'text' => get_the_title( $region[0] ),
'url' => get_permalink( $region[0] ),
'text' => $primary_term->name,
'url' => get_term_link( $primary_term, 'travel-style' ),
);
} else {
$counter = 0;
$terms = wp_get_object_terms( get_the_ID(), 'travel-style' );

Check notice on line 492 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L492

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space. (Generic.Formatting.MultipleStatementAlignment-[fixable])
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {

Check warning on line 493 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L493

Expected 0 spaces before closing bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])

Check warning on line 493 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L493

Expected 0 spaces after opening bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])
foreach ( $terms as $term ) {

Check warning on line 494 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L494

Expected 0 spaces before closing bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])

Check warning on line 494 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L494

Expected 0 spaces after opening bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])
if ( 0 < $counter ) {

Check warning on line 495 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L495

Expected 0 spaces after opening bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])

Check warning on line 495 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L495

Expected 0 spaces before closing bracket; 1 found. (Squiz.WhiteSpace.ControlStructureSpacing-[fixable])
continue;
}

$new_crumbs[] = array(
'text' => $term->name,
'url' => get_term_link( $term ),
);
$counter++;

Check notice on line 503 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L503

Stand-alone post-increment statement found. Use pre-increment instead: ++$counter. (Universal.Operators.DisallowStandalonePostIncrementDecrement-[fixable])
}
}
}

Check warning on line 507 in includes/classes/legacy/class-frontend.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/legacy/class-frontend.php#L507

Whitespace found at end of line. (Squiz.WhiteSpace.SuperfluousWhitespace-[fixable])
$new_crumbs[] = array(
'text' => get_the_title(),
'url' => get_permalink(),
);
$crumbs = $new_crumbs;

return $crumbs;
}
}

0 comments on commit be40920

Please sign in to comment.