Skip to content

Standardize accommodation block metadata and improve example structure#625

Merged
krugazul merged 3 commits into2.1-trunkfrom
624-standardize-accommodation-block-meta
Oct 14, 2025
Merged

Standardize accommodation block metadata and improve example structure#625
krugazul merged 3 commits into2.1-trunkfrom
624-standardize-accommodation-block-meta

Conversation

@tibiii
Copy link
Copy Markdown
Contributor

@tibiii tibiii commented Sep 11, 2025

Description

This PR standardizes the metadata for accommodation-related blocks as part of the larger block standardization effort (issue #583). This is the first chunk focusing on accommodation blocks to make the review process more manageable.

Blocks updated:

  • accommodation-related-accommodation
  • accommodation-related-destination
  • accommodation-related-tour
  • accommodation-type

Changes include:

  • Standardized block.json schema with proper $schema declaration
  • Added comprehensive textdomain and internationalization support
  • Enhanced block descriptions and relevant keywords for better discoverability
  • Consistent icon assignments and category organization
  • Added detailed example blocks for preview functionality
  • Improved code formatting and consistency in index.js files
  • Proper metadata naming conventions following WordPress Block Editor guidelines

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code Refactor / Review
  • Performance Improvement
  • Test or CI Update
  • Other (please describe):

Benefits

  • Developers: Consistent block development patterns make it easier to maintain and extend blocks
  • Content creators: More predictable block behavior and better discovery in the block editor
  • Translators: Proper internationalization support with consistent text domains
  • Plugin maintainers: Reduced technical debt and standardized architecture
  • Site administrators: Better block categorization and more meaningful descriptions

Possible Drawbacks

  • None expected - these are non-breaking metadata improvements that enhance existing functionality without changing block behavior

Alternate Designs

  • Considered: Processing all blocks in a single large PR
  • Rejected: Too complex for effective review and potential merge conflicts
  • Selected: Chunked approach with logical groupings (accommodation blocks first)

Checklist

  • I agree to follow this project's Code of Conduct
  • I have read the CONTRIBUTING guidelines
  • My code follows the code style of this project
  • Linting and tests pass locally with my changes
  • I have added or updated documentation as needed
  • I have added tests to cover my change
  • All new and existing tests pass

How to Test

  1. Block Editor Testing:

    • Open WordPress admin and create a new page/post
    • Search for "accommodation" in the block inserter
    • Verify blocks appear with proper icons and descriptions
    • Insert each block and verify they function as before
  2. Internationalization Testing:

    • Verify text domain is properly set in all block.json files
    • Check that translatable strings are properly wrapped
  3. Schema Validation:

    • Validate that all block.json files follow WordPress schema
    • Ensure no console errors in block editor
  4. Backward Compatibility:

    • Test existing pages with these blocks still render correctly
    • Verify no breaking changes to block attributes or functionality

Applicable Issues

Addresses #624
Part of #583


Changelog Entry

Developer - Standardized metadata for accommodation-related blocks (accommodation-related-accommodation, accommodation-related-destination, accommodation-related-tour, accommodation-type) with improved internationalization, enhanced descriptions, and consistent schema following WordPress Block Editor guidelines.

Summary by CodeRabbit

  • New Features

    • Enhanced Related Accommodation, Destination and Tour variations with translated titles/descriptions, locked variation names, clearer headers and query-driven 3‑column grids.
    • Added rich editor previews/examples for all related blocks and Accommodation Type to showcase sample content.
    • Improved discovery with icons, keywords and descriptions; added i18n support and standardized metadata.
  • Documentation

    • Changelog updated (v2.1.0) noting standardized accommodation block metadata, improved internationalisation and schema compliance.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 11, 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

Adds i18n and standardized metadata (textdomain, description, icon, keywords, example) to multiple accommodation block manifests; refactors four block variation registrations to explicit innerBlocks with header + query + 3‑column grid, adds example previews and supports.renaming=false, and adjusts one isActive signature. Updates changelog for 2.1.0.

Changes

Cohort / File(s) Summary
Changelog entry
changelog.md
Added 2.1.0 “Changed” note referencing standardized accommodation block metadata (PR #625, Issue #624).
Block manifests: i18n, metadata, examples
src/blocks/accommodation-related-accommodation/block.json, src/blocks/accommodation-related-destination/block.json, src/blocks/accommodation-related-tour/block.json, src/blocks/accommodation-type/block.json
Added textdomain, description, icon, keywords, and detailed example previews; minor JSON formatting tweaks; updated titles/casing where applicable.
Block variations: structure, examples, supports
src/blocks/accommodation-related-accommodation/index.js, src/blocks/accommodation-related-destination/index.js, src/blocks/accommodation-related-tour/index.js, src/blocks/accommodation-type/index.js
Localised user-facing strings with wp.i18n; reworked innerBlocks into explicit header + separators + query + post-template grid with pattern usage; added example previews and supports: { renaming: false }; accommodation-related-accommodation variation changed isActive signature to (blockAttributes).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Editor
    participant Variation as Block Variation (core/group)
    participant Header as Header Group
    participant Query as core/query (accommodation)
    participant Template as core/post-template (grid:3)
    participant Card as Pattern: accommodation-card

    Editor->>Variation: Insert variation
    Variation->>Header: Render separators + centered heading
    Variation->>Query: Initialise perPage, postType, order/orderBy
    Query->>Template: Build grid layout
    Template->>Card: Render each item via pattern
    Note over Variation,Template: supports.renaming = false (related variations)
    alt isActive by className (related-accommodation only)
        Editor->>Variation: Evaluate className.includes(wrapper)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Suggested labels

[Component] Block Variations, Enhancement, 2.1.0, Tour Operator

Suggested reviewers

  • ZaredRogers

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description does not follow the repository’s prescribed template because it uses a “## Description” heading instead of “## Summary” and omits an explicit linked issues line. It also lacks a dedicated “## Changes” section header and does not include the required “## Risk & Rollback” section or rollback details. This divergence from the template structure can lead to missing critical information and inconsistent formatting. Rename the “## Description” heading to “## Summary” and add an explicit “Linked issues” line listing the relevant issue references. Create a separate “## Changes” section with concise bullet points summarising the key modifications, and include a “## Risk & Rollback” section that specifies the risk level and a rollback plan. Ensure that all headings and sections follow the description template exactly and that optional sections are either used or clearly omitted if not applicable.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly summarises the key changes by indicating that block metadata is standardised and example structures are improved, which directly reflects the modifications made across block.json schemas and index.js examples for accommodation-related blocks. It is concise, specific, and focused on the main intent without extraneous details. The phrasing is clear and would make sense to a reviewer scanning the history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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 624-standardize-accommodation-block-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 Sep 11, 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.

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 2d45fed and 8de4e9a commits.
Files selected (6)
  • build/blocks/modal-button/index.js (1)
  • changelog.md (1)
  • src/blocks/accommodation-related-accommodation/index.js (2)
  • src/blocks/accommodation-related-destination/index.js (1)
  • src/blocks/accommodation-related-tour/index.js (1)
  • src/blocks/accommodation-type/index.js (1)
Files ignored due to filter (9)
  • build/blocks/accommodation-related-accommodation/block.json
  • build/blocks/accommodation-related-destination/block.json
  • build/blocks/accommodation-related-tour/block.json
  • build/blocks/accommodation-type/block.json
  • build/blocks/modal-button/block.json
  • src/blocks/accommodation-related-accommodation/block.json
  • src/blocks/accommodation-related-destination/block.json
  • src/blocks/accommodation-related-tour/block.json
  • src/blocks/accommodation-type/block.json
Files not summarized due to errors (6)
  • build/blocks/modal-button/index.js (diff tokens exceeds limit)
  • src/blocks/accommodation-type/index.js (nothing obtained from openai)
  • changelog.md (nothing obtained from openai)
  • src/blocks/accommodation-related-accommodation/index.js (nothing obtained from openai)
  • src/blocks/accommodation-related-tour/index.js (nothing obtained from openai)
  • src/blocks/accommodation-related-destination/index.js (nothing obtained from openai)
Files not reviewed due to errors (6)
  • changelog.md (no response)
  • src/blocks/accommodation-related-destination/index.js (no response)
  • src/blocks/accommodation-type/index.js (no response)
  • build/blocks/modal-button/index.js (no response)
  • src/blocks/accommodation-related-tour/index.js (no response)
  • src/blocks/accommodation-related-accommodation/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: 9

🧹 Nitpick comments (11)
changelog.md (1)

38-38: Wording: prefer “internationalisation (i18n)” for consistency

Minor copy edit to match en-ZA spelling and common shorthand.

-- Standardized accommodation block metadata with improved internationalization, descriptions, and schema compliance - PR [#625](https://github.com/lightspeedwp/tour-operator/pull/625), Issue [#624](https://github.com/lightspeedwp/tour-operator/issues/624)
+- Standardised accommodation block metadata with improved internationalisation (i18n), descriptions, and schema compliance – PR [#625](https://github.com/lightspeedwp/tour-operator/pull/625), Issue [#624](https://github.com/lightspeedwp/tour-operator/issues/624)
src/blocks/accommodation-related-tour/block.json (1)

16-143: Example payload is fine; consider keeping examples in one place

Optional: keep the example either here (block.json) or in the variation (index.js), but not both, to avoid drift.

src/blocks/accommodation-type/block.json (1)

16-43: Single source of truth for examples

Since index.js also defines an example for this variation, prefer keeping the example in one place (recommend block.json) and removing the duplicate from JS.

src/blocks/accommodation-type/index.js (2)

65-92: De-duplicate example (keep it in block.json, remove here)

Having two copies invites drift.

-		example: {
-			attributes: {
-				metadata: {
-					name: "Accommodation Type",
-				},
-			},
-			innerBlocks: [
-				[
-					"core/group",
-					{},
-					[
-						[
-							"core/heading",
-							{
-								content: "Accommodation Type",
-								level: 3,
-							},
-						],
-						[
-							"core/paragraph",
-							{
-								content: "Luxury Safari Lodge",
-							},
-						],
-					],
-				],
-			],
-		},

1-5: Optional: define __ once

For cleanliness, pull __ from wp.i18n once at the top of the callback.

-wp.domReady(() => {
+wp.domReady(() => {
+	const { __ } = wp.i18n;
src/blocks/accommodation-related-destination/index.js (2)

95-97: Add isActive to reliably detect the variation in the editor.

Match on the wrapper class the same way as the “accommodation-related-accommodation” build artifact.

Apply:

 		supports: {
 			renaming: false,
 		},
+		isActive: ( attributes ) =>
+			attributes?.className === 'lsx-accommodation-related-destination-query-wrapper' ||
+			attributes?.className?.includes( 'lsx-accommodation-related-destination-query-wrapper' ),

63-69: Confirm sort order (“asc” by date).

For related content, latest-first is typical. If there’s no product reason for ascending, consider “desc”.

Apply (if desired):

-                               order: 'asc',
+                               order: 'desc',
src/blocks/accommodation-related-destination/block.json (2)

11-15: Add “accommodation” to keywords for better discoverability.

Apply:

   "keywords": [
     "related",
+    "accommodation",
     "destinations",
     "similar"
   ],

64-76: Optional: Make example cards accommodation‑centric.

Current items are destination names; consider sample accommodation names to avoid confusion.

Also applies to: 94-106, 124-136

src/blocks/accommodation-related-accommodation/block.json (1)

16-21: Align example metadata.name with the registered variation title.

Minor naming consistency.

Apply:

-      "metadata": {
-        "name": "Related Accommodation"
-      }
+      "metadata": {
+        "name": "Related Accommodation - Accommodation"
+      }
src/blocks/accommodation-related-accommodation/index.js (1)

193-199: Consider simplifying the isActive check.

The current implementation checks for both exact match and includes, but since includes() would also match an exact string, the first condition is redundant.

-		isActive: ( blockAttributes ) => {
-			return (
-				blockAttributes.className === 'lsx-accommodation-related-accommodation-query-wrapper' ||
-				( blockAttributes.className &&
-					blockAttributes.className.includes( 'lsx-accommodation-related-accommodation-query-wrapper' ) )
-			);
-		},
+		isActive: ( blockAttributes ) => {
+			return blockAttributes.className?.includes( 'lsx-accommodation-related-accommodation-query-wrapper' ) || false;
+		},
📜 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 2d45fed and 8de4e9a.

⛔ Files ignored due to path filters (20)
  • build/admin.asset.php is excluded by !build/**
  • build/blocks/accommodation-related-accommodation/block.json is excluded by !build/**
  • build/blocks/accommodation-related-accommodation/index.asset.php is excluded by !build/**
  • build/blocks/accommodation-related-accommodation/index.js is excluded by !build/**
  • build/blocks/accommodation-related-destination/block.json is excluded by !build/**
  • build/blocks/accommodation-related-destination/index.asset.php is excluded by !build/**
  • build/blocks/accommodation-related-destination/index.js is excluded by !build/**
  • build/blocks/accommodation-related-tour/block.json is excluded by !build/**
  • build/blocks/accommodation-related-tour/index.asset.php is excluded by !build/**
  • build/blocks/accommodation-related-tour/index.js is excluded by !build/**
  • build/blocks/accommodation-type/block.json is excluded by !build/**
  • build/blocks/accommodation-type/index.asset.php is excluded by !build/**
  • build/blocks/accommodation-type/index.js is excluded by !build/**
  • build/blocks/modal-button/block.json is excluded by !build/**
  • build/blocks/modal-button/index.asset.php is excluded by !build/**
  • build/blocks/modal-button/index.js is excluded by !build/**
  • build/custom.asset.php is excluded by !build/**
  • build/custom.js is excluded by !build/**
  • build/metaboxes.asset.php is excluded by !build/**
  • build/style.asset.php is excluded by !build/**
📒 Files selected for processing (9)
  • changelog.md (1 hunks)
  • src/blocks/accommodation-related-accommodation/block.json (1 hunks)
  • src/blocks/accommodation-related-accommodation/index.js (2 hunks)
  • src/blocks/accommodation-related-destination/block.json (1 hunks)
  • src/blocks/accommodation-related-destination/index.js (1 hunks)
  • src/blocks/accommodation-related-tour/block.json (1 hunks)
  • src/blocks/accommodation-related-tour/index.js (1 hunks)
  • src/blocks/accommodation-type/block.json (1 hunks)
  • src/blocks/accommodation-type/index.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{php,js,ts,jsx,tsx}

⚙️ CodeRabbit configuration file

**/*.{php,js,ts,jsx,tsx}: - Follow WordPress coding standards.

  • Escape output and sanitize input.
  • Follow plugin security best practices.
  • Enforce prefixing for all functions, classes, and constants to avoid naming collisions.
  • Check for accessibility best practices in UI code (labels, ARIA attributes, color contrast).
  • Ensure inline documentation/comments for all custom functions and classes.
  • Ensure consistent formatting and schema validation.
  • Keep documentation up to date and clear.
  • On Pull Requests check for updates to the changelog file.

Files:

  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-accommodation/index.js
  • src/blocks/accommodation-type/index.js
🧠 Learnings (1)
📚 Learning: 2025-08-25T13:07:05.897Z
Learnt from: CR
PR: lightspeedwp/tour-operator#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-25T13:07:05.897Z
Learning: Applies to tour-operator/src/**/*.js : Use the block namespace `lsx-to` when registering Gutenberg blocks (e.g., name: 'lsx-to/your-block')

Applied to files:

  • src/blocks/accommodation-type/block.json
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-tour/block.json
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-accommodation/index.js
  • src/blocks/accommodation-type/index.js
🧬 Code graph analysis (7)
src/blocks/accommodation-related-accommodation/block.json (1)
build/blocks/accommodation-related-accommodation/index.js (1)
  • wp (1-1)
src/blocks/accommodation-type/block.json (2)
src/blocks/destination-to-accommodation/index.js (1)
  • wp (1-67)
src/blocks/featured-accommodation/index.js (1)
  • wp (1-70)
src/blocks/accommodation-related-destination/index.js (4)
build/blocks/accommodation-related-accommodation/index.js (1)
  • wp (1-1)
src/blocks/destination-to-accommodation/index.js (1)
  • wp (1-67)
src/blocks/featured-accommodation/index.js (1)
  • wp (1-70)
src/blocks/tour-related-accommodation/index.js (1)
  • wp (1-69)
src/blocks/accommodation-related-tour/block.json (2)
src/blocks/featured-accommodation/index.js (1)
  • wp (1-70)
src/blocks/tour-related-accommodation/index.js (1)
  • wp (1-69)
src/blocks/accommodation-related-tour/index.js (4)
build/blocks/tour-related-accommodation/index.js (1)
  • wp (1-1)
src/blocks/featured-accommodation/index.js (1)
  • wp (1-70)
src/blocks/tour-related-accommodation/index.js (1)
  • wp (1-69)
src/blocks/review-related-accommodation/index.js (1)
  • wp (1-69)
src/blocks/accommodation-related-accommodation/index.js (2)
build/blocks/accommodation-related-accommodation/index.js (1)
  • wp (1-1)
src/blocks/featured-accommodation/index.js (1)
  • wp (1-70)
src/blocks/accommodation-type/index.js (2)
src/blocks/destination-to-accommodation/index.js (1)
  • wp (1-67)
src/blocks/review-related-accommodation/index.js (1)
  • wp (1-69)
⏰ 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). (1)
  • GitHub Check: Summary
🔇 Additional comments (8)
src/blocks/accommodation-related-tour/block.json (2)

4-15: Metadata additions look good

textdomain, description, icon, and keywords are correctly added and align with WP block.json schema.


5-5: Confirm no name collision between block and variation

If index.js also registers a variation named "lsx-tour-operator/accommodation-related-tour", ensure there’s no duplicate block registration or inserter confusion.

Would you confirm whether this slug is used only as a variation name and not as a separate block elsewhere in the codebase?

src/blocks/accommodation-type/block.json (1)

2-15: Schema + metadata are correct

$schema, apiVersion, textdomain, description, icon, and keywords conform to expectations.

src/blocks/accommodation-related-destination/index.js (1)

3-3: Confirm canonical block namespace: 'lsx-to' vs 'lsx-tour-operator'

src/blocks/accommodation-related-destination/index.js registers name 'lsx-tour-operator/accommodation-related-destination' but internal guidance references 'lsx-to/...'. Standardise the namespace across the repo or justify keeping 'lsx-tour-operator'. I couldn't verify occurrences across the repo (ripgrep returned no files); run locally: rg -n "lsx-to/|lsx-tour-operator/" -g '!/node_modules/' and align registrations.

src/blocks/accommodation-related-accommodation/block.json (1)

1-15: LGTM on schema, i18n fields, and example structure.

Consistent with WP block.json conventions and the rest of the PR.

src/blocks/accommodation-related-accommodation/index.js (2)

94-96: LGTM! Good addition of the renaming support.

The renaming: false support prevents users from accidentally changing the block variation's name, which helps maintain consistency across the site.


98-192: Well-structured example block for preview functionality.

The example provides a clear visual representation of the block's purpose with proper heading and grid layout. The sample accommodation cards effectively demonstrate the expected output structure.

src/blocks/accommodation-related-tour/index.js (1)

95-97: Good addition of renaming support.

The renaming: false prevents accidental renaming of the block variation, maintaining consistency.

@tibiii tibiii added comp:block-variations Block variations comp:block-editor Block/site editor work comp:block-supports Block supports comp:block-json Block metadata (block.json) comp:block-inserter Inserter UI/behaviour area:block-editor labels Oct 9, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Tour Operator Oct 9, 2025
@tibiii tibiii moved this from Needs Triage to 🏗️ In Progress in Tour Operator Oct 9, 2025
@tibiii tibiii added this to the v2.1.0 milestone Oct 9, 2025
@tibiii tibiii linked an issue Oct 9, 2025 that may be closed by this pull request
8 tasks
@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to Needs Triage in Tour Operator Oct 9, 2025
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: 3

♻️ Duplicate comments (3)
src/blocks/accommodation-related-destination/index.js (2)

58-91: Core/query still misses the related query class

The PHP filter (includes/classes/blocks/class-query-loop.php::query_args_filter) only activates when the core/query block itself carries a *-related-*-query class. Here the class is applied to the core/post-template, so the filter never scopes the results to the current destination. Users will just see generic accommodation listings. Please add className: 'lsx-accommodation-related-destination-query' (or append the class) to the core/query block attributes so the related-query behaviour works again.


106-189: Example heading should match the variation

The preview still shows “Related Destinations”, which disagrees with the registered variation heading (“Related accommodation”). Update the example heading string to keep the example aligned with the actual block.

src/blocks/accommodation-related-tour/index.js (1)

99-193: Address previously flagged inconsistencies in the example section.

The example section contains two critical issues that were previously flagged:

  1. Lines 102, 113: The example uses "Related tours" but the block is meant to display "Related accommodation". This creates confusion about the block's actual purpose.

  2. Lines 146-147, 165-166, 184-185: The example content shows tour descriptions (African Safari Adventure, European Cultural Journey, Tropical Island Escape) instead of accommodation descriptions. Since this block displays accommodation related to tours, the example should showcase accommodation items (e.g., Safari Lodge, Historic City Hotel, Beach Resort).

These inconsistencies will mislead users during block insertion and preview. Please refer to the previously suggested fixes in the existing review comments.

🧹 Nitpick comments (3)
src/blocks/accommodation-type/index.js (1)

61-93: Consider adding inline documentation.

The block variation registration lacks JSDoc comments explaining its purpose, parameters, and behaviour. Per coding guidelines, inline documentation should be provided for all custom functions and classes.

As per coding guidelines.

Add a JSDoc comment above the registration:

 wp.domReady(() => {
 	const { __ } = wp.i18n;
+	/**
+	 * Registers the Accommodation Type block variation.
+	 * 
+	 * Creates a group block variation that displays the accommodation type
+	 * taxonomy term with an icon and label.
+	 */
 	wp.blocks.registerBlockVariation("core/group", {
src/blocks/accommodation-related-accommodation/index.js (1)

101-114: Keep the variation example label consistent

The variation registers metadata.name as “Related accommodation - accommodation”, but the example hard-codes “Related Accommodation”. Because renaming is disabled, editors will see two different labels between the preview and the inserted block. Please align the example string with the registered default to avoid that mismatch.

src/blocks/accommodation-related-accommodation/block.json (1)

18-21: Align example metadata with the registered name

The example metadata name (“Related accommodation”) doesn’t match the variation’s registered name (“Related accommodation - accommodation”). Harmonising these avoids showing editors one label in previews and another after insertion.

📜 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 8de4e9a and b2f55f1.

📒 Files selected for processing (8)
  • src/blocks/accommodation-related-accommodation/block.json (1 hunks)
  • src/blocks/accommodation-related-accommodation/index.js (2 hunks)
  • src/blocks/accommodation-related-destination/block.json (1 hunks)
  • src/blocks/accommodation-related-destination/index.js (1 hunks)
  • src/blocks/accommodation-related-tour/block.json (1 hunks)
  • src/blocks/accommodation-related-tour/index.js (1 hunks)
  • src/blocks/accommodation-type/block.json (1 hunks)
  • src/blocks/accommodation-type/index.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/blocks/accommodation-type/block.json
  • src/blocks/accommodation-related-destination/block.json
🧰 Additional context used
📓 Path-based instructions (13)
src/**/*.{js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use @wordpress/eslint-plugin for JavaScript linting

Files:

  • src/blocks/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/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/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/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/accommodation-type/index.js
  • src/blocks/accommodation-related-accommodation/block.json
  • src/blocks/accommodation-related-tour/block.json
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/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/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/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/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/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/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/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/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/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/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/index.js
**/*.{css,js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)

Minimize CSS/JS payload size

Files:

  • src/blocks/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/index.js
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/instructions/reviews.instructions.md)

Lazy-load code and resources where possible

Files:

  • src/blocks/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/index.js
**/*.{php,js,ts,jsx,tsx}

⚙️ CodeRabbit configuration file

**/*.{php,js,ts,jsx,tsx}: - Follow WordPress coding standards.

  • Escape output and sanitize input.
  • Follow plugin security best practices.
  • Enforce prefixing for all functions, classes, and constants to avoid naming collisions.
  • Check for accessibility best practices in UI code (labels, ARIA attributes, color contrast).
  • Ensure inline documentation/comments for all custom functions and classes.
  • Ensure consistent formatting and schema validation.
  • Keep documentation up to date and clear.
  • On Pull Requests check for updates to the changelog file.

Files:

  • src/blocks/accommodation-type/index.js
  • src/blocks/accommodation-related-tour/index.js
  • src/blocks/accommodation-related-destination/index.js
  • src/blocks/accommodation-related-accommodation/index.js
src/**/block.json

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/block.json: Prefer block.json with server-side registration for blocks (avoid ad‑hoc registration)
Use the block namespace lsx-to in block names

Files:

  • src/blocks/accommodation-related-accommodation/block.json
  • src/blocks/accommodation-related-tour/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/accommodation-related-accommodation/block.json
  • src/blocks/accommodation-related-tour/block.json
🧬 Code graph analysis (6)
src/blocks/accommodation-type/index.js (3)
src/blocks/accommodation-related-accommodation/index.js (1)
  • wp (2-2)
src/blocks/accommodation-related-destination/index.js (1)
  • wp (2-2)
src/blocks/accommodation-related-tour/index.js (1)
  • wp (2-2)
src/blocks/accommodation-related-accommodation/block.json (1)
build/blocks/accommodation-related-accommodation/index.js (1)
  • wp (1-1)
src/blocks/accommodation-related-tour/block.json (3)
src/blocks/destination-to-accommodation/index.js (1)
  • wp (1-67)
src/blocks/featured-accommodation/index.js (1)
  • wp (1-70)
src/blocks/tour-related-accommodation/index.js (1)
  • wp (1-69)
src/blocks/accommodation-related-tour/index.js (2)
src/blocks/featured-accommodation/index.js (1)
  • wp (1-70)
src/blocks/tour-related-accommodation/index.js (1)
  • wp (1-69)
src/blocks/accommodation-related-destination/index.js (3)
src/blocks/accommodation-related-accommodation/index.js (1)
  • wp (2-2)
src/blocks/accommodation-related-tour/index.js (1)
  • wp (2-2)
src/blocks/accommodation-type/index.js (1)
  • wp (2-2)
src/blocks/accommodation-related-accommodation/index.js (4)
src/blocks/accommodation-related-destination/index.js (1)
  • wp (2-2)
src/blocks/accommodation-related-tour/index.js (1)
  • wp (2-2)
src/blocks/accommodation-type/index.js (1)
  • wp (2-2)
build/blocks/accommodation-related-accommodation/index.js (1)
  • wp (1-1)
⏰ 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). (1)
  • GitHub Check: Summary
🔇 Additional comments (6)
src/blocks/accommodation-related-tour/index.js (4)

1-8: LGTM! Proper i18n implementation.

The block registration correctly imports and uses the WordPress i18n API, with all user-facing strings properly wrapped with the tour-operator textdomain. The block title and description accurately reflect the block's purpose.


9-19: LGTM! Attributes properly configured.

The attributes configuration is consistent with similar blocks in the codebase, with proper internationalization of the metadata name and appropriate alignment and layout settings.


20-95: LGTM! Main block structure correctly configured.

The innerBlocks structure properly implements a two-tier layout with a decorated heading section and a query block for accommodation. All strings are correctly internationalized, and the query configuration appropriately targets the accommodation post type.


96-98: LGTM! Supports configuration appropriate.

The renaming: false configuration prevents users from renaming block instances, which is consistent with other related blocks in the codebase.

src/blocks/accommodation-type/index.js (2)

1-2: LGTM! i18n import correctly added.

The destructured import of __ from wp.i18n follows WordPress best practices for internationalization and addresses the previous review comment about localizing user-facing strings.


28-34: Verified icon block registration
The lsx-tour-operator/icons block is registered in src/blocks/icons/index.js and declared in its block.json.

"category": "lsx-tour-operator",
"editorScript": "file:index.js"
"editorScript": "file:index.js",
"description": "Displays accommodation related to this tour via the destinations.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add accessibility guidance to the block description.

The block description must include editor-facing accessibility guidance (per our block.json standards), but right now it only states what the block does. Please expand it with actionable advice for authors.

Apply something like:

-  "description": "Displays accommodation related to this tour via the destinations.",
+  "description": "Displays accommodation related to this tour via the destinations. Ensure the heading level fits the page hierarchy and that any linked media include descriptive alternative text for accessibility.",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"description": "Displays accommodation related to this tour via the destinations.",
"description": "Displays accommodation related to this tour via the destinations. Ensure the heading level fits the page hierarchy and that any linked media include descriptive alternative text for accessibility.",
🤖 Prompt for AI Agents
In src/blocks/accommodation-related-tour/block.json around line 9, the
"description" only states the block's function and lacks editor-facing
accessibility guidance; update the description string to include brief,
actionable accessibility instructions for authors (e.g., guidance about using
meaningful alt text for images, ensuring link text is descriptive, using
headings appropriately, and avoiding color-only cues) so the block.json follows
our accessibility guidance standard.

Comment on lines +3 to 16
wp.blocks.registerBlockVariation("core/group", {
name: "lsx-tour-operator/accommodation-type",
title: __( "Accommodation type", "tour-operator" ),
icon: "admin-multisite",
category: 'lsx-tour-operator',
category: "lsx-tour-operator",
attributes: {
metadata: {
name: 'Accommodation Type',
name: __( "Accommodation type", "tour-operator" ),
},
className: 'lsx-accommodation-type-wrapper',
className: "lsx-accommodation-type-wrapper",
layout: {
type: 'constrained'
}
type: "constrained",
},
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Capitalization inconsistency in block title.

The block title uses "Accommodation type" (lowercase "t") on line 5, but "Accommodation Type" (uppercase "T") is used elsewhere (lines 67, 78). For consistency and to follow proper title casing conventions, standardize on "Accommodation Type" throughout.

Apply this diff to standardize the capitalization:

-		title: __( "Accommodation type", "tour-operator" ),
+		title: __( "Accommodation Type", "tour-operator" ),
 		icon: "admin-multisite",
 		category: "lsx-tour-operator",
 		attributes: {
 			metadata: {
-				name: __( "Accommodation type", "tour-operator" ),
+				name: __( "Accommodation Type", "tour-operator" ),
 			},
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
wp.blocks.registerBlockVariation("core/group", {
name: "lsx-tour-operator/accommodation-type",
title: __( "Accommodation type", "tour-operator" ),
icon: "admin-multisite",
category: 'lsx-tour-operator',
category: "lsx-tour-operator",
attributes: {
metadata: {
name: 'Accommodation Type',
name: __( "Accommodation type", "tour-operator" ),
},
className: 'lsx-accommodation-type-wrapper',
className: "lsx-accommodation-type-wrapper",
layout: {
type: 'constrained'
}
type: "constrained",
},
},
wp.blocks.registerBlockVariation("core/group", {
name: "lsx-tour-operator/accommodation-type",
title: __( "Accommodation Type", "tour-operator" ),
icon: "admin-multisite",
category: "lsx-tour-operator",
attributes: {
metadata: {
name: __( "Accommodation Type", "tour-operator" ),
},
className: "lsx-accommodation-type-wrapper",
layout: {
type: "constrained",
},
},
} );
🤖 Prompt for AI Agents
In src/blocks/accommodation-type/index.js around lines 3 to 16, the block title
and metadata name use "Accommodation type" (lowercase "t") while other
occurrences use "Accommodation Type"; update the title string and the
metadata.name string to "Accommodation Type" so capitalization is consistent
across the file (align with lines 67 and 78).

Comment on lines +36 to +40
"core/paragraph",
{
content: "<strong>" + __( "Accommodation Type", "tour-operator" ) + "</strong>:",
},
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Use template literals instead of string concatenation.

String concatenation is used to build the paragraph content. Per coding guidelines, prefer template literals for string interpolation to improve readability and maintainability.

As per coding guidelines.

Apply this diff:

 					[
 						"core/paragraph",
 						{
-							content: "<strong>" + __( "Accommodation Type", "tour-operator" ) + "</strong>:",
+							content: `<strong>${__( "Accommodation Type", "tour-operator" )}</strong>:`,
 						},
 					],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"core/paragraph",
{
content: "<strong>" + __( "Accommodation Type", "tour-operator" ) + "</strong>:",
},
],
[
"core/paragraph",
{
content: `<strong>${__( "Accommodation Type", "tour-operator" )}</strong>:`,
},
],
🤖 Prompt for AI Agents
In src/blocks/accommodation-type/index.js around lines 36 to 40, the paragraph
content is built using string concatenation; replace the concatenation with a
template literal that embeds the localized string (e.g. `\`<strong>${__(
"Accommodation Type", "tour-operator" )}</strong>:\``) so the paragraph content
uses a template string for clearer interpolation and maintain coding guidelines.

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 ive tested the changes, they are working quite nicely.

@krugazul krugazul merged commit 60ce87a into 2.1-trunk Oct 14, 2025
3 checks passed
@krugazul krugazul deleted the 624-standardize-accommodation-block-meta branch October 14, 2025 20:28
@github-project-automation github-project-automation bot moved this from Needs Triage to ✅ Done in Tour Operator Oct 14, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 21, 2025
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:block-editor comp:block-editor Block/site editor work comp:block-inserter Inserter UI/behaviour comp:block-json Block metadata (block.json) comp:block-supports Block supports comp:block-variations Block variations

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

[Refactor]: Standardize Metadata for Accommodation-Related Blocks

2 participants