Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta 2 bugfixes 3 #447

Merged
merged 16 commits into from
Nov 26, 2024
Merged

Beta 2 bugfixes 3 #447

merged 16 commits into from
Nov 26, 2024

Conversation

krugazul
Copy link
Collaborator

@krugazul krugazul commented Nov 26, 2024

Description of the Change

This PR contains the following Bugherd updates.

Fixing the layout of the facilities BH-68
Fixing the rating image BH-51
Fixing the itinerary Image not showing. BH-45

Fixing the target issues #342
Fixing the gallery images BH-56
Fixing the drinks and room basis fields BH-87

Removing the unused frontend functions

  • Layout Functions
  • Compatability checks for LSX
  • Template Tags

Designs

Screenshot 2024-11-26 at 13 40 54
Screenshot 2024-11-26 at 13 40 59
Screenshot 2024-11-26 at 13 41 18

Summary by CodeRabbit

Refactor:

  • Updated class names and core settings for better facilities display.
  • Enhanced handling of facilities, image attributes, and gallery links with added support for customizing link targets in the gallery block.
  • Improved build_slider_lightbox function to dynamically fetch room images and set up the lightbox.
  • Simplified rating function by using specific image paths for full and empty stars.
  • Refactored lsx_to_accommodation_facilities function for improved code readability.

Bug Fix:

  • Added safer handling of gallery data in the query_item array.

Chore:

  • Removed unused frontend functions related to layout, compatibility checks, and template tags.
  • Removed bash script for Gulp tasks.

New Feature:

  • Added debug actions for logging purposes in the query_args_filter function.
  • Expanded and clarified options for 'Drinks Basis' and 'Room Basis' fields for better user understanding.

@krugazul krugazul added the [Type] Bug An existing feature does not function as intended label Nov 26, 2024
@krugazul krugazul added this to the 2.0.0 milestone Nov 26, 2024
@krugazul krugazul self-assigned this Nov 26, 2024
Copy link

coderabbitai bot commented Nov 26, 2024

Warning

CodeRabbit GitHub Action detected

The repository is using both CodeRabbit Pro and CodeRabbit Open Source (via GitHub Actions), which is not recommended as it may lead to duplicate comments and extra noise. Please remove the CodeRabbit GitHub Action.

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Nov 26, 2024

Image description CodeRabbit

Walkthrough

This update brings a significant overhaul to the codebase, focusing on improving readability, maintainability, and performance. It includes changes to class names, block settings, image handling, lightbox setup, rating function, and HTML output. Additionally, it removes unused frontend functions, debug actions, redundant lines, and updates initialization of classes. The update also ensures safer data handling and expands options for better user understanding.

Changes

Files Summary
assets/js/blocks/accommodation.js,
includes/classes/blocks/class-bindings.php,
assets/js/src/custom.js,
includes/classes/legacy/class-accommodation.php,
includes/template-tags/accommodation.php
Renamed classes, updated block settings, improved image handling, lightbox setup, and rating function. Refactored variable declarations and adjusted HTML output.
includes/actions.php,
includes/classes/legacy/class-frontend.php,
tour-operator-bootstrap.php
Removed unused frontend functions related to layout, compatibility checks, and template tags. Altered functionality related to class replacement, archive content, and pagination.
includes/classes/blocks/class-registration.php,
includes/classes/class-tour-operator.php,
includes/classes/legacy/class-admin.php,
includes/classes/legacy/class-tour.php,
includes/classes/legacy/class-unit-query.php
Added debug actions, updated class initialization, removed redundant lines, and ensured safer data handling.
includes/customizer.php,
includes/functions.php,
includes/metaboxes/config-tour.php
Removed color scheme function, modified room data handling, and expanded field options.
bin/build.command Removed bash script for Gulp tasks.

"In the land of code, where logic is king, 🤴

A rabbit hopped in, making changes with a zing. 🐇💥

Unused functions gone, like leaves in the fall, 🍂

Refactoring done, improving it all. 🛠️✨

With safer data handling, and expanded field options too, 📊🔄

The code now sings a tune that's new! 🎵🎉"


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between d9fe389 and 3ea90fd commits.
Files selected (20)
  • assets/js/blocks/accommodation.js (2)
  • assets/js/src/custom.js (1)
  • bin/build.command (1)
  • includes/actions.php (1)
  • includes/classes/admin/class-setup.php (3)
  • includes/classes/blocks/class-bindings.php (3)
  • includes/classes/blocks/class-registration.php (2)
  • includes/classes/class-tour-operator.php (1)
  • includes/classes/legacy/class-accommodation.php (1)
  • includes/classes/legacy/class-admin.php (1)
  • includes/classes/legacy/class-frontend.php (4)
  • includes/classes/legacy/class-tour-operator.php (6)
  • includes/classes/legacy/class-tour.php (2)
  • includes/classes/legacy/class-unit-query.php (2)
  • includes/customizer.php (1)
  • includes/functions.php (9)
  • includes/layout.php (1)
  • includes/metaboxes/config-tour.php (1)
  • includes/template-tags/accommodation.php (2)
  • tour-operator-bootstrap.php (1)
Files ignored due to filter (5)
  • assets/img/rating-star-empty.png
  • assets/img/rating-star-full.png
  • post-types/accommodation.json
  • post-types/destinations.json
  • post-types/tours.json
Files not summarized due to errors (3)
  • includes/classes/admin/class-setup.php (diff tokens exceeds limit)
  • includes/classes/legacy/class-tour-operator.php (diff tokens exceeds limit)
  • includes/layout.php (diff tokens exceeds limit)
Files not reviewed due to errors (7)
  • assets/js/blocks/accommodation.js (no response)
  • includes/classes/legacy/class-accommodation.php (no response)
  • includes/classes/legacy/class-frontend.php (no response)
  • includes/classes/class-tour-operator.php (no response)
  • includes/classes/legacy/class-tour-operator.php (no response)
  • includes/template-tags/accommodation.php (no response)
  • includes/metaboxes/config-tour.php (no response)
Files skipped from review due to trivial changes (7)
  • bin/build.command
  • includes/actions.php
  • includes/classes/blocks/class-bindings.php
  • includes/classes/blocks/class-registration.php
  • includes/classes/legacy/class-admin.php
  • tour-operator-bootstrap.php
  • includes/layout.php (diff too large)
Review comments generated (18)
  • Review: 7
  • LGTM: 11

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +335 to +341
if ( 0 < $( '.wp-block-gallery.has-nested-images' ).length ) {
$( '.wp-block-gallery.has-nested-images' ).slickLightbox( {
caption: function( element, info ) {
return $( element ).find( 'img' ).attr( 'alt' );
}
} );
}

Choose a reason for hiding this comment

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

Image description CodeRabbit

The new code checks if there are any elements with the class .wp-block-gallery.has-nested-images and applies slickLightbox to them. This is a good change as it ensures that the lightbox functionality is only applied when necessary, improving performance.

+ 		if ( 0 <  $( '.wp-block-gallery.has-nested-images' ).length ) {
+ 			$( '.wp-block-gallery.has-nested-images' ).slickLightbox( {
+ 				caption: function( element, info ) {
+ 					return $( element ).find( 'img' ).attr( 'alt' );
+ 				}
+ 			} );
+ 		}

Comment on lines +343 to +356
if ( 0 < $( '.lsx-units-wrapper .unit-image a' ).length ) {
let roomImages = $('.lsx-units-wrapper .unit-image a img').map(function() {
return $(this).attr('src');
}).get();
console.log(roomImages);

$( '.lsx-units-wrapper' ).slickLightbox( {
//images : roomImages,
itemSelector: '.unit-image a',
caption: function( element, info ) {
return $( element ).find( 'img' ).attr( 'alt' );
}
} );
}

Choose a reason for hiding this comment

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

Image description CodeRabbit

This block of code checks for images within a specific wrapper .lsx-units-wrapper .unit-image a and applies slickLightbox to them. However, there's a console.log statement on line 347 which should be removed as it's not a good practice to leave debugging logs in production code.

+ 		if ( 0 <  $( '.lsx-units-wrapper .unit-image a' ).length ) {
+ 			let roomImages = $('.lsx-units-wrapper .unit-image a img').map(function() {
+ 				return $(this).attr('src');
+ 			}).get();
- 			console.log(roomImages);
+ 
+ 			$( '.lsx-units-wrapper' ).slickLightbox( {
+ 				//images : roomImages,
+ 				itemSelector: '.unit-image a',
+ 				caption: function( element, info ) {
+ 					return $( element ).find( 'img' ).attr( 'alt' );
+ 				}
+ 			} );
+ 		}

Comment on lines +178 to +348
$allowedtags['div']['data-type'] = true;
$allowedtags['div']['data-cluster-small'] = true;
$allowedtags['div']['data-cluster-medium'] = true;
$allowedtags['div']['data-cluster-large'] = true;
$allowedtags['div']['data-fusion-tables'] = true;
$allowedtags['div']['data-fusion-tables-colour-border'] = true;
$allowedtags['div']['data-fusion-tables-width-border'] = true;
$allowedtags['div']['data-fusion-tables-colour-background'] = true;
$allowedtags['div']['itemscope'] = true;
$allowedtags['div']['itemtype'] = true;
$allowedtags['div']['data-row-height'] = true;
$allowedtags['div']['data-justified-margins'] = true;
$allowedtags['div']['data-slick'] = true;

//Envirta Gallery tags
//
$allowedtags['div']['data-envira-id'] = true;
$allowedtags['div']['data-gallery-config'] = true;
$allowedtags['div']['data-gallery-images'] = true;
$allowedtags['div']['data-gallery-theme'] = true;
$allowedtags['div']['data-envira-columns'] = true;

if ( ! isset( $allowedtags['img'] ) ) {
$allowedtags['img'] = array();
}

$allowedtags['img']['data-envira-index'] = true;
$allowedtags['img']['data-envira-caption'] = true;
$allowedtags['img']['data-envira-gallery-id'] = true;
$allowedtags['img']['data-envira-item-id'] = true;
$allowedtags['img']['data-envira-src'] = true;
$allowedtags['img']['data-envira-srcset'] = true;

if ( ! isset( $allowedtags['input'] ) ) {
$allowedtags['input'] = array();
}

$allowedtags['input']['type'] = true;
$allowedtags['input']['id'] = true;
$allowedtags['input']['name'] = true;
$allowedtags['input']['value'] = true;
$allowedtags['input']['size'] = true;
$allowedtags['input']['checked'] = true;
$allowedtags['input']['onclick'] = true;
$allowedtags['input']['class'] = true;
$allowedtags['input']['placeholder'] = true;
$allowedtags['input']['autocomplete'] = true;

if ( ! isset( $allowedtags['select'] ) ) {
$allowedtags['select'] = array();
}

$allowedtags['select']['name'] = true;
$allowedtags['select']['id'] = true;
$allowedtags['select']['disabled'] = true;
$allowedtags['select']['onchange'] = true;

if ( ! isset( $allowedtags['option'] ) ) {
$allowedtags['option'] = array();
}

$allowedtags['option']['value'] = true;
$allowedtags['option']['selected'] = true;

if ( ! isset( $allowedtags['iframe'] ) ) {
$allowedtags['iframe'] = array();
}

$allowedtags['iframe']['src'] = true;
$allowedtags['iframe']['width'] = true;
$allowedtags['iframe']['height'] = true;
$allowedtags['iframe']['frameborder'] = true;
$allowedtags['iframe']['allowfullscreen'] = true;
$allowedtags['iframe']['style'] = true;

if ( ! isset( $allowedtags['noscript'] ) ) {
$allowedtags['noscript'] = array();
}

return $allowedtags;
}

/**
* Allow extra protocols to wp_kses_post()
*/
public function kses_allowed_protocols( $allowedprotocols ) {
$allowedprotocols[] = 'tel';

return $allowedprotocols;
}

/**
* Allow extra style attributes to wp_kses_post()
*/
public function safe_style_css( $allowedstyles ) {
$allowedstyles[] = 'display';
$allowedstyles[] = 'background-image';

return $allowedstyles;
}

Choose a reason for hiding this comment

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

Image description CodeRabbit

The wp_kses_allowed_html function is used to allow extra tags and attributes for the wp_kses_post() function. This is a good practice for security reasons, as it allows you to control what HTML elements and attributes are allowed. However, this list seems quite extensive and could potentially open up for vulnerabilities if not all of these tags and attributes are strictly necessary for your application. I would recommend reviewing this list and removing any tags or attributes that are not needed.

Also, it's important to note that allowing certain attributes like onclick (line 292) can potentially lead to XSS attacks if user input is not properly sanitized before being used in these attributes. Make sure that any data used in these attributes is properly sanitized before use.

- $allowedtags['input']['onclick'] = true;

Lastly, there is no newline at the end of the file (line 348). While this won't cause any issues with PHP, it's generally considered good practice to end a file with a newline.

+ 

Comment on lines 43 to 48
*/
public $search_fields = false;

/**
* Holds the meal plan options
*
* @var array
*/
public $room_basis = array();

/**
* Holds the meal plan options
*
* @var array
*/
public $drinks_basis = array();

/**
* Initialize the plugin by setting localization, filters, and
* administration functions.

Choose a reason for hiding this comment

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

Image description CodeRabbit

The removal of $room_basis and $drinks_basis arrays seems to be a significant change. Ensure that these arrays are not used elsewhere in the codebase, or this could lead to undefined variable errors. If they are used elsewhere, consider providing a fallback or handling for their absence.

@@ -212,7 +212,7 @@ public function item_thumbnail() {
$thumbnail_src = false;
$thumbnail_src = apply_filters( 'lsx_to_accommodation_room_thumbnail', $thumbnail_src );
if ( $this->have_query && false !== $this->query_item && ! empty( $this->query_item ) ) {
if ( false !== $this->query_item['gallery'] ) {
if ( isset( $this->query_item['gallery'] ) && ! empty( $this->query_item['gallery'] ) ) {

Choose a reason for hiding this comment

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

Image description CodeRabbit

The new code checks if the 'gallery' key is present and not empty in $this->query_item before proceeding, which is a good practice to avoid potential PHP warnings or errors. This change improves error handling.

- if ( false !== $this->query_item['gallery'] ) {
+ if ( isset( $this->query_item['gallery'] ) && ! empty( $this->query_item['gallery'] ) ) {

@@ -234,7 +234,7 @@
if ( $this->have_query && false !== $this->query_item ) {
$images_return = array();

if ( isset( $this->query_item['gallery'] ) && false !== $this->query_item['gallery'] ) {
if ( isset( $this->query_item['gallery'] ) && ! empty( $this->query_item['gallery'] ) ) {

Choose a reason for hiding this comment

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

Image description CodeRabbit

Similar to the previous comment, this change also improves error handling by checking for the presence and non-emptiness of the 'gallery' key in $this->query_item.

- if ( isset( $this->query_item['gallery'] ) && false !== $this->query_item['gallery'] ) {
+ if ( isset( $this->query_item['gallery'] ) && ! empty( $this->query_item['gallery'] ) ) {

Comment on lines 610 to 614
*/
function lsx_to_accommodation_reset_units_loop() {
global $rooms;

return $rooms->reset_loop();
}

Choose a reason for hiding this comment

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

Image description CodeRabbit

The removal of the SCP Order Uninstall hook and related functions in this hunk is a significant change. If these functions are no longer needed, this is fine. However, if they are still required, their removal could cause issues. Please ensure that this uninstall functionality is either not needed or implemented elsewhere.

+  function lsx_to_accommodation_reset_units_loop() {
+  	global $rooms;
+  	return $rooms->reset_loop();
+  }

Copy link
Contributor

@ZaredRogers ZaredRogers left a comment

Choose a reason for hiding this comment

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

Looks good, thanks Warwick

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 3ea90fd and 708f1fa commits.
Files selected (1)
  • includes/classes/legacy/class-accommodation.php (1)
Review comments generated (3)
  • Review: 3
  • LGTM: 0

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +176 to +184
$ratings_array[] = '<figure class="wp-block-image size-large is-resized">';
$ratings_array[] = '<img src="';
if ( (int) $value > 0 ) {
$ratings_array[] = '<i class="fa fa-star"></i>';
$ratings_array[] = LSX_TO_URL . 'assets/img/rating-star-full.png';
} else {
$ratings_array[] = '<i class="fa fa-star-o"></i>';
$ratings_array[] = LSX_TO_URL . 'assets/img/rating-star-empty.png';
}
$ratings_array[] = '" alt="" style="width:20px;vertical-align:sub;">';
$ratings_array[] = '</figure>';

Choose a reason for hiding this comment

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

Image description CodeRabbit

The new code is using hardcoded image paths for the rating stars. This could be problematic if the images are moved or their names are changed. It would be better to define these paths as constants or configuration settings, so they can be easily updated in one place if necessary.

- $ratings_array[] = LSX_TO_URL . 'assets/img/rating-star-full.png';
+ $ratings_array[] = defined('RATING_STAR_FULL') ? RATING_STAR_FULL : LSX_TO_URL . 'assets/img/rating-star-full.png';

- $ratings_array[] = LSX_TO_URL . 'assets/img/rating-star-empty.png';
+ $ratings_array[] = defined('RATING_STAR_EMPTY') ? RATING_STAR_EMPTY : LSX_TO_URL . 'assets/img/rating-star-empty.png';

$rating_description = ' <small>(' . $rating_type . ')</small>';
}
$html = $before . implode( '', $ratings_array ) . $rating_description . $after;
do_action( 'qm/debug', [ $html ] );

Choose a reason for hiding this comment

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

Image description CodeRabbit

The debug action do_action( 'qm/debug', [ $html ] ); seems to be left from debugging and should be removed for production code.

- do_action( 'qm/debug', [ $html ] );

Comment on lines 186 to 188
$counter --;
$value --;
}

Choose a reason for hiding this comment

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

Image description CodeRabbit

The decrement of $counter and $value variables is not protected by any condition. If $value becomes negative, it will still continue to decrement until $counter reaches 0. This might lead to unexpected behavior. Consider adding a condition to break the loop when $value is less than or equal to 0.

- $counter --;
- $value --;
+ if ($value > 0) {
+     $counter--;
+     $value--;
+ } else {
+     break;
+ }

@krugazul krugazul merged commit d07b42e into 2.0-beta-2 Nov 26, 2024
6 of 7 checks passed
@krugazul krugazul deleted the beta-2-bugfixes-2 branch November 26, 2024 12:00
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 708f1fa and abb957f commits.
Files selected (2)
  • includes/classes/legacy/class-accommodation.php (1)
  • includes/template-tags/accommodation.php (2)
Files skipped from review due to trivial changes (1)
  • includes/classes/legacy/class-accommodation.php
Review comments generated (2)
  • Review: 2
  • LGTM: 0

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +117 to +121
$args = [];
$facilities = wp_get_object_terms( get_the_ID(), 'facility' );
$main_facilities = [];
$child_facilities = [];
$return = '';

Choose a reason for hiding this comment

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

Image description CodeRabbit

The refactoring of the variable initialization is a good improvement. It makes the code cleaner and more readable.

-	$facilities = wp_get_object_terms( get_the_ID(), 'facility' );
-	$main_facilities = array();
-	$child_facilities = array();
-	$return = '';
+ 	$args             = [];
+ 	$facilities       = wp_get_object_terms( get_the_ID(), 'facility' );
+ 	$main_facilities  = [];
+ 	$child_facilities = [];
+ 	$return           = '';

Comment on lines +134 to +149
$return .= '<div class="' . $heading->slug . ' wp-block-columns is-layout-flex wp-block-columns-is-layout-flex">';
foreach ( $main_facilities as $heading ) {
if ( isset( $child_facilities[ $heading->term_id ] ) ) {
$return .= '<div class="' . $heading->slug . ' col-xs-12 col-sm-6"><div class="facilities-content"><h5 class="facilities-title"><a href="' . esc_url( get_term_link( $heading->slug, 'facility' ) ) . '">' . esc_html( $heading->name ) . '</a></h5>';
$return .= '<ul class="facilities-list">';
$return .= '<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<p class="has-medium-font-size facilities-title wp-block-heading"><a href="' . esc_url( get_term_link( $heading->slug, 'facility' ) ) . '">' . esc_html( $heading->name ) . '</a></h5>';
$return .= '<ul class="facilities-list wp-block-list">';

foreach ( $child_facilities[ $heading->term_id ] as $child_facility ) {
$return .= '<li class="facility-item"><a href="' . esc_url( get_term_link( $child_facility->slug, 'facility' ) ) . '">' . esc_html( $child_facility->name ) . '</a></li>';
}

$return .= '</ul>';
$return .= '</div></div>';
$return .= '</div>';
}
}
$return .= '</div>';

Choose a reason for hiding this comment

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

Image description CodeRabbit

The changes made to the HTML structure and class names seem to be for styling purposes. However, there's a mismatch in the opening and closing tags on line 138. The opening tag is <p> but the closing tag is </h5>. This should be corrected to maintain proper HTML structure.

- 	$return .= '<div class="' . $heading->slug . ' col-xs-12 col-sm-6"><div class="facilities-content"><h5 class="facilities-title"><a href="' . esc_url( get_term_link( $heading->slug, 'facility' ) ) . '">' . esc_html( $heading->name ) . '</a></h5>';
+ 	$return .= '<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
+ 	<p class="has-medium-font-size facilities-title wp-block-heading"><a href="' . esc_url( get_term_link( $heading->slug, 'facility' ) ) . '">' . esc_html( $heading->name ) . '</a></h5>';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants