-
-
Notifications
You must be signed in to change notification settings - Fork 1
Standardize PHP naming conventions and improve theme generator #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…in generate-theme script
…imensions to placeholder map
|
Caution Review failedThe pull request is closed. Note
|
| Cohort / File(s) | Summary |
|---|---|
Top-level theme functions functions.php |
Renamed exported/public theme functions and their action/filter hook names from {{theme_slug}}_* to snake_case `{{theme_slug |
Inc — block patterns inc/block-patterns.php |
Renamed pattern registration functions to snake_case and updated add_action( 'init', ... ) hooks for hero, cta, and team patterns; pattern markup unchanged. |
Inc — block styles inc/block-styles.php |
Renamed block style registration function to snake_case and updated its init hook; implementation unchanged. |
Inc — template helpers inc/template-functions.php |
Renamed multiple template helper/public functions to snake_case and updated their add_action/add_filter registrations (get_version, body_classes, viewport_meta, custom_logo_setup, editor_color_palette, custom_excerpt_length, remove_version, security_headers). |
Generator script scripts/generate-theme.js |
Reworked placeholder processing to single-pass regex with filter support (upper, snakeCase, phpCase, pascalCase, camelCase); centralizes placeholder derivation/validation (including theme_slug sanitization), adds new placeholders (logo_width, logo_height, archive_excerpt_length), and removes in-error placeholder mutations. |
Placeholders map scripts/utils/placeholders.js |
Converted content_width_num to numeric, added logo_width, logo_height, and archive_excerpt_length; kept existing image-size placeholders. |
Theme config theme.json |
Changed typography.fontFamilies entries from strings to objects with slug, fontFamily, and name; removed top-level settings.color. |
Schema .github/schemas/theme-config.schema.json |
Added archive_excerpt_length integer property under content (default 40, min 20, max 200). |
Tests & test config phpunit.xml, tests/php/* |
PHPUnit discovery path/prefix/suffix updated; tests adjusted to expect snake_case function names; added tests/php/Test_Template_Functions.php; block styles tests now call get_registered_styles_for_block() instead of get_registered_styles(). |
Docs / repo metadata .github/README.md |
Substantially expanded README: Getting Started, install/generation workflows (interactive/CLI/JSON), VSCode guidance, scripts, and repo/workflow docs. |
Changelog & versioning CHANGELOG.md, VERSION, package.json |
Added Unreleased changelog details; bumped VERSION and package.json version 1.0.0 → 1.0.1. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant CLI as Generator CLI
participant Script as generate-theme.js
participant Map as placeholders.js
participant FS as File System
User->>CLI: invoke generator (interactive/CLI/JSON)
CLI->>Script: pass inputs/options
Script->>Map: load PLACEHOLDER_MAP
Script->>Script: sanitize theme_slug & validate placeholders
Script->>Map: apply filters (snakeCase, phpCase, etc.) to tokens
Script->>FS: write generated files (theme files, theme.json, assets)
Script-->>CLI: return success/error
CLI-->>User: display result or error
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
- Standardize PHP naming conventions and improve theme generator #5 — Appears to perform the same snake_case function standardization, placeholder/validator extensions, theme.json/schema updates, and matching test adjustments; strong code-level overlap.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title accurately reflects the primary changes: standardizing PHP naming conventions (snake_case) and improving the theme generator with multiple placeholder filters. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 95.12% which is sufficient. The required threshold is 80.00%. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
- 📝 Generate docstrings
📜 Recent review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/README.mdscripts/generate-theme.js
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Summary of ChangesHello @krugazul, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on refining the theme scaffolding process by standardizing PHP naming conventions, enhancing the theme generation script with better placeholder handling and validation, and updating all associated tests. The goal is to improve consistency, maintainability, and robustness for themes generated by the system. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9095e4e755
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request does a great job of standardizing PHP function names using a new phpCase filter, which significantly improves code consistency. The refactoring of the theme generation script to improve error handling and placeholder logic is also a major step up in robustness and readability. I've identified one important correctness issue with how $content_width is being set and have a couple of suggestions to improve maintainability and consistency in the generator script and tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
scripts/utils/placeholders.js (1)
1-9: File header comment does not match the actual filename.The header comment states
scripts/test-placeholders.jsbut the file is located atscripts/utils/placeholders.js. This may cause confusion for developers.📝 Suggested fix
/** - * scripts/test-placeholders.js + * scripts/utils/placeholders.js * * Centralized test placeholder values for mustache variables.tests/php/test-theme-setup.php (1)
78-82: Test expects theme.json version 2, but actual file uses version 3.The theme.json file at line 3 declares
"version": 3, but this test asserts$this->assertEquals( 2, $theme_json_data['version'] ). This will cause test failures.🔧 Suggested fix
- $this->assertEquals( 2, $theme_json_data['version'] ); + $this->assertEquals( 3, $theme_json_data['version'] );tests/php/test-template-functions.php (1)
69-69: Apply snakeCase filter to direct function calls.The function calls on lines 69, 92, and 95 are missing the
snakeCasefilter that is applied consistently to other function references throughout this file. These should use{{theme_slug|snakeCase}}_footer_text()and{{theme_slug|snakeCase}}_show_social_links()to match the naming convention.Proposed fix
ob_start(); - {{theme_slug}}_footer_text(); + {{theme_slug|snakeCase}}_footer_text(); $output = ob_get_clean();set_theme_mod( '{{theme_slug}}_show_social_links', false ); - $this->assertFalse( {{theme_slug}}_show_social_links() ); + $this->assertFalse( {{theme_slug|snakeCase}}_show_social_links() ); set_theme_mod( '{{theme_slug}}_show_social_links', true ); - $this->assertTrue( {{theme_slug}}_show_social_links() ); + $this->assertTrue( {{theme_slug|snakeCase}}_show_social_links() );Also applies to: 92-92, 95-95
🤖 Fix all issues with AI agents
In @functions.php:
- Line 40: The assignment to $GLOBALS['content_width'] is setting a string
because '{{content_width_px}}' is quoted; update the apply_filters call so it
assigns an integer (use {{content_width_num}} without quotes) to
$GLOBALS['content_width'] in the theme setup code (the line using
apply_filters('{{theme_slug}}_content_width', ...)) to ensure $content_width
remains an int for embed sizing and tests.
In @scripts/generate-theme.js:
- Around line 716-718: The if block checking placeholders['Example Author'] is
dead/unreachable and should be removed; delete the conditional that references
placeholders['Example Author'] and its throw (which currently tests
argMap.author against an invalid placeholder key), or if validation is needed
instead, replace the condition with a correct lookup like
placeholders['{{Example Author}}'] (or directly validate argMap.author) and keep
a clear error message — target the argMap.author check and the
placeholders['Example Author'] code block for removal/fix.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
functions.phpinc/block-patterns.phpinc/block-styles.phpinc/template-functions.phpscripts/generate-theme.jsscripts/utils/placeholders.jstests/php/test-block-styles.phptests/php/test-template-functions.phptests/php/test-theme-setup.phptheme.json
🧰 Additional context used
📓 Path-based instructions (25)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}: Always prefer block-first solutions (patterns, template parts, template composition) over classic PHP templates
Keep business logic in PHP (inc/,functions.php) and presentation in blocks/patterns
Test code with accessibility tools (axe, Lighthouse, WAVE) to ensure WCAG 2.2 AA compliance
Files:
scripts/generate-theme.jstests/php/test-block-styles.phpinc/block-patterns.phptests/php/test-template-functions.phptheme.jsontests/php/test-theme-setup.phpscripts/utils/placeholders.jsinc/template-functions.phpinc/block-styles.phpfunctions.php
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{js,jsx,ts,tsx}: Store JavaScript/JSX source files inassets/directory and output transpiled bundles tobuild/; use build tools for transpilation and optimization
Follow JavaScript and JSDoc standards as defined injavascript.instructions.md; use ESLint for linting and Prettier for formatting
**/*.{js,jsx,ts,tsx}: Use@wordpress/i18npackage functions (__,_x,_n,sprintf) in JavaScript/TypeScript with text domain '{{theme_slug}}'
Use translator comments in JavaScript (format:/* translators: ... */) for placeholder-containing or ambiguous strings with@wordpress/i18n
Usesprintf()with placeholders from@wordpress/i18nin JavaScript instead of template literals for translatable strings with variables
**/*.{js,jsx,ts,tsx}: Localize nonces to JavaScript usingwp_localize_script()with nonce in object (e.g.,BlockTheme.nonce) and never hard-code or omit nonces from AJAX/REST requests
In JavaScript, includeX-WP-Nonceheader in fetch requests to REST API endpoints using the WordPress globalwpApiSettings.nonceor localized nonce value
Files:
scripts/generate-theme.jsscripts/utils/placeholders.js
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)
**/*.{php,js,jsx,ts,tsx}: All user-facing strings must use translation functions with the text domain '{{theme_slug}}'
Never use string concatenation to combine translatable strings; use placeholders with sprintf() instead
Never translate variable content directly; use conditional statements to provide full translatable strings
Avoid including HTML markup in translatable strings; wrap HTML elements separately and combine them with placeholders
Ensure text domain used in all translation functions exactly matches the theme slug '{{theme_slug}}'
**/*.{php,js,jsx,ts,tsx}: Always verify nonces before processing state-changing operations (AJAX, REST, admin) usinglswp_theme_verify_request_nonce(),lswp_theme_verify_rest_nonce(), orcheck_admin_referer()functions
Never skip nonce verification, use incorrect nonce parameter names (must use_wpnonceas default), use generic nonce actions without the theme prefix, or bypass verification with conditional logic
Files:
scripts/generate-theme.jstests/php/test-block-styles.phpinc/block-patterns.phptests/php/test-template-functions.phptests/php/test-theme-setup.phpscripts/utils/placeholders.jsinc/template-functions.phpinc/block-styles.phpfunctions.php
**/*.{js,jsx,ts,tsx,mjs,cjs}
📄 CodeRabbit inference engine (.github/instructions/javascript.instructions.md)
**/*.{js,jsx,ts,tsx,mjs,cjs}: Use modern ES modules withconst/let, arrow functions, and WordPress packages
Keep code i18n-ready using@wordpress/i18n; avoid string concatenation for translatable strings
Follow naming conventions: camelCase for variables/functions, PascalCase for classes/components, UPPER_SNAKE_CASE for constants
Use 2 spaces for indentation (no tabs)
Maintain 80 character soft line length limit
Use single quotes for strings and template literals for interpolation
Semicolons are required at statement ends
Never usevar; preferconst/letfor variable declarations
Prefer arrow functions for callbacks
Use ES6+ features (destructuring, spread operator, etc.)
Use strict equality operators (===,!==) instead of loose equality (==,!=)
Use@wordpress/*packages for block registration, block editor components, and utilities
Document functions and exported members with JSDoc comments including @param, @returns, and @example tags
Use@wordpress/i18nfunctions (__,_n,sprintf) for all translatable strings with matching text domain
Run ESLint with WordPress config and pass linting before merging code
Files:
scripts/generate-theme.jsscripts/utils/placeholders.js
**/*.js
📄 CodeRabbit inference engine (.github/instructions/jest-tests.instructions.md)
**/*.js: Ensure all new code has 80%+ test coverage for JavaScript files
Exclude specific files and lines from Jest coverage usingcoveragePathIgnorePatternsand/* istanbul ignore */comments
**/*.js: Use kebab-case for JavaScript file names with meaningful names (e.g., file-handler.js, data-processor.js)
JavaScript class exports should use PascalCase (e.g., export class FileHandler {})
JavaScript function exports should use camelCase (e.g., export function processData() {})
JavaScript constant exports should use UPPER_SNAKE_CASE (e.g., export const MAX_FILE_SIZE = 1024)
Files:
scripts/generate-theme.jsscripts/utils/placeholders.js
**
📄 CodeRabbit inference engine (.github/instructions/release.instructions.md)
Ensure the repository is placeholder-free before any release action using
grep -R "{{" .
Files:
scripts/generate-theme.jstests/php/test-block-styles.phpinc/block-patterns.phptests/php/test-template-functions.phptheme.jsontests/php/test-theme-setup.phpscripts/utils/placeholders.jsinc/template-functions.phpinc/block-styles.phpfunctions.php
**/*.{js,ts,json,sh,yml,yaml}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
Store all reports only in
.github/reports/directory organized by category (coverage, analysis, validation, performance, agents, projects, comparison) - never in repository root or tmp directories
Files:
scripts/generate-theme.jstheme.jsonscripts/utils/placeholders.js
**/*.{js,ts,json,sh}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
Include ISO 8601 date (YYYY-MM-DD format) at the start of all report filenames, followed by hyphen-separated description
Files:
scripts/generate-theme.jstheme.jsonscripts/utils/placeholders.js
**/*.{js,ts,sh}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
**/*.{js,ts,sh}: Use kebab-case naming for report filenames; never use underscores, and date must appear at start (e.g.,2025-12-07-eslint-report.jsonnoteslint_report.jsonoreslint-report-2025-12-07.json)
Create nested directory structure automatically in.github/reports/if it doesn't exist; ensure parent directories are created before writing report files
Usetmp/directory only for temporary intermediate files during processing; never save final reports totmp/- move completed reports to.github/reports/and clean up temp files when done
Clean up temporary files intmp/directory after report generation is complete; do not leave intermediate processing files behind
Files:
scripts/generate-theme.jsscripts/utils/placeholders.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
**/*.{js,ts}: Include metadata in all reports with: date (ISO timestamp), type/category, tool/agent name, status, and logFile reference pointing to related log underlogs/
Reference related log files in every report vialogFilefield pointing to the process that generated it (e.g.,logs/test/2025-12-07-jest.log)
Always verify report content validity (JSON parsing, HTML structure) before saving and include error handling for file write failures with appropriate logging
Files:
scripts/generate-theme.jsscripts/utils/placeholders.js
**/*.{html,php}
📄 CodeRabbit inference engine (.github/instructions/a11y.instructions.md)
**/*.{html,php}: Maintain proper heading hierarchy and landmark structure in templates and patterns
Use semantic HTML and block patterns; avoid div-only structures
Keep ARIA usage minimal and purposeful; never use ARIA to patch invalid HTML in WordPress block themes
Supply meaningful alt text for images in WordPress block themes
Supply meaningful labels for form elements in WordPress block themes
Files:
tests/php/test-block-styles.phpinc/block-patterns.phptests/php/test-template-functions.phptests/php/test-theme-setup.phpinc/template-functions.phpinc/block-styles.phpfunctions.php
**/*.php
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
Follow WordPress PHP coding standards as defined in
wpcs-php.instructions.mdincluding PHPDoc documentationUse tabs for indentation to match PHP code blocks when mixing HTML and PHP
**/*.php: Use__()function to return translated strings in PHP with text domain '{{theme_slug}}'
Use_e()function to directly echo translated strings in PHP with text domain '{{theme_slug}}' instead of echoing__()
Useesc_html__()oresc_html_e()for escaped translation in PHP templates with text domain '{{theme_slug}}'
Useesc_attr__()oresc_attr_e()for HTML attribute translation in PHP with text domain '{{theme_slug}}'
Use_n()function for plural forms in PHP with text domain '{{theme_slug}}' instead of conditional string concatenation
Use_x()or_ex()function in PHP to provide context for ambiguous translatable strings with text domain '{{theme_slug}}'
Use translator comments in PHP (format:/* translators: ... */) for ambiguous, contextual, or placeholder-containing strings
Usesprintf()with numbered placeholders (e.g.,%1$s,%2$s) in PHP instead of string concatenation for translatable strings with variables
Always use escaped translation functions (esc_html__,esc_attr__, etc.) in templates instead of double-escaping with both function and manual escape
**/*.php: Use kebab-case for PHP file names with meaningful names (e.g., file-handler.php, theme-setup.php)
PHP function names should use prefix_snake_case format with a mandatory prefix (e.g., lightspeed_process_file())
PHP class names should use PascalCase (e.g., class FileHandler {})
PHP constants should use PREFIX_UPPER_SNAKE_CASE format (e.g., const LIGHTSPEED_VERSION = '1.0.0')
PHP variables should use $snake_case format (e.g., $file_path, $block_config)
**/*.php: Prefix all global functions with the theme namespace (mytheme_function_name())
Prefix all constants with the theme namespace (MYTHEME_CONSTANT)
Use snake_case for function and variable names throughout PHP code
Us...
Files:
tests/php/test-block-styles.phpinc/block-patterns.phptests/php/test-template-functions.phptests/php/test-theme-setup.phpinc/template-functions.phpinc/block-styles.phpfunctions.php
**/*.{html,htm,php}
📄 CodeRabbit inference engine (.github/instructions/html-markup.instructions.md)
**/*.{html,htm,php}: Use semantic HTML5 elements and maintain proper heading hierarchy in WordPress block theme templates
Prefer core blocks andtheme.jsontokens for structure and spacing instead of custom structural HTML
Keep attributes lowercase, quoted, and avoid unnecessary ARIA in HTML markup
Use self-closing tags where appropriate, correct boolean attributes, and avoid custom wrappers when a core block exists
Run W3C validator on templates and patterns, and verify block comments render valid block markup (<!-- wp:block -->/<!-- /wp:block -->)
Files:
tests/php/test-block-styles.phpinc/block-patterns.phptests/php/test-template-functions.phptests/php/test-theme-setup.phpinc/template-functions.phpinc/block-styles.phpfunctions.php
tests/**/*.{js,php}
📄 CodeRabbit inference engine (.github/instructions/naming-conventions.instructions.md)
Test files should use test-{feature-name} prefix format (e.g., tests/js/test-file-handler.js or tests/php/test-block-register.php)
Files:
tests/php/test-block-styles.phptests/php/test-template-functions.phptests/php/test-theme-setup.php
tests/php/**/*.php
📄 CodeRabbit inference engine (.github/instructions/phpunit-tests.instructions.md)
tests/php/**/*.php: Structure PHPUnit test classes by extending WP_UnitTestCase with setUp() and tearDown() methods for proper test initialization and cleanup
Use descriptive test method names following the pattern test__() to clearly communicate test intent
Organize test data using setUp() for initialization and tearDown() for cleanup to ensure test isolation
Test one concept per test method to maintain clear test purpose and improve readability
Use WordPress factories ($this->factory()->post->create(), $this->factory()->user->create()) to generate test data
Test error conditions and invalid inputs in addition to valid inputs to ensure robust error handling
Use meaningful test data with clear variable names that indicate test intent
Use data providers (@dataProvider) for testing multiple input scenarios in a single test method
Verify that WordPress hooks are registered and execute correctly using has_action(), has_filter(), and do_action()
Test block pattern registration using WP_Block_Patterns_Registry::get_instance()->get_registered()
Test block style registration using WP_Block_Styles_Registry::get_instance()->get_registered_styles()
Test asset enqueuing by simulating the appropriate screen context and checking wp_style_is() or wp_script_is()
Files:
tests/php/test-block-styles.phptests/php/test-template-functions.phptests/php/test-theme-setup.php
**/*test*.php
📄 CodeRabbit inference engine (.github/instructions/security-nonce.instructions.md)
Write unit tests for all nonce implementations including: nonce creation success, nonce verification success, nonce verification failure, and REST nonce verification with proper assertions
Files:
tests/php/test-block-styles.phptests/php/test-template-functions.phptests/php/test-theme-setup.php
**/test-*.php
📄 CodeRabbit inference engine (.github/instructions/wpcs-php.instructions.md)
Write unit tests with PHPUnit and integration tests with WordPress testing suite for PHP functionality
Files:
tests/php/test-block-styles.phptests/php/test-template-functions.phptests/php/test-theme-setup.php
**/*.{json,php}
📄 CodeRabbit inference engine (AGENTS.md)
Validate all JSON and PHP output
Files:
tests/php/test-block-styles.phpinc/block-patterns.phptests/php/test-template-functions.phptheme.jsontests/php/test-theme-setup.phpinc/template-functions.phpinc/block-styles.phpfunctions.php
**/*.{css,scss,html,json}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
Align styles and spacing with
theme.jsontokens instead of ad-hoc CSS
Files:
theme.json
theme.json
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
theme.json: Define color palette, typography, spacing, and block settings intheme.json; use it for global styles and editor appearance control
Avoid hardcoding styles in PHP or CSS; prefertheme.jsonfor consistency with design system tokens
Files:
theme.json
**/*.{html,json}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
Ensure semantic HTML and proper accessibility in templates and patterns; use ARIA attributes appropriately
Files:
theme.json
**/theme.json
📄 CodeRabbit inference engine (.github/instructions/theme-json.instructions.md)
**/theme.json: Define design tokens (colors, typography, spacing) in theme.json; avoid hard-coded CSS when a token exists
Keep theme.json valid against the WordPress schema and use version 3 for WordPress 6.6+
Prefer block supports and presets over custom CSS; minimize per-block overrides
Maintain accessibility (contrast, focus states) when defining colors and typography in theme.json
Use $schema pointing to WordPress theme.json schema for validation
Enable fluid typography for responsive sizing with min/max values in font sizes
Provide 5-7 font sizes for flexibility in typography system
Use rem units for font sizes and spacing to ensure accessibility
Include system fonts as fallback in font family definitions
Disable default palettes (defaultPalettes, defaultGradients, defaultDuotones) to avoid confusion
Use CSS custom properties (var(--wp--preset--*)) for color and design token consistency
Provide sufficient color contrast (WCAG AA minimum) between colors in the palette
Test colors in light and dark modes when defining color palettes in theme.json
Use consistent spacing scale with defined spacingSizes array in theme.json
Limit custom spacing options (set customSpacingSize to false) to maintain design system consistency
Configure content width and wide width for layout using contentSize and wideSize settings
Enable useRootPaddingAwareAlignments for proper alignment behavior in WordPress block themes
Define global element styles (link, heading, button) before block-specific styles
Include hover and focus states for interactive elements in global styles
Use camelCase slugs with kebab-case naming convention for presets in theme.json
Keep theme.json file size under 100KB for performance optimization
Use CSS custom properties efficiently to minimize custom styles in favor of presets
Document custom decisions and complex configurations with comments in theme.json
Test keyboard navigation and validate with accessibility tools when defining interactive element styles
Files:
theme.json
{theme.json,**/blocks/**}
📄 CodeRabbit inference engine (AGENTS.md)
For block theme–specific automation, prefer theme.json and block components over bespoke code
Files:
theme.json
functions.php
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
functions.php: Enqueue only built assets from thebuild/directory; usewp_enqueue_block_styleandwp_enqueue_block_scriptfor block-specific assets with cache busting via file modification time or build hash
Use conditional enqueuing to load assets only when needed
Files:
functions.php
**/functions.php
📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)
Load theme textdomain in
functions.phpusingload_theme_textdomain()hooked to 'after_setup_theme' action with domain '{{theme_slug}}' and path to languages directory
Files:
functions.php
🧬 Code graph analysis (1)
tests/php/test-template-functions.php (1)
scripts/generate-theme.js (3)
value(14-14)value(84-84)result(312-312)
🔇 Additional comments (18)
scripts/utils/placeholders.js (1)
84-98: LGTM! New placeholder additions are well-organized.The added placeholders for image sizes, logo dimensions, and excerpt settings align with the PR objectives. Values are reasonable defaults for scaffold/test mode.
scripts/generate-theme.js (2)
650-665: Improved error handling for author URI validation.The explicit error messages for invalid protocols and URIs will help users understand validation failures. The try/catch blocks properly propagate meaningful errors.
667-715: Well-structured placeholder population with sensible defaults.The centralized placeholder object with fallback values improves maintainability. Derived values like
security_emailandcontact_emailare computed correctly fromauthorUri.theme.json (1)
71-80: LGTM! Font families now use proper object structure.The change from string values to structured objects with
slug,fontFamily, andnameproperties complies with the WordPress theme.json schema. This enables proper CSS custom property generation (--wp--preset--font-family--body) and provides display names for the editor UI.inc/template-functions.php (7)
19-21: LGTM! Function renamed to snake_case.The
{{theme_slug|snakeCase}}_get_version()function follows PHP coding guidelines for prefix_snake_case naming.
29-39: LGTM! Body classes function and hook updated to snake_case.Both the function declaration and
add_filterhook registration consistently use the snakeCase filter.
44-47: LGTM! Viewport meta function updated to snake_case.The function and hook registration are consistent. The viewport meta tag uses correct HTML5 syntax.
52-63: LGTM! Custom logo setup function updated to snake_case.The function uses the new
{{logo_height}}and{{logo_width}}placeholders added to the placeholder map.
68-95: LGTM! Editor color palette function updated to snake_case.Function naming is consistent with the new convention.
103-114: LGTM! Custom excerpt length function updated to snake_case.The function uses the new
{{archive_excerpt_length}}placeholder for archive pages.
119-134: LGTM! Security-related functions updated to snake_case.Both the generator removal and security headers functions follow the new naming convention.
inc/block-patterns.php (3)
17-47: LGTM! Hero pattern function renamed to snake_case.The function name uses
{{theme_slug|snakeCase}}_register_hero_patternwhile the pattern slug correctly retains{{theme_slug}}/hero-sectionfor WordPress pattern registration.
52-82: LGTM! CTA pattern function renamed to snake_case.Consistent with the hero pattern, function naming and hook registration follow the new convention.
87-161: LGTM! Team pattern function renamed to snake_case.All three pattern registration functions now consistently use the snakeCase filter for PHP function naming.
tests/php/test-block-styles.php (1)
23-28: LGTM! Test updated to verify snake_case function name.The test correctly checks for
{{theme_slug|snakeCase}}_register_block_stylesto match the renamed function ininc/block-styles.php.tests/php/test-theme-setup.php (2)
13-15: LGTM! Test updated to verify snake_case setup function.The test correctly checks for
{{theme_slug|snakeCase}}_setupto match the renamed function.
51-55: LGTM! Tests updated to verify snake_case include functions.All three function existence checks correctly use the snakeCase filter.
inc/block-styles.php (1)
17-17: LGTM! Snake_case conversion applied consistently.The function name and hook registration are both correctly updated to use the
snakeCasefilter, maintaining consistency with the standardization effort across the theme codebase.Also applies to: 79-79
There was a problem hiding this 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
🤖 Fix all issues with AI agents
In @.github/README.md:
- Line 38: Replace the bolded section headers "**Interactive prompts
(easiest)**", the bold text at the other two locations on the same file, and the
third bold header with proper Markdown heading syntax (e.g., "## Interactive
prompts (easiest)"), preserving the same text but converting from bold emphasis
to an appropriate heading level to satisfy MD036 and maintain heading hierarchy;
locate the three exact bold strings in the file and swap each "**...**" wrapper
for the chosen heading marker (## or ###) so they become real headings.
- Line 44: Replace the Windows-style backslashes in the agent path string shown
(`scripts\agents\generate-theme.agent.js`) with forward slashes for
cross-platform consistency—update the README entry that reads "Agent Location:
`scripts\agents\generate-theme.agent.js`" to use
`scripts/agents/generate-theme.agent.js`.
- Line 17: The README contains a capitalization inconsistency: replace the
phrase "DataBase" in the string "A WordPress environment with a DataBase." with
the standard lowercase "database" so the sentence reads "A WordPress environment
with a database."
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/README.md
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
.github/README.md
38-38: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
46-46: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
51-51: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
⏰ 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: validate-theme-json
🔇 Additional comments (1)
.github/README.md (1)
2-95: Well-structured documentation aligned with PR objectives.The README effectively documents the new theme generation workflow with clear sections for prerequisites, installation, generation modes (interactive, CLI, JSON), and GitHub configuration. The structure supports the PR's goal of improving the theme generator's usability and documenting the snake_case naming standardization across the codebase. The examples and available scripts section provide practical guidance for users.
…update placeholders in generate-theme script
There was a problem hiding this 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
🤖 Fix all issues with AI agents
In @.github/README.md:
- Line 49: The README entry uses a Windows-style path with backslashes
("scripts\agents\generate-theme.agent.js"); update it to use forward slashes
("scripts/agents/generate-theme.agent.js") for cross-platform compatibility
wherever that string appears (e.g., the "Agent Location" line) so the path works
on Unix-like systems and Windows alike.
- Line 17: Replace the typo in the README line that currently reads "A WordPress
environment with a DataBase." so that "DataBase" is lowercase and correct
("database"); update the sentence to "A WordPress environment with a database."
to maintain consistent casing and grammar.
- Line 68: Fix the grammar in the README line referencing the theme copy
instruction: change the phrase "the will be" to "that will be" so the sentence
reads "Copy the `output-theme` directory that will be generated in your
repository and copy and paste that in your `themes` directory." Update the
sentence containing `output-theme` and `themes` to use the corrected wording.
In @scripts/generate-theme.js:
- Around line 667-718: The placeholders object incorrectly references
configData.image_sizes_* keys for image dimensions (e.g., '{{thumbnail_width}}',
'{{thumbnail_height}}', '{{featured_image_width}}', '{{featured_image_height}}',
'{{gallery_image_width}}', '{{gallery_image_height}}') which don't exist in the
schema; update those properties inside the placeholders map to use the correct
configData.images_* keys (e.g., configData.images_thumbnail_width,
configData.images_thumbnail_height, configData.images_featured_image_width,
configData.images_featured_image_height, configData.images_gallery_image_width,
configData.images_gallery_image_height) so the defaults only apply when the
schema values are absent.
🧹 Nitpick comments (1)
.github/README.md (1)
38-38: Convert bold text to proper headings for better structure.Lines 38, 57, and 62 use bold text (
**Interactive prompts (easiest)**,**CLI Mode**,**JSON Mode**) where headings would be more semantically appropriate. This also resolves the markdownlint warnings (MD036).Based on static analysis hints, this improves document structure and accessibility.
📋 Proposed refactor
-**Interactive prompts (easiest)** +#### Interactive prompts (easiest) -**CLI Mode** +#### CLI Mode -**JSON Mode** +#### JSON ModeAlso applies to: 57-57, 62-62
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/README.md.github/schemas/theme-config.schema.jsonscripts/generate-theme.js
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}: Always prefer block-first solutions (patterns, template parts, template composition) over classic PHP templates
Keep business logic in PHP (inc/,functions.php) and presentation in blocks/patterns
Test code with accessibility tools (axe, Lighthouse, WAVE) to ensure WCAG 2.2 AA compliance
Files:
scripts/generate-theme.js
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{js,jsx,ts,tsx}: Store JavaScript/JSX source files inassets/directory and output transpiled bundles tobuild/; use build tools for transpilation and optimization
Follow JavaScript and JSDoc standards as defined injavascript.instructions.md; use ESLint for linting and Prettier for formatting
**/*.{js,jsx,ts,tsx}: Use@wordpress/i18npackage functions (__,_x,_n,sprintf) in JavaScript/TypeScript with text domain '{{theme_slug}}'
Use translator comments in JavaScript (format:/* translators: ... */) for placeholder-containing or ambiguous strings with@wordpress/i18n
Usesprintf()with placeholders from@wordpress/i18nin JavaScript instead of template literals for translatable strings with variables
**/*.{js,jsx,ts,tsx}: Localize nonces to JavaScript usingwp_localize_script()with nonce in object (e.g.,BlockTheme.nonce) and never hard-code or omit nonces from AJAX/REST requests
In JavaScript, includeX-WP-Nonceheader in fetch requests to REST API endpoints using the WordPress globalwpApiSettings.nonceor localized nonce value
Files:
scripts/generate-theme.js
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)
**/*.{php,js,jsx,ts,tsx}: All user-facing strings must use translation functions with the text domain '{{theme_slug}}'
Never use string concatenation to combine translatable strings; use placeholders with sprintf() instead
Never translate variable content directly; use conditional statements to provide full translatable strings
Avoid including HTML markup in translatable strings; wrap HTML elements separately and combine them with placeholders
Ensure text domain used in all translation functions exactly matches the theme slug '{{theme_slug}}'
**/*.{php,js,jsx,ts,tsx}: Always verify nonces before processing state-changing operations (AJAX, REST, admin) usinglswp_theme_verify_request_nonce(),lswp_theme_verify_rest_nonce(), orcheck_admin_referer()functions
Never skip nonce verification, use incorrect nonce parameter names (must use_wpnonceas default), use generic nonce actions without the theme prefix, or bypass verification with conditional logic
Files:
scripts/generate-theme.js
**/*.{js,jsx,ts,tsx,mjs,cjs}
📄 CodeRabbit inference engine (.github/instructions/javascript.instructions.md)
**/*.{js,jsx,ts,tsx,mjs,cjs}: Use modern ES modules withconst/let, arrow functions, and WordPress packages
Keep code i18n-ready using@wordpress/i18n; avoid string concatenation for translatable strings
Follow naming conventions: camelCase for variables/functions, PascalCase for classes/components, UPPER_SNAKE_CASE for constants
Use 2 spaces for indentation (no tabs)
Maintain 80 character soft line length limit
Use single quotes for strings and template literals for interpolation
Semicolons are required at statement ends
Never usevar; preferconst/letfor variable declarations
Prefer arrow functions for callbacks
Use ES6+ features (destructuring, spread operator, etc.)
Use strict equality operators (===,!==) instead of loose equality (==,!=)
Use@wordpress/*packages for block registration, block editor components, and utilities
Document functions and exported members with JSDoc comments including @param, @returns, and @example tags
Use@wordpress/i18nfunctions (__,_n,sprintf) for all translatable strings with matching text domain
Run ESLint with WordPress config and pass linting before merging code
Files:
scripts/generate-theme.js
**/*.js
📄 CodeRabbit inference engine (.github/instructions/jest-tests.instructions.md)
**/*.js: Ensure all new code has 80%+ test coverage for JavaScript files
Exclude specific files and lines from Jest coverage usingcoveragePathIgnorePatternsand/* istanbul ignore */comments
**/*.js: Use kebab-case for JavaScript file names with meaningful names (e.g., file-handler.js, data-processor.js)
JavaScript class exports should use PascalCase (e.g., export class FileHandler {})
JavaScript function exports should use camelCase (e.g., export function processData() {})
JavaScript constant exports should use UPPER_SNAKE_CASE (e.g., export const MAX_FILE_SIZE = 1024)
Files:
scripts/generate-theme.js
**
📄 CodeRabbit inference engine (.github/instructions/release.instructions.md)
Ensure the repository is placeholder-free before any release action using
grep -R "{{" .
Files:
scripts/generate-theme.js
**/*.{js,ts,json,sh,yml,yaml}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
Store all reports only in
.github/reports/directory organized by category (coverage, analysis, validation, performance, agents, projects, comparison) - never in repository root or tmp directories
Files:
scripts/generate-theme.js
**/*.{js,ts,json,sh}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
Include ISO 8601 date (YYYY-MM-DD format) at the start of all report filenames, followed by hyphen-separated description
Files:
scripts/generate-theme.js
**/*.{js,ts,sh}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
**/*.{js,ts,sh}: Use kebab-case naming for report filenames; never use underscores, and date must appear at start (e.g.,2025-12-07-eslint-report.jsonnoteslint_report.jsonoreslint-report-2025-12-07.json)
Create nested directory structure automatically in.github/reports/if it doesn't exist; ensure parent directories are created before writing report files
Usetmp/directory only for temporary intermediate files during processing; never save final reports totmp/- move completed reports to.github/reports/and clean up temp files when done
Clean up temporary files intmp/directory after report generation is complete; do not leave intermediate processing files behind
Files:
scripts/generate-theme.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
**/*.{js,ts}: Include metadata in all reports with: date (ISO timestamp), type/category, tool/agent name, status, and logFile reference pointing to related log underlogs/
Reference related log files in every report vialogFilefield pointing to the process that generated it (e.g.,logs/test/2025-12-07-jest.log)
Always verify report content validity (JSON parsing, HTML structure) before saving and include error handling for file write failures with appropriate logging
Files:
scripts/generate-theme.js
🪛 markdownlint-cli2 (0.18.1)
.github/README.md
38-38: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
57-57: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
62-62: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
⏰ 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: validate-theme-json
🔇 Additional comments (4)
.github/schemas/theme-config.schema.json (1)
462-468: LGTM! The new property follows existing patterns.The
archive_excerpt_lengthproperty is well-structured with appropriate constraints (minimum 20, maximum 200 words) and mirrors the existingexcerpt_lengthproperty pattern. The default value of 40 words is reasonable for archive/listing contexts.scripts/generate-theme.js (2)
650-665: Excellent error handling improvements.The refactored validation logic provides clear, user-friendly error messages that distinguish between protocol errors ("must start with http:// or https://") and general invalid URI/slug errors. Early validation of
theme_slugbefore placeholder population is also a good practice.
329-337: No action needed — implementation is consistent with PHP template usage.The codebase consistently uses
{{theme_slug|snakeCase}}across 60 occurrences in PHP template files (functions.php, inc/, and test files). There are zero occurrences ofphpCasesyntax anywhere. The filter namesnakeCasecorrectly reflects PHP naming conventions where identifiers use snake_case (with underscores). The implementation and actual template usage are aligned.Likely an incorrect or invalid review comment.
.github/README.md (1)
10-76: Well-structured getting started guide.The rewritten installation section provides clear, step-by-step instructions covering prerequisites, installation, and multiple theme generation methods (interactive, CLI, JSON). The addition of available scripts is also helpful for developers.
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
theme.json (1)
352-365: Structural issue:styles,customTemplates, andtemplatePartsmust be root-level properties, not nested insidesettings.Per the WordPress theme.json schema, these properties should be siblings of
settingsat the root level. The current nesting prevents WordPress from properly recognizing and applying these declarations. Restructuretheme.jsonto move these out of thesettingsobject to the root level.Correct structure
{ "$schema": ".github/schemas/theme.6.9.json", "version": 3, "settings": { // ... settings content ... }, "styles": { // ... styles content ... }, "customTemplates": [ // ... custom templates ... ], "templateParts": [ // ... template parts ... ] }
🧹 Nitpick comments (1)
theme.json (1)
12-14: Consider disabling default palettes per coding guidelines.The coding guidelines recommend disabling
defaultPalette,defaultGradients, anddefaultDuotoneto avoid confusion with your custom theme palette. Currently these are set totrue.♻️ Suggested change
"color": { "background": true, "custom": true, - "customDuotone": true, + "customDuotone": false, "customGradient": true, - "defaultDuotone": true, - "defaultGradients": true, - "defaultPalette": true, + "defaultDuotone": false, + "defaultGradients": false, + "defaultPalette": false, "text": true,
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
theme.json
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}: Always prefer block-first solutions (patterns, template parts, template composition) over classic PHP templates
Keep business logic in PHP (inc/,functions.php) and presentation in blocks/patterns
Test code with accessibility tools (axe, Lighthouse, WAVE) to ensure WCAG 2.2 AA compliance
Files:
theme.json
**/*.{css,scss,html,json}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
Align styles and spacing with
theme.jsontokens instead of ad-hoc CSS
Files:
theme.json
theme.json
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
theme.json: Define color palette, typography, spacing, and block settings intheme.json; use it for global styles and editor appearance control
Avoid hardcoding styles in PHP or CSS; prefertheme.jsonfor consistency with design system tokens
Files:
theme.json
**/*.{html,json}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
Ensure semantic HTML and proper accessibility in templates and patterns; use ARIA attributes appropriately
Files:
theme.json
**
📄 CodeRabbit inference engine (.github/instructions/release.instructions.md)
Ensure the repository is placeholder-free before any release action using
grep -R "{{" .
Files:
theme.json
**/*.{js,ts,json,sh,yml,yaml}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
Store all reports only in
.github/reports/directory organized by category (coverage, analysis, validation, performance, agents, projects, comparison) - never in repository root or tmp directories
Files:
theme.json
**/*.{js,ts,json,sh}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
Include ISO 8601 date (YYYY-MM-DD format) at the start of all report filenames, followed by hyphen-separated description
Files:
theme.json
**/theme.json
📄 CodeRabbit inference engine (.github/instructions/theme-json.instructions.md)
**/theme.json: Define design tokens (colors, typography, spacing) in theme.json; avoid hard-coded CSS when a token exists
Keep theme.json valid against the WordPress schema and use version 3 for WordPress 6.6+
Prefer block supports and presets over custom CSS; minimize per-block overrides
Maintain accessibility (contrast, focus states) when defining colors and typography in theme.json
Use $schema pointing to WordPress theme.json schema for validation
Enable fluid typography for responsive sizing with min/max values in font sizes
Provide 5-7 font sizes for flexibility in typography system
Use rem units for font sizes and spacing to ensure accessibility
Include system fonts as fallback in font family definitions
Disable default palettes (defaultPalettes, defaultGradients, defaultDuotones) to avoid confusion
Use CSS custom properties (var(--wp--preset--*)) for color and design token consistency
Provide sufficient color contrast (WCAG AA minimum) between colors in the palette
Test colors in light and dark modes when defining color palettes in theme.json
Use consistent spacing scale with defined spacingSizes array in theme.json
Limit custom spacing options (set customSpacingSize to false) to maintain design system consistency
Configure content width and wide width for layout using contentSize and wideSize settings
Enable useRootPaddingAwareAlignments for proper alignment behavior in WordPress block themes
Define global element styles (link, heading, button) before block-specific styles
Include hover and focus states for interactive elements in global styles
Use camelCase slugs with kebab-case naming convention for presets in theme.json
Keep theme.json file size under 100KB for performance optimization
Use CSS custom properties efficiently to minimize custom styles in favor of presets
Document custom decisions and complex configurations with comments in theme.json
Test keyboard navigation and validate with accessibility tools when defining interactive element styles
Files:
theme.json
{theme.json,**/blocks/**}
📄 CodeRabbit inference engine (AGENTS.md)
For block theme–specific automation, prefer theme.json and block components over bespoke code
Files:
theme.json
**/*.{json,php}
📄 CodeRabbit inference engine (AGENTS.md)
Validate all JSON and PHP output
Files:
theme.json
⏰ 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: validate-theme-json
- GitHub Check: validate-theme-json
🔇 Additional comments (1)
theme.json (1)
71-80: LGTM! Font families now use proper object structure.The fontFamilies array correctly follows the WordPress theme.json schema with
slug,fontFamily, andnameproperties for each entry. The slugs use appropriate camelCase naming.One consideration per coding guidelines: ensure the placeholder values (e.g.,
{{body_font_family}},{{heading_font_family}}) resolve to font stacks that include system font fallbacks for graceful degradation.
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/php/Test_Template_Functions.php (1)
39-39: Inconsistent placeholder usage for function names.The file inconsistently applies the
snakeCasefilter to theme slug placeholders:
- Lines 15, 25, 61, 86, 109, 131, 161, 171, 181, 191, 213, 230 use
{{theme_slug|snakeCase}}_function_name- Lines 39, 69, 92, 95 use
{{theme_slug}}_function_namewithout the filterThis inconsistency will cause runtime errors when the generated test attempts to call functions with mismatched names. All PHP function references should consistently use the same placeholder format.
🔧 Proposed fix for consistent naming
public function test_get_theme_mod_wrapper() { $this->assertTrue( - function_exists( '{{theme_slug}}_get_theme_mod' ), + function_exists( '{{theme_slug|snakeCase}}_get_theme_mod' ), 'Get theme mod wrapper should exist' ); try { set_theme_mod( '{{theme_slug}}_test', 'test_value' ); - $value = {{theme_slug|snakeCase}}_get_theme_mod( 'test', 'default' ); + $value = {{theme_slug}}_get_theme_mod( 'test', 'default' );And for the footer text and social links functions:
try { set_theme_mod( '{{theme_slug}}_footer_text', 'Test Footer' ); ob_start(); - {{theme_slug}}_footer_text(); + {{theme_slug|snakeCase}}_footer_text(); $output = ob_get_clean();try { set_theme_mod( '{{theme_slug}}_show_social_links', false ); - $this->assertFalse( {{theme_slug}}_show_social_links() ); + $this->assertFalse( {{theme_slug|snakeCase}}_show_social_links() ); set_theme_mod( '{{theme_slug}}_show_social_links', true ); - $this->assertTrue( {{theme_slug}}_show_social_links() ); + $this->assertTrue( {{theme_slug|snakeCase}}_show_social_links() );Also applies to: 69-69, 92-92, 95-95
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
phpunit.xmltests/php/Test_Block_Patterns.phptests/php/Test_Block_Styles.phptests/php/Test_Template_Functions.phptests/php/Test_Theme_Setup.php
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{html,php}
📄 CodeRabbit inference engine (.github/instructions/a11y.instructions.md)
**/*.{html,php}: Maintain proper heading hierarchy and landmark structure in templates and patterns
Use semantic HTML and block patterns; avoid div-only structures
Keep ARIA usage minimal and purposeful; never use ARIA to patch invalid HTML in WordPress block themes
Supply meaningful alt text for images in WordPress block themes
Supply meaningful labels for form elements in WordPress block themes
Files:
tests/php/Test_Theme_Setup.phptests/php/Test_Template_Functions.phptests/php/Test_Block_Styles.php
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}: Always prefer block-first solutions (patterns, template parts, template composition) over classic PHP templates
Keep business logic in PHP (inc/,functions.php) and presentation in blocks/patterns
Test code with accessibility tools (axe, Lighthouse, WAVE) to ensure WCAG 2.2 AA compliance
Files:
tests/php/Test_Theme_Setup.phptests/php/Test_Template_Functions.phptests/php/Test_Block_Styles.php
**/*.php
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
Follow WordPress PHP coding standards as defined in
wpcs-php.instructions.mdincluding PHPDoc documentationUse tabs for indentation to match PHP code blocks when mixing HTML and PHP
**/*.php: Use__()function to return translated strings in PHP with text domain '{{theme_slug}}'
Use_e()function to directly echo translated strings in PHP with text domain '{{theme_slug}}' instead of echoing__()
Useesc_html__()oresc_html_e()for escaped translation in PHP templates with text domain '{{theme_slug}}'
Useesc_attr__()oresc_attr_e()for HTML attribute translation in PHP with text domain '{{theme_slug}}'
Use_n()function for plural forms in PHP with text domain '{{theme_slug}}' instead of conditional string concatenation
Use_x()or_ex()function in PHP to provide context for ambiguous translatable strings with text domain '{{theme_slug}}'
Use translator comments in PHP (format:/* translators: ... */) for ambiguous, contextual, or placeholder-containing strings
Usesprintf()with numbered placeholders (e.g.,%1$s,%2$s) in PHP instead of string concatenation for translatable strings with variables
Always use escaped translation functions (esc_html__,esc_attr__, etc.) in templates instead of double-escaping with both function and manual escape
**/*.php: Use kebab-case for PHP file names with meaningful names (e.g., file-handler.php, theme-setup.php)
PHP function names should use prefix_snake_case format with a mandatory prefix (e.g., lightspeed_process_file())
PHP class names should use PascalCase (e.g., class FileHandler {})
PHP constants should use PREFIX_UPPER_SNAKE_CASE format (e.g., const LIGHTSPEED_VERSION = '1.0.0')
PHP variables should use $snake_case format (e.g., $file_path, $block_config)
**/*.php: Prefix all global functions with the theme namespace (mytheme_function_name())
Prefix all constants with the theme namespace (MYTHEME_CONSTANT)
Use snake_case for function and variable names throughout PHP code
Us...
Files:
tests/php/Test_Theme_Setup.phptests/php/Test_Template_Functions.phptests/php/Test_Block_Styles.php
**/*.{html,htm,php}
📄 CodeRabbit inference engine (.github/instructions/html-markup.instructions.md)
**/*.{html,htm,php}: Use semantic HTML5 elements and maintain proper heading hierarchy in WordPress block theme templates
Prefer core blocks andtheme.jsontokens for structure and spacing instead of custom structural HTML
Keep attributes lowercase, quoted, and avoid unnecessary ARIA in HTML markup
Use self-closing tags where appropriate, correct boolean attributes, and avoid custom wrappers when a core block exists
Run W3C validator on templates and patterns, and verify block comments render valid block markup (<!-- wp:block -->/<!-- /wp:block -->)
Files:
tests/php/Test_Theme_Setup.phptests/php/Test_Template_Functions.phptests/php/Test_Block_Styles.php
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)
**/*.{php,js,jsx,ts,tsx}: All user-facing strings must use translation functions with the text domain '{{theme_slug}}'
Never use string concatenation to combine translatable strings; use placeholders with sprintf() instead
Never translate variable content directly; use conditional statements to provide full translatable strings
Avoid including HTML markup in translatable strings; wrap HTML elements separately and combine them with placeholders
Ensure text domain used in all translation functions exactly matches the theme slug '{{theme_slug}}'
**/*.{php,js,jsx,ts,tsx}: Always verify nonces before processing state-changing operations (AJAX, REST, admin) usinglswp_theme_verify_request_nonce(),lswp_theme_verify_rest_nonce(), orcheck_admin_referer()functions
Never skip nonce verification, use incorrect nonce parameter names (must use_wpnonceas default), use generic nonce actions without the theme prefix, or bypass verification with conditional logic
Files:
tests/php/Test_Theme_Setup.phptests/php/Test_Template_Functions.phptests/php/Test_Block_Styles.php
tests/**/*.{js,php}
📄 CodeRabbit inference engine (.github/instructions/naming-conventions.instructions.md)
Test files should use test-{feature-name} prefix format (e.g., tests/js/test-file-handler.js or tests/php/test-block-register.php)
Files:
tests/php/Test_Theme_Setup.phptests/php/Test_Template_Functions.phptests/php/Test_Block_Styles.php
tests/php/**/*.php
📄 CodeRabbit inference engine (.github/instructions/phpunit-tests.instructions.md)
tests/php/**/*.php: Structure PHPUnit test classes by extending WP_UnitTestCase with setUp() and tearDown() methods for proper test initialization and cleanup
Use descriptive test method names following the pattern test__() to clearly communicate test intent
Organize test data using setUp() for initialization and tearDown() for cleanup to ensure test isolation
Test one concept per test method to maintain clear test purpose and improve readability
Use WordPress factories ($this->factory()->post->create(), $this->factory()->user->create()) to generate test data
Test error conditions and invalid inputs in addition to valid inputs to ensure robust error handling
Use meaningful test data with clear variable names that indicate test intent
Use data providers (@dataProvider) for testing multiple input scenarios in a single test method
Verify that WordPress hooks are registered and execute correctly using has_action(), has_filter(), and do_action()
Test block pattern registration using WP_Block_Patterns_Registry::get_instance()->get_registered()
Test block style registration using WP_Block_Styles_Registry::get_instance()->get_registered_styles()
Test asset enqueuing by simulating the appropriate screen context and checking wp_style_is() or wp_script_is()
Files:
tests/php/Test_Theme_Setup.phptests/php/Test_Template_Functions.phptests/php/Test_Block_Styles.php
**
📄 CodeRabbit inference engine (.github/instructions/release.instructions.md)
Ensure the repository is placeholder-free before any release action using
grep -R "{{" .
Files:
tests/php/Test_Theme_Setup.phpphpunit.xmltests/php/Test_Template_Functions.phptests/php/Test_Block_Styles.php
**/*.{json,php}
📄 CodeRabbit inference engine (AGENTS.md)
Validate all JSON and PHP output
Files:
tests/php/Test_Theme_Setup.phptests/php/Test_Template_Functions.phptests/php/Test_Block_Styles.php
{package.json,composer.json,jest.config.js,webpack.config.js,phpunit.xml,phpcs.xml,.github/workflows/*.yml}
📄 CodeRabbit inference engine (.github/instructions/naming-conventions.instructions.md)
Configuration files should use standard names: package.json, composer.json, jest.config.js, webpack.config.js, phpunit.xml, phpcs.xml
Files:
phpunit.xml
phpunit.xml
📄 CodeRabbit inference engine (.github/instructions/phpunit-tests.instructions.md)
Configure PHPUnit in phpunit.xml to include theme-specific directories in code coverage and exclude tests/vendor directories
Files:
phpunit.xml
**/{phpunit.xml*,**/*Test.php,**/*coverage*.php}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
Coverage reports generated by PHPUnit should be saved to
.github/reports/coverage/php/YYYY-MM-DD-coverage.{json|html}
Files:
phpunit.xml
⏰ 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: validate-theme-json
🔇 Additional comments (5)
tests/php/Test_Block_Styles.php (1)
25-25: LGTM! Function name updated to snake_case convention.The test correctly references the renamed function using the snake_case variant, aligning with the PR's standardization objective.
phpunit.xml (1)
12-12: LGTM! Test discovery configuration correctly updated.The change from
test-prefix toTest_prefix and./tests/php/directory correctly reflects the actual test file structure and follows WordPress PHPUnit best practices.tests/php/Test_Template_Functions.php (1)
15-15: Function references correctly updated to snake_case convention.These lines properly apply the
snakeCasefilter to theme slug placeholders, ensuring consistent PHP function naming throughout the generated theme.Also applies to: 25-25, 45-45, 61-61, 86-86, 109-109, 115-115, 131-131, 136-136, 161-161, 171-171, 181-181, 191-191, 198-198, 213-213, 218-218, 230-230
tests/php/Test_Theme_Setup.php (2)
14-14: LGTM! Test assertions correctly updated to snake_case function names.The function existence checks properly use the
snakeCasefilter for PHP function names, aligning with the PR's standardization objective:
- Theme setup function
- Pattern category registration
- Asset enqueuing functions
Also applies to: 52-54
35-36: LGTM! Constant naming follows PHP conventions.The use of
{{theme_slug|upper}}_VERSIONcorrectly applies UPPER_SNAKE_CASE for PHP constants, following standard PHP naming conventions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @tests/php/Test_Template_Functions.php:
- Around line 97-114: The test uses an invalid cleanup screen and misses
front-end assertions: replace the cleanup call to unset the current screen
(unset($GLOBALS['current_screen'])) or set_current_screen('index') instead of
set_current_screen('front'), and extend the test to assert front-end behavior by
simulating a front-end screen (e.g., set_current_screen('front' is invalid) or
unset current screen) then calling
{{theme_slug|snakeCase}}_custom_excerpt_length(55) and asserting the returned
length equals the expected modified value; keep the existing admin-context check
that calls set_current_screen('edit') and asserts 55 remains unchanged, then
perform the front-end simulation and assert the changed length.
🧹 Nitpick comments (1)
tests/php/Test_Template_Functions.php (1)
1-142: Add tearDown method for proper test isolation.The test class manipulates global state (via
set_current_screen()) but lacks atear_down()method to ensure cleanup between tests. This follows the WordPress testing best practice of proper test initialization and cleanup.Add tearDown method
class Test_Template_Functions extends WP_UnitTestCase { + /** + * Clean up after each test + */ + public function tear_down() { + // Clear current screen if set + unset( $GLOBALS['current_screen'] ); + parent::tear_down(); + } + /** * Test get version function exists */
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{html,php}
📄 CodeRabbit inference engine (.github/instructions/a11y.instructions.md)
**/*.{html,php}: Maintain proper heading hierarchy and landmark structure in templates and patterns
Use semantic HTML and block patterns; avoid div-only structures
Keep ARIA usage minimal and purposeful; never use ARIA to patch invalid HTML in WordPress block themes
Supply meaningful alt text for images in WordPress block themes
Supply meaningful labels for form elements in WordPress block themes
Files:
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}: Always prefer block-first solutions (patterns, template parts, template composition) over classic PHP templates
Keep business logic in PHP (inc/,functions.php) and presentation in blocks/patterns
Test code with accessibility tools (axe, Lighthouse, WAVE) to ensure WCAG 2.2 AA compliance
Files:
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
**/*.php
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
Follow WordPress PHP coding standards as defined in
wpcs-php.instructions.mdincluding PHPDoc documentationUse tabs for indentation to match PHP code blocks when mixing HTML and PHP
**/*.php: Use__()function to return translated strings in PHP with text domain '{{theme_slug}}'
Use_e()function to directly echo translated strings in PHP with text domain '{{theme_slug}}' instead of echoing__()
Useesc_html__()oresc_html_e()for escaped translation in PHP templates with text domain '{{theme_slug}}'
Useesc_attr__()oresc_attr_e()for HTML attribute translation in PHP with text domain '{{theme_slug}}'
Use_n()function for plural forms in PHP with text domain '{{theme_slug}}' instead of conditional string concatenation
Use_x()or_ex()function in PHP to provide context for ambiguous translatable strings with text domain '{{theme_slug}}'
Use translator comments in PHP (format:/* translators: ... */) for ambiguous, contextual, or placeholder-containing strings
Usesprintf()with numbered placeholders (e.g.,%1$s,%2$s) in PHP instead of string concatenation for translatable strings with variables
Always use escaped translation functions (esc_html__,esc_attr__, etc.) in templates instead of double-escaping with both function and manual escape
**/*.php: Use kebab-case for PHP file names with meaningful names (e.g., file-handler.php, theme-setup.php)
PHP function names should use prefix_snake_case format with a mandatory prefix (e.g., lightspeed_process_file())
PHP class names should use PascalCase (e.g., class FileHandler {})
PHP constants should use PREFIX_UPPER_SNAKE_CASE format (e.g., const LIGHTSPEED_VERSION = '1.0.0')
PHP variables should use $snake_case format (e.g., $file_path, $block_config)
**/*.php: Prefix all global functions with the theme namespace (mytheme_function_name())
Prefix all constants with the theme namespace (MYTHEME_CONSTANT)
Use snake_case for function and variable names throughout PHP code
Us...
Files:
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
**/*.{html,htm,php}
📄 CodeRabbit inference engine (.github/instructions/html-markup.instructions.md)
**/*.{html,htm,php}: Use semantic HTML5 elements and maintain proper heading hierarchy in WordPress block theme templates
Prefer core blocks andtheme.jsontokens for structure and spacing instead of custom structural HTML
Keep attributes lowercase, quoted, and avoid unnecessary ARIA in HTML markup
Use self-closing tags where appropriate, correct boolean attributes, and avoid custom wrappers when a core block exists
Run W3C validator on templates and patterns, and verify block comments render valid block markup (<!-- wp:block -->/<!-- /wp:block -->)
Files:
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)
**/*.{php,js,jsx,ts,tsx}: All user-facing strings must use translation functions with the text domain '{{theme_slug}}'
Never use string concatenation to combine translatable strings; use placeholders with sprintf() instead
Never translate variable content directly; use conditional statements to provide full translatable strings
Avoid including HTML markup in translatable strings; wrap HTML elements separately and combine them with placeholders
Ensure text domain used in all translation functions exactly matches the theme slug '{{theme_slug}}'
**/*.{php,js,jsx,ts,tsx}: Always verify nonces before processing state-changing operations (AJAX, REST, admin) usinglswp_theme_verify_request_nonce(),lswp_theme_verify_rest_nonce(), orcheck_admin_referer()functions
Never skip nonce verification, use incorrect nonce parameter names (must use_wpnonceas default), use generic nonce actions without the theme prefix, or bypass verification with conditional logic
Files:
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
tests/**/*.{js,php}
📄 CodeRabbit inference engine (.github/instructions/naming-conventions.instructions.md)
Test files should use test-{feature-name} prefix format (e.g., tests/js/test-file-handler.js or tests/php/test-block-register.php)
Files:
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
tests/php/**/*.php
📄 CodeRabbit inference engine (.github/instructions/phpunit-tests.instructions.md)
tests/php/**/*.php: Structure PHPUnit test classes by extending WP_UnitTestCase with setUp() and tearDown() methods for proper test initialization and cleanup
Use descriptive test method names following the pattern test__() to clearly communicate test intent
Organize test data using setUp() for initialization and tearDown() for cleanup to ensure test isolation
Test one concept per test method to maintain clear test purpose and improve readability
Use WordPress factories ($this->factory()->post->create(), $this->factory()->user->create()) to generate test data
Test error conditions and invalid inputs in addition to valid inputs to ensure robust error handling
Use meaningful test data with clear variable names that indicate test intent
Use data providers (@dataProvider) for testing multiple input scenarios in a single test method
Verify that WordPress hooks are registered and execute correctly using has_action(), has_filter(), and do_action()
Test block pattern registration using WP_Block_Patterns_Registry::get_instance()->get_registered()
Test block style registration using WP_Block_Styles_Registry::get_instance()->get_registered_styles()
Test asset enqueuing by simulating the appropriate screen context and checking wp_style_is() or wp_script_is()
Files:
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
**
📄 CodeRabbit inference engine (.github/instructions/release.instructions.md)
Ensure the repository is placeholder-free before any release action using
grep -R "{{" .
Files:
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
**/*.{json,php}
📄 CodeRabbit inference engine (AGENTS.md)
Validate all JSON and PHP output
Files:
tests/php/Test_Block_Patterns.phptests/php/Test_Template_Functions.php
⏰ 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: validate-theme-json
🔇 Additional comments (3)
tests/php/Test_Block_Patterns.php (1)
30-30: LGTM! Function naming updated correctly to snake_case.The updates to use
{{theme_slug|snakeCase}}_prefix for the three pattern registration functions align perfectly with the PR's objective to standardize PHP identifiers to snake_case.Also applies to: 40-40, 50-50
tests/php/Test_Template_Functions.php (2)
13-18: LGTM! Function existence and basic behavior tests are well-structured.The test methods appropriately verify function existence using the snake_case naming convention and include proper exception handling for behavioral tests.
Also applies to: 23-32, 67-72, 77-82, 87-92, 119-131, 136-141
37-62: No action needed. The test assertion correctly matches the implementation. The version class prefix uses the raw{{theme_slug}}placeholder (not snake_case) in both the implementation and test assertion, so they are consistent.Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
functions.php (1)
47-80: Fix indentation to use tabs consistently.The function logic and asset handle naming are correct. However, the indentation within the
wp_enqueue_style()andwp_enqueue_script()calls is inconsistent—lines 52-57 and 64-70 appear to use spaces instead of tabs.♻️ Proposed fix for indentation
$asset_file = get_theme_file_path( 'build/css/style.asset.php' ); if ( file_exists( $asset_file ) ) { $asset = include $asset_file; - wp_enqueue_style( - '{{theme_slug}}-style', - get_theme_file_uri( 'build/css/style.css' ), - $asset['dependencies'] ?? array(), - $asset['version'] ?? {{theme_slug|upper}}_VERSION - ); + wp_enqueue_style( + '{{theme_slug}}-style', + get_theme_file_uri( 'build/css/style.css' ), + $asset['dependencies'] ?? array(), + $asset['version'] ?? {{theme_slug|upper}}_VERSION + ); } // Main JavaScript. $js_asset_file = get_theme_file_path( 'build/js/theme.asset.php' ); if ( file_exists( $js_asset_file ) ) { $js_asset = include $js_asset_file; - wp_enqueue_script( - '{{theme_slug}}-script', - get_theme_file_uri( 'build/js/theme.js' ), - $js_asset['dependencies'] ?? array(), - $js_asset['version'] ?? {{theme_slug|upper}}_VERSION, - true - ); + wp_enqueue_script( + '{{theme_slug}}-script', + get_theme_file_uri( 'build/js/theme.js' ), + $js_asset['dependencies'] ?? array(), + $js_asset['version'] ?? {{theme_slug|upper}}_VERSION, + true + ); // Set script translations. - wp_set_script_translations( - '{{theme_slug}}-script', - '{{theme_slug}}', - get_theme_file_path( 'languages' ) - ); + wp_set_script_translations( + '{{theme_slug}}-script', + '{{theme_slug}}', + get_theme_file_path( 'languages' ) + ); }As per coding guidelines: "Use tabs for indentation in PHP files".
🤖 Fix all issues with AI agents
In @functions.php:
- Line 40: $GLOBALS['content_width'] is being set with a string literal
'{{content_width_px}}' via apply_filters('{{theme_slug}}_content_width',
'{{content_width_px}}'); change this to pass an integer (cast or literal) so
WordPress receives a number; update the default value passed to apply_filters
for the filter name '{{theme_slug}}_content_width' to be an integer (e.g.,
(int){{content_width_px}} or a numeric literal) and ensure
$GLOBALS['content_width'] is assigned that integer result.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
functions.php
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{html,php}
📄 CodeRabbit inference engine (.github/instructions/a11y.instructions.md)
**/*.{html,php}: Maintain proper heading hierarchy and landmark structure in templates and patterns
Use semantic HTML and block patterns; avoid div-only structures
Keep ARIA usage minimal and purposeful; never use ARIA to patch invalid HTML in WordPress block themes
Supply meaningful alt text for images in WordPress block themes
Supply meaningful labels for form elements in WordPress block themes
Files:
functions.php
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}: Always prefer block-first solutions (patterns, template parts, template composition) over classic PHP templates
Keep business logic in PHP (inc/,functions.php) and presentation in blocks/patterns
Test code with accessibility tools (axe, Lighthouse, WAVE) to ensure WCAG 2.2 AA compliance
Files:
functions.php
functions.php
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
functions.php: Enqueue only built assets from thebuild/directory; usewp_enqueue_block_styleandwp_enqueue_block_scriptfor block-specific assets with cache busting via file modification time or build hash
Use conditional enqueuing to load assets only when needed
Files:
functions.php
**/*.php
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
Follow WordPress PHP coding standards as defined in
wpcs-php.instructions.mdincluding PHPDoc documentationUse tabs for indentation to match PHP code blocks when mixing HTML and PHP
**/*.php: Use__()function to return translated strings in PHP with text domain '{{theme_slug}}'
Use_e()function to directly echo translated strings in PHP with text domain '{{theme_slug}}' instead of echoing__()
Useesc_html__()oresc_html_e()for escaped translation in PHP templates with text domain '{{theme_slug}}'
Useesc_attr__()oresc_attr_e()for HTML attribute translation in PHP with text domain '{{theme_slug}}'
Use_n()function for plural forms in PHP with text domain '{{theme_slug}}' instead of conditional string concatenation
Use_x()or_ex()function in PHP to provide context for ambiguous translatable strings with text domain '{{theme_slug}}'
Use translator comments in PHP (format:/* translators: ... */) for ambiguous, contextual, or placeholder-containing strings
Usesprintf()with numbered placeholders (e.g.,%1$s,%2$s) in PHP instead of string concatenation for translatable strings with variables
Always use escaped translation functions (esc_html__,esc_attr__, etc.) in templates instead of double-escaping with both function and manual escape
**/*.php: Use kebab-case for PHP file names with meaningful names (e.g., file-handler.php, theme-setup.php)
PHP function names should use prefix_snake_case format with a mandatory prefix (e.g., lightspeed_process_file())
PHP class names should use PascalCase (e.g., class FileHandler {})
PHP constants should use PREFIX_UPPER_SNAKE_CASE format (e.g., const LIGHTSPEED_VERSION = '1.0.0')
PHP variables should use $snake_case format (e.g., $file_path, $block_config)
**/*.php: Prefix all global functions with the theme namespace (mytheme_function_name())
Prefix all constants with the theme namespace (MYTHEME_CONSTANT)
Use snake_case for function and variable names throughout PHP code
Us...
Files:
functions.php
**/*.{html,htm,php}
📄 CodeRabbit inference engine (.github/instructions/html-markup.instructions.md)
**/*.{html,htm,php}: Use semantic HTML5 elements and maintain proper heading hierarchy in WordPress block theme templates
Prefer core blocks andtheme.jsontokens for structure and spacing instead of custom structural HTML
Keep attributes lowercase, quoted, and avoid unnecessary ARIA in HTML markup
Use self-closing tags where appropriate, correct boolean attributes, and avoid custom wrappers when a core block exists
Run W3C validator on templates and patterns, and verify block comments render valid block markup (<!-- wp:block -->/<!-- /wp:block -->)
Files:
functions.php
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)
**/*.{php,js,jsx,ts,tsx}: All user-facing strings must use translation functions with the text domain '{{theme_slug}}'
Never use string concatenation to combine translatable strings; use placeholders with sprintf() instead
Never translate variable content directly; use conditional statements to provide full translatable strings
Avoid including HTML markup in translatable strings; wrap HTML elements separately and combine them with placeholders
Ensure text domain used in all translation functions exactly matches the theme slug '{{theme_slug}}'
**/*.{php,js,jsx,ts,tsx}: Always verify nonces before processing state-changing operations (AJAX, REST, admin) usinglswp_theme_verify_request_nonce(),lswp_theme_verify_rest_nonce(), orcheck_admin_referer()functions
Never skip nonce verification, use incorrect nonce parameter names (must use_wpnonceas default), use generic nonce actions without the theme prefix, or bypass verification with conditional logic
Files:
functions.php
**/functions.php
📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)
Load theme textdomain in
functions.phpusingload_theme_textdomain()hooked to 'after_setup_theme' action with domain '{{theme_slug}}' and path to languages directory
Files:
functions.php
**
📄 CodeRabbit inference engine (.github/instructions/release.instructions.md)
Ensure the repository is placeholder-free before any release action using
grep -R "{{" .
Files:
functions.php
**/*.{json,php}
📄 CodeRabbit inference engine (AGENTS.md)
Validate all JSON and PHP output
Files:
functions.php
🪛 GitHub Actions: Code Quality
functions.php
[error] 1-1: Could not find /tmp/wordpress-tests-lib/includes/functions.php, have you run bin/install-wp-tests.sh ?
⏰ 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: validate-theme-json
🔇 Additional comments (6)
functions.php (6)
22-42: LGTM! Theme setup function correctly renamed to snake_case.The function naming convention change follows WordPress PHP coding standards. The hook registration is properly updated to match the new function name.
85-117: LGTM! Editor assets function correctly renamed.The function naming and asset handle conventions are correct. Note: indentation issues in this function are similar to those flagged in the previous enqueue function.
122-136: LGTM! Pattern categories function correctly updated.The function naming follows WordPress standards, and the pattern category slugs correctly use kebab-case. Translation functions are properly implemented with the theme text domain.
157-162: LGTM! Image sizes function correctly renamed.The function naming and image size handles follow WordPress conventions. The implementation properly registers custom image sizes with crop enabled.
167-170: LGTM! Excerpt length filter correctly updated.The function naming follows WordPress standards and the filter is properly registered.
175-178: LGTM! Excerpt more filter correctly updated.The function naming follows WordPress standards and the filter is properly registered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @scripts/generate-theme.js:
- Line 718: The code that builds '{{content_width_num}}' uses
(configData.design_system_layout_content_width || 720).replace(...), which will
throw if design_system_layout_content_width is a number; fix by coercing the
value to a string before calling replace (e.g., convert the expression used for
'{{content_width_num}}' to String(configData.design_system_layout_content_width
|| 720) or use template interpolation) so .replace() always runs on a string and
preserves the existing default behavior.
- Around line 340-346: The 'const parts' declaration in the 'camelCase' switch
case is not block-scoped and can leak into other cases; wrap the 'camelCase'
case body in its own block (add { ... } around the case code) so 'parts' is
scoped only to that case and then return the computed string as before.
🧹 Nitpick comments (2)
.github/README.md (1)
38-65: Consider using proper headings instead of bold emphasis for generation modes.Lines 38, 57, and 62 use bold text (
**Interactive prompts (easiest)**,**CLI Mode**,**JSON Mode**) where subheadings (e.g.,##### Interactive prompts (easiest)) would be more semantically appropriate and improve document navigation.♻️ Suggested improvement
-**Interactive prompts (easiest)** +##### Interactive prompts (easiest) ... -**CLI Mode** +##### CLI Mode ... -**JSON Mode** +##### JSON Modescripts/generate-theme.js (1)
335-338:snakeCaseandphpCasefilters have identical implementations.Both filters perform the same transformation (
toLowerCase().replace(/-/g, '_')). If this is intentional for semantic distinction, consider adding a brief comment to clarify. Otherwise, one could delegate to the other.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.github/README.mdfunctions.phpscripts/generate-theme.jsscripts/utils/placeholders.jstests/php/Test_Block_Styles.phptests/php/Test_Template_Functions.phptests/php/Test_Theme_Setup.php
🚧 Files skipped from review as they are similar to previous changes (2)
- scripts/utils/placeholders.js
- tests/php/Test_Template_Functions.php
🧰 Additional context used
📓 Path-based instructions (18)
**/*.{html,php}
📄 CodeRabbit inference engine (.github/instructions/a11y.instructions.md)
**/*.{html,php}: Maintain proper heading hierarchy and landmark structure in templates and patterns
Use semantic HTML and block patterns; avoid div-only structures
Keep ARIA usage minimal and purposeful; never use ARIA to patch invalid HTML in WordPress block themes
Supply meaningful alt text for images in WordPress block themes
Supply meaningful labels for form elements in WordPress block themes
Files:
tests/php/Test_Block_Styles.phpfunctions.phptests/php/Test_Theme_Setup.php
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{php,html,json,css,scss,js,jsx,ts,tsx}: Always prefer block-first solutions (patterns, template parts, template composition) over classic PHP templates
Keep business logic in PHP (inc/,functions.php) and presentation in blocks/patterns
Test code with accessibility tools (axe, Lighthouse, WAVE) to ensure WCAG 2.2 AA compliance
Files:
tests/php/Test_Block_Styles.phpscripts/generate-theme.jsfunctions.phptests/php/Test_Theme_Setup.php
**/*.php
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
Follow WordPress PHP coding standards as defined in
wpcs-php.instructions.mdincluding PHPDoc documentationUse tabs for indentation to match PHP code blocks when mixing HTML and PHP
**/*.php: Use__()function to return translated strings in PHP with text domain '{{theme_slug}}'
Use_e()function to directly echo translated strings in PHP with text domain '{{theme_slug}}' instead of echoing__()
Useesc_html__()oresc_html_e()for escaped translation in PHP templates with text domain '{{theme_slug}}'
Useesc_attr__()oresc_attr_e()for HTML attribute translation in PHP with text domain '{{theme_slug}}'
Use_n()function for plural forms in PHP with text domain '{{theme_slug}}' instead of conditional string concatenation
Use_x()or_ex()function in PHP to provide context for ambiguous translatable strings with text domain '{{theme_slug}}'
Use translator comments in PHP (format:/* translators: ... */) for ambiguous, contextual, or placeholder-containing strings
Usesprintf()with numbered placeholders (e.g.,%1$s,%2$s) in PHP instead of string concatenation for translatable strings with variables
Always use escaped translation functions (esc_html__,esc_attr__, etc.) in templates instead of double-escaping with both function and manual escape
**/*.php: Use kebab-case for PHP file names with meaningful names (e.g., file-handler.php, theme-setup.php)
PHP function names should use prefix_snake_case format with a mandatory prefix (e.g., lightspeed_process_file())
PHP class names should use PascalCase (e.g., class FileHandler {})
PHP constants should use PREFIX_UPPER_SNAKE_CASE format (e.g., const LIGHTSPEED_VERSION = '1.0.0')
PHP variables should use $snake_case format (e.g., $file_path, $block_config)
**/*.php: Prefix all global functions with the theme namespace (mytheme_function_name())
Prefix all constants with the theme namespace (MYTHEME_CONSTANT)
Use snake_case for function and variable names throughout PHP code
Us...
Files:
tests/php/Test_Block_Styles.phpfunctions.phptests/php/Test_Theme_Setup.php
**/*.{html,htm,php}
📄 CodeRabbit inference engine (.github/instructions/html-markup.instructions.md)
**/*.{html,htm,php}: Use semantic HTML5 elements and maintain proper heading hierarchy in WordPress block theme templates
Prefer core blocks andtheme.jsontokens for structure and spacing instead of custom structural HTML
Keep attributes lowercase, quoted, and avoid unnecessary ARIA in HTML markup
Use self-closing tags where appropriate, correct boolean attributes, and avoid custom wrappers when a core block exists
Run W3C validator on templates and patterns, and verify block comments render valid block markup (<!-- wp:block -->/<!-- /wp:block -->)
Files:
tests/php/Test_Block_Styles.phpfunctions.phptests/php/Test_Theme_Setup.php
**/*.{php,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)
**/*.{php,js,jsx,ts,tsx}: All user-facing strings must use translation functions with the text domain '{{theme_slug}}'
Never use string concatenation to combine translatable strings; use placeholders with sprintf() instead
Never translate variable content directly; use conditional statements to provide full translatable strings
Avoid including HTML markup in translatable strings; wrap HTML elements separately and combine them with placeholders
Ensure text domain used in all translation functions exactly matches the theme slug '{{theme_slug}}'
**/*.{php,js,jsx,ts,tsx}: Always verify nonces before processing state-changing operations (AJAX, REST, admin) usinglswp_theme_verify_request_nonce(),lswp_theme_verify_rest_nonce(), orcheck_admin_referer()functions
Never skip nonce verification, use incorrect nonce parameter names (must use_wpnonceas default), use generic nonce actions without the theme prefix, or bypass verification with conditional logic
Files:
tests/php/Test_Block_Styles.phpscripts/generate-theme.jsfunctions.phptests/php/Test_Theme_Setup.php
tests/**/*.{js,php}
📄 CodeRabbit inference engine (.github/instructions/naming-conventions.instructions.md)
Test files should use test-{feature-name} prefix format (e.g., tests/js/test-file-handler.js or tests/php/test-block-register.php)
Files:
tests/php/Test_Block_Styles.phptests/php/Test_Theme_Setup.php
tests/php/**/*.php
📄 CodeRabbit inference engine (.github/instructions/phpunit-tests.instructions.md)
tests/php/**/*.php: Structure PHPUnit test classes by extending WP_UnitTestCase with setUp() and tearDown() methods for proper test initialization and cleanup
Use descriptive test method names following the pattern test__() to clearly communicate test intent
Organize test data using setUp() for initialization and tearDown() for cleanup to ensure test isolation
Test one concept per test method to maintain clear test purpose and improve readability
Use WordPress factories ($this->factory()->post->create(), $this->factory()->user->create()) to generate test data
Test error conditions and invalid inputs in addition to valid inputs to ensure robust error handling
Use meaningful test data with clear variable names that indicate test intent
Use data providers (@dataProvider) for testing multiple input scenarios in a single test method
Verify that WordPress hooks are registered and execute correctly using has_action(), has_filter(), and do_action()
Test block pattern registration using WP_Block_Patterns_Registry::get_instance()->get_registered()
Test block style registration using WP_Block_Styles_Registry::get_instance()->get_registered_styles()
Test asset enqueuing by simulating the appropriate screen context and checking wp_style_is() or wp_script_is()
Files:
tests/php/Test_Block_Styles.phptests/php/Test_Theme_Setup.php
**
📄 CodeRabbit inference engine (.github/instructions/release.instructions.md)
Ensure the repository is placeholder-free before any release action using
grep -R "{{" .
Files:
tests/php/Test_Block_Styles.phpscripts/generate-theme.jsfunctions.phptests/php/Test_Theme_Setup.php
**/*.{json,php}
📄 CodeRabbit inference engine (AGENTS.md)
Validate all JSON and PHP output
Files:
tests/php/Test_Block_Styles.phpfunctions.phptests/php/Test_Theme_Setup.php
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
**/*.{js,jsx,ts,tsx}: Store JavaScript/JSX source files inassets/directory and output transpiled bundles tobuild/; use build tools for transpilation and optimization
Follow JavaScript and JSDoc standards as defined injavascript.instructions.md; use ESLint for linting and Prettier for formatting
**/*.{js,jsx,ts,tsx}: Use@wordpress/i18npackage functions (__,_x,_n,sprintf) in JavaScript/TypeScript with text domain '{{theme_slug}}'
Use translator comments in JavaScript (format:/* translators: ... */) for placeholder-containing or ambiguous strings with@wordpress/i18n
Usesprintf()with placeholders from@wordpress/i18nin JavaScript instead of template literals for translatable strings with variables
**/*.{js,jsx,ts,tsx}: Localize nonces to JavaScript usingwp_localize_script()with nonce in object (e.g.,BlockTheme.nonce) and never hard-code or omit nonces from AJAX/REST requests
In JavaScript, includeX-WP-Nonceheader in fetch requests to REST API endpoints using the WordPress globalwpApiSettings.nonceor localized nonce value
Files:
scripts/generate-theme.js
**/*.{js,jsx,ts,tsx,mjs,cjs}
📄 CodeRabbit inference engine (.github/instructions/javascript.instructions.md)
**/*.{js,jsx,ts,tsx,mjs,cjs}: Use modern ES modules withconst/let, arrow functions, and WordPress packages
Keep code i18n-ready using@wordpress/i18n; avoid string concatenation for translatable strings
Follow naming conventions: camelCase for variables/functions, PascalCase for classes/components, UPPER_SNAKE_CASE for constants
Use 2 spaces for indentation (no tabs)
Maintain 80 character soft line length limit
Use single quotes for strings and template literals for interpolation
Semicolons are required at statement ends
Never usevar; preferconst/letfor variable declarations
Prefer arrow functions for callbacks
Use ES6+ features (destructuring, spread operator, etc.)
Use strict equality operators (===,!==) instead of loose equality (==,!=)
Use@wordpress/*packages for block registration, block editor components, and utilities
Document functions and exported members with JSDoc comments including @param, @returns, and @example tags
Use@wordpress/i18nfunctions (__,_n,sprintf) for all translatable strings with matching text domain
Run ESLint with WordPress config and pass linting before merging code
Files:
scripts/generate-theme.js
**/*.js
📄 CodeRabbit inference engine (.github/instructions/jest-tests.instructions.md)
**/*.js: Ensure all new code has 80%+ test coverage for JavaScript files
Exclude specific files and lines from Jest coverage usingcoveragePathIgnorePatternsand/* istanbul ignore */comments
**/*.js: Use kebab-case for JavaScript file names with meaningful names (e.g., file-handler.js, data-processor.js)
JavaScript class exports should use PascalCase (e.g., export class FileHandler {})
JavaScript function exports should use camelCase (e.g., export function processData() {})
JavaScript constant exports should use UPPER_SNAKE_CASE (e.g., export const MAX_FILE_SIZE = 1024)
Files:
scripts/generate-theme.js
**/*.{js,ts,json,sh,yml,yaml}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
Store all reports only in
.github/reports/directory organized by category (coverage, analysis, validation, performance, agents, projects, comparison) - never in repository root or tmp directories
Files:
scripts/generate-theme.js
**/*.{js,ts,json,sh}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
Include ISO 8601 date (YYYY-MM-DD format) at the start of all report filenames, followed by hyphen-separated description
Files:
scripts/generate-theme.js
**/*.{js,ts,sh}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
**/*.{js,ts,sh}: Use kebab-case naming for report filenames; never use underscores, and date must appear at start (e.g.,2025-12-07-eslint-report.jsonnoteslint_report.jsonoreslint-report-2025-12-07.json)
Create nested directory structure automatically in.github/reports/if it doesn't exist; ensure parent directories are created before writing report files
Usetmp/directory only for temporary intermediate files during processing; never save final reports totmp/- move completed reports to.github/reports/and clean up temp files when done
Clean up temporary files intmp/directory after report generation is complete; do not leave intermediate processing files behind
Files:
scripts/generate-theme.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)
**/*.{js,ts}: Include metadata in all reports with: date (ISO timestamp), type/category, tool/agent name, status, and logFile reference pointing to related log underlogs/
Reference related log files in every report vialogFilefield pointing to the process that generated it (e.g.,logs/test/2025-12-07-jest.log)
Always verify report content validity (JSON parsing, HTML structure) before saving and include error handling for file write failures with appropriate logging
Files:
scripts/generate-theme.js
functions.php
📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)
functions.php: Enqueue only built assets from thebuild/directory; usewp_enqueue_block_styleandwp_enqueue_block_scriptfor block-specific assets with cache busting via file modification time or build hash
Use conditional enqueuing to load assets only when needed
Files:
functions.php
**/functions.php
📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)
Load theme textdomain in
functions.phpusingload_theme_textdomain()hooked to 'after_setup_theme' action with domain '{{theme_slug}}' and path to languages directory
Files:
functions.php
🧠 Learnings (1)
📚 Learning: 2025-12-17T08:12:09.993Z
Learnt from: CR
Repo: lightspeedwp/block-theme-scaffold PR: 0
File: .github/instructions/phpunit-tests.instructions.md:0-0
Timestamp: 2025-12-17T08:12:09.993Z
Learning: Applies to tests/php/**/*.php : Test block style registration using WP_Block_Styles_Registry::get_instance()->get_registered_styles()
Applied to files:
tests/php/Test_Block_Styles.php
🧬 Code graph analysis (1)
scripts/generate-theme.js (2)
scripts/utils/placeholders.js (2)
result(112-112)value(198-198)scripts/utils/scan.js (1)
match(230-230)
🪛 Biome (2.1.2)
scripts/generate-theme.js
[error] 342-342: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Safe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
🪛 markdownlint-cli2 (0.18.1)
.github/README.md
38-38: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
57-57: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
62-62: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
⏰ 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: validate-theme-json
🔇 Additional comments (13)
.github/README.md (1)
84-84: Placeholder{{theme_name}}in GitHub Configuration section.Line 84 contains
{{theme_name}}which appears to be a template placeholder. Verify this is intentional for the scaffold - if this README is meant to remain in generated themes, the placeholder should be replaced during generation. If it's scaffold-only documentation, consider using a generic term instead.scripts/generate-theme.js (2)
694-699: Email domain extraction may produce unexpected results.The email generation logic on lines 698-699 assumes
authorUrifollows a specific URL structure. If the URI has a path or unusual format, the extracted domain may be incorrect (e.g.,https://example.com/path→security@example.comworks, but edge cases may fail silently).Consider adding validation or a fallback:
const domain = authorUri.replace(/^https?:\/\/(www\.)?/, '').split('/')[0] || 'example.com';
681-732: Comprehensive placeholder population looks good.The rebuilt placeholders object consolidates all mustache variables in a validated path with proper sanitization. The structure is clear and well-organized.
functions.php (4)
22-42: LGTM - Consistent snake_case naming for theme setup.The function rename to
{{theme_slug|snakeCase}}_setupand corresponding hook update follows the PR's naming standardization correctly.
47-80: LGTM - Asset enqueue function properly refactored.The function and asset handles are consistently renamed. The enqueue logic correctly uses file existence checks and proper WordPress patterns.
122-136: LGTM - Pattern category registration updated correctly.Function renamed to snake_case and category slugs consistently use
{{theme_slug}}-*pattern. The translation functions correctly use the theme text domain.
157-178: LGTM - Image sizes and excerpt functions properly renamed.All functions follow the snake_case naming convention and hooks are updated accordingly. Image size names use the
{{theme_slug}}-*pattern for consistency.tests/php/Test_Block_Styles.php (2)
23-28: LGTM - Function existence check updated to snake_case.The test correctly verifies the renamed
{{theme_slug|snakeCase}}_register_block_stylesfunction.
120-138: LGTM - Comprehensive style label validation.The test iterates through all styled blocks and verifies each style has a non-empty label. Good coverage pattern.
tests/php/Test_Theme_Setup.php (4)
13-15: LGTM - Function existence check updated to snake_case.The test correctly verifies the renamed
{{theme_slug|snakeCase}}_setupfunction.
45-49: LGTM - Theme includes function checks updated to snake_case.All three function existence assertions correctly use the snake_case naming convention.
66-76: LGTM - theme.json validation updated for version 3.The version assertion correctly expects version 3, aligning with the commit message about bumping from version 2 to 3. The removal of the 'styles' key assertion (mentioned in summary) is acceptable as styles are optional in theme.json.
20-23: Remove this comment—editor-color-paletteis correctly registered.The theme explicitly registers
editor-color-palettesupport viaadd_theme_support()ininc/template-functions.php, which is included and hooked to theafter_setup_themeaction. The test assertion will pass as intended.Likely an incorrect or invalid review comment.
… placeholder replacement logic in generate-theme.js
There was a problem hiding this 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
🤖 Fix all issues with AI agents
In @.github/README.md:
- Line 66: The CLI example for the theme generator has an extra space before the
--author value in the command shown (node scripts/generate-theme.js --slug
my-theme --name "My Theme" --author "Your Name" ...); remove the duplicate
space so the --author flag and its value are separated by a single space (e.g.,
--author "Your Name") to correct the example for scripts/generate-theme.js
usage.
- Around line 16-17: The README sentence "This tool is ment to be used on its
own, and not inside a WordPress install. We suggest creating a "tools" folder at
the root of your hosting applications folder (where all the sites are housed).
You can then clone your it to your tools folder, and re-use it everytime you
need a new theme." contains typos and awkward phrasing; change "ment" to
"meant", remove the stray "your" in "clone your it", and fix "everytime" to
"every time", and rephrase for clarity—e.g., split into two clear sentences: say
the tool is meant to be used standalone (not inside a WordPress install) and
recommend creating a "tools" folder at the hosting root where you clone the repo
into that folder so it can be reused whenever you need a new theme.
- Line 12: Replace the non-descriptive link text "here" in the sentence
"Advanced documentation on the theme generation is provided
[here](../docs/GENERATE_THEME.md)" with meaningful, descriptive link text (e.g.,
"the theme generation guide" or "GENERATE_THEME documentation") so the Markdown
becomes: Advanced documentation on the theme generation is provided [the theme
generation guide](../docs/GENERATE_THEME.md); ensure the chosen text clearly
describes the target document for accessibility and scanning.
In @scripts/generate-theme.js:
- Line 719: The mapping for '{{content_width_num}}' calls .replace() on
(configData.design_system_layout_content_width || 720), which can be a number
and thus throw a TypeError; fix it by coercing the value to a string before
calling .replace (e.g., use String(...) or a string fallback) so that
configData.design_system_layout_content_width (or the default 720) is always a
string when you call .replace; update the expression that builds
'{{content_width_num}}' accordingly.
- Around line 699-700: The email-domain extraction for '{{security_email}}' and
'{{contact_email}}' uses authorUri.replace(...).split('/')[0] which can include
a port (e.g. example.com:8080); update the logic in scripts/generate-theme.js to
derive the hostname without port (e.g. use new URL(authorUri).hostname or strip
the port with a post-replace like .split(':')[0] on the extracted host) and then
build the addresses as `security@<hostname>` and `contact@<hostname>` so ports
are never included in the generated emails.
🧹 Nitpick comments (3)
scripts/generate-theme.js (2)
319-352: Single-pass regex is well designed, butsnakeCaseandphpCaseare duplicates.Lines 335-338 implement identical logic for both
snakeCaseandphpCasefilters. Consider consolidating them or documenting why both exist (perhaps for semantic clarity in templates).case 'snakeCase': return value.toLowerCase().replace( /-/g, '_' ); case 'phpCase': - return value.toLowerCase().replace( /-/g, '_' ); + // Alias for snakeCase - PHP naming convention + return value.toLowerCase().replace( /-/g, '_' );Also note: The
pascalCaseandcamelCaseimplementations (lines 340-344) don't lowercase the individual parts first, so input likeMY-THEMEwould produceMYThemerather thanMyTheme. If the input is always expected to be lowercase slugs this is fine, but worth documenting.
671-680: Consider preserving specific error messages for better debugging.The
sanitizeInput(..., 'slug')function can throw either "path traversal" or "Invalid slug" errors. Currently, both are masked as "Invalid theme slug provided". For consistency with the author_uri handling (lines 665-669), consider differentiating the error messages.♻️ Optional improvement
try { if ( configData.theme_slug || argMap.slug ) { themeSlug = sanitizeInput( configData.theme_slug || argMap.slug, 'slug' ); } } catch ( e ) { + if ( e.message === 'path traversal' ) { + throw new Error( 'Invalid theme slug: path traversal detected' ); + } throw new Error( 'Invalid theme slug provided' ); }.github/README.md (1)
45-72: Convert bold text to proper headings for better document structure.Lines 45, 64, and 69 use bold emphasis (
**text**) instead of proper headings. This affects document outline navigation and accessibility.♻️ Suggested fix
-**Interactive prompts (easiest)** +##### Interactive Prompts (Easiest) Add the folder to the chat to your IDE, and select the "Generate Theme Agent" from the agent dropdown, ... -**CLI Mode** +##### CLI Mode ```bash node scripts/generate-theme.js --slug my-theme --name "My Theme" --author "Your Name" ...-JSON Mode
+##### JSON Modenode scripts/generate-theme.js --config theme-config.json</details> </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: Path: .coderabbit.yml **Review profile**: CHILL **Plan**: Pro <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 1b3e85a4a1b6f28c7966f7df29d54ab354204e3d and e7a061435ce47a0626eaa79e0bf039c159d6d9c7. </details> <details> <summary>📒 Files selected for processing (3)</summary> * `.github/README.md` * `CHANGELOG.md` * `scripts/generate-theme.js` </details> <details> <summary>✅ Files skipped from review due to trivial changes (1)</summary> * CHANGELOG.md </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>📓 Path-based instructions (10)</summary> <details> <summary>**/*.{php,html,json,css,scss,js,jsx,ts,tsx}</summary> **📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)** > `**/*.{php,html,json,css,scss,js,jsx,ts,tsx}`: Always prefer block-first solutions (patterns, template parts, template composition) over classic PHP templates > Keep business logic in PHP (`inc/`, `functions.php`) and presentation in blocks/patterns > Test code with accessibility tools (axe, Lighthouse, WAVE) to ensure WCAG 2.2 AA compliance Files: - `scripts/generate-theme.js` </details> <details> <summary>**/*.{js,jsx,ts,tsx}</summary> **📄 CodeRabbit inference engine (.github/instructions/block-theme-development.instructions.md)** > `**/*.{js,jsx,ts,tsx}`: Store JavaScript/JSX source files in `assets/` directory and output transpiled bundles to `build/`; use build tools for transpilation and optimization > Follow JavaScript and JSDoc standards as defined in `javascript.instructions.md`; use ESLint for linting and Prettier for formatting > > `**/*.{js,jsx,ts,tsx}`: Use `@wordpress/i18n` package functions (`__`, `_x`, `_n`, `sprintf`) in JavaScript/TypeScript with text domain '{{theme_slug}}' > Use translator comments in JavaScript (format: `/* translators: ... */`) for placeholder-containing or ambiguous strings with `@wordpress/i18n` > Use `sprintf()` with placeholders from `@wordpress/i18n` in JavaScript instead of template literals for translatable strings with variables > > `**/*.{js,jsx,ts,tsx}`: Localize nonces to JavaScript using `wp_localize_script()` with nonce in object (e.g., `BlockTheme.nonce`) and never hard-code or omit nonces from AJAX/REST requests > In JavaScript, include `X-WP-Nonce` header in fetch requests to REST API endpoints using the WordPress global `wpApiSettings.nonce` or localized nonce value Files: - `scripts/generate-theme.js` </details> <details> <summary>**/*.{php,js,jsx,ts,tsx}</summary> **📄 CodeRabbit inference engine (.github/instructions/i18n.instructions.md)** > `**/*.{php,js,jsx,ts,tsx}`: All user-facing strings must use translation functions with the text domain '{{theme_slug}}' > Never use string concatenation to combine translatable strings; use placeholders with sprintf() instead > Never translate variable content directly; use conditional statements to provide full translatable strings > Avoid including HTML markup in translatable strings; wrap HTML elements separately and combine them with placeholders > Ensure text domain used in all translation functions exactly matches the theme slug '{{theme_slug}}' > > `**/*.{php,js,jsx,ts,tsx}`: Always verify nonces before processing state-changing operations (AJAX, REST, admin) using `lswp_theme_verify_request_nonce()`, `lswp_theme_verify_rest_nonce()`, or `check_admin_referer()` functions > Never skip nonce verification, use incorrect nonce parameter names (must use `_wpnonce` as default), use generic nonce actions without the theme prefix, or bypass verification with conditional logic Files: - `scripts/generate-theme.js` </details> <details> <summary>**/*.{js,jsx,ts,tsx,mjs,cjs}</summary> **📄 CodeRabbit inference engine (.github/instructions/javascript.instructions.md)** > `**/*.{js,jsx,ts,tsx,mjs,cjs}`: Use modern ES modules with `const`/`let`, arrow functions, and WordPress packages > Keep code i18n-ready using `@wordpress/i18n`; avoid string concatenation for translatable strings > Follow naming conventions: camelCase for variables/functions, PascalCase for classes/components, UPPER_SNAKE_CASE for constants > Use 2 spaces for indentation (no tabs) > Maintain 80 character soft line length limit > Use single quotes for strings and template literals for interpolation > Semicolons are required at statement ends > Never use `var`; prefer `const`/`let` for variable declarations > Prefer arrow functions for callbacks > Use ES6+ features (destructuring, spread operator, etc.) > Use strict equality operators (`===`, `!==`) instead of loose equality (`==`, `!=`) > Use `@wordpress/*` packages for block registration, block editor components, and utilities > Document functions and exported members with JSDoc comments including @param, @returns, and @example tags > Use `@wordpress/i18n` functions (`__`, `_n`, `sprintf`) for all translatable strings with matching text domain > Run ESLint with WordPress config and pass linting before merging code Files: - `scripts/generate-theme.js` </details> <details> <summary>**/*.js</summary> **📄 CodeRabbit inference engine (.github/instructions/jest-tests.instructions.md)** > `**/*.js`: Ensure all new code has 80%+ test coverage for JavaScript files > Exclude specific files and lines from Jest coverage using `coveragePathIgnorePatterns` and `/* istanbul ignore */` comments > > `**/*.js`: Use kebab-case for JavaScript file names with meaningful names (e.g., file-handler.js, data-processor.js) > JavaScript class exports should use PascalCase (e.g., export class FileHandler {}) > JavaScript function exports should use camelCase (e.g., export function processData() {}) > JavaScript constant exports should use UPPER_SNAKE_CASE (e.g., export const MAX_FILE_SIZE = 1024) Files: - `scripts/generate-theme.js` </details> <details> <summary>**</summary> **📄 CodeRabbit inference engine (.github/instructions/release.instructions.md)** > Ensure the repository is placeholder-free before any release action using `grep -R "{{" .` Files: - `scripts/generate-theme.js` </details> <details> <summary>**/*.{js,ts,json,sh,yml,yaml}</summary> **📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)** > Store all reports only in `.github/reports/` directory organized by category (coverage, analysis, validation, performance, agents, projects, comparison) - never in repository root or tmp directories Files: - `scripts/generate-theme.js` </details> <details> <summary>**/*.{js,ts,json,sh}</summary> **📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)** > Include ISO 8601 date (YYYY-MM-DD format) at the start of all report filenames, followed by hyphen-separated description Files: - `scripts/generate-theme.js` </details> <details> <summary>**/*.{js,ts,sh}</summary> **📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)** > `**/*.{js,ts,sh}`: Use kebab-case naming for report filenames; never use underscores, and date must appear at start (e.g., `2025-12-07-eslint-report.json` not `eslint_report.json` or `eslint-report-2025-12-07.json`) > Create nested directory structure automatically in `.github/reports/` if it doesn't exist; ensure parent directories are created before writing report files > Use `tmp/` directory only for temporary intermediate files during processing; never save final reports to `tmp/` - move completed reports to `.github/reports/` and clean up temp files when done > Clean up temporary files in `tmp/` directory after report generation is complete; do not leave intermediate processing files behind Files: - `scripts/generate-theme.js` </details> <details> <summary>**/*.{js,ts}</summary> **📄 CodeRabbit inference engine (.github/instructions/reporting.instructions.md)** > `**/*.{js,ts}`: Include metadata in all reports with: date (ISO timestamp), type/category, tool/agent name, status, and logFile reference pointing to related log under `logs/` > Reference related log files in every report via `logFile` field pointing to the process that generated it (e.g., `logs/test/2025-12-07-jest.log`) > Always verify report content validity (JSON parsing, HTML structure) before saving and include error handling for file write failures with appropriate logging Files: - `scripts/generate-theme.js` </details> </details><details> <summary>🧬 Code graph analysis (1)</summary> <details> <summary>scripts/generate-theme.js (2)</summary><blockquote> <details> <summary>scripts/utils/placeholders.js (2)</summary> * `result` (112-112) * `value` (198-198) </details> <details> <summary>scripts/utils/scan.js (1)</summary> * `match` (230-230) </details> </blockquote></details> </details><details> <summary>🪛 markdownlint-cli2 (0.18.1)</summary> <details> <summary>.github/README.md</summary> 12-12: Link text should be descriptive (MD059, descriptive-link-text) --- 45-45: Emphasis used instead of a heading (MD036, no-emphasis-as-heading) --- 64-64: Emphasis used instead of a heading (MD036, no-emphasis-as-heading) --- 69-69: Emphasis used instead of a heading (MD036, no-emphasis-as-heading) </details> </details> </details> <details> <summary>⏰ 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)</summary> * GitHub Check: validate-theme-json </details> <details> <summary>🔇 Additional comments (4)</summary><blockquote> <details> <summary>scripts/generate-theme.js (2)</summary><blockquote> `734-736`: **Defensive validation is good, but consider clarifying intent.** The check at line 734-736 guards against an author CLI arg that somehow resolves to the default value. Since `sanitizeInput(..., 'name')` throws on invalid input, this mainly catches edge cases. The logic is sound. --- `682-733`: **Comprehensive placeholder population with proper sanitization.** The placeholders object is well-structured with appropriate sanitization for each input type. The fallback defaults are reasonable. URL construction for support/docs/changelog assumes GitHub hosting, which is documented as the default pattern. </blockquote></details> <details> <summary>.github/README.md (2)</summary><blockquote> `91-91`: **Placeholder in documentation is intentional.** The `{{theme_name}}` placeholder on line 91 will be replaced during theme generation. This is expected behavior per the scaffold design. --- `79-84`: **Scripts documentation is clear and helpful.** The available scripts section provides a good quick reference for developers. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Overview
This PR standardizes PHP naming conventions throughout the theme scaffold by implementing a
phpCasefilter for thetheme_slugplaceholder. This ensures all generated PHP identifiers consistently use snake_case, improving code quality and adherence to WordPress coding standards.Key Changes
1. PHP Naming Convention Standardization
Problem: Theme functions and hooks used inconsistent naming (kebab-case vs snake_case)
Solution: Introduced
{{theme_slug|phpCase}}placeholder filter that converts theme slugs to snake_caseFiles Updated:
Examples:
2. Theme Generator Enhancements
Improved Placeholder System (scripts/generate-theme.js):
upper,snakeCase,phpCase,pascalCase,camelCase{{logo_width}},{{logo_height}},{{archive_excerpt_length}},{{content_width_num}}Better Input Validation:
3. Asset Handle Consistency
Unified asset handles to use
{{theme_slug}}instead of separate{{asset_slug}}:{{theme_slug}}-style,{{theme_slug}}-editor-style{{theme_slug}}-script,{{theme_slug}}-editor-script{{theme_slug}}-featured,{{theme_slug}}-thumbnail,{{theme_slug}}-gallery4. Content Width Fix
Fixed critical bug where
$GLOBALS['content_width']was set as a string instead of integer:5. Test Suite Updates
Updated All Tests to reflect new naming conventions:
Test Configuration (phpunit.xml):
Test_prefix andtests/php/directoryFixed Registry Method Calls:
get_registered_styles()toget_registered_styles_for_block()6. Theme.json Updates
Updated typography structure for better WordPress compatibility:
7. Documentation Improvements
Enhanced .github/README.md with:
8. Schema Additions
Added new configuration option in
.github/schemas/theme-config.schema.json:archive_excerpt_length- Controls excerpt length in archive/listing pages (default: 40, range: 20-200)Breaking Changes
Testing
Benefits
Related Issues
Closes: Fixes identified in theme scaffold audit
Checklist
Review Notes: This is a significant refactoring that touches many files but maintains backward compatibility for generated themes. The changes are primarily internal to the scaffold and improve the quality of generated theme code.
Summary by CodeRabbit
New Features
Changes
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.