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 Round 3 #450

Merged
merged 11 commits into from
Dec 3, 2024
Merged

Beta 2 - Bugfixes Round 3 #450

merged 11 commits into from
Dec 3, 2024

Conversation

krugazul
Copy link
Collaborator

@krugazul krugazul commented Dec 3, 2024

Description of the Change

The following PR contains a third round of bug fixes as well as a some items to close off some issues.

Alternate Designs

Itinerary Read More
Screenshot 2024-12-03 at 13 39 53

Rooms showing a currency symbol
Screenshot 2024-12-03 at 15 58 54

Images sizes showing via the Regenerate Thumbnails plugin
Screenshot 2024-12-03 at 12 42 13

Related Tours with fixed currency
Screenshot 2024-12-03 at 16 00 23

Related Accommodation card with fixed currency.
Screenshot 2024-12-03 at 16 01 37

Verification Process (once deployed)

Summary by CodeRabbit

  • New Feature: Introduced a new "TO Gallery" block in WordPress for enhanced content management and display.
  • Refactor: Updated block names and icons for Gallery, Price, and More Button blocks to improve user experience in the WordPress editor.
  • Refactor: Enhanced read more functionality for tour itineraries with improved handling of content wrappers and show/hide conditions.
  • New Feature: Added image sizes configuration to the Setup class, allowing better control over image display.
  • Bug Fix: Improved handling of currency display and unit field values for consistency across the platform.
  • Refactor: Modified item_thumbnail method to accept size parameter, providing flexibility in image retrieval.
  • Style: Adjusted CSS styling and class names for better layout and element presentation.

@krugazul krugazul added [Type] Bug An existing feature does not function as intended [Type] Enhancement A suggestion for improvement labels Dec 3, 2024
@krugazul krugazul added this to the 2.0.0 milestone Dec 3, 2024
@krugazul krugazul self-assigned this Dec 3, 2024
Copy link

coderabbitai bot commented Dec 3, 2024

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 Dec 3, 2024

Image description CodeRabbit

Walkthrough

This update introduces enhancements to the WordPress editor, including new block configurations and improved handling of image sizes. It also refines CSS styling and HTML structure for better layout and presentation. Additionally, it optimizes function signatures and logic related to content display, and includes debugging improvements.

Changes

Files Summary
assets/css/scss/_icons.scss, assets/css/scss/_slider.scss, includes/patterns/room-card.php Introduced a new CSS class .unit-price-wrapper and updated class names in the HTML structure for better styling and layout.
assets/js/blocks/general.js, assets/js/src/custom.js, includes/classes/admin/class-setup.php, includes/classes/blocks/class-bindings.php, includes/classes/blocks/class-registration.php, includes/classes/legacy/class-accommodation.php, includes/classes/legacy/class-unit-query.php Enhanced block configurations in the WordPress editor, improved handling of image sizes, optimized function signatures and logic related to content display, and added debugging improvements.
includes/patterns/gallery.php Added a new array configuration for a "TO Gallery" block in WordPress with defined title, description, categories, template types, and content structure.

🐰💻

In the land of code, where the semicolons grow,

A rabbit hopped, tweaking as it goes.

With each key press, a change unfurls,

In the world of WordPress, where creativity swirls.

Blocks enhanced, images resized,

Debugging improved, nothing disguised.

Celebrate the changes, for they're here to stay,

In the land of code, where the rabbits play. 🎉🥕


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 d07b42e and 5319270 commits.
Files selected (13)
  • assets/css/scss/_icons.scss (1)
  • assets/css/scss/_slider.scss (1)
  • assets/css/style.css (2)
  • assets/js/blocks/general.js (3)
  • assets/js/src/custom.js (4)
  • includes/classes/admin/class-setup.php (3)
  • includes/classes/blocks/class-bindings.php (6)
  • includes/classes/blocks/class-registration.php (5)
  • includes/classes/legacy/class-accommodation.php (1)
  • includes/classes/legacy/class-unit-query.php (1)
  • includes/patterns/gallery.php (1)
  • includes/patterns/room-card.php (3)
  • includes/template-tags/helpers.php (1)
Files ignored due to filter (1)
  • vendor/cmb-field-select2/cmb-field-select2.php
Files not summarized due to errors (1)
  • assets/css/style.css (diff tokens exceeds limit)
Files not reviewed due to errors (4)
  • includes/classes/legacy/class-unit-query.php (no response)
  • includes/classes/blocks/class-bindings.php (no response)
  • includes/classes/legacy/class-accommodation.php (no response)
  • assets/css/style.css (no response)
Files skipped from review due to trivial changes (5)
  • assets/css/scss/_icons.scss
  • assets/css/scss/_slider.scss
  • assets/js/blocks/general.js
  • includes/classes/blocks/class-registration.php
  • includes/patterns/gallery.php
Review comments generated (12)
  • Review: 11
  • LGTM: 1

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 +54 to +80
lsx_to.readMoreSet( $(this), $(this).closest( '.wp-block-group' ).find('.wp-block-post-content') );
} );

$( '.single-tour-operator .wp-block-read-more' ).on( 'click', function( event ) {
event.preventDefault();
$( this ).hide();

if ( $( this ).hasClass( 'less-link' ) ) {
lsx_to.readMoreSet($( this ));
lsx_to.readMoreSet( $(this), $(this).closest( '.wp-block-group' ).find('.wp-block-post-content') );
} else {
lsx_to.readMoreOpen($( this ));
lsx_to.readMoreOpen( $(this), $(this).closest( '.wp-block-group' ).find('.wp-block-post-content') );
}

$( this ).show();
} );
};

lsx_to.readMoreSet = function( button ) {
let contentWrapper = button.closest( '.wp-block-group' ).find('.wp-block-post-content');
lsx_to.readMoreSet = function( button, contentWrapper ) {
console.log(contentWrapper);
console.log(contentWrapper.length);
if ( 0 < contentWrapper.length ) {
if ( 1 < contentWrapper.find('p').length ) {
if ( 1 < contentWrapper.children().length ) {

var limit = 1;
let counter = 0;

contentWrapper.find('p').each( function() {
contentWrapper.children().each( function() {
Copy link

Choose a reason for hiding this comment

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

Image description CodeRabbit

The use of console.log statements on lines 72 and 73 should be removed as they are likely used for debugging purposes and should not be present in production code. Also, the logic to hide elements based on a counter and limit could be optimized by using jQuery's :gt() selector which selects elements with an index greater than a number.

- console.log(contentWrapper);
- console.log(contentWrapper.length);
- if ( 0 < contentWrapper.length ) {
-     if ( 1 < contentWrapper.children().length ) {
-         var limit = 1;
-         let counter = 0;
-         contentWrapper.children().each( function() {
-             if ( limit <= counter ) {
-                 $(this).hide();
-             }
-             counter++;
-         });
-     }
- }
+ if (contentWrapper && contentWrapper.children().length > 1) {
+     contentWrapper.children(':gt(0)').hide();
+ }

Comment on lines +91 to +101
} else {
button.hide();
}
}

lsx_to.readMoreOpen = function( button ) {
let contentWrapper = button.closest( '.wp-block-group' ).find('.wp-block-post-content p');
if ( 0 < contentWrapper.length ) {
contentWrapper.each( function() {
$(this).show();
lsx_to.readMoreOpen = function( button, contentWrapper ) {
if ( 0 < contentWrapper.children().length ) {
contentWrapper.children().each( function() {
if ( ! $(this).hasClass('wp-block-read-more') ) {
$(this).show();
}
Copy link

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 is fine, but it would be better to check if the button exists before trying to hide it or change its text. This will prevent potential errors if the button does not exist.

- } else {
-     button.hide();
- }
+ } else if (button) {
+     button.hide();
+ }

Comment on lines +121 to 135
lsx_to.readMoreSet( $(this), $(this).closest( '.additional-info' ).find('.content') );
} );

$( '.single-tour-operator .additional-info .lsx-to-more-link' ).on( 'click', function( event ) {
event.preventDefault();
$( this ).hide();

if ( $( this ).hasClass( 'less-link' ) ) {
lsx_to.readMoreSetTI($( this ));
lsx_to.readMoreSet( $(this), $(this).closest( '.additional-info' ).find('.content') );
} else {
lsx_to.readMoreOpenTI($( this ));
lsx_to.readMoreOpenTI( $(this), $(this).closest( '.additional-info' ).find('.content') );
}

$( this ).show();
} );
Copy link

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, it would be better to check if the element exists before trying to hide it or perform operations on it.

- $( this ).hide();
+ if ($(this)) {
+     $(this).hide();
+ }

Comment on lines +148 to +164
$( '.single-tour-operator .lsx-itinerary-wrapper .wp-block-read-more' ).each( function() {
$(this).show();
lsx_to.readMoreItinText = $(this).find('a').text();
lsx_to.readMoreSet( $(this), $(this).parent( 'div' ).find('.itinerary-description') );
} );

$( '.single-tour-operator .lsx-itinerary-wrapper .wp-block-read-more' ).on( 'click', function( event ) {
event.preventDefault();
$( this ).hide();

$( this ).parents( '#itinerary' ).find( '.itinerary-item.hidden' ).each( function() {
$( this ).removeClass( 'hidden' );
} );
if ( $( this ).hasClass( 'less-link' ) ) {
lsx_to.readMoreSet( $(this), $(this).parent( 'div' ).find('.itinerary-description') );
} else {
lsx_to.readMoreOpen( $(this), $(this).parent( 'div' ).find('.itinerary-description') );
}

$( this ).show();
Copy link

Choose a reason for hiding this comment

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

Image description CodeRabbit

Again, it would be better to check if the element exists before trying to hide it or perform operations on it.

- $( this ).hide();
+ if ($(this)) {
+     $(this).hide();
+ }

@@ -378,7 +353,7 @@
$document.ready( function() {
lsx_to.set_read_more();
lsx_to.set_read_more_travel_info();
//lsx_to.set_read_more_itinerary();
lsx_to.set_read_more_itinerary();
Copy link

Choose a reason for hiding this comment

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

Image description CodeRabbit

This line is fine as it is. It's just calling a function when the document is ready, which is a common practice in jQuery.

- lsx_to.set_read_more_itinerary();
+ lsx_to.set_read_more_itinerary();

Comment on lines +381 to +405

/**
* Register the image sizes with WordPress
*
* @return void
*/
public function register_image_sizes() {
foreach ( $this->image_sizes as $key => $params ) {
add_image_size( $key, $params['width'], $params['height'], $params['crop'] );
}
}

/**
* The array of image sizes from WordPress
*
* @param array $sizes
* @return array
*/
public function editor_image_sizes( $sizes ) {
$new_sizes = [];
foreach ( $this->image_sizes as $key => $params ) {
$new_sizes[ $key ] = $params['title'];
}
return array_merge( $sizes, $new_sizes );
}
Copy link

Choose a reason for hiding this comment

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

Image description CodeRabbit

This code registers the image sizes with WordPress and adds them to the editor options. It's a good practice to check if the $params['title'] exists before using it to avoid PHP notices.

	public function editor_image_sizes( $sizes ) {
		$new_sizes = [];
		foreach ( $this->image_sizes as $key => $params ) {
			if (isset($params['title'])) {
				$new_sizes[ $key ] = $params['title'];
			}
		}
		return array_merge( $sizes, $new_sizes );
	}

Comment on lines +287 to 289
$value = array_filter($value);
$value = implode( ', ', $value );
}
Copy link

Choose a reason for hiding this comment

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

Image description CodeRabbit

The addition of array_filter before imploding the array is a good practice as it removes any empty or false values from the array. This can prevent issues where you might end up with extra commas due to empty values in your final string.

+    $value = array_filter($value);
     $value = implode( ', ', $value );

This change improves the robustness of the code by ensuring that only meaningful data (non-empty values) are processed.

Comment on lines +38 to +39
<!-- wp:group {"className":"unit-type-wrapper","style":{"spacing":{"margin":{"top":"0","bottom":"0"},"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group unit-type-wrapper" style="margin-top:0;margin-bottom:0"><!-- wp:group {"style":{"spacing":{"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap","verticalAlignment":"top"}} -->
Copy link

Choose a reason for hiding this comment

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

Image description CodeRabbit

The class name has been changed from itin-type-wrapper to unit-type-wrapper. This change should be fine as long as it is consistent across all the files and the new class unit-type-wrapper is defined in the CSS with the required properties. If not, it might break the styling.

- <!-- wp:group {"className":"itin-type-wrapper","style":{"spacing":{"margin":{"top":"0","bottom":"0"},"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
- <div class="wp-block-group itin-type-wrapper" style="margin-top:0;margin-bottom:0">
+ <!-- wp:group {"className":"unit-type-wrapper","style":{"spacing":{"margin":{"top":"0","bottom":"0"},"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
+ <div class="wp-block-group unit-type-wrapper" style="margin-top:0;margin-bottom:0">

Comment on lines +54 to +55
<!-- wp:group {"className":"unit-price-wrapper","style":{"spacing":{"margin":{"top":"0","bottom":"0"},"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group unit-price-wrapper" style="margin-top:0;margin-bottom:0"><!-- wp:group {"style":{"spacing":{"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap","verticalAlignment":"top"}} -->
Copy link

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, the class name has been changed from itin-type-wrapper to unit-price-wrapper. Ensure that this change is consistent across all the files and the new class unit-price-wrapper is defined in the CSS with the required properties.

- <!-- wp:group {"className":"itin-type-wrapper","style":{"spacing":{"margin":{"top":"0","bottom":"0"},"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
- <div class="wp-block-group itin-type-wrapper" style="margin-top:0;margin-bottom:0">
+ <!-- wp:group {"className":"unit-price-wrapper","style":{"spacing":{"margin":{"top":"0","bottom":"0"},"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
+ <div class="wp-block-group unit-price-wrapper" style="margin-top:0;margin-bottom:0">

@@ -63,7 +63,7 @@
<!-- /wp:group -->

<!-- wp:group {"style":{"spacing":{"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:paragraph {"className":"unit-price","style":{"elements":{"link":{"color":{"text":"var:preset|color|primary-700"}}},"spacing":{"padding":{"top":"2px","bottom":"2px"}}},"textColor":"primary-700"} -->
<div class="wp-block-group"><!-- wp:paragraph {"className":"unit-price amount","style":{"elements":{"link":{"color":{"text":"var:preset|color|primary-700"}}},"spacing":{"padding":{"top":"2px","bottom":"2px"}}},"textColor":"primary-700"} -->
Copy link

Choose a reason for hiding this comment

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

Image description CodeRabbit

The class name amount has been added to the paragraph element. This change should be fine as long as it is consistent across all the files and the new class amount is defined in the CSS with the required properties.

- <p class="unit-price has-primary-700-color has-text-color has-link-color" style="padding-top:2px;padding-bottom:2px"></p>
+ <p class="unit-price amount has-primary-700-color has-text-color has-link-color" style="padding-top:2px;padding-bottom:2px"></p>

@Justinabes007 Justinabes007 merged commit 16b7739 into 2.0-beta-2 Dec 3, 2024
6 of 8 checks passed
@Justinabes007 Justinabes007 deleted the beta-2-bugfixes-3 branch December 3, 2024 14:09
@krugazul krugazul mentioned this pull request Dec 3, 2024
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 [Type] Enhancement A suggestion for improvement
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Parent: Tour Operator Plugin Tasks Titles and Descriptions for Meta and Custom Fields
2 participants