Conversation
- Updated block.json files for "Best Time To Visit", "Country", "Regions List", "Safety", and "Visa" blocks to include descriptions, keywords, icons, versioning, and support settings. - Refactored index.js files for each block to register variations with improved structure and error handling. - Added example attributes for better block representation in the editor. - Ensured compatibility with destination post types for all blocks.
|
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. WalkthroughUpdated five block manifests with richer metadata and editor supports; refactored each block variation into guarded, i18n-enabled Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Editor as Editor UI
participant DOM as wp.domReady
participant Data as wp.data.select
participant Reg as registerXVariation()
participant Blocks as wp.blocks
Editor->>DOM: editor load
DOM->>Data: getCurrentPostType(), getEditedPostSlug()
alt supported context (destination / template slug)
DOM->>Reg: invoke registration
Reg->>Blocks: registerBlockVariation(...)
Note right of Blocks #d5f0e6: registration uses i18n, icons block, example, isActive
Reg-->>DOM: return true (registered)
else not ready / unsupported
DOM->>DOM: poll every 100ms (timeout 5s)
DOM->>Data: re-check post type/slug
alt becomes supported within timeout
DOM->>Reg: invoke registration
Reg->>Blocks: registerBlockVariation(...)
Reg-->>DOM: return true
else timeout / failure
Reg-->>DOM: log error / return false
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
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 (5)
- src/blocks/best-time-to-visit/index.js (1)
- src/blocks/facts-country-wrapper/index.js (1)
- src/blocks/facts-regions-wrapper/index.js (1)
- src/blocks/safety/index.js (1)
- src/blocks/visa/index.js (1)
Files ignored due to filter (10)
- build/blocks/best-time-to-visit/block.json
- build/blocks/facts-country-wrapper/block.json
- build/blocks/facts-regions-wrapper/block.json
- build/blocks/safety/block.json
- build/blocks/visa/block.json
- src/blocks/best-time-to-visit/block.json
- src/blocks/facts-country-wrapper/block.json
- src/blocks/facts-regions-wrapper/block.json
- src/blocks/safety/block.json
- src/blocks/visa/block.json
Files not summarized due to errors (5)
- src/blocks/safety/index.js (diff tokens exceeds limit)
- src/blocks/best-time-to-visit/index.js (nothing obtained from openai)
- src/blocks/facts-regions-wrapper/index.js (nothing obtained from openai)
- src/blocks/facts-country-wrapper/index.js (nothing obtained from openai)
- src/blocks/visa/index.js (nothing obtained from openai)
Files not reviewed due to errors (5)
- src/blocks/safety/index.js (no response)
- src/blocks/facts-country-wrapper/index.js (no response)
- src/blocks/facts-regions-wrapper/index.js (no response)
- src/blocks/best-time-to-visit/index.js (no response)
- src/blocks/visa/index.js (no response)
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: 4
🧹 Nitpick comments (40)
src/blocks/facts-regions-wrapper/block.json (5)
4-4: Use the "lsx-to" namespace for the block name.
As per guidelines, blocks under src should use the lsx-to namespace. If you must keep the old name for back-compat, consider aliasing via a JS deprecation path and registering the new name alongside it. As per coding guidelines- "name": "lsx-tour-operator/facts-regions-wrapper", + "name": "lsx-to/facts-regions-wrapper",
15-15: Icon should use the central icon system.
PR objective says to replace hardcoded icons with the central lsx-tour-operator/icons. Keep a generic fallback here if needed, but override the icon via editorScript (index.js) to pull from the central icons registry. As per coding guidelinesExample override in index.js (no block.json change required):
registerBlockType( metadata.name, { ...metadata, icon: lsxTOIcons?.regions || metadata.icon, } );
19-35: Clean up supports: remove non-standard key and tighten accessibility supports.
“renaming” isn’t a valid supports flag. Consider adding anchor and disabling raw HTML editing. As per coding guidelines"supports": { - "renaming": false, + "anchor": true, + "html": false, "color": { "background": true, "text": true, "link": true }, "spacing": { "padding": true, "margin": true, "blockGap": true }, "typography": { "fontSize": true, "lineHeight": true } },Note: keep blockGap only if this wrapper actually contains InnerBlocks or nested content.
36-43: Enhance example for inserter preview and accessibility.
Consider adding a minimal innerBlocks preview (if this wrapper contains InnerBlocks) and clarify accessible usage in description (e.g., heading levels, list semantics). As per coding guidelinesExample augmentation:
"example": { "attributes": { "metadata": { "name": "Regions list" }, "className": "facts-regions-query-wrapper" - } + }, + "innerBlocks": [ + { "name": "core/list", "attributes": { "ordered": false }, "innerBlocks": [ + { "name": "core/list-item", "attributes": { "content": "Region A" } }, + { "name": "core/list-item", "attributes": { "content": "Region B" } } + ] } + ] },Also consider adding "usesInnerBlocks": true if applicable.
6-14: Description and keywords look good, but add editor a11y guidance.
Include brief guidance (e.g., “Use appropriate heading hierarchy; lists should reflect actual regions; avoid using this block for arbitrary content”). As per coding guidelinessrc/blocks/safety/block.json (6)
19-35: Harden supports: disable HTML editing and enable anchors.Prevents raw HTML edits and allows anchor links. Non-breaking.
"supports": { "renaming": false, + "html": false, + "anchor": true, "color": { "background": true, "text": true, "link": true },
17-19: Restrict inserter to destination contexts via postTypes.Add postTypes to align with conditional registration goals and hide the block outside allowed editors. Confirm CPT slugs (e.g. destination, country, region).
Example:
"postTypes": ["destination", "country", "region"]
6-14: Augment description with editor a11y guidance.Add a short note (e.g. avoid colour-only cues; provide clear headings/ARIA for expandable sections).
36-43: Enrich example for better inserter preview.Include innerBlocks (e.g. an icon + paragraph) so users see a realistic preview.
Example:
"example": { "attributes": { "metadata": { "name": "Safety" }, "className": "lsx-safety-wrapper" }, "innerBlocks": [ { "name": "core/paragraph", "attributes": { "content": "Always follow local guidance and check travel advisories." } } ] }
15-15: Align icon with the central icons system."shield" is a Dashicon slug. If the project uses a central icons package, ensure index.js sets the icon from that source or update block.json to reference it.
17-17: Confirm the non-standard "version" field.Block schema may ignore unknown fields. If unused by tooling, consider removing to reduce noise; else document its purpose.
src/blocks/visa/block.json (3)
6-6: Enhance description with accessibility guidance.Add editor-facing a11y guidance (e.g., icons are decorative; ensure headings/text convey meaning for screen readers).
As per coding guidelines
16-20: Add post type gating in manifest (if keeping this as a real block).If this block.json is intended to define a block (with future server-side registration), include
postTypesto limit insertion to Destinations. Note: this has no effect on a client-only variation."category": "lsx-tour-operator", + "postTypes": [ "destination" ], "version": "1.0.0",As per coding guidelines
19-43: Clarify intent: block vs variation.At runtime you only register a variation of
core/group. Without server-sideregister_block_type, this block.json’ssupports,version,example, etc. will not affect the editor. Either:
- Register a real block server-side (preferred for manifests), or
- Treat this as variation-only and remove/reduce block.json to avoid confusion.
As per coding guidelines
src/blocks/facts-country-wrapper/block.json (3)
6-6: Add a11y detail in description.Include guidance for screen reader users and explain icon semantics.
As per coding guidelines
16-20: Limit to Destination post type in manifest (if this remains a block).Add
postTypesto constrain usage. Has effect only if block is actually registered server-side."category": "lsx-tour-operator", + "postTypes": [ "destination" ], "version": "1.0.0",As per coding guidelines
19-43: Manifest vs variation mismatch.Current runtime registers a
core/groupvariation. If there is no PHPregister_block_type, the manifest’ssupportsandexamplewon’t apply. Decide between promoting this to a real block (server-side registration) or keeping it as variation-only and simplifying the manifest.As per coding guidelines
src/blocks/facts-regions-wrapper/index.js (4)
18-22: Remove unsupported variation properties and stabilise isActive.
categoryis not a supported property for block variations and has no effect.isActivecomparing translatedmetadata.nameis brittle across locales. Prefer a stable marker likeclassName.wp.blocks.registerBlockVariation('core/group', { name: 'lsx-tour-operator/facts-regions-wrapper', title: __('Regions list', 'tour-operator'), - icon: 'admin-site-alt', - category: 'lsx-tour-operator', - isActive: (blockAttributes, variationAttributes) => { - return blockAttributes.metadata?.name === variationAttributes.metadata?.name; - }, + icon: 'admin-site-alt', + isActive: (blockAttributes, variationAttributes) => { + return blockAttributes.className === variationAttributes.className; + },As per coding guidelines
87-89: Dropsupportsfrom variation; it is ignored.
supportsis for block types, not variations. Safe to remove.- supports: - { - renaming: false, - },As per coding guidelines
126-166: Replace polling with wp.data.subscribe for robust gating.Polling every 100ms for up to 5s is noisy and can miss late readiness. Use
subscribeand unsubscribe once registered.-wp.domReady(() => { - const { select } = wp.data; - // Define supported post types - const supportedPostTypes = ['destination']; - let registered = false; - // Check if current post type is supported - const checkAndRegister = () => { - if (registered) { - return true; - } - const postType = select('core/editor')?.getCurrentPostType(); - const postSlug = select('core/editor')?.getEditedPostSlug(); - if (!postType || !postSlug) { - return false; - } - if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && (postSlug.includes('destination') || postSlug.includes('country') || postSlug.includes('region')))) { - registerFactsRegionsWrapperVariation(); - registered = true; - } - return registered; - }; - // Try immediate registration - if (!checkAndRegister()) { - // If not ready, check periodically - const interval = setInterval(() => { - if (checkAndRegister()) { - clearInterval(interval); - } - }, 100); - // Clean up after 5 seconds to prevent infinite checking - setTimeout(() => clearInterval(interval), 5000); - } -}); +wp.domReady(() => { + const { select, subscribe } = wp.data; + const supportedPostTypes = ['destination']; + let unsub; + const timeout = setTimeout(() => { if (unsub) { unsub(); } }, 5000); + unsub = subscribe(() => { + const postType = select('core/editor')?.getCurrentPostType(); + const postSlug = select('core/editor')?.getEditedPostSlug(); + if (!postType || !postSlug) { + return; + } + if ( + supportedPostTypes.includes(postType) || + ((postType === 'wp_template' || postType === 'wp_template_part') && + (postSlug.includes('destination') || postSlug.includes('country') || postSlug.includes('region'))) + ) { + if (registerFactsRegionsWrapperVariation()) { + if (unsub) { unsub(); } + clearTimeout(timeout); + } + } + }); +});As per coding guidelines
129-134: Nit: end line comments with periods.Inline comments should end with a period per guidelines.
As per coding guidelines
Also applies to: 154-165
src/blocks/best-time-to-visit/block.json (3)
6-6: Add accessibility note in description.Include brief guidance for assistive tech (e.g., ensure month labels are text; icons are decorative).
As per coding guidelines
17-20: AddpostTypesif treating this as a block.Limit inserter availability to Destinations at manifest level. Has effect only with server-side registration.
"category": "lsx-tour-operator", + "postTypes": [ "destination" ], "version": "1.0.0",As per coding guidelines
19-44: Manifest likely unused for a variation-only implementation.Since runtime registers a
core/groupvariation, this manifest’ssupports/examplewill not apply unless you also register a block type server-side. Please align intent.As per coding guidelines
src/blocks/best-time-to-visit/index.js (4)
18-22: Remove unsupportedcategoryand stabiliseisActive.
categoryis ignored for variations.- Comparing translated
metadata.namerisks false negatives when locale changes. Use a stable className.wp.blocks.registerBlockVariation('core/group', { name: 'lsx-tour-operator/best-time-to-visit', title: __('Best time to visit', 'tour-operator'), - icon: 'calendar-alt', - category: 'lsx-tour-operator', - isActive: (blockAttributes, variationAttributes) => { - return blockAttributes.metadata?.name === variationAttributes.metadata?.name; - }, + icon: 'calendar-alt', + isActive: (blockAttributes, variationAttributes) => { + return blockAttributes.className === variationAttributes.className; + },As per coding guidelines
82-84: Removesupportsfrom the variation.
supportsonly applies to block types; it is ignored here.- supports: { - renaming: false, - },As per coding guidelines
121-161: Preferwp.data.subscribeto polling for registration gating.Replace setInterval + timeout with a one-shot subscription that cleans up. Less churn, more reliable.
-wp.domReady(() => { - const { select } = wp.data; - // Define supported post types - const supportedPostTypes = ['destination']; - let registered = false; - // Check if current post type is supported - const checkAndRegister = () => { - if (registered) { - return true; - } - const postType = select('core/editor')?.getCurrentPostType(); - const postSlug = select('core/editor')?.getEditedPostSlug(); - if (!postType || !postSlug) { - return false; - } - if (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && (postSlug.includes('destination') || postSlug.includes('country') || postSlug.includes('region')))) { - registerBestTimeToVisitVariation(); - registered = true; - } - return registered; - }; - // Try immediate registration - if (!checkAndRegister()) { - // If not ready, check periodically - const interval = setInterval(() => { - if (checkAndRegister()) { - clearInterval(interval); - } - }, 100); - // Clean up after 5 seconds to prevent infinite checking - setTimeout(() => clearInterval(interval), 5000); - } -}); +wp.domReady(() => { + const { select, subscribe } = wp.data; + const supportedPostTypes = ['destination']; + let unsub; + const timeout = setTimeout(() => { if (unsub) { unsub(); } }, 5000); + unsub = subscribe(() => { + const postType = select('core/editor')?.getCurrentPostType(); + const postSlug = select('core/editor')?.getEditedPostSlug(); + if (!postType || !postSlug) { + return; + } + if ( + supportedPostTypes.includes(postType) || + ((postType === 'wp_template' || postType === 'wp_template_part') && + (postSlug.includes('destination') || postSlug.includes('country') || postSlug.includes('region'))) + ) { + if (registerBestTimeToVisitVariation()) { + if (unsub) { unsub(); } + clearTimeout(timeout); + } + } + }); +});As per coding guidelines
124-129: Minor: end comments with periods.Inline comments should end with a period to match guidelines.
As per coding guidelines
Also applies to: 149-160
src/blocks/visa/index.js (4)
17-20: Remove non-variation props; consider centralised icon source.
- category is not a supported variation option; remove it.
- Keep icon, but prefer using your central icons module if available for consistency.
As per coding guidelines.
- icon: 'id-alt', - category: 'lsx-tour-operator', + icon: 'id-alt',If the icons package exposes an inserter icon, import and use it for the icon prop. Please confirm the module’s API before changing.
96-99: Drop unsupported supports on variation.supports.renaming is a block-level setting, not recognised on variations; it has no effect here.
As per coding guidelines.
- supports: { - renaming: false, - }, + // Removed unsupported variation property: supports.
47-52: Use a semantic heading instead of paragraph+strong.For accessibility and consistency with your example, use core/heading (with level) instead of a paragraph with bold text.
As per coding guidelines.
- [ - 'core/paragraph', - { - align: 'center', - content: `<strong>${__('Visa', 'tour-operator')}</strong>`, - }, - ], + [ + 'core/heading', + { + textAlign: 'center', + level: 3, + content: __('Visa', 'tour-operator'), + }, + ],
138-174: Prefer wp.data.subscribe over polling; add full stop to comments.
- Replace setInterval/timeout polling with wp.data.subscribe to react to editor readiness/state changes reliably.
- Also, end single-line comments with a period to meet the style guide.
As per coding guidelines.
Example approach:
const unsubscribe = wp.data.subscribe(() => { const postType = select('core/editor')?.getCurrentPostType(); const postSlug = select('core/editor')?.getEditedPostSlug(); if (postType && postSlug && !registered && (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && (postSlug.includes('destination') || postSlug.includes('country') || postSlug.includes('region'))))) { if (registerVisaVariation()) { registered = true; unsubscribe(); } } });src/blocks/safety/index.js (4)
17-20: Remove category on variation; consider central icon source.
- category isn’t a supported variation prop; remove it.
- Prefer a centralised icon import for icon consistency if available.
As per coding guidelines.
- icon: 'shield', - category: 'lsx-tour-operator', + icon: 'shield',
96-98: Remove unsupported supports from the variation.supports.renaming won’t be applied at the variation level.
As per coding guidelines.
- supports: { - renaming: false, - }, + // Removed unsupported variation property: supports.
47-52: Use core/heading for the title (semantic).Replace paragraph+strong with a heading for better a11y.
As per coding guidelines.
- [ - 'core/paragraph', - { - align: 'center', - content: `<strong>${__('Safety', 'tour-operator')}</strong>`, - }, - ], + [ + 'core/heading', + { + textAlign: 'center', + level: 3, + content: __('Safety', 'tour-operator'), + }, + ],
135-176: Switch polling to wp.data.subscribe; end comments with full stops.
- Use a subscribe listener to register when state is ready.
- Ensure inline comments end with a period.
As per coding guidelines.
Example:
const unsubscribe = wp.data.subscribe(() => { const postType = select('core/editor')?.getCurrentPostType(); const postSlug = select('core/editor')?.getEditedPostSlug(); if (!registeredSafety && postType && postSlug && (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && (postSlug.includes('destination') || postSlug.includes('country') || postSlug.includes('region'))))) { if (registerSafetyVariation()) { registeredSafety = true; unsubscribe(); } } });src/blocks/facts-country-wrapper/index.js (4)
27-31: Standardise class naming with the lsx- prefix.Other wrappers use the lsx- prefix (e.g., lsx-safety-wrapper). Aligning improves consistency and theming hooks.
As per coding guidelines.
- className: 'facts-country-query-wrapper', + className: 'lsx-facts-country-query-wrapper',Remember to update the isActive check and any CSS selectors accordingly.
19-19: Remove category from the variation.category is not a recognised variation option.
As per coding guidelines.
- category: 'lsx-tour-operator', + // Removed unsupported variation property: category.
87-89: Remove unsupported supports from the variation.supports.renaming has no effect at the variation level.
As per coding guidelines.
- supports: { - renaming: false, - }, + // Removed unsupported variation property: supports.
126-165: Replace polling with subscribe; add full stops to comments.Use wp.data.subscribe to register deterministically when editor state is ready, and end comments with periods.
As per coding guidelines.
Example:
const unsubscribe = wp.data.subscribe(() => { const postType = select('core/editor')?.getCurrentPostType(); const postSlug = select('core/editor')?.getEditedPostSlug(); if (!registered && postType && postSlug && (supportedPostTypes.includes(postType) || ((postType === 'wp_template' || postType === 'wp_template_part') && (postSlug.includes('destination') || postSlug.includes('country') || postSlug.includes('region'))))) { if (registerFactsCountryWrapperVariation()) { registered = true; unsubscribe(); } } });
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (15)
build/blocks/best-time-to-visit/block.jsonis 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/facts-country-wrapper/block.jsonis 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/block.jsonis 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/safety/block.jsonis excluded by!build/**build/blocks/safety/index.asset.phpis excluded by!build/**build/blocks/safety/index.jsis excluded by!build/**build/blocks/visa/block.jsonis excluded by!build/**build/blocks/visa/index.asset.phpis excluded by!build/**build/blocks/visa/index.jsis excluded by!build/**
📒 Files selected for processing (10)
src/blocks/best-time-to-visit/block.json(1 hunks)src/blocks/best-time-to-visit/index.js(1 hunks)src/blocks/facts-country-wrapper/block.json(1 hunks)src/blocks/facts-country-wrapper/index.js(1 hunks)src/blocks/facts-regions-wrapper/block.json(1 hunks)src/blocks/facts-regions-wrapper/index.js(1 hunks)src/blocks/safety/block.json(1 hunks)src/blocks/safety/index.js(1 hunks)src/blocks/visa/block.json(1 hunks)src/blocks/visa/index.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (14)
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/best-time-to-visit/block.jsonsrc/blocks/safety/block.jsonsrc/blocks/facts-country-wrapper/block.jsonsrc/blocks/visa/block.jsonsrc/blocks/facts-regions-wrapper/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/best-time-to-visit/block.jsonsrc/blocks/safety/block.jsonsrc/blocks/facts-country-wrapper/block.jsonsrc/blocks/visa/block.jsonsrc/blocks/facts-regions-wrapper/block.json
{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/best-time-to-visit/block.jsonsrc/blocks/safety/block.jsonsrc/blocks/facts-country-wrapper/block.jsonsrc/blocks/visa/block.jsonsrc/blocks/facts-regions-wrapper/block.jsonsrc/blocks/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/index.js
src/**/*.{js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use @wordpress/eslint-plugin for JavaScript linting
Files:
src/blocks/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/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/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/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/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/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/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/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/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/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/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/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/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/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/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/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/facts-regions-wrapper/index.jssrc/blocks/safety/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/visa/index.js
🧬 Code graph analysis (5)
src/blocks/facts-regions-wrapper/index.js (3)
src/blocks/best-time-to-visit/index.js (5)
wp(122-122)supportedPostTypes(125-125)registered(126-126)checkAndRegister(129-147)interval(152-156)src/blocks/facts-country-wrapper/index.js (5)
wp(127-127)supportedPostTypes(130-130)registered(131-131)checkAndRegister(134-152)interval(157-161)build/blocks/facts-regions-wrapper/index.js (5)
wp(176-178)supportedPostTypes(181-181)registered(182-182)checkAndRegister(185-199)interval(204-208)
src/blocks/safety/index.js (2)
src/blocks/best-time-to-visit/index.js (4)
wp(122-122)supportedPostTypes(125-125)checkAndRegister(129-147)interval(152-156)src/blocks/visa/index.js (4)
wp(136-136)supportedPostTypes(139-139)checkAndRegister(143-161)interval(166-170)
src/blocks/facts-country-wrapper/index.js (4)
src/blocks/best-time-to-visit/index.js (5)
wp(122-122)supportedPostTypes(125-125)registered(126-126)checkAndRegister(129-147)interval(152-156)src/blocks/facts-regions-wrapper/index.js (5)
wp(127-127)supportedPostTypes(130-130)registered(131-131)checkAndRegister(134-152)interval(157-161)src/blocks/safety/index.js (4)
wp(136-136)supportedPostTypes(139-139)checkAndRegister(143-163)interval(168-172)src/blocks/visa/index.js (5)
wp(136-136)supportedPostTypes(139-139)registered(140-140)checkAndRegister(143-161)interval(166-170)
src/blocks/best-time-to-visit/index.js (2)
src/blocks/facts-country-wrapper/index.js (5)
wp(127-127)supportedPostTypes(130-130)registered(131-131)checkAndRegister(134-152)interval(157-161)build/blocks/best-time-to-visit/index.js (5)
wp(172-174)supportedPostTypes(177-177)registered(178-178)checkAndRegister(181-195)interval(200-204)
src/blocks/visa/index.js (3)
src/blocks/best-time-to-visit/index.js (5)
wp(122-122)supportedPostTypes(125-125)registered(126-126)checkAndRegister(129-147)interval(152-156)src/blocks/safety/index.js (4)
wp(136-136)supportedPostTypes(139-139)checkAndRegister(143-163)interval(168-172)build/blocks/visa/index.js (5)
wp(173-175)supportedPostTypes(178-178)registered(179-179)checkAndRegister(182-196)interval(201-205)
⏰ 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). (3)
- GitHub Check: pr-labels
- GitHub Check: review
- GitHub Check: Summary
🔇 Additional comments (6)
src/blocks/facts-regions-wrapper/block.json (1)
17-18: Ignore textdomain change: block.json’s “textdomain” ("tour-operator") already matches the plugin’s Text Domain header, so translations remain correct.Likely an incorrect or invalid review comment.
src/blocks/safety/block.json (2)
19-23: Confirm supports.renaming is a valid key.Please verify the exact supports flag name used by current Gutenberg for list view renaming; adjust if necessary.
18-18: No update needed for textdomain The block.json textdomain (tour-operator) matches the plugin’s header.src/blocks/visa/block.json (1)
4-4: Confirm block namespace convention.Guidelines recommend the
lsx-tonamespace, but this useslsx-tour-operator. Please confirm the canonical namespace for this repo to avoid future drift.As per coding guidelines
src/blocks/facts-country-wrapper/block.json (1)
4-4: Confirm block namespace convention.Guidelines say
lsx-to; file useslsx-tour-operator. Please confirm standard to avoid inconsistency across blocks.As per coding guidelines
src/blocks/best-time-to-visit/block.json (1)
5-5: Confirm namespace choice.Guidelines prefer
lsx-to; this useslsx-tour-operator. Please confirm the standard to follow.As per coding guidelines
There was a problem hiding this comment.
Files selected (5)
- src/blocks/best-time-to-visit/index.js (1)
- src/blocks/facts-country-wrapper/index.js (1)
- src/blocks/facts-regions-wrapper/index.js (1)
- src/blocks/safety/index.js (1)
- src/blocks/visa/index.js (1)
Files not summarized due to errors (5)
- src/blocks/safety/index.js (diff tokens exceeds limit)
- src/blocks/best-time-to-visit/index.js (nothing obtained from openai)
- src/blocks/facts-regions-wrapper/index.js (nothing obtained from openai)
- src/blocks/facts-country-wrapper/index.js (nothing obtained from openai)
- src/blocks/visa/index.js (nothing obtained from openai)
Files not reviewed due to errors (5)
- src/blocks/visa/index.js (no response)
- src/blocks/facts-country-wrapper/index.js (no response)
- src/blocks/best-time-to-visit/index.js (no response)
- src/blocks/safety/index.js (no response)
- src/blocks/facts-regions-wrapper/index.js (no response)
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.
Pull Request Overview
This PR enhances destination-related blocks with conditional registration and standardized Block API v3 metadata. The changes implement conditional registration logic to ensure blocks only appear on appropriate post types (destination, country, region), integrate with a centralized icon system, and apply comprehensive Block API v3 metadata compliance including proper localization support.
Key changes:
- Added conditional registration logic for destination context detection
- Replaced hardcoded image paths with centralized icon system integration
- Applied Block API v3 metadata standardization with comprehensive supports objects
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/blocks/visa/index.js | Added conditional registration logic and localization support |
| src/blocks/visa/block.json | Enhanced with comprehensive Block API v3 metadata and supports object |
| src/blocks/safety/index.js | Implemented conditional registration and removed duplicate block registrations |
| src/blocks/safety/block.json | Added comprehensive metadata, supports object, and example |
| src/blocks/facts-regions-wrapper/index.js | Added conditional registration and icon system integration |
| src/blocks/facts-regions-wrapper/block.json | Enhanced with sentence case title and comprehensive metadata |
| src/blocks/facts-country-wrapper/index.js | Implemented conditional registration and icon system integration |
| src/blocks/facts-country-wrapper/block.json | Added comprehensive Block API v3 metadata and supports |
| src/blocks/best-time-to-visit/index.js | Added conditional registration and icon system integration |
| src/blocks/best-time-to-visit/block.json | Enhanced with sentence case title and comprehensive metadata |
| build/* | Compiled output files reflecting source changes |
There was a problem hiding this comment.
Actionable comments posted: 5
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (10)
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/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/safety/index.asset.phpis excluded by!build/**build/blocks/safety/index.jsis excluded by!build/**build/blocks/visa/index.asset.phpis excluded by!build/**build/blocks/visa/index.jsis excluded by!build/**
📒 Files selected for processing (5)
src/blocks/best-time-to-visit/index.js(1 hunks)src/blocks/facts-country-wrapper/index.js(1 hunks)src/blocks/facts-regions-wrapper/index.js(1 hunks)src/blocks/safety/index.js(1 hunks)src/blocks/visa/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/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/facts-regions-wrapper/index.jssrc/blocks/visa/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/best-time-to-visit/index.jssrc/blocks/safety/index.js
🧬 Code graph analysis (5)
src/blocks/facts-regions-wrapper/index.js (2)
src/blocks/best-time-to-visit/index.js (5)
wp(121-121)supportedPostTypes(124-124)registered(125-125)checkAndRegister(128-146)interval(151-155)src/blocks/facts-country-wrapper/index.js (5)
wp(126-126)supportedPostTypes(129-129)registered(130-130)checkAndRegister(133-151)interval(156-160)
src/blocks/visa/index.js (2)
src/blocks/best-time-to-visit/index.js (5)
wp(121-121)supportedPostTypes(124-124)registered(125-125)checkAndRegister(128-146)interval(151-155)build/blocks/visa/index.js (5)
wp(171-173)supportedPostTypes(176-176)registered(177-177)checkAndRegister(180-194)interval(199-203)
src/blocks/facts-country-wrapper/index.js (2)
src/blocks/best-time-to-visit/index.js (4)
wp(121-121)supportedPostTypes(124-124)registered(125-125)checkAndRegister(128-146)build/blocks/facts-country-wrapper/index.js (4)
wp(174-176)supportedPostTypes(179-179)registered(180-180)checkAndRegister(183-197)
src/blocks/best-time-to-visit/index.js (2)
src/blocks/facts-country-wrapper/index.js (5)
wp(126-126)supportedPostTypes(129-129)registered(130-130)checkAndRegister(133-151)interval(156-160)build/blocks/best-time-to-visit/index.js (5)
wp(169-171)supportedPostTypes(174-174)registered(175-175)checkAndRegister(178-192)interval(197-201)
src/blocks/safety/index.js (2)
src/blocks/best-time-to-visit/index.js (4)
wp(121-121)supportedPostTypes(124-124)checkAndRegister(128-146)interval(151-155)src/blocks/visa/index.js (4)
wp(135-135)supportedPostTypes(138-138)checkAndRegister(142-160)interval(165-169)
⏰ 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
There was a problem hiding this comment.
Files selected (5)
- src/blocks/best-time-to-visit/index.js (1)
- src/blocks/facts-country-wrapper/index.js (1)
- src/blocks/facts-regions-wrapper/index.js (1)
- src/blocks/safety/index.js (1)
- src/blocks/visa/index.js (1)
Files not summarized due to errors (5)
- src/blocks/safety/index.js (diff tokens exceeds limit)
- src/blocks/facts-country-wrapper/index.js (nothing obtained from openai)
- src/blocks/facts-regions-wrapper/index.js (nothing obtained from openai)
- src/blocks/best-time-to-visit/index.js (nothing obtained from openai)
- src/blocks/visa/index.js (nothing obtained from openai)
Files not reviewed due to errors (5)
- src/blocks/best-time-to-visit/index.js (no response)
- src/blocks/facts-country-wrapper/index.js (no response)
- src/blocks/facts-regions-wrapper/index.js (no response)
- src/blocks/safety/index.js (no response)
- src/blocks/visa/index.js (no response)
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: 0
♻️ Duplicate comments (3)
src/blocks/safety/index.js (1)
134-186: Extract the registration orchestration into a shared utility.The domReady callback (lines 134-186) duplicates identical registration logic across visa, safety, facts-country-wrapper, and facts-regions-wrapper files.
See the recommendation in
src/blocks/visa/index.jsat lines 134-184 to extract this pattern into a shared utility function.src/blocks/facts-country-wrapper/index.js (1)
125-175: Extract the registration orchestration into a shared utility.The domReady callback (lines 125-175) duplicates identical registration logic across visa, safety, facts-country-wrapper, and facts-regions-wrapper files.
See the recommendation in
src/blocks/visa/index.jsat lines 134-184 to extract this pattern into a shared utility function.src/blocks/facts-regions-wrapper/index.js (1)
125-175: Extract the registration orchestration into a shared utility.The domReady callback (lines 125-175) duplicates identical registration logic across visa, safety, facts-country-wrapper, and facts-regions-wrapper files.
See the recommendation in
src/blocks/visa/index.jsat lines 134-184 to extract this pattern into a shared utility function.
🧹 Nitpick comments (7)
src/blocks/visa/index.js (2)
13-132: Add JSDoc documentation for the registration function.The
registerVisaVariationfunction lacks JSDoc comments. All functions should include JSDoc with a description,@returntag, and@sincetag.As per coding guidelines.
Apply this diff to add documentation:
+/** + * Registers the Visa block variation for destination post types. + * + * @since 2.1.0 + * @return {boolean} True if registration succeeded, false otherwise. + */ function registerVisaVariation() {
134-184: Extract the registration orchestration into a shared utility.The domReady callback (lines 134-184) duplicates identical registration logic across visa, safety, facts-country-wrapper, and facts-regions-wrapper files. This pattern appears in all four files with only the function name differing.
Consider extracting this into a shared utility function to reduce duplication and improve maintainability:
/** * Registers a block variation when the editor is ready and context matches. * * @since 2.1.0 * @param {Function} registrationFn Function that registers the variation. * @param {string[]} supportedPostTypes Array of supported post type slugs. */ function registerVariationWhenReady(registrationFn, supportedPostTypes) { const { select } = wp.data; let registered = false; const checkAndRegister = () => { if (registered) { return true; } const postType = select('core/editor')?.getCurrentPostType(); const postSlug = select('core/editor')?.getEditedPostSlug(); if (!postType) { return false; } const isTemplateContext = postType === 'wp_template' || postType === 'wp_template_part'; if ( supportedPostTypes.includes(postType) || (isTemplateContext && postSlug && (postSlug.includes('destination') || postSlug.includes('country') || postSlug.includes('region'))) ) { registrationFn(); registered = true; } return registered; }; if (!checkAndRegister()) { const interval = setInterval(() => { if (checkAndRegister()) { clearInterval(interval); } }, 100); setTimeout(() => clearInterval(interval), 5000); } }Then simplify each block file to:
wp.domReady(() => { - const { select } = wp.data; - - // Define supported post types - const supportedPostTypes = ['destination']; - let registered = false; - - // Check if current post type is supported - const checkAndRegister = () => { - if (registered) { - return true; - } - - const postType = select('core/editor')?.getCurrentPostType(); - const postSlug = select('core/editor')?.getEditedPostSlug(); - - if (!postType) { - return false; - } - - const isTemplateContext = - postType === 'wp_template' || postType === 'wp_template_part'; - - if ( - supportedPostTypes.includes(postType) || - (isTemplateContext && - postSlug && - (postSlug.includes('destination') || - postSlug.includes('country') || - postSlug.includes('region'))) - ) { - registerVisaVariation(); - registered = true; - } - - return registered; - }; - - // Try immediate registration - if (!checkAndRegister()) { - // If not ready, check periodically - const interval = setInterval(() => { - if (checkAndRegister()) { - clearInterval(interval); - } - }, 100); - - // Clean up after 5 seconds to prevent infinite checking - setTimeout(() => clearInterval(interval), 5000); - } + registerVariationWhenReady(registerVisaVariation, ['destination']); });src/blocks/safety/index.js (3)
13-132: Add JSDoc documentation for the registration function.The
registerSafetyVariationfunction lacks JSDoc comments. All functions should include JSDoc with a description,@returntag, and@sincetag.As per coding guidelines.
Apply this diff to add documentation:
+/** + * Registers the Safety block variation for destination post types. + * + * @since 2.1.0 + * @return {boolean} True if registration succeeded, false otherwise. + */ function registerSafetyVariation() {
139-139: Use consistent variable naming across files.This file uses
registeredSafetywhilst other block files useregistered. Consistent naming improves code readability and maintainability.Apply this diff for consistency:
- let registeredSafety = false; + let registered = false;Update all references throughout the domReady callback accordingly.
165-168: Remove redundant registration guard.The inner check
if (!registeredSafety)at lines 165-168 is redundant. ThecheckAndRegisterfunction already returns early at line 143 ifregisteredSafetyis true, making this double-check unnecessary.Apply this diff to simplify:
- if (!registeredSafety) { - registerSafetyVariation(); - registeredSafety = true; - } + registerSafetyVariation(); + registeredSafety = true;src/blocks/facts-country-wrapper/index.js (1)
13-123: Add JSDoc documentation for the registration function.The
registerFactsCountryWrapperVariationfunction lacks JSDoc comments. All functions should include JSDoc with a description,@returntag, and@sincetag.As per coding guidelines.
Apply this diff to add documentation:
+/** + * Registers the Country block variation for destination post types. + * + * @since 2.1.0 + * @return {boolean} True if registration succeeded, false otherwise. + */ function registerFactsCountryWrapperVariation() {src/blocks/facts-regions-wrapper/index.js (1)
13-123: Add JSDoc documentation for the registration function.The
registerFactsRegionsWrapperVariationfunction lacks JSDoc comments. All functions should include JSDoc with a description,@returntag, and@sincetag.As per coding guidelines.
Apply this diff to add documentation:
+/** + * Registers the Regions List block variation for destination post types. + * + * @since 2.1.0 + * @return {boolean} True if registration succeeded, false otherwise. + */ function registerFactsRegionsWrapperVariation() {
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (10)
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/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/safety/index.asset.phpis excluded by!build/**build/blocks/safety/index.jsis excluded by!build/**build/blocks/visa/index.asset.phpis excluded by!build/**build/blocks/visa/index.jsis excluded by!build/**
📒 Files selected for processing (5)
src/blocks/best-time-to-visit/index.js(1 hunks)src/blocks/facts-country-wrapper/index.js(1 hunks)src/blocks/facts-regions-wrapper/index.js(1 hunks)src/blocks/safety/index.js(1 hunks)src/blocks/visa/index.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/blocks/best-time-to-visit/index.js
🧰 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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/index.js
**/*.{css,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Minimize CSS/JS payload size
Files:
src/blocks/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/index.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)
Lazy-load code and resources where possible
Files:
src/blocks/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/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/safety/index.jssrc/blocks/facts-regions-wrapper/index.jssrc/blocks/facts-country-wrapper/index.jssrc/blocks/visa/index.js
🧬 Code graph analysis (4)
src/blocks/safety/index.js (4)
src/blocks/best-time-to-visit/index.js (4)
wp(121-121)supportedPostTypes(124-124)checkAndRegister(128-156)interval(161-165)src/blocks/facts-country-wrapper/index.js (4)
wp(126-126)supportedPostTypes(129-129)checkAndRegister(133-161)interval(166-170)src/blocks/facts-regions-wrapper/index.js (4)
wp(126-126)supportedPostTypes(129-129)checkAndRegister(133-161)interval(166-170)src/blocks/visa/index.js (4)
wp(135-135)supportedPostTypes(138-138)checkAndRegister(142-170)interval(175-179)
src/blocks/facts-regions-wrapper/index.js (3)
src/blocks/best-time-to-visit/index.js (4)
wp(121-121)supportedPostTypes(124-124)registered(125-125)checkAndRegister(128-156)src/blocks/facts-country-wrapper/index.js (4)
wp(126-126)supportedPostTypes(129-129)registered(130-130)checkAndRegister(133-161)build/blocks/facts-regions-wrapper/index.js (4)
wp(174-176)supportedPostTypes(179-179)registered(180-180)checkAndRegister(183-198)
src/blocks/facts-country-wrapper/index.js (5)
src/blocks/best-time-to-visit/index.js (5)
wp(121-121)supportedPostTypes(124-124)registered(125-125)checkAndRegister(128-156)interval(161-165)src/blocks/facts-regions-wrapper/index.js (5)
wp(126-126)supportedPostTypes(129-129)registered(130-130)checkAndRegister(133-161)interval(166-170)src/blocks/safety/index.js (4)
wp(135-135)supportedPostTypes(138-138)checkAndRegister(142-172)interval(177-181)src/blocks/visa/index.js (5)
wp(135-135)supportedPostTypes(138-138)registered(139-139)checkAndRegister(142-170)interval(175-179)build/blocks/facts-country-wrapper/index.js (5)
wp(174-176)supportedPostTypes(179-179)registered(180-180)checkAndRegister(183-198)interval(203-207)
src/blocks/visa/index.js (2)
src/blocks/best-time-to-visit/index.js (5)
wp(121-121)supportedPostTypes(124-124)registered(125-125)checkAndRegister(128-156)interval(161-165)build/blocks/visa/index.js (5)
wp(171-173)supportedPostTypes(176-176)registered(177-177)checkAndRegister(180-195)interval(200-204)
⏰ 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
pr: '#656'
related_issues: '#651'
blocks:
post_types:
author: '@tibibuzdu'
labels: ['enhancement', 'blocks', 'frontend']
Summary
This PR implements GitHub issue #651 by enhancing destination-related blocks with conditional registration logic and comprehensive Block API v3 metadata standardization. The changes ensure blocks only appear in appropriate contexts while providing consistent user experience and proper localization support.
Key Changes
• Conditional Registration: Implemented post type detection for destination, country, and region contexts
• Icon System Integration: Replaced hardcoded image paths with centralized
lsx-tour-operator/iconssystem• Block API v3 Compliance: Added comprehensive metadata, supports object, and examples
• Localization Improvements: Applied sentence case formatting and proper text domain usage
• Code Quality: Removed hardcoded styles and improved maintainability
Files Modified
src/blocks/best-time-to-visit/block.json- Enhanced with full API v3 metadata and sentence case titlesrc/blocks/best-time-to-visit/index.js- Added conditional registration and icon integrationsrc/blocks/facts-country-wrapper/block.json- Standardized metadata and enhanced descriptionsrc/blocks/facts-country-wrapper/index.js- Implemented conditional registration logicsrc/blocks/facts-regions-wrapper/block.json- Added comprehensive metadata with sentence casesrc/blocks/facts-regions-wrapper/index.js- Added post type detection and icon systemsrc/blocks/safety/block.json- Standardized with Block API v3 metadatasrc/blocks/safety/index.js- Implemented conditional registrationsrc/blocks/visa/block.json- Enhanced with comprehensive supports objectsrc/blocks/visa/index.js- Added destination context detectionScope
✅ PHP
✅ JS/Blocks
✅ Styles
⏳ Tests
✅ Docs
Technical Implementation
Conditional Registration Logic
Icon System Integration
Block API v3 Metadata Structure
{ "apiVersion": 3, "supports": { "color": { "background": true, "text": true, "link": true }, "spacing": { "padding": true, "margin": true, "blockGap": true }, "typography": { "fontSize": true, "lineHeight": true } }, "example": { /* Comprehensive example */ } }Testing Notes
Related Issues
Closes #651
Summary by CodeRabbit
New Features
Refactor