Skip to content

Enhance destination blocks with conditional registration and standardized metadata#656

Merged
krugazul merged 3 commits into2.1-trunkfrom
refactor/destination-blocks-icon-meta
Oct 14, 2025
Merged

Enhance destination blocks with conditional registration and standardized metadata#656
krugazul merged 3 commits into2.1-trunkfrom
refactor/destination-blocks-icon-meta

Conversation

@tibiii
Copy link
Copy Markdown
Contributor

@tibiii tibiii commented Oct 10, 2025


pr: '#656'
related_issues: '#651'
blocks:

  • best-time-to-visit
  • facts-country-wrapper
  • facts-regions-wrapper
  • safety
  • visa
    post_types:
  • destination
  • country
  • region
    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/icons system
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

Scope

✅ PHP

  • No PHP backend changes required

✅ JS/Blocks

  • Block API v3 metadata compliance
  • block.json updated with comprehensive supports
  • Conditional registration implemented
  • Icon system integration
  • Sentence case text formatting
  • Proper localization with text domains

✅ Styles

  • Removed hardcoded image paths
  • Integrated with centralized icon system

⏳ Tests

  • Block registration tests (future enhancement)
  • Conditional display tests (future enhancement)

✅ Docs

  • Enhanced block descriptions and keywords
  • Comprehensive examples in block.json files

Technical Implementation

Conditional Registration Logic

// Post type detection with template slug validation
function shouldRegisterBlock() {
  const post = wp.data.select('core/editor').getCurrentPost();
  const template = wp.data.select('core/editor').getEditedPostAttribute('template');
  
  return ['destination', 'country', 'region'].includes(post.type) || 
         ['single-destination', 'single-country', 'single-region'].includes(template);
}

Icon System Integration

// Replaced hardcoded paths with centralized icons
['lsx-tour-operator/icons', {
  iconName: 'bestMonthsToTravelIcon' // Central icon system
}]

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

  • All blocks now register conditionally based on post type context
  • Icon system integration maintains visual consistency
  • Sentence case formatting improves user experience
  • Block metadata follows WordPress standards
  • Localization properly implemented throughout

Related Issues

Closes #651

Summary by CodeRabbit

  • New Features

    • Enhanced Best time to visit, Safety, Visa, Facts (country/regions) blocks with richer metadata (descriptions, icons, keywords, version, textdomain) and example previews.
    • Added styling controls (background/text/link colours, padding, margin, gap, font size, line height).
    • Localised titles, labels and example content; variations include isActive predicates and show only in relevant destination contexts.
  • Refactor

    • Guarded, deferred registration flow with readiness checks, polling/timeouts and error handling for more reliable editor behaviour.

- 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.
@github-actions github-actions bot added lang:php PHP code lang:javascript area:block-editor status:needs-review Awaiting code review meta:needs-changelog Requires a changelog entry before merge labels Oct 10, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 10, 2025

Warning

CodeRabbit GitHub Action detected

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

Walkthrough

Updated five block manifests with richer metadata and editor supports; refactored each block variation into guarded, i18n-enabled registerXVariation() functions that add isActive checks, example payloads, icons-block usage, and conditional domReady/post-type/template gated registration with polling.

Changes

Cohort / File(s) Summary
Block manifest enhancements
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
Add/adjust title/description/keywords/icon/version/textdomain; add supports (renaming, color, spacing, typography) and example attributes; editorScript unchanged.
Guarded variation registration + i18n + examples
src/blocks/best-time-to-visit/index.js, src/blocks/facts-country-wrapper/index.js, src/blocks/facts-regions-wrapper/index.js, src/blocks/safety/index.js, src/blocks/visa/index.js
Replace immediate registrations with registerXVariation() functions; import __ from @wordpress/i18n, localise strings, add isActive predicates, restructure attributes/innerBlocks to include lsx-tour-operator/icons, add example payloads, wrap registration in wp.domReady/post-type/template gating with polling and try/catch logging; functions return boolean success.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Suggested labels

comp:block-variations, comp:block-supports, comp:block-json, 2.1.0

Suggested reviewers

  • ZaredRogers
  • krugazul

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The PR correctly implements conditional registration logic, comprehensive Block API v3 metadata updates, icon system integration, and localization as required by issue #651, but it omits the server-side PHP registration calls (register_block_type) and the CSS-to-theme.json styling migration specified in the linked issue. Add the necessary PHP register_block_type calls for each block in your plugin and migrate legacy CSS rules into theme.json selectors to fully satisfy the linked issue’s requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and concisely summarizes the primary changes of this PR by highlighting enhancement of destination blocks, conditional registration, and metadata standardisation, making it easy for team members to understand the main intent at a glance.
Out of Scope Changes Check ✅ Passed All modifications are confined to the specified destination-related blocks and directly support the outlined objectives, with no unrelated or extraneous code changes detected.
Description Check ✅ Passed The description provides a clear summary, key changes list, detailed file modifications, technical implementation snippets, testing notes, and linked issue references, fulfilling most template requirements. It omits a dedicated Risk & Rollback section and the global DoD checklist, and uses “### Key Changes” instead of the expected “## Changes” heading.
✨ 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/destination-blocks-icon-meta

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

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 10, 2025

Image description CodeRabbit


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

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

@tibiii tibiii self-assigned this Oct 10, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Tour Operator Oct 10, 2025
@tibiii tibiii moved this from Needs Triage to 🔎 In Review in Tour Operator Oct 10, 2025
@tibiii tibiii added this to the v2.1.0 milestone Oct 10, 2025
@github-actions github-actions bot added status:needs-review Awaiting code review and removed status:needs-review Awaiting code review labels Oct 10, 2025
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between e0781ef and 4ad1399 commits.
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 Image description CodeRabbit Bot (@coderabbitai)

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

Code suggestions

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

Pausing incremental reviews

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 guidelines

Example 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 guidelines

Example 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 guidelines

src/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 postTypes to 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-side register_block_type, this block.json’s supports, 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 postTypes to 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/group variation. If there is no PHP register_block_type, the manifest’s supports and example won’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.

  • category is not a supported property for block variations and has no effect.
  • isActive comparing translated metadata.name is brittle across locales. Prefer a stable marker like className.
         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: Drop supports from variation; it is ignored.

supports is 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 subscribe and 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: Add postTypes if 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/group variation, this manifest’s supports/example will 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 unsupported category and stabilise isActive.

  • category is ignored for variations.
  • Comparing translated metadata.name risks 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: Remove supports from the variation.

supports only applies to block types; it is ignored here.

-            supports: {
-                renaming: false,
-            },

As per coding guidelines


121-161: Prefer wp.data.subscribe to 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

📥 Commits

Reviewing files that changed from the base of the PR and between e0781ef and 4ad1399.

⛔ Files ignored due to path filters (15)
  • build/blocks/best-time-to-visit/block.json is excluded by !build/**
  • build/blocks/best-time-to-visit/index.asset.php is excluded by !build/**
  • build/blocks/best-time-to-visit/index.js is excluded by !build/**
  • build/blocks/facts-country-wrapper/block.json is excluded by !build/**
  • build/blocks/facts-country-wrapper/index.asset.php is excluded by !build/**
  • build/blocks/facts-country-wrapper/index.js is excluded by !build/**
  • build/blocks/facts-regions-wrapper/block.json is excluded by !build/**
  • build/blocks/facts-regions-wrapper/index.asset.php is excluded by !build/**
  • build/blocks/facts-regions-wrapper/index.js is excluded by !build/**
  • build/blocks/safety/block.json is excluded by !build/**
  • build/blocks/safety/index.asset.php is excluded by !build/**
  • build/blocks/safety/index.js is excluded by !build/**
  • build/blocks/visa/block.json is excluded by !build/**
  • build/blocks/visa/index.asset.php is excluded by !build/**
  • build/blocks/visa/index.js is 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 namespace lsx-to in block names

Files:

  • src/blocks/best-time-to-visit/block.json
  • src/blocks/safety/block.json
  • src/blocks/facts-country-wrapper/block.json
  • src/blocks/visa/block.json
  • src/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.json
  • src/blocks/safety/block.json
  • src/blocks/facts-country-wrapper/block.json
  • src/blocks/visa/block.json
  • src/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.json
  • src/blocks/safety/block.json
  • src/blocks/facts-country-wrapper/block.json
  • src/blocks/visa/block.json
  • src/blocks/facts-regions-wrapper/block.json
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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 domain tour-operator for JS i18n calls

Files:

  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/safety/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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-to namespace, but this uses lsx-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 uses lsx-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 uses lsx-tour-operator. Please confirm the standard to follow.

As per coding guidelines

@github-project-automation github-project-automation bot moved this from 🔎 In Review to Needs Triage in Tour Operator Oct 10, 2025
@github-actions github-actions bot added status:needs-review Awaiting code review and removed status:needs-review Awaiting code review labels Oct 10, 2025
@github-actions github-actions bot added status:needs-review Awaiting code review and removed status:needs-review Awaiting code review labels Oct 10, 2025
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 4ad1399 and 61da8e3 commits.
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 Image description CodeRabbit Bot (@coderabbitai)

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

Code suggestions

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

Pausing incremental reviews

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

@tibiii tibiii requested a review from Copilot October 10, 2025 15:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This 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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad1399 and 61da8e3.

⛔ Files ignored due to path filters (10)
  • build/blocks/best-time-to-visit/index.asset.php is excluded by !build/**
  • build/blocks/best-time-to-visit/index.js is excluded by !build/**
  • build/blocks/facts-country-wrapper/index.asset.php is excluded by !build/**
  • build/blocks/facts-country-wrapper/index.js is excluded by !build/**
  • build/blocks/facts-regions-wrapper/index.asset.php is excluded by !build/**
  • build/blocks/facts-regions-wrapper/index.js is excluded by !build/**
  • build/blocks/safety/index.asset.php is excluded by !build/**
  • build/blocks/safety/index.js is excluded by !build/**
  • build/blocks/visa/index.asset.php is excluded by !build/**
  • build/blocks/visa/index.js is 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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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 domain tour-operator for JS i18n calls

Files:

  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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.js
  • src/blocks/visa/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/blocks/best-time-to-visit/index.js
  • src/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

@github-actions github-actions bot added status:needs-review Awaiting code review and removed status:needs-review Awaiting code review labels Oct 10, 2025
@github-actions github-actions bot added status:needs-review Awaiting code review and removed status:needs-review Awaiting code review labels Oct 10, 2025
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 61da8e3 and 196a9ac commits.
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 Image description CodeRabbit Bot (@coderabbitai)

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

Code suggestions

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

Pausing incremental reviews

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.js at 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.js at 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.js at 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 registerVisaVariation function lacks JSDoc comments. All functions should include JSDoc with a description, @return tag, and @since tag.

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 registerSafetyVariation function lacks JSDoc comments. All functions should include JSDoc with a description, @return tag, and @since tag.

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 registeredSafety whilst other block files use registered. 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. The checkAndRegister function already returns early at line 143 if registeredSafety is 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 registerFactsCountryWrapperVariation function lacks JSDoc comments. All functions should include JSDoc with a description, @return tag, and @since tag.

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 registerFactsRegionsWrapperVariation function lacks JSDoc comments. All functions should include JSDoc with a description, @return tag, and @since tag.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 61da8e3 and 196a9ac.

⛔ Files ignored due to path filters (10)
  • build/blocks/best-time-to-visit/index.asset.php is excluded by !build/**
  • build/blocks/best-time-to-visit/index.js is excluded by !build/**
  • build/blocks/facts-country-wrapper/index.asset.php is excluded by !build/**
  • build/blocks/facts-country-wrapper/index.js is excluded by !build/**
  • build/blocks/facts-regions-wrapper/index.asset.php is excluded by !build/**
  • build/blocks/facts-regions-wrapper/index.js is excluded by !build/**
  • build/blocks/safety/index.asset.php is excluded by !build/**
  • build/blocks/safety/index.js is excluded by !build/**
  • build/blocks/visa/index.asset.php is excluded by !build/**
  • build/blocks/visa/index.js is 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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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 domain tour-operator for JS i18n calls

Files:

  • src/blocks/safety/index.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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.js
  • src/blocks/facts-regions-wrapper/index.js
  • src/blocks/facts-country-wrapper/index.js
  • src/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

@krugazul krugazul self-requested a review October 14, 2025 20:36
Copy link
Copy Markdown
Collaborator

@krugazul krugazul left a comment

Choose a reason for hiding this comment

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

@tibiii I have tested the branch, the blocks are restricting well to the destinations templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:block-editor lang:javascript lang:php PHP code meta:needs-changelog Requires a changelog entry before merge status:needs-review Awaiting code review

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Block Audit: best-time-to-visit, facts-country-wrapper, facts-region-wrapper, safety & visa (Destination post type meta & icons integration)

3 participants