Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
- **Accommodation price display** - Added price information to single accommodation template with improved layout for better presentation
- **Rating stars styling** - Added new styles for rating stars display with improved spacing and alignment in accommodation info section

#### Itinerary

- **Itinerary connected field term list** - Fixed term list retrieval in `lsx_to_itinerary_connected_field()` by normalising the data array with `array_values()` before extracting the first element, ensuring `get_the_term_list()` always receives a valid post ID rather than a potentially non-zero-indexed array offset

#### Query Loops & Filtering

- **Query Block Class Detection** - Improved reliability of query block class detection by checking `innerHTML` instead of `attrs['className']`, ensuring custom classes like `on-sale`, `parents-only`, and `custom-order` are properly detected even when applied via block variations or programmatically
Expand Down
6 changes: 5 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ function lsx_to_itinerary_connected_field( $field, $type, $before = '', $after =
$data = (array) $data;

if ( $term_list ) {
$return = get_the_term_list( $data[0], $type, $before, ', ', $after );
$first_term = array_values( $data );
if ( is_array( $first_term ) && ! empty( $first_term ) ) {
$first_term = $first_term[0];
}
$return = get_the_term_list( $first_term, $type, $before, ', ', $after );
Comment on lines +318 to +322

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable $first_term is misleadingly named because it actually holds a post ID (which is passed as the first argument to get_the_term_list()), not a term.

Additionally, the conditional checks is_array( $first_term ) and ! empty( $first_term ) are redundant. Since $data is guaranteed to be a non-empty array at this point (due to the empty( $data ) check on line 311 and the (array) cast on line 315), array_values( $data ) will always return a non-empty array.

We can simplify this code significantly by directly retrieving the first element of the array values and using a clearer variable name like $post_id.

		$post_id = array_values( $data )[0];
		$return  = get_the_term_list( $post_id, $type, $before, ', ', $after );

} else {
$return = $before . lsx_to_connected_list( $data, $type, true, ', ' ) . $after;
}
Expand Down
Loading