Conversation
…itional registration for destination specific posts/pages - Updated additional-info, banking, climate, cuisine, dress, electricity, health and transport blocks to include proper descriptions and editor previews - Added support for translations using the __() function for block titles and content.
|
Warning CodeRabbit GitHub Action detectedThe 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. Note Other AI code review bot(s) detectedCodeRabbit 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. Note
|
| Cohort / File(s) | Summary |
|---|---|
Block manifests enrichment src/blocks/additional-info/block.json, src/blocks/banking/block.json, src/blocks/climate/block.json, src/blocks/cuisine/block.json, src/blocks/dress/block.json, src/blocks/electricity/block.json, src/blocks/health/block.json, src/blocks/transport/block.json |
Added metadata fields to each block.json: textdomain ("tour-operator"), description, icon, and keywords array. Added example structures demonstrating nested innerBlocks (group containing heading and paragraph). No functional changes to block registration. |
Block variation registration refactoring src/blocks/additional-info/index.js, src/blocks/banking/index.js, src/blocks/climate/index.js, src/blocks/cuisine/index.js, src/blocks/dress/index.js, src/blocks/electricity/index.js, src/blocks/health/index.js, src/blocks/transport/index.js |
Converted static variations into dynamic, i18n-enabled registration functions. Added __() translations for title, description, keywords, and button labels. Introduced isActive predicate comparing className attributes. Expanded innerBlocks with nested group structures. Implemented conditional registration via registerForPostTypesAndTemplates for destination post type gating. Added example configurations. |
Sequence Diagram(s)
sequenceDiagram
participant Editor as Block Editor
participant Init as DOM Ready
participant Reg as registerForPostTypesAndTemplates
participant WP as wp.blocks
Init->>Reg: Initialize block variation registration
activate Reg
Note over Reg: Check post type/template filters
Reg->>WP: Register variation if destination post type matches
deactivate Reg
activate WP
WP->>Editor: Variation available in inserter
deactivate WP
Editor->>Editor: User inserts block
activate Editor
Note over Editor: isActive predicate evaluates className
Editor->>Editor: Render with translated labels & nested blocks
deactivate Editor
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
- High homogeneity: Identical registration pattern repeated across 8 blocks reduces cognitive load; validating one block pattern applies to all others
- Moderate file count: 16 files (8 block.json + 8 index.js) require review, but changes within each file are predictable
- Areas requiring attention:
- Verify
isActiveclassName comparisons are semantically consistent across all variations - Confirm all translated strings use correct text domain ("tour-operator")
- Ensure
registerForPostTypesAndTemplatespost type selectors ("destination") are correct and consistent - Validate that all innerBlocks structures maintain proper nesting and layout constraints
- Check that example configurations in block.json match runtime variation structure
- Verify
Possibly related PRs
- Enhance check-in and check-out blocks with meta and post types #645 — Implements identical block variation registration refactoring pattern with i18n and conditional gating across multiple blocks.
- Enhance tour blocks with comprehensive metadata, icons integration, and conditional registration #696 — Applies the same metadata enrichment, i18n conversion, and conditional registration utility usage to tour-related blocks.
- Enhance destination blocks with conditional registration and standardized metadata #656 — Enriches block.json metadata and converts static variations to conditionally-registered, i18n-enabled functions following the same standardised pattern.
Suggested labels
comp:block-variations, comp:block-json, comp:block-editor, comp:block-inserter, comp:block-supports
Suggested reviewers
- krugazul
Pre-merge checks and finishing touches
❌ Failed checks (1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description check | ❓ Inconclusive | The PR description is comprehensive with summary, key changes, scope, technical implementation, and testing notes. However, it does not follow the specified template structure with required sections like AC, Test Notes, Risk & Rollback checklists. | Consider formatting the description to match the repository template structure, including explicit checklist items, risk level assessment, and rollback plan. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately summarizes the main objective: enhancing destination blocks with metadata, icon integration, and conditional registration. |
| Linked Issues check | ✅ Passed | The PR implements all coding requirements from issue #691: Block API v3 metadata compliance, comprehensive block.json updates, conditional registration, icon system integration, localization, and reusable utility creation across all eight destination blocks. |
| Out of Scope Changes check | ✅ Passed | All code changes directly address issue #691 requirements: metadata enhancements, conditional registration implementation, and utility creation for destination blocks. No out-of-scope changes detected. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
refactor/691-destination-blocks-meta-icons
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf 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. |
There was a problem hiding this comment.
Files selected (10)
- src/blocks/additional-info/index.js (1)
- src/blocks/banking/index.js (1)
- src/blocks/climate/index.js (1)
- src/blocks/cuisine/index.js (1)
- src/blocks/dress/index.js (1)
- src/blocks/electricity/index.js (1)
- src/blocks/health/index.js (4)
- src/blocks/transport/index.js (5)
- src/js/conditional-block-registration.js (1)
- webpack.config.js (1)
Files ignored due to filter (16)
- build/blocks/additional-info/block.json
- build/blocks/banking/block.json
- build/blocks/climate/block.json
- build/blocks/cuisine/block.json
- build/blocks/dress/block.json
- build/blocks/electricity/block.json
- build/blocks/health/block.json
- build/blocks/transport/block.json
- src/blocks/additional-info/block.json
- src/blocks/banking/block.json
- src/blocks/climate/block.json
- src/blocks/cuisine/block.json
- src/blocks/dress/block.json
- src/blocks/electricity/block.json
- src/blocks/health/block.json
- src/blocks/transport/block.json
Files not summarized due to errors (10)
- src/blocks/additional-info/index.js (diff tokens exceeds limit)
- src/blocks/banking/index.js (diff tokens exceeds limit)
- src/blocks/climate/index.js (diff tokens exceeds limit)
- src/blocks/cuisine/index.js (diff tokens exceeds limit)
- src/blocks/dress/index.js (diff tokens exceeds limit)
- src/blocks/electricity/index.js (diff tokens exceeds limit)
- src/js/conditional-block-registration.js (diff tokens exceeds limit)
- src/blocks/transport/index.js (nothing obtained from openai)
- webpack.config.js (nothing obtained from openai)
- src/blocks/health/index.js (nothing obtained from openai)
Files not reviewed due to errors (9)
- src/blocks/electricity/index.js (no response)
- src/blocks/banking/index.js (no response)
- src/blocks/additional-info/index.js (no response)
- src/blocks/health/index.js (no response)
- src/blocks/dress/index.js (no response)
- src/blocks/cuisine/index.js (no response)
- src/js/conditional-block-registration.js (no response)
- webpack.config.js (no response)
- src/blocks/transport/index.js (no response)
Files skipped from review due to trivial changes (1)
- src/blocks/climate/index.js (diff too large)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
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
@coderabbitaiin 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: ignoreanywhere in the PR description to pause further reviews from the bot.
There was a problem hiding this comment.
Actionable comments posted: 13
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/blocks/transport/index.js (3)
1-178: Add comprehensive JSDoc comments and @SInCE tags.The file lacks JSDoc documentation required by the coding guidelines. All functions require JSDoc comments with @SInCE tags.
Apply this pattern:
+/** + * Transport block variation registration. + * + * Registers a conditional block variation for displaying transport information. + * Only available in destination post type and template contexts. + * + * @since 2.1.0 + */ + import { __ } from '@wordpress/i18n'; import { registerForPostTypesAndTemplates } from '@utils/conditional-block-registration.js'; wp.domReady(() => { + /** + * Registers the Transport block variation. + * + * Creates a variation of core/group block with transport metadata bindings. + * + * @since 2.1.0 + */ const registerTransportVariation = () => {As per coding guidelines.
66-81: Fix attribute structure: content must be sibling of metadata, not nested within it.Line 78 places
contentinside themetadataobject, which is incorrect. Thecontentattribute should be a sibling ofmetadatafor the paragraph block.Apply this fix:
[ 'core/paragraph', { metadata: { bindings: { content: { source: 'lsx/post-meta', args: { key: 'transport', }, }, }, - content: '', }, + content: '', }, ],
90-96: Inconsistent backgroundColor between innerBlocks and example.The button in the main innerBlocks (lines 90-96) lacks
backgroundColor: 'primary', but the example (lines 157-161) includes it. This creates inconsistency.Add backgroundColor to the main innerBlocks for consistency:
[ 'core/button', { + backgroundColor: 'primary', width: 100, text: __('View More', 'tour-operator'), }, ],Also applies to: 154-163
🧹 Nitpick comments (5)
src/blocks/dress/block.json (1)
10-10: Consider a more intuitive icon for dress/clothing context.The "admin-customizer" icon may not be immediately recognisable as dress-related. Consider alternatives such as "admin-appearance" or "admin-users" for better semantic alignment with clothing/attire.
src/blocks/electricity/block.json (1)
10-10: Consider a more semantic icon for electricity context.The "admin-plugins" icon doesn't clearly relate to electricity or power. Consider more intuitive alternatives such as "lightbulb" or "admin-tools" for better semantic alignment.
src/blocks/additional-info/index.js (1)
53-53: Consider using template literals for HTML strings.The string concatenation with
+operator works but template literals provide better readability and are more idiomatic in modern JavaScript.-content: '<strong>' + __('General', 'tour-operator') + '</strong>', +content: `<strong>${__('General', 'tour-operator')}</strong>`,Apply the same pattern on line 127.
Also applies to: 127-127
src/blocks/cuisine/index.js (1)
53-53: Consider using template literals for HTML strings.Template literals provide better readability than string concatenation.
-content: '<strong>' + __('Cuisine', 'tour-operator') + '</strong>', +content: `<strong>${__('Cuisine', 'tour-operator')}</strong>`,Apply the same pattern on line 129.
Also applies to: 129-129
src/blocks/transport/index.js (1)
53-53: Consider using template literals for HTML strings.Template literals are more readable than string concatenation.
-content: '<strong>' + __('Transport', 'tour-operator') + '</strong>', +content: `<strong>${__('Transport', 'tour-operator')}</strong>`,Apply the same pattern on line 128.
Also applies to: 128-128
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (175)
build/admin-rtl.cssis excluded by!build/**build/admin-script.asset.phpis excluded by!build/**build/admin-script.jsis excluded by!build/**build/admin.asset.phpis excluded by!build/**build/admin.cssis excluded by!build/**build/blocks/accommodation-related-accommodation/index.asset.phpis excluded by!build/**build/blocks/accommodation-related-accommodation/index.jsis excluded by!build/**build/blocks/accommodation-related-destination/index.asset.phpis excluded by!build/**build/blocks/accommodation-related-destination/index.jsis excluded by!build/**build/blocks/accommodation-related-tour/index.asset.phpis excluded by!build/**build/blocks/accommodation-related-tour/index.jsis excluded by!build/**build/blocks/accommodation-type/index.asset.phpis excluded by!build/**build/blocks/accommodation-type/index.jsis excluded by!build/**build/blocks/additional-info/block.jsonis excluded by!build/**build/blocks/additional-info/index.asset.phpis excluded by!build/**build/blocks/additional-info/index.jsis excluded by!build/**build/blocks/banking/block.jsonis excluded by!build/**build/blocks/banking/index.asset.phpis excluded by!build/**build/blocks/banking/index.jsis excluded by!build/**build/blocks/banner-cover/index.asset.phpis excluded by!build/**build/blocks/banner-cover/index.jsis excluded by!build/**build/blocks/best-time-to-visit/index.asset.phpis excluded by!build/**build/blocks/best-time-to-visit/index.jsis excluded by!build/**build/blocks/booking-validity/index.asset.phpis excluded by!build/**build/blocks/booking-validity/index.jsis excluded by!build/**build/blocks/checkin-time/index.asset.phpis excluded by!build/**build/blocks/checkin-time/index.jsis excluded by!build/**build/blocks/checkout-time/index.asset.phpis excluded by!build/**build/blocks/checkout-time/index.jsis excluded by!build/**build/blocks/climate/block.jsonis excluded by!build/**build/blocks/climate/index.asset.phpis excluded by!build/**build/blocks/climate/index.jsis excluded by!build/**build/blocks/cuisine/block.jsonis excluded by!build/**build/blocks/cuisine/index.asset.phpis excluded by!build/**build/blocks/cuisine/index.jsis excluded by!build/**build/blocks/day-by-day/index.asset.phpis excluded by!build/**build/blocks/day-by-day/index.jsis excluded by!build/**build/blocks/departs-from/index.asset.phpis excluded by!build/**build/blocks/departs-from/index.jsis excluded by!build/**build/blocks/destination-to-accommodation/index.asset.phpis excluded by!build/**build/blocks/destination-to-accommodation/index.jsis excluded by!build/**build/blocks/dress/block.jsonis excluded by!build/**build/blocks/dress/index.asset.phpis excluded by!build/**build/blocks/dress/index.jsis excluded by!build/**build/blocks/duration/index.asset.phpis excluded by!build/**build/blocks/duration/index.jsis excluded by!build/**build/blocks/electricity/block.jsonis excluded by!build/**build/blocks/electricity/index.asset.phpis excluded by!build/**build/blocks/electricity/index.jsis excluded by!build/**build/blocks/ends-in/index.asset.phpis excluded by!build/**build/blocks/ends-in/index.jsis excluded by!build/**build/blocks/facilities/index.asset.phpis excluded by!build/**build/blocks/facilities/index.jsis excluded by!build/**build/blocks/facts-country-wrapper/index.asset.phpis excluded by!build/**build/blocks/facts-country-wrapper/index.jsis excluded by!build/**build/blocks/facts-regions-wrapper/index.asset.phpis excluded by!build/**build/blocks/facts-regions-wrapper/index.jsis excluded by!build/**build/blocks/featured-accommodation/index.asset.phpis excluded by!build/**build/blocks/featured-accommodation/index.jsis excluded by!build/**build/blocks/featured-destinations/index.asset.phpis excluded by!build/**build/blocks/featured-destinations/index.jsis excluded by!build/**build/blocks/featured-tours/index.asset.phpis excluded by!build/**build/blocks/featured-tours/index.jsis excluded by!build/**build/blocks/gallery/index.asset.phpis excluded by!build/**build/blocks/gallery/index.jsis excluded by!build/**build/blocks/google-map/index.asset.phpis excluded by!build/**build/blocks/google-map/index.jsis excluded by!build/**build/blocks/group-size/index.asset.phpis excluded by!build/**build/blocks/group-size/index.jsis excluded by!build/**build/blocks/health/block.jsonis excluded by!build/**build/blocks/health/index.asset.phpis excluded by!build/**build/blocks/health/index.jsis excluded by!build/**build/blocks/icons/index.asset.phpis excluded by!build/**build/blocks/icons/index.jsis excluded by!build/**build/blocks/icons/style-index-rtl.cssis excluded by!build/**build/blocks/icons/style-index.cssis excluded by!build/**build/blocks/included/index.asset.phpis excluded by!build/**build/blocks/included/index.jsis excluded by!build/**build/blocks/itinerary/index.asset.phpis excluded by!build/**build/blocks/itinerary/index.jsis excluded by!build/**build/blocks/lsx-destination-to-tour/index.asset.phpis excluded by!build/**build/blocks/lsx-destination-to-tour/index.jsis excluded by!build/**build/blocks/minimum-child-age/index.asset.phpis excluded by!build/**build/blocks/minimum-child-age/index.jsis excluded by!build/**build/blocks/modal-button/index.asset.phpis excluded by!build/**build/blocks/modal-button/index.jsis excluded by!build/**build/blocks/more-link/index.asset.phpis excluded by!build/**build/blocks/more-link/index.jsis excluded by!build/**build/blocks/not-included/index.asset.phpis excluded by!build/**build/blocks/not-included/index.jsis excluded by!build/**build/blocks/number-of-rooms/index.asset.phpis excluded by!build/**build/blocks/number-of-rooms/index.jsis excluded by!build/**build/blocks/permalink-button/index.asset.phpis excluded by!build/**build/blocks/permalink-button/index.jsis excluded by!build/**build/blocks/price-include-exclude/index.asset.phpis excluded by!build/**build/blocks/price-include-exclude/index.jsis excluded by!build/**build/blocks/price/index.asset.phpis excluded by!build/**build/blocks/price/index.jsis excluded by!build/**build/blocks/rating/index.asset.phpis excluded by!build/**build/blocks/rating/index.jsis excluded by!build/**build/blocks/regions/index.asset.phpis excluded by!build/**build/blocks/regions/index.jsis excluded by!build/**build/blocks/related-regions/index.asset.phpis excluded by!build/**build/blocks/related-regions/index.jsis excluded by!build/**build/blocks/review-related-accommodation/index.asset.phpis excluded by!build/**build/blocks/review-related-accommodation/index.jsis excluded by!build/**build/blocks/review-related-destination/index.asset.phpis excluded by!build/**build/blocks/review-related-destination/index.jsis excluded by!build/**build/blocks/review-related-tour/index.asset.phpis excluded by!build/**build/blocks/review-related-tour/index.jsis excluded by!build/**build/blocks/safety/index.asset.phpis excluded by!build/**build/blocks/safety/index.jsis excluded by!build/**build/blocks/single-supplement-wrapper/index.asset.phpis excluded by!build/**build/blocks/single-supplement-wrapper/index.jsis excluded by!build/**build/blocks/special-interests/index.asset.phpis excluded by!build/**build/blocks/special-interests/index.jsis excluded by!build/**build/blocks/spoken-languages/index.asset.phpis excluded by!build/**build/blocks/spoken-languages/index.jsis excluded by!build/**build/blocks/sticky-menu/index.asset.phpis excluded by!build/**build/blocks/sticky-menu/index.jsis excluded by!build/**build/blocks/sticky-menu/sticky-menu-editor-extension.asset.phpis excluded by!build/**build/blocks/sticky-menu/sticky-menu-editor-extension.jsis excluded by!build/**build/blocks/sticky-menu/style-index-rtl.cssis excluded by!build/**build/blocks/sticky-menu/style-index.cssis excluded by!build/**build/blocks/sticky-menu/view.asset.phpis excluded by!build/**build/blocks/sticky-menu/view.jsis excluded by!build/**build/blocks/suggested-visitor-types/index.asset.phpis excluded by!build/**build/blocks/suggested-visitor-types/index.jsis excluded by!build/**build/blocks/tagline/index.asset.phpis excluded by!build/**build/blocks/tagline/index.jsis excluded by!build/**build/blocks/tour-related-accommodation/index.asset.phpis excluded by!build/**build/blocks/tour-related-accommodation/index.jsis excluded by!build/**build/blocks/tour-related-destination/index.asset.phpis excluded by!build/**build/blocks/tour-related-destination/index.jsis excluded by!build/**build/blocks/tour-related-tour/index.asset.phpis excluded by!build/**build/blocks/tour-related-tour/index.jsis excluded by!build/**build/blocks/transport/block.jsonis excluded by!build/**build/blocks/transport/index.asset.phpis excluded by!build/**build/blocks/transport/index.jsis excluded by!build/**build/blocks/travel-styles/index.asset.phpis excluded by!build/**build/blocks/travel-styles/index.jsis excluded by!build/**build/blocks/unit-rooms/index.asset.phpis excluded by!build/**build/blocks/unit-rooms/index.jsis excluded by!build/**build/blocks/units/index.asset.phpis excluded by!build/**build/blocks/units/index.jsis excluded by!build/**build/blocks/videos/index.asset.phpis excluded by!build/**build/blocks/videos/index.jsis excluded by!build/**build/blocks/visa/index.asset.phpis excluded by!build/**build/blocks/visa/index.jsis excluded by!build/**build/blocks/wetu-map/index.asset.phpis excluded by!build/**build/blocks/wetu-map/index.jsis excluded by!build/**build/custom.asset.phpis excluded by!build/**build/custom.jsis excluded by!build/**build/general.asset.phpis excluded by!build/**build/general.jsis excluded by!build/**build/linked-cover.asset.phpis excluded by!build/**build/linked-cover.jsis excluded by!build/**build/maps.asset.phpis excluded by!build/**build/maps.jsis excluded by!build/**build/metabox-structure.asset.phpis excluded by!build/**build/metabox-structure.jsis excluded by!build/**build/metaboxes-rtl.cssis excluded by!build/**build/metaboxes.asset.phpis excluded by!build/**build/metaboxes.cssis excluded by!build/**build/modals.asset.phpis excluded by!build/**build/modals.jsis excluded by!build/**build/scporder.asset.phpis excluded by!build/**build/scporder.jsis excluded by!build/**build/slider-query.asset.phpis excluded by!build/**build/slider-query.jsis excluded by!build/**build/slotfills.asset.phpis excluded by!build/**build/slotfills.jsis excluded by!build/**build/style-rtl.cssis excluded by!build/**build/style.asset.phpis excluded by!build/**build/style.cssis excluded by!build/**
📒 Files selected for processing (18)
src/blocks/additional-info/block.json(1 hunks)src/blocks/additional-info/index.js(1 hunks)src/blocks/banking/block.json(1 hunks)src/blocks/banking/index.js(1 hunks)src/blocks/climate/block.json(1 hunks)src/blocks/climate/index.js(1 hunks)src/blocks/cuisine/block.json(1 hunks)src/blocks/cuisine/index.js(1 hunks)src/blocks/dress/block.json(1 hunks)src/blocks/dress/index.js(1 hunks)src/blocks/electricity/block.json(1 hunks)src/blocks/electricity/index.js(1 hunks)src/blocks/health/block.json(1 hunks)src/blocks/health/index.js(4 hunks)src/blocks/transport/block.json(1 hunks)src/blocks/transport/index.js(5 hunks)src/js/conditional-block-registration.js(1 hunks)webpack.config.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (14)
src/**/*.{js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use @wordpress/eslint-plugin for JavaScript linting
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
src/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.{js,jsx,ts,tsx}: Use useBlockProps() in block edit/save components when applicable
Use the text domaintour-operatorfor JS i18n calls
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
{assets,src}/**/*
📄 CodeRabbit inference engine (.github/instructions/block-theme-structure.instructions.md)
Keep SCSS/JS/images source assets in assets/ or src/
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/blocks/dress/block.jsonsrc/js/conditional-block-registration.jssrc/blocks/electricity/block.jsonsrc/blocks/transport/block.jsonsrc/blocks/health/block.jsonsrc/blocks/health/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/banking/block.jsonsrc/blocks/climate/block.jsonsrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/additional-info/block.jsonsrc/blocks/cuisine/index.jssrc/blocks/cuisine/block.json
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts}: Use const or let instead of var for variable declarations
Use default parameters for function arguments where appropriate
Use @wordpress/api-fetch (optionally with addQueryArgs) for REST API requests
Register blocks via registerBlockType using block metadata (imported from block.json), and localize title/description/keywords
Use wp.media for media selection in custom components/utilities when needed
Create and register custom data stores with @wordpress/data (createReduxStore + register), and structure actions/selectors clearly
Initialize frontend interactivity after DOMContentLoaded and implement ARIA attributes for toggles (aria-controls, aria-expanded)
Handle AJAX form submissions with fetch, proper loading states, and user notices; restore UI state in finally
Implement accessibility utilities like focus trapping and polite screen reader announcements for dynamic content
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jswebpack.config.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts,jsx,tsx}: Prefer arrow functions for callbacks and inline handlers
Use object/array destructuring for cleaner code
Use template literals for string interpolation
Use async/await for promise handling with try/catch for errors
Use WordPress i18n APIs (__/_n/sprintf) with a consistent textdomain for all user-facing strings; include translator comments where needed
Use @wordpress/data dispatch/select for interacting with WP data stores (e.g., core/notices, core/editor)
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jswebpack.config.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/js-ts.instructions.md)
**/*.{ts,tsx,js,jsx}: Debounce user inputs to prevent excessive processing
Avoid blocking the UI thread (prefer async/non-blocking operations)
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jswebpack.config.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
**/*.{js,mjs,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/performance.instructions.md)
Defer non-critical JavaScript and avoid synchronous blocking operations
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jswebpack.config.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/review.instructions.md)
Internationalize user‑facing strings using WordPress i18n APIs
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jswebpack.config.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jswebpack.config.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jswebpack.config.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
**/*.{js,ts,tsx,jsx}
⚙️ CodeRabbit configuration file
**/*.{js,ts,tsx,jsx}: Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards and @wordpress/eslint-plugin rules.
- Ensure the code is well-documented with proper JSDoc comments.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features.
- Follow WordPress JavaScript coding standards and use WordPress script localization.
- Use WordPress script dependencies and enqueue properly.
- Ensure React/JSX best practices for blocks and modern JavaScript/TypeScript patterns.
- Implement proper error handling and loading states.
- Use WordPress components and design system where applicable.
- For Tour Operator: Focus on tour booking interfaces, search functionality, and tour display components.
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/js/conditional-block-registration.jssrc/blocks/health/index.jswebpack.config.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
src/blocks/**/*.{js,jsx,ts,tsx}
⚙️ CodeRabbit configuration file
src/blocks/**/*.{js,jsx,ts,tsx}: - Follow WordPress JavaScript coding standards and @wordpress/scripts configuration.
- Use WordPress components from @wordpress/components and design system.
- Implement proper React/JSX patterns for WordPress blocks.
- Ensure proper WordPress script dependencies and localization.
- Use WordPress data store patterns with @wordpress/data.
- Implement proper error boundaries and loading states.
- Follow modern JavaScript/TypeScript patterns with proper typing.
- Ensure accessibility in interactive block components.
- Use WordPress block editor APIs correctly (useBlockProps, InspectorControls, etc.).
- Implement proper block validation and save/edit functionality.
Files:
src/blocks/climate/index.jssrc/blocks/electricity/index.jssrc/blocks/health/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/dress/index.jssrc/blocks/banking/index.jssrc/blocks/cuisine/index.js
src/**/block.json
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/block.json: Prefer block.json with server-side registration for blocks (avoid ad‑hoc registration)
Use the block namespacelsx-toin block names
Files:
src/blocks/dress/block.jsonsrc/blocks/electricity/block.jsonsrc/blocks/transport/block.jsonsrc/blocks/health/block.jsonsrc/blocks/banking/block.jsonsrc/blocks/climate/block.jsonsrc/blocks/additional-info/block.jsonsrc/blocks/cuisine/block.json
**/block.json
📄 CodeRabbit inference engine (.github/instructions/accessibility.instructions.md)
**/block.json: Provide meaningful block titles, descriptions, and keywords in block.json
Include editor-specific accessibility guidance in block descriptions (block.json)
Include accessibility considerations in block registration (e.g., supports, attributes)
**/block.json: In block.json, include required fields: name, title, description, category, keywords, and supports
Ensure accessible metadata in block.json: use clear, descriptive title and description
Provide reasonable default values for attributes in block.json
Use usesInnerBlocks in block.json only when the block actually contains InnerBlocks
Define block variations in block.json to provide common starting points
Ensure i18n and RTL safety for user-facing strings in block.json (including variations)
Files:
src/blocks/dress/block.jsonsrc/blocks/electricity/block.jsonsrc/blocks/transport/block.jsonsrc/blocks/health/block.jsonsrc/blocks/banking/block.jsonsrc/blocks/climate/block.jsonsrc/blocks/additional-info/block.jsonsrc/blocks/cuisine/block.json
🧬 Code graph analysis (8)
src/blocks/climate/index.js (2)
src/blocks/dress/index.js (1)
conditionalRegister(184-188)src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/electricity/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/health/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/additional-info/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/transport/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/dress/index.js (2)
src/blocks/climate/index.js (1)
conditionalRegister(185-189)src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/banking/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/cuisine/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: review
- GitHub Check: Summary
🔇 Additional comments (17)
src/blocks/cuisine/block.json (1)
4-44: LGTM! Comprehensive metadata additions.The block.json enhancements are well-structured with appropriate textdomain, description, icon, keywords, and example. The example payload properly demonstrates the block's nested structure with a group containing a heading and paragraph.
src/blocks/banking/block.json (1)
4-43: LGTM! Metadata additions follow established pattern.The banking block metadata is comprehensive and consistent with the broader PR pattern. The textdomain, description, icon, keywords, and example are all appropriate and well-structured.
webpack.config.js (1)
31-35: LGTM! Alias simplifies utility imports.The @utils alias properly maps to src/js/ and enables clean imports throughout the codebase. This supports the conditional registration pattern used across multiple blocks in this PR.
src/blocks/dress/block.json (1)
4-43: Metadata additions are comprehensive and well-structured.The textdomain, description, keywords, and example payload are all appropriate and follow the established pattern across the PR.
src/blocks/health/block.json (1)
4-43: LGTM! Well-chosen metadata for health block.The health block enhancements are comprehensive with appropriate textdomain, description, icon ("heart"), keywords, and example structure. All additions align with WordPress standards and the PR pattern.
src/blocks/additional-info/block.json (1)
4-43: LGTM! Clear and semantic metadata additions.The additional-info block metadata is comprehensive with appropriate textdomain, description, icon ("info-outline"), keywords, and example structure. All additions follow WordPress standards.
src/blocks/electricity/block.json (1)
4-44: Comprehensive metadata with good example content.The textdomain, description, keywords, and example payload (with specific voltage/plug information) are well-structured and follow the established PR pattern.
src/blocks/climate/index.js (5)
1-3: LGTM! Proper i18n and utility imports.The imports correctly use @wordpress/i18n for internationalisation and the new @utils alias for the conditional registration utility, aligning with the project's patterns.
33-44: LGTM! Robust variation attributes and isActive predicate.The isActive predicate correctly compares metadata.className for variation activation, and the attributes properly define the metadata and layout structure.
45-113: LGTM! Well-structured innerBlocks with metadata bindings.The innerBlocks structure properly uses nested groups with constrained layouts, implements metadata bindings to the 'climate' post meta field, and includes internationalised content. The button configuration is appropriate for the destination context.
117-180: LGTM! Comprehensive example payload for editor preview.The example provides a complete demonstration with nested groups, placeholder content, and properly structured attributes, enhancing the block inserter experience.
185-191: LGTM! Proper conditional registration implementation.The conditional registration correctly uses registerForPostTypesAndTemplates with destination post type and template slugs, ensuring the block variation only appears in the appropriate context.
src/blocks/climate/block.json (1)
4-43: LGTM! Comprehensive block metadata additions.The additions follow Block API v3 standards properly:
- Correct textdomain matching the coding guidelines
- Descriptive metadata (description, icon, keywords)
- Well-structured example with nested innerBlocks for editor preview
src/blocks/additional-info/index.js (1)
169-175: Conditional registration implemented correctly.The use of
registerForPostTypesAndTemplatesproperly restricts the block variation to destination contexts.src/blocks/cuisine/index.js (1)
172-178: Conditional registration implemented correctly.The block variation is properly restricted to destination contexts using the conditional registration utility.
src/blocks/transport/index.js (1)
171-177: Conditional registration implemented correctly.The variation is properly restricted to destination contexts.
src/blocks/transport/block.json (1)
4-43: LGTM! Comprehensive block metadata additions.The additions follow Block API v3 standards with proper textdomain, descriptive metadata, and a well-structured example for editor preview.
There was a problem hiding this comment.
Pull Request Overview
This PR enhances destination-related blocks with comprehensive Block API v3 metadata, centralized icon integration, and conditional registration logic. The key implementation creates a reusable conditional registration utility and applies it to 8 destination blocks (additional-info, banking, climate, cuisine, dress, electricity, health, transport).
Reviewed Changes
Copilot reviewed 192 out of 193 changed files in this pull request and generated 26 comments.
Show a summary per file
| File | Description |
|---|---|
webpack.config.js |
Adds @utils webpack alias for importing the conditional registration utility |
src/js/conditional-block-registration.js |
NEW - Reusable conditional registration utility with comprehensive JSDoc documentation |
src/blocks/*/index.js (8 blocks) |
Enhanced with i18n, conditional registration, localized keywords, and improved example configurations |
src/blocks/*/block.json (8 blocks) |
Enhanced with API v3 metadata, textdomain, descriptions, keywords, and example configurations |
build/* files |
Compiled build artifacts (expected changes) |
There was a problem hiding this comment.
Files selected (3)
- src/blocks/climate/index.js (1)
- src/blocks/cuisine/index.js (1)
- src/blocks/transport/index.js (4)
Files not summarized due to errors (3)
- src/blocks/climate/index.js (diff tokens exceeds limit)
- src/blocks/cuisine/index.js (diff tokens exceeds limit)
- src/blocks/transport/index.js (diff tokens exceeds limit)
Files not reviewed due to errors (2)
- src/blocks/transport/index.js (no response)
- src/blocks/cuisine/index.js (no response)
Files skipped from review due to trivial changes (1)
- src/blocks/climate/index.js (diff too large)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
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
@coderabbitaiin 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: ignoreanywhere in the PR description to pause further reviews from the bot.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (4)
src/blocks/climate/index.js (2)
4-6: Add JSDoc comments for the registration function.The coding guidelines require JSDoc comments with a @SInCE tag for all functions. This was previously flagged and remains unaddressed.
12-25: Replace inline SVG with centralized icon system or dashicon.This inline SVG icon conflicts with the PR objectives which explicitly require using the centralized icons system. The past review comprehensively documented this issue, noting that
block.jsonalready defines"icon": "cloud". This remains unaddressed.src/blocks/transport/index.js (1)
20-27: Fix isActive predicate logic mismatch.The
isActivefunction comparesmetadata.className(line 21), but the variation only definesmetadata.name(line 25), notmetadata.className. This will cause the isActive check to fail.Apply this diff to fix the predicate:
isActive: (blockAttributes, variationAttributes) => { - return blockAttributes.metadata?.className === variationAttributes.metadata?.className; + return blockAttributes.metadata?.name === variationAttributes.metadata?.name; },src/blocks/cuisine/index.js (1)
67-80: Empty content attribute for metadata-bound paragraph.The paragraph block with metadata bindings lacks a
contentattribute fallback. Whilst the binding to post meta key 'cuisine' will populate the content, consider adding a default/placeholder content value for clarity and to handle cases where the binding may not resolve.
🧹 Nitpick comments (2)
src/blocks/climate/index.js (1)
66-66: Consider using template literals for string interpolation.Whilst the string concatenation works correctly, the coding guidelines prefer template literals for cleaner code. Consider updating to:
-content: '<strong>' + __('Climate', 'tour-operator') + '</strong>', +content: `<strong>${__('Climate', 'tour-operator')}</strong>`,This also applies to line 141 in the example configuration.
src/blocks/transport/index.js (1)
4-177: Consider adding error handling for registration robustness.The registration code lacks error handling. Wrapping the registration logic in a try-catch block would improve robustness and provide better debugging information if registration fails.
Consider this pattern:
wp.domReady(() => { + try { // Register variation function const registerTransportVariation = () => { // ... existing code ... }; // Initialize conditional registration const conditionalRegister = registerForPostTypesAndTemplates( ['destination'], ['destination'], registerTransportVariation ); conditionalRegister(); + } catch (error) { + // eslint-disable-next-line no-console + console.error('Failed to register Transport block variation:', error); + } });
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
build/blocks/climate/index.asset.phpis excluded by!build/**build/blocks/climate/index.jsis excluded by!build/**build/blocks/cuisine/index.asset.phpis excluded by!build/**build/blocks/cuisine/index.jsis excluded by!build/**build/blocks/transport/index.asset.phpis excluded by!build/**build/blocks/transport/index.jsis excluded by!build/**
📒 Files selected for processing (3)
src/blocks/climate/index.js(1 hunks)src/blocks/cuisine/index.js(1 hunks)src/blocks/transport/index.js(4 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
src/**/*.{js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use @wordpress/eslint-plugin for JavaScript linting
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
src/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.{js,jsx,ts,tsx}: Use useBlockProps() in block edit/save components when applicable
Use the text domaintour-operatorfor JS i18n calls
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
{assets,src}/**/*
📄 CodeRabbit inference engine (.github/instructions/block-theme-structure.instructions.md)
Keep SCSS/JS/images source assets in assets/ or src/
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts}: Use const or let instead of var for variable declarations
Use default parameters for function arguments where appropriate
Use @wordpress/api-fetch (optionally with addQueryArgs) for REST API requests
Register blocks via registerBlockType using block metadata (imported from block.json), and localize title/description/keywords
Use wp.media for media selection in custom components/utilities when needed
Create and register custom data stores with @wordpress/data (createReduxStore + register), and structure actions/selectors clearly
Initialize frontend interactivity after DOMContentLoaded and implement ARIA attributes for toggles (aria-controls, aria-expanded)
Handle AJAX form submissions with fetch, proper loading states, and user notices; restore UI state in finally
Implement accessibility utilities like focus trapping and polite screen reader announcements for dynamic content
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts,jsx,tsx}: Prefer arrow functions for callbacks and inline handlers
Use object/array destructuring for cleaner code
Use template literals for string interpolation
Use async/await for promise handling with try/catch for errors
Use WordPress i18n APIs (__/_n/sprintf) with a consistent textdomain for all user-facing strings; include translator comments where needed
Use @wordpress/data dispatch/select for interacting with WP data stores (e.g., core/notices, core/editor)
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/js-ts.instructions.md)
**/*.{ts,tsx,js,jsx}: Debounce user inputs to prevent excessive processing
Avoid blocking the UI thread (prefer async/non-blocking operations)
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
**/*.{js,mjs,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/performance.instructions.md)
Defer non-critical JavaScript and avoid synchronous blocking operations
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/review.instructions.md)
Internationalize user‑facing strings using WordPress i18n APIs
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
**/*.{js,ts,tsx,jsx}
⚙️ CodeRabbit configuration file
**/*.{js,ts,tsx,jsx}: Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards and @wordpress/eslint-plugin rules.
- Ensure the code is well-documented with proper JSDoc comments.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features.
- Follow WordPress JavaScript coding standards and use WordPress script localization.
- Use WordPress script dependencies and enqueue properly.
- Ensure React/JSX best practices for blocks and modern JavaScript/TypeScript patterns.
- Implement proper error handling and loading states.
- Use WordPress components and design system where applicable.
- For Tour Operator: Focus on tour booking interfaces, search functionality, and tour display components.
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
src/blocks/**/*.{js,jsx,ts,tsx}
⚙️ CodeRabbit configuration file
src/blocks/**/*.{js,jsx,ts,tsx}: - Follow WordPress JavaScript coding standards and @wordpress/scripts configuration.
- Use WordPress components from @wordpress/components and design system.
- Implement proper React/JSX patterns for WordPress blocks.
- Ensure proper WordPress script dependencies and localization.
- Use WordPress data store patterns with @wordpress/data.
- Implement proper error boundaries and loading states.
- Follow modern JavaScript/TypeScript patterns with proper typing.
- Ensure accessibility in interactive block components.
- Use WordPress block editor APIs correctly (useBlockProps, InspectorControls, etc.).
- Implement proper block validation and save/edit functionality.
Files:
src/blocks/cuisine/index.jssrc/blocks/climate/index.jssrc/blocks/transport/index.js
🧬 Code graph analysis (3)
src/blocks/cuisine/index.js (3)
src/blocks/climate/index.js (1)
conditionalRegister(184-188)src/blocks/transport/index.js (1)
conditionalRegister(170-174)src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/climate/index.js (4)
src/blocks/cuisine/index.js (1)
conditionalRegister(171-175)src/blocks/transport/index.js (1)
conditionalRegister(170-174)src/blocks/dress/index.js (1)
conditionalRegister(184-188)src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/transport/index.js (3)
src/blocks/climate/index.js (1)
conditionalRegister(184-188)src/blocks/cuisine/index.js (1)
conditionalRegister(171-175)src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: review
- GitHub Check: Summary
🔇 Additional comments (5)
src/blocks/climate/index.js (4)
1-2: LGTM: Imports are correct.The imports properly follow WordPress standards, using the i18n API and the centralized conditional registration utility consistent with other destination blocks in this PR.
27-35: LGTM: Keywords and activation logic are well implemented.The keywords are comprehensive and properly internationalized, improving block discoverability. The
isActivepredicate correctly uses optional chaining to match block variations by metadata className, which is a valid approach.
79-93: LGTM: Metadata bindings correctly configured.The paragraph block correctly uses the bindings API to connect to the 'climate' post meta field. The absence of a
contentattribute is intentional and expected, as content will be populated dynamically from post meta. Whilst a previous review suggested adding a comment explaining this pattern, it follows standard WordPress bindings API conventions.
183-191: LGTM: Conditional registration correctly implemented.The conditional registration setup correctly restricts the climate block variation to the 'destination' post type, following the exact pattern used in other destination blocks (cuisine, transport, dress). This fulfills the PR objective to implement conditional registration for destination-context awareness.
src/blocks/cuisine/index.js (1)
12-12: Verificação necessária: Integração de ícones em bloco picker vs. utilização dentro de blocos.Análise do código revela que TODOS os blocos de variação no repositório usam strings de dashicon (exemplo:
'food','airplane','admin-site-alt3') para a propriedadeiconno registrador de variações. Este padrão é consistente em todo o código base, incluindo wetu-map, visa, accommodation-related-tour e travel-styles.O sistema de ícones centralizado (src/blocks/icons/) contém componentes React (exemplo: arrowDownIcon, bestMonthsToTravelIcon) que parecem destinados para renderização dentro de blocos, não para ícones do seletor de blocos. Os objetivos do PR mencionam "integração de sistema de ícones centralizado", mas é incerto se isto se aplica a ícones do seletor (que requerem strings) ou a ícones renderizados dentro de componentes de blocos.
Recomenda-se clarificar os objetivos do PR: se a alteração aplica-se apenas a ícones renderizados dentro de blocos, o código atual está correto. Se aplica-se a ícones do seletor de blocos, verificar se um ícone apropriado existe no sistema centralizado (actualmente não existe um ícone 'food' ou 'cuisine').
…o refactor/691-destination-blocks-meta-icons
There was a problem hiding this comment.
Files selected (8)
- src/blocks/additional-info/index.js (1)
- src/blocks/banking/index.js (1)
- src/blocks/climate/index.js (1)
- src/blocks/cuisine/index.js (1)
- src/blocks/dress/index.js (1)
- src/blocks/electricity/index.js (1)
- src/blocks/health/index.js (1)
- src/blocks/transport/index.js (1)
Files not summarized due to errors (8)
- src/blocks/additional-info/index.js (diff tokens exceeds limit)
- src/blocks/banking/index.js (diff tokens exceeds limit)
- src/blocks/climate/index.js (diff tokens exceeds limit)
- src/blocks/cuisine/index.js (diff tokens exceeds limit)
- src/blocks/dress/index.js (diff tokens exceeds limit)
- src/blocks/electricity/index.js (diff tokens exceeds limit)
- src/blocks/health/index.js (diff tokens exceeds limit)
- src/blocks/transport/index.js (diff tokens exceeds limit)
Files not reviewed due to errors (7)
- src/blocks/cuisine/index.js (no response)
- src/blocks/health/index.js (no response)
- src/blocks/electricity/index.js (no response)
- src/blocks/additional-info/index.js (no response)
- src/blocks/banking/index.js (no response)
- src/blocks/dress/index.js (no response)
- src/blocks/transport/index.js (no response)
Files skipped from review due to trivial changes (1)
- src/blocks/climate/index.js (diff too large)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
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
@coderabbitaiin 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: ignoreanywhere in the PR description to pause further reviews from the bot.
There was a problem hiding this comment.
Actionable comments posted: 6
♻️ Duplicate comments (19)
src/blocks/cuisine/index.js (2)
1-178: Add comprehensive JSDoc comments and @SInCE tags.The file lacks JSDoc documentation required by the coding guidelines. All functions should have JSDoc comments including @SInCE tags indicating version 2.1.0.
53-53: String concatenation in translatable content can cause issues for translators.The
__()function should wrap the entire HTML string including the<strong>tags to provide proper context for translation.Also applies to: 128-128
src/blocks/transport/index.js (4)
20-22: Consider using metadata.name for variation matching.Whilst the current
isActivepredicate comparingclassNameis functional (sinceclassNameis defined on line 27), usingmetadata.namewould be more semantically consistent with WordPress block variation patterns and align with the metadata-driven approach used throughout the variation definition.Apply this diff to use metadata-based matching:
isActive: (blockAttributes, variationAttributes) => { - return blockAttributes.className === variationAttributes.className; + return blockAttributes.metadata?.name === variationAttributes.metadata?.name; },
5-6: Add JSDoc documentation for the function.The
registerTransportVariationfunction lacks JSDoc documentation. According to coding guidelines, all functions must include proper JSDoc comments with a@sincetag indicating the next version of the plugin (e.g.,@since 2.1.0).Apply this diff to add proper documentation:
+/** + * Registers the Transport block variation for destination post types. + * + * Creates a core/group variation with transport-specific attributes, + * innerBlocks structure, and metadata bindings for destination contexts. + * + * @since 2.1.0 + */ const registerTransportVariation = () => {As per coding guidelines.
12-12: Replace hardcoded icon with custom SVG icon.The transport block uses the hardcoded Dashicon string
'car', whilst other destination blocks (e.g., climate, ends-in) use custom SVG icons that align with the design system (20x20 viewBox, currentColor for fill/stroke). The PR objectives explicitly state to "integrate a centralized icon system" and "replace inline/hardcoded icons".Replace the hardcoded string with a custom SVG icon following the pattern used by other blocks:
-icon: 'car', +icon: ( + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"> + <path fill="currentColor" d="M15 8h-1V6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v2H5c-1.1 0-2 .9-2 2v5h2c0 1.1.9 2 2 2s2-.9 2-2h2c0 1.1.9 2 2 2s2-.9 2-2h2v-5c0-1.1-.9-2-2-2zM8 6h4v2H8V6zm-1 9c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1zm6 0c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1z"/> + </svg> +),
53-53: Wrap entire HTML string in translation function.Both lines 53 and 127 use string concatenation with
__(), placing HTML tags outside the translation function. This prevents translators from seeing the full context and may cause translation issues. The entire HTML string, including tags, should be wrapped in__()to provide proper context for translators.Apply these diffs to fix both occurrences:
Line 53:
-content: '<strong>' + __('Transport', 'tour-operator') + '</strong>', +content: __('<strong>Transport</strong>', 'tour-operator'),Line 127:
-content: '<strong>' + __('Transport', 'tour-operator') + '</strong>', +content: __('<strong>Transport</strong>', 'tour-operator'),Also applies to: 127-127
src/blocks/additional-info/index.js (3)
4-176: Add comprehensive JSDoc documentation.The file lacks JSDoc comments required by the coding guidelines. Add a file-level JSDoc block describing the module and include @SInCE tags for all functions.
As per coding guidelines.
Apply this pattern:
+/** + * Additional Information block variation registration. + * + * Registers a conditional block variation for displaying additional destination information. + * Only available in destination post type and template contexts. + * + * @since 2.1.0 + */ + import { __ } from '@wordpress/i18n'; import { registerForPostTypesAndTemplates } from '@utils/conditional-block-registration.js'; wp.domReady(() => { + /** + * Registers the Additional Information block variation. + * + * Creates a variation of core/group block with destination-specific metadata bindings. + * + * @since 2.1.0 + */ const registerAdditionalInfoVariation = () => {
53-53: Fix string concatenation in translatable content.String concatenation with HTML tags breaks translator context. The __() function should wrap the entire string including HTML tags so translators see the complete context.
Apply this diff:
- content: '<strong>' + __('General', 'tour-operator') + '</strong>', + content: __('<strong>General</strong>', 'tour-operator'),
127-127: Fix string concatenation in translatable content (duplicate).Same issue as line 53: string concatenation breaks translator context.
Apply this diff:
- content: '<strong>' + __('General', 'tour-operator') + '</strong>', + content: __('<strong>General</strong>', 'tour-operator'),src/blocks/climate/index.js (3)
4-6: Add JSDoc comments for the registration function.The coding guidelines require JSDoc comments for all functions, including an @SInCE tag indicating the next version. Add documentation for
registerClimateVariationexplaining its purpose, parameters (if any), and the version.Apply this diff to add JSDoc comments:
wp.domReady(() => { - // Register variation function + /** + * Registers the Climate block variation for destination post types. + * + * Creates a variation of core/group that displays climate and weather + * information with metadata bindings to the 'climate' post meta field. + * + * @since 2.1.0 + */ const registerClimateVariation = () => {As per coding guidelines.
12-25: Replace inline SVG with icon from block.json.The PR objectives (#691) require replacing inline icons with the centralized icon system. Your
block.jsonalready defines"icon": "cloud"(WordPress Dashicon), yet this code overrides it with an inline SVG. Remove the inlineiconproperty from the variation registration to allow WordPress to use the icon defined inblock.json.Apply this diff to remove the inline icon:
wp.blocks.registerBlockVariation('core/group', { name: 'lsx-tour-operator/climate', title: __('Climate', 'tour-operator'), description: __('Display climate and weather information for destinations.', 'tour-operator'), - icon: wp.element.createElement( - 'svg', - { - xmlns: 'http://www.w3.org/2000/svg', - width: 20, - height: 20, - viewBox: '0 0 20 20', - fill: 'none', - }, - wp.element.createElement('path', { - d: 'M15.175 1.5371C15.3281 1.5996 15.4406 1.7371 15.4719 1.8996L16 4.4996L18.6 5.0246C18.7625 5.05897 18.8969 5.16835 18.9625 5.32147C19.0281 5.4746 19.0094 5.6496 18.9188 5.7871L17.4531 7.99647L18.9188 10.2058C19.0094 10.3433 19.0281 10.5183 18.9625 10.6715C18.8969 10.8246 18.7625 10.9371 18.6 10.9683L16.6562 11.3652C16.2844 11.0933 15.8719 10.8777 15.425 10.7277C15.3469 10.3308 15.2125 9.95585 15.0281 9.6121C15.325 9.14647 15.5 8.59335 15.5 7.99647C15.5 6.34022 14.1562 4.99647 12.5 4.99647C11.0031 4.99647 9.7625 6.09335 9.5375 7.5246C8.70938 6.89022 7.67813 6.50897 6.55625 6.49647L6.08437 5.7871C5.99375 5.6496 5.975 5.4746 6.04063 5.32147C6.10625 5.16835 6.24062 5.05585 6.40312 5.0246L9 4.4996L9.525 1.8996C9.55937 1.7371 9.66875 1.60272 9.82187 1.5371C9.975 1.47147 10.15 1.49022 10.2875 1.58085L12.5 3.0496L14.7094 1.58397C14.8469 1.49335 15.0219 1.4746 15.175 1.54022V1.5371ZM14 7.9996C14 8.11835 13.9875 8.23397 13.9594 8.34647C13.2812 7.81522 12.4281 7.4996 11.5 7.4996C11.3562 7.4996 11.2156 7.50585 11.0781 7.52147C11.2781 6.92772 11.8406 6.4996 12.5 6.4996C13.3281 6.4996 14 7.17147 14 7.9996ZM4 17.9996C2.34375 17.9996 1 16.6558 1 14.9996C1 13.6715 1.8625 12.5433 3.05938 12.1496C3.01875 11.9402 3 11.7215 3 11.4996C3 9.56522 4.56562 7.9996 6.5 7.9996C7.84688 7.9996 9.01562 8.75897 9.6 9.8746C10.0594 9.34022 10.7406 8.9996 11.5 8.9996C12.8813 8.9996 14 10.1183 14 11.4996C14 11.6715 13.9812 11.8371 13.95 11.9996C13.9656 11.9996 13.9844 11.9996 14 11.9996C15.6562 11.9996 17 13.3433 17 14.9996C17 16.6558 15.6562 17.9996 14 17.9996H4Z', - fill: '#currentColor', - }) - ), category: 'lsx-tour-operator',
66-66: Wrap entire HTML string in translation function for proper translator context.String concatenation in translatable content causes issues for translators. The
__()function should wrap the entire HTML string including the<strong>tags to provide proper context for translation.Apply this diff to lines 66 and 141:
- content: '<strong>' + __('Climate', 'tour-operator') + '</strong>', + content: __('<strong>Climate</strong>', 'tour-operator'),Also applies to: 141-141
src/blocks/health/index.js (2)
53-53: Wrap the entire HTML string in the translation function.String concatenation in translatable content causes issues for translators. The
__()function should wrap the entire HTML string including the<strong>tags to provide proper context for translation.Apply this diff:
- content: '<strong>' + __('Health', 'tour-operator') + '</strong>', + content: __('<strong>Health</strong>', 'tour-operator'),
128-128: Wrap the entire HTML string in the translation function.Same issue as line 53: string concatenation in translatable content prevents translators from seeing the full context. The
__()function should wrap the entire HTML string including the<strong>tags.Apply this diff:
- content: '<strong>' + __('Health', 'tour-operator') + '</strong>', + content: __('<strong>Health</strong>', 'tour-operator'),src/blocks/electricity/index.js (2)
53-53: Fix translatable string to include HTML tags.This issue was previously flagged but remains unresolved. The HTML
<strong>tags should be inside the translatable string to provide proper context for translators. Concatenating HTML outside the translation function can cause localisation issues.Apply this diff:
- content: '<strong>' + __('Electricity', 'tour-operator') + '</strong>', + content: __('<strong>Electricity</strong>', 'tour-operator'),
128-128: Fix translatable string to include HTML tags.Same issue as Line 53. The HTML
<strong>tags should be inside the translatable string to provide proper context for translators.Apply this diff:
- content: '<strong>' + __('Electricity', 'tour-operator') + '</strong>', + content: __('<strong>Electricity</strong>', 'tour-operator'),src/blocks/dress/index.js (3)
21-24: Use a valid colour keyword for the SVG fill.
'#currentColor'is not a valid CSS colour token, so the icon will not inherit the theme colour correctly. Switch to'currentColor'(without the #) to let the icon follow editor styling.- fill: '#currentColor', + fill: 'currentColor',
66-66: Wrap the entire HTML string in the translation function.String concatenation in translatable content can cause issues for translators. The
__()function should wrap the entire HTML string including the<strong>tags to provide proper context for translation.- content: '<strong>' + __('Dress', 'tour-operator') + '</strong>', + content: __('<strong>Dress</strong>', 'tour-operator'),
33-35: Guard against undefined className values.Whilst the predicate now correctly compares
classNamedirectly (good fix from previous review), it will still match unrelated blocks when bothclassNamevalues are undefined. Add a guard to ensure only blocks with the intended className are matched.- isActive: (blockAttributes, variationAttributes) => { - return blockAttributes.className === variationAttributes.className; - }, + isActive: (blockAttributes, variationAttributes) => { + return blockAttributes?.className === variationAttributes?.className && + blockAttributes?.className !== undefined; + },
🧹 Nitpick comments (7)
src/blocks/cuisine/index.js (1)
20-27: Consider comparing metadata.name in isActive predicate for consistency.While the current className comparison should work, WordPress best practice for block variations recommends comparing
metadata.nameinstead. This approach is more reliable and aligns with the recommended pattern across the WordPress ecosystem.Apply this diff:
isActive: (blockAttributes, variationAttributes) => { - return blockAttributes.className === variationAttributes.className; + return blockAttributes.metadata?.name === variationAttributes.metadata?.name; },src/blocks/health/index.js (1)
24-26: Consider internationalizing the metadata name.The
metadata.nameis set to a static string 'Health'. Whilst this may be intentional for internal use, consider whether it should be internationalized for consistency with the rest of the variation metadata.metadata: { - name: 'Health', + name: __('Health', 'tour-operator'), },src/blocks/electricity/index.js (2)
20-22: Add optional chaining to the isActive predicate for robustness.Whilst the className comparison is now correct (addressing the previous review), adding optional chaining would make this more defensive against edge cases where className might be undefined.
Apply this diff:
isActive: (blockAttributes, variationAttributes) => { - return blockAttributes.className === variationAttributes.className; + return blockAttributes?.className === variationAttributes?.className; },
170-178: Add error handling for registration failures.The coding guidelines require proper error handling. If the conditional registration fails, there's no feedback or graceful degradation.
As per coding guidelines.
Apply this diff to add error handling:
// Initialize conditional registration const conditionalRegister = registerForPostTypesAndTemplates( ['destination'], // Supported post types ['destination'], // Template slug patterns registerElectricityVariation ); - conditionalRegister(); + try { + conditionalRegister(); + } catch (error) { + console.error('Failed to register Electricity block variation:', error); + } });src/blocks/banking/index.js (3)
20-22: Consider adding optional chaining for defensive coding.Whilst the main issue from the previous review has been addressed (comparing
classNameinstead ofmetadata?.className), adding optional chaining toblockAttributeswould make the code more defensive against edge cases.isActive: (blockAttributes, variationAttributes) => { - return blockAttributes.className === variationAttributes.className; + return blockAttributes?.className === variationAttributes.className; },
4-6: Consider adding JSDoc documentation.According to the coding guidelines, functions should be documented with JSDoc comments including a
@sincetag. Adding documentation would improve code maintainability.wp.domReady(() => { - // Register variation function + /** + * Registers the Banking block variation for destination contexts. + * + * Creates a group block variation with banking-specific metadata, + * nested blocks for title and description, and a "View More" button. + * + * @since 2.1.0 + */ const registerBankingVariation = () => {
6-194: Consider adding error handling for block registration.Wrapping the block registration in a try-catch block would improve robustness and provide better debugging information if registration fails.
const registerBankingVariation = () => { - + try { wp.blocks.registerBlockVariation('core/group', { name: 'lsx-tour-operator/banking', // ... rest of configuration }); + } catch (error) { + // eslint-disable-next-line no-console + console.error('Failed to register Banking block variation:', error); + } };
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (20)
build/blocks/additional-info/index.asset.phpis excluded by!build/**build/blocks/additional-info/index.jsis excluded by!build/**build/blocks/banking/index.asset.phpis excluded by!build/**build/blocks/banking/index.jsis excluded by!build/**build/blocks/climate/index.asset.phpis excluded by!build/**build/blocks/climate/index.jsis excluded by!build/**build/blocks/cuisine/index.asset.phpis excluded by!build/**build/blocks/cuisine/index.jsis excluded by!build/**build/blocks/dress/index.asset.phpis excluded by!build/**build/blocks/dress/index.jsis excluded by!build/**build/blocks/electricity/index.asset.phpis excluded by!build/**build/blocks/electricity/index.jsis excluded by!build/**build/blocks/health/index.asset.phpis excluded by!build/**build/blocks/health/index.jsis excluded by!build/**build/blocks/sticky-menu/style-index-rtl.cssis excluded by!build/**build/blocks/sticky-menu/style-index.cssis excluded by!build/**build/blocks/transport/index.asset.phpis excluded by!build/**build/blocks/transport/index.jsis excluded by!build/**build/style-rtl.cssis excluded by!build/**build/style.cssis excluded by!build/**
📒 Files selected for processing (8)
src/blocks/additional-info/index.js(1 hunks)src/blocks/banking/index.js(1 hunks)src/blocks/climate/index.js(1 hunks)src/blocks/cuisine/index.js(1 hunks)src/blocks/dress/index.js(1 hunks)src/blocks/electricity/index.js(1 hunks)src/blocks/health/index.js(1 hunks)src/blocks/transport/index.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
src/**/*.{js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use @wordpress/eslint-plugin for JavaScript linting
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
src/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/**/*.{js,jsx,ts,tsx}: Use useBlockProps() in block edit/save components when applicable
Use the text domaintour-operatorfor JS i18n calls
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
{assets,src}/**/*
📄 CodeRabbit inference engine (.github/instructions/block-theme-structure.instructions.md)
Keep SCSS/JS/images source assets in assets/ or src/
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts}: Use const or let instead of var for variable declarations
Use default parameters for function arguments where appropriate
Use @wordpress/api-fetch (optionally with addQueryArgs) for REST API requests
Register blocks via registerBlockType using block metadata (imported from block.json), and localize title/description/keywords
Use wp.media for media selection in custom components/utilities when needed
Create and register custom data stores with @wordpress/data (createReduxStore + register), and structure actions/selectors clearly
Initialize frontend interactivity after DOMContentLoaded and implement ARIA attributes for toggles (aria-controls, aria-expanded)
Handle AJAX form submissions with fetch, proper loading states, and user notices; restore UI state in finally
Implement accessibility utilities like focus trapping and polite screen reader announcements for dynamic content
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.github/instructions/javascript-react.instructions.md)
**/*.{js,ts,jsx,tsx}: Prefer arrow functions for callbacks and inline handlers
Use object/array destructuring for cleaner code
Use template literals for string interpolation
Use async/await for promise handling with try/catch for errors
Use WordPress i18n APIs (__/_n/sprintf) with a consistent textdomain for all user-facing strings; include translator comments where needed
Use @wordpress/data dispatch/select for interacting with WP data stores (e.g., core/notices, core/editor)
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/js-ts.instructions.md)
**/*.{ts,tsx,js,jsx}: Debounce user inputs to prevent excessive processing
Avoid blocking the UI thread (prefer async/non-blocking operations)
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
**/*.{js,mjs,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/performance.instructions.md)
Defer non-critical JavaScript and avoid synchronous blocking operations
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/review.instructions.md)
Internationalize user‑facing strings using WordPress i18n APIs
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
**/*.{js,ts,tsx,jsx}
⚙️ CodeRabbit configuration file
**/*.{js,ts,tsx,jsx}: Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards and @wordpress/eslint-plugin rules.
- Ensure the code is well-documented with proper JSDoc comments.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features.
- Follow WordPress JavaScript coding standards and use WordPress script localization.
- Use WordPress script dependencies and enqueue properly.
- Ensure React/JSX best practices for blocks and modern JavaScript/TypeScript patterns.
- Implement proper error handling and loading states.
- Use WordPress components and design system where applicable.
- For Tour Operator: Focus on tour booking interfaces, search functionality, and tour display components.
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
src/blocks/**/*.{js,jsx,ts,tsx}
⚙️ CodeRabbit configuration file
src/blocks/**/*.{js,jsx,ts,tsx}: - Follow WordPress JavaScript coding standards and @wordpress/scripts configuration.
- Use WordPress components from @wordpress/components and design system.
- Implement proper React/JSX patterns for WordPress blocks.
- Ensure proper WordPress script dependencies and localization.
- Use WordPress data store patterns with @wordpress/data.
- Implement proper error boundaries and loading states.
- Follow modern JavaScript/TypeScript patterns with proper typing.
- Ensure accessibility in interactive block components.
- Use WordPress block editor APIs correctly (useBlockProps, InspectorControls, etc.).
- Implement proper block validation and save/edit functionality.
Files:
src/blocks/banking/index.jssrc/blocks/health/index.jssrc/blocks/dress/index.jssrc/blocks/cuisine/index.jssrc/blocks/additional-info/index.jssrc/blocks/transport/index.jssrc/blocks/electricity/index.jssrc/blocks/climate/index.js
🧬 Code graph analysis (8)
src/blocks/banking/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/health/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/dress/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/cuisine/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/additional-info/index.js (8)
src/blocks/banking/index.js (1)
conditionalRegister(197-201)src/blocks/climate/index.js (1)
conditionalRegister(184-188)src/blocks/cuisine/index.js (1)
conditionalRegister(171-175)src/blocks/dress/index.js (1)
conditionalRegister(184-188)src/blocks/electricity/index.js (1)
conditionalRegister(171-175)src/blocks/health/index.js (1)
conditionalRegister(171-175)src/blocks/transport/index.js (1)
conditionalRegister(170-174)src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/transport/index.js (2)
src/blocks/additional-info/index.js (1)
conditionalRegister(169-173)src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/electricity/index.js (1)
src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
src/blocks/climate/index.js (2)
src/blocks/additional-info/index.js (1)
conditionalRegister(169-173)src/js/conditional-block-registration.js (1)
registerForPostTypesAndTemplates(170-177)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: review
- GitHub Check: Summary
🔇 Additional comments (21)
src/blocks/additional-info/index.js (8)
1-2: LGTM: Imports are correct.The imports follow WordPress coding standards and use the proper webpack alias for utility imports.
8-19: LGTM: Block variation metadata is well-structured.The variation registration includes proper i18n for title, description, and keywords using the correct textdomain.
20-22: LGTM: isActive predicate is correct.The isActive function correctly compares className at the top level of both blockAttributes and variationAttributes, matching the className defined at line 27. The previous metadata.className issue has been resolved.
23-31: LGTM: Attributes are properly structured.The attributes configuration is correct with metadata, className, and layout properties appropriately defined.
66-80: LGTM: Metadata bindings are correctly configured.The paragraph block properly uses metadata bindings to connect to the 'additional_info' post-meta field via the 'lsx/post-meta' source.
99-101: LGTM: Supports configuration is appropriate.Disabling renaming for this destination-specific variation is a reasonable choice to maintain consistency.
102-164: LGTM: Example configuration is comprehensive.The example provides a thorough inserter preview with properly internationalized content that demonstrates the block's structure and purpose.
169-175: LGTM: Conditional registration is correctly implemented.The conditional registration pattern matches the other destination blocks and properly restricts this variation to destination post types and templates. The immediate invocation ensures proper initialization.
src/blocks/climate/index.js (2)
1-2: LGTM!The imports are clean and follow WordPress patterns. The i18n import enables proper internationalization, and the conditional registration utility import aligns with the PR's objective of standardized conditional registration.
183-190: LGTM!The conditional registration implementation correctly restricts the climate variation to destination post types and templates, aligning with the PR objectives. The pattern follows the established approach used in other blocks like additional-info.
src/blocks/health/index.js (1)
170-177: Conditional registration implementation looks solid.The use of
registerForPostTypesAndTemplatescorrectly restricts the Health variation to destination post types and templates, aligning with the PR objectives to limit block availability to destination editing contexts.src/blocks/electricity/index.js (3)
1-2: Imports are properly structured.The imports correctly use WordPress i18n APIs and the custom conditional registration utility with webpack aliasing.
23-31: Attributes are properly configured.The metadata, className, and layout attributes are correctly structured for the block variation.
86-98: Button configuration is correctly structured.The button block with internationalized text and theme-aware styling is properly configured.
src/blocks/dress/index.js (3)
1-4: LGTM! Proper imports and DOM readiness check.The imports and domReady wrapper follow WordPress coding standards correctly.
98-111: LGTM! Button block properly configured.The button text is correctly internationalized using the
textattribute, which is the proper approach for button blocks.
184-190: LGTM! Conditional registration properly implemented.The conditional registration correctly uses the utility function to limit block availability to destination contexts.
src/blocks/banking/index.js (4)
1-2: LGTM!Imports are correctly structured using WordPress i18n and the conditional registration utility.
32-112: LGTM!The innerBlocks structure is well-organised with proper metadata, internationalized names, and correct post meta bindings. The nested group structure provides good flexibility for content layout.
116-192: LGTM!The example configuration is comprehensive and provides a realistic preview for the block inserter. The sample content on line 167 effectively demonstrates the block's purpose.
197-203: LGTM!The conditional registration correctly restricts the Banking block variation to destination post types and templates, aligning with the PR objectives. The implementation is clean and uses the shared utility appropriately.
pr: '#691'
blocks:
post_types:
author: '@tibibuzdu'
labels: ['enhancement', 'blocks', 'frontend']
Summary
This PR implements GitHub issue #691 by enhancing destination-related blocks with comprehensive Block API v3 metadata standardization, centralized icon integration, and conditional registration logic. The changes focus on destination-specific blocks (additional-info, banking, climate, cuisine, dress, electricity, health, transport) while ensuring consistent user experience and proper Block Editor integration.
The conditional registration logic was extracted into a reusable utility module for better developer experience and easier maintainability across the codebase.
Key Changes
• Block API v3 Compliance: Enhanced metadata with comprehensive descriptions, keywords, and examples
• Icon System Integration: Replaced hardcoded icons with centralized
lsx-tour-operator/iconssystem• Conditional Registration: Implemented destination-context awareness for appropriate block visibility
• Enhanced Block Metadata: Added detailed descriptions, keywords, and comprehensive example configurations
• Improved User Experience: Applied consistent formatting and proper localization throughout
• Code Standardization: Refactored registration logic with better error handling and readiness checks
• Reusable Utilities: Created shared conditional registration system for better maintainability
Files Modified
src/blocks/additional-info/block.json- Enhanced with full API v3 metadata and comprehensive supportssrc/blocks/additional-info/index.js- Improved with conditional registration and icon integrationsrc/blocks/banking/block.json- Standardized metadata with enhanced descriptions and examplessrc/blocks/banking/index.js- Added conditional registration and icon system integrationsrc/blocks/climate/block.json- Comprehensive metadata with supports object and keywordssrc/blocks/climate/index.js- Enhanced registration with destination-context detectionsrc/blocks/cuisine/block.json- API v3 compliance with detailed example configurationssrc/blocks/cuisine/index.js- Improved with centralized icon system and meta bindingsrc/blocks/dress/block.json- Enhanced metadata and comprehensive supportssrc/blocks/dress/index.js- Standardized with icon integration and improved layoutsrc/blocks/electricity/block.json- Full metadata enhancement with keywords and examplessrc/blocks/electricity/index.js- Conditional registration with destination context awarenesssrc/blocks/health/block.json- API v3 compliance with comprehensive block configurationsrc/blocks/health/index.js- Enhanced with icon system and proper localizationsrc/blocks/transport/block.json- Standardized metadata with detailed descriptionssrc/blocks/transport/index.js- Improved registration logic with conditional renderingsrc/js/conditional-block-registration.js- NEW: Reusable conditional registration utilityScope
✅ PHP
✅ JS/Blocks
block.jsonupdates with descriptions and keywords✅ Styles
⏳ Tests
✅ Docs
Technical Implementation
Enhanced Block Metadata Structure
{ "apiVersion": 3, "description": "Display additional information content for destinations.", "keywords": ["additional", "information", "general", "details"], "example": { "attributes": { "metadata": { "name": "Additional Information" } }, "innerBlocks": [/* Comprehensive example data */] } }Conditional Registration System
Centralized Utility Functions
Block Variation Structure
Testing Notes
Related Issues
Closes #691
Summary by CodeRabbit
New Features
Refactor
Documentation
Summary by CodeRabbit
Release Notes
New Features
Documentation