Skip to content

Comments

Fix: Ensure Query Loop pagination inherits adjusted query vars & cache variation args#608

Merged
krugazul merged 21 commits into2.1-trunkfrom
2.1-bugherd-fixes
Sep 2, 2025
Merged

Fix: Ensure Query Loop pagination inherits adjusted query vars & cache variation args#608
krugazul merged 21 commits into2.1-trunkfrom
2.1-bugherd-fixes

Conversation

@krugazul
Copy link
Collaborator

@krugazul krugazul commented Sep 2, 2025

Summary

Fixes an issue where Query Loop / pagination pages were not inheriting the adjusted query vars applied by Tour Operator block variations (e.g. featured / related / on-sale / parents-only). Introduces cached processing of query args per core/query block instance so subsequent renders (including pagination, multiple template passes, and nested block re-renders) reuse the same altered args.

Problem

Pagination for Query Loop blocks (and any re-render cycle on the same request) would re-run query_args_filter and, in some cases, lose previously injected modifications (meta_query additions, post__in filtering, parent filters, featured pre-query overrides). This resulted in:

  • Pagination pages ignoring onsale / parents-only filters.
  • Featured / related variations performing extra queries per render.
  • Inconsistent disabling of blocks when no related content exists (first page hidden, subsequent pages still attempted a query).

Key Changes

  • Added $saved_queries property to Query_Loop class to cache processed query args keyed by the core/query queryId.
  • Short-circuit query_args_filter early when a cached set of args exists, ensuring stable inheritance across pagination and repeated renders.
  • Ensures meta_query, post_parent / post_parent__in, post__in, tax_query, and custom lsx_to_featured shadow query linkage persist across requests within the same render cycle.
  • Minor code comments and structural clarification around variation detection.

Affected File(s)

  • includes/classes/blocks/class-query-loop.php
  • changelog.md (Added entry: “Query Block Pagination not Inherting the correct query vars.”)

Detailed Behavior Improvements

Aspect Before After
Pagination filter persistence Modified args recalculated; some flags reset First processed args stored & reused, consistent results
Performance Repeated featured / related subqueries per render Single processing per queryId per request
Disabled state reliability Could inconsistently attempt empty queries Deterministic: once disabled stays disabled for that block instance

Backwards Compatibility

  • No public APIs changed.
  • Only internal class gains a new protected property. Existing filters (lsx_to_*) unchanged.

Testing Steps

  1. Create a Query Loop block variation (e.g. add class on-sale or a featured/related variation) with pagination enabled.
  2. Ensure multiple pages are available (set posts per page low).
  3. Navigate to page 2+ of the loop.
  4. Confirm filtered criteria (e.g. only featured, only on-sale, parents-only) remain applied; item counts remain consistent.
  5. Inspect queries (e.g. via Query Monitor) – meta_query / post__in etc. should match page 1.
  6. For a related variation with no relationships, verify the block is hidden on all pages.

Performance Considerations

Caching removes redundant WP_Query executions for featured detection and related content resolution during a single request, reducing DB load on complex templates with repeated rendering.

Security

No new input surfaces. Uses existing sanitized values. Caching is per-request only (no persistence between requests).

Documentation / Changelog

Changelog updated under 2.1.0 “Fixed” section.

Follow Ups (Optional)

  • Consider resetting $parents_only similar to $onsale after application for explicitness.
  • Add unit test coverage for variation caching + pagination.

Closes: (add issue reference if one exists)

Summary by CodeRabbit

  • New Features

    • Added option to disable links in accommodation facilities.
    • Introduced Wetu map embedding alongside Google Maps.
    • Switched to block-based modal registration; modals now support embedded styles/scripts.
    • Overhauled Travel Information into a rich, card-based pattern with sliders and “Read more” modals.
    • Automatic detection of YouTube videos to rebuild video sliders.
    • Added UI toggle buttons for section visibility.
  • Enhancements

    • Enabled slider dots and dynamic slide counts.
    • Improved “Read more” behaviour when content is absent.
  • Bug Fixes

    • Gallery block outputs nothing when empty.
    • Fixed Query Loop pagination inheriting correct query vars.
  • Documentation

    • Updated coding standards links and structure to GitHub-hosted guides.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 2, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

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.

Warning

Rate limit exceeded

@krugazul has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8992cc5 and f74ce61.

📒 Files selected for processing (15)
  • .github/copilot-wpcs.md (8 hunks)
  • build/custom.asset.php (1 hunks)
  • build/custom.js (1 hunks)
  • build/style-rtl.css (1 hunks)
  • build/style.asset.php (1 hunks)
  • build/style.css (1 hunks)
  • changelog.md (3 hunks)
  • includes/classes/blocks/class-bindings.php (2 hunks)
  • includes/classes/blocks/class-query-loop.php (4 hunks)
  • includes/classes/frontend/class-modals.php (5 hunks)
  • includes/metaboxes/config-post.php (2 hunks)
  • includes/patterns/travel-information.php (1 hunks)
  • includes/template-tags/general.php (2 hunks)
  • src/css/_modals.scss (1 hunks)
  • src/js/custom.js (5 hunks)

Walkthrough

Refactors WETU map URL generation into a helper and updates map rendering to use it. Adds per-block query-args caching, block-driven modal registration via modal-button, a YouTube MutationObserver and slider tweaks, read-more guards, UI toggles, pattern/content updates, CSS spacing tweaks, asset version bumps, and documentation link updates.

Changes

Cohort / File(s) Summary
Documentation & changelog
.github/copilot-wpcs.md, changelog.md
Migrated standards links to GitHub wpcs-docs, reorganised Markdown/JSON sections, added JS inline docs link, updated changelog notes and documented new filter.
Block bindings & map helper
includes/classes/blocks/class-bindings.php
Added public function get_wetu_map_link() and refactored render_map_block to use it; WETU iframe URL construction moved into helper; Google map branch preserves original CSS class.
Query loop caching
includes/classes/blocks/class-query-loop.php
Added protected $saved_queries = []; and per-block (queryId) caching in query_args_filter to avoid repeated processing.
Modals / frontend
includes/classes/frontend/class-modals.php
Switched to modal-button driven registration; added register_button_modal( $block_content, $block ), removed footer-only output, expanded allowed modal HTML, and adjusted modal content registration flow.
Patterns & template tags
includes/patterns/travel-information.php, includes/template-tags/general.php
Replaced travel-information pattern with multi-card, meta-driven layout linking to modals; added apply_filters( 'lsx_to_accommodation_facilities_should_link', true ) to toggle facility links.
Metabox config
includes/metaboxes/config-post.php
Changed top-level metabox shape from id/name/type to title/pages/fields; updated gallery field description.
Source JS
src/js/custom.js
Read-more guards for missing content; enabled slider dots and dynamic slidesToShow; added lsx_to.watch_for_youtube_videos() MutationObserver to debounce/rebuild video slider; added modal init hook and DOM heading toggles.
Source SCSS
src/css/_modals.scss
Added .wp-block-hm-popup .wp-block-template-part p:last-child { margin-bottom: 0; }.
Built assets
build/custom.js, build/style.css, build/style-rtl.css, build/custom.asset.php, build/style.asset.php
Mirrored JS guards and added console.log in build/custom.js; adjusted currency-icon margin rules in build/style.css (then overridden); RTL CSS formatting change only; bumped asset version hashes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User as Viewer
  participant WP as WP Render
  participant Bind as Bindings
  participant Helper as get_wetu_map_link
  participant WETU as WETU Service

  User->>WP: Request page with Map block
  WP->>Bind: render_map_block($block,...)
  Bind->>Helper: get_wetu_map_link(context, post_meta)
  alt Tour / Accommodation / Cluster
    Helper->>WETU: Build Itinerary/EmbedMap URL with IDs
    WETU-->>Helper: URL string
  else Coordinates only
    Helper-->>Bind: Coordinate-centred EmbedMap URL
  end
  Bind-->>WP: Iframe markup (with class preserved for Google maps)
  WP-->>User: Rendered iframe
Loading
sequenceDiagram
  autonumber
  participant WP as Block Renderer
  participant Modals as Modals
  participant Store as modal_contents

  WP->>Modals: render modal-button block
  Modals->>Modals: register_button_modal(block_content, block)
  alt modalId present and not registered
    Modals->>Modals: register_modal_content(slug)
    Modals->>Store: save modal HTML by slug
  end
  Modals-->>WP: return block_content
Loading
sequenceDiagram
  autonumber
  participant DOM as Document
  participant JS as lsx_to
  participant Obs as MutationObserver
  participant Slider as build_video_slider

  DOM->>JS: document.ready -> lsx_to.watch_for_youtube_videos()
  JS->>Obs: observe .lsx-block-videos subtree
  DOM-->>Obs: YouTube iframe inserted
  Obs-->>JS: change detected (debounced 200ms)
  JS->>Slider: rebuild video slider
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

[Type] Bug, [Component] Block Variations

Suggested reviewers

  • ZaredRogers
  • tibiii
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2.1-bugherd-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@github-actions
Copy link

github-actions bot commented Sep 2, 2025

Image description CodeRabbit


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.

@krugazul krugazul requested a review from Copilot September 2, 2025 19:46
@krugazul krugazul self-assigned this Sep 2, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Tour Operator Sep 2, 2025
@krugazul krugazul moved this from Needs Triage to 🏗️ In Progress in Tour Operator Sep 2, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request makes several enhancements to the Tour Operator plugin, focusing on Query Loop pagination, JavaScript slider improvements, template pattern updates, and various bug fixes.

Key changes include:

  • Fixed Query Loop pagination not inheriting correct query variables by implementing caching of processed query args
  • Enhanced JavaScript slider functionality with improved dots display and read-more button validation
  • Updated travel information pattern with improved structure and modal functionality
  • Added filter for controlling facility block links and improved modal handling

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/js/custom.js Added validation checks for read-more functionality and enabled dots display for sliders
src/css/_modals.scss Added styling for template part margin handling in modals
includes/template-tags/general.php Added filter to control facility links and improved HTML structure
includes/patterns/travel-information.php Complete redesign of travel information pattern with improved layout and modal integration
includes/metaboxes/config-post.php Updated media metabox configuration and gallery description
includes/classes/frontend/class-modals.php Enhanced modal system with better button registration and content handling
includes/classes/blocks/class-query-loop.php Fixed pagination inheritance by implementing query caching mechanism
includes/classes/blocks/class-bindings.php Enhanced map block rendering with improved WETU integration
changelog.md Added entries for new features and bug fixes
build/* Updated compiled assets with new version hashes
Comments suppressed due to low confidence (1)

includes/patterns/travel-information.php:1

  • This line appears to contain corrupted HTML content with malformed block comments and mixed content that would break the pattern structure.
<?php

krugazul and others added 3 commits September 2, 2025 21:48
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Warwick Booth <krugazul@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Warwick Booth <krugazul@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Warwick Booth <krugazul@users.noreply.github.com>
@krugazul krugazul merged commit 172deba into 2.1-trunk Sep 2, 2025
3 of 5 checks passed
@krugazul krugazul deleted the 2.1-bugherd-fixes branch September 2, 2025 19:49
@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to ✅ Done in Tour Operator Sep 2, 2025
@krugazul krugazul restored the 2.1-bugherd-fixes branch September 2, 2025 19:49
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 8992cc5 and f74ce61 commits.
Files selected (10)
  • .github/copilot-wpcs.md (8)
  • changelog.md (3)
  • includes/classes/blocks/class-bindings.php (2)
  • includes/classes/blocks/class-query-loop.php (4)
  • includes/classes/frontend/class-modals.php (5)
  • includes/metaboxes/config-post.php (2)
  • includes/patterns/travel-information.php (1)
  • includes/template-tags/general.php (2)
  • src/css/_modals.scss (1)
  • src/js/custom.js (5)
Files not summarized due to errors (10)
  • includes/metaboxes/config-post.php (nothing obtained from openai)
  • includes/patterns/travel-information.php (diff tokens exceeds limit)
  • .github/copilot-wpcs.md (nothing obtained from openai)
  • includes/classes/frontend/class-modals.php (nothing obtained from openai)
  • includes/classes/blocks/class-query-loop.php (nothing obtained from openai)
  • changelog.md (nothing obtained from openai)
  • includes/classes/blocks/class-bindings.php (nothing obtained from openai)
  • includes/template-tags/general.php (nothing obtained from openai)
  • src/js/custom.js (nothing obtained from openai)
  • src/css/_modals.scss (nothing obtained from openai)
Files not reviewed due to errors (9)
  • changelog.md (no response)
  • .github/copilot-wpcs.md (no response)
  • includes/classes/blocks/class-query-loop.php (no response)
  • includes/classes/frontend/class-modals.php (no response)
  • includes/metaboxes/config-post.php (no response)
  • includes/classes/blocks/class-bindings.php (no response)
  • src/js/custom.js (no response)
  • src/css/_modals.scss (no response)
  • includes/template-tags/general.php (no response)
Files skipped from review due to trivial changes (1)
  • includes/patterns/travel-information.php (diff too large)
Review comments generated (0)
  • Review: 0
  • 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.

@ashleyshaw ashleyshaw added this to the 2.1.0 milestone Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants