feat(gutenberg): add standalone Gutenberg integration plugin (v1) - #168
Conversation
Three files, zero Bricks dependencies — designed to be severable into an
independent plugin at any time:
- integrations/gutenberg/slashed-gutenberg.php: entry point with its own
constants (VERSION, PATH, URL, CSS_REF, DIST_SHA), CSS URL resolution
(CDN → local fallback, slashed_gutenberg/css_bundle_url filter), and
bootstrap hook.
- integrations/gutenberg/includes/class-enqueue.php: loads the SLASHED CSS
bundle via enqueue_block_editor_assets (editor canvas) and wp_enqueue_scripts
(frontend). Adds an inline dark-mode bridge that maps
html[data-wp-dark-mode-active] (WP 6.4+) into SLASHED's color-scheme system.
- integrations/gutenberg/includes/class-color-palette.php: registers 21 SLASHED
tokens with add_theme_support('editor-color-palette'). Each entry references
var(--sf-color-*) so swatches resolve live from the loaded CSS — no hardcoded
hex values. Slugs use single dashes (slashed-text-secondary) while the CSS var
reference retains the canonical double-dash form (--sf-color-text--secondary).
Also updates docs/roadmap.md: marks Gutenberg integration as in-progress,
corrects the original "hard / 2-3 weeks" framing, and documents what is
explicitly out of scope for v1 (theme.json --wp--custom--* mapping, token
override UI, reBEMer parity).
https://claude.ai/code/session_01DU3r3kT7GqH7w7jeadV2DT
Introduces slashed.php — a single plugin that orchestrates both the Bricks
and Gutenberg integrations, with a settings page to enable/disable each
independently. Designed so any integration can be extracted into a standalone
plugin at any time.
Architecture
────────────
slashed.php
Defines canonical SLASHED_* constants, then pre-defines SLASHED_BRICKS_*
and SLASHED_GUTENBERG_* constants as aliases pointing to their integration
subdirectories. Each integration's entry point is conditionally require_once'd
based on the enabled flags in slashed_settings. The standalone plugins remain
fully functional and unchanged in behaviour.
includes/class-settings.php
Manages the slashed_settings WP option. Stores per-integration enable/disable
flags. Defaults all known integrations to enabled so a fresh install activates
everything; users opt out of what they don't need.
includes/class-admin.php
Top-level "SLASHED" admin menu with integration toggle checkboxes, builder
detection status (Bricks version shown if active), and a link to the Bricks
token overrides sub-page when that integration is enabled.
Integration compatibility guards
slashed-bricks.php: wraps define() calls in !defined('SLASHED_BRICKS_VERSION')
so the unified plugin can pre-define the constants and path resolution works
from either root. Activation/deactivation hooks guarded with !defined('SLASHED_VERSION').
slashed-gutenberg.php: same treatment for its constants.
class-admin-page-svelte.php: register_menu() checks defined('SLASHED_VERSION');
when true registers as add_submenu_page under 'slashed' rather than a
competing top-level menu.
Severability
Each integration is self-contained in integrations/{builder}/. Extracting one
into a standalone plugin requires only: copy the directory, add constant
definitions at the top of its entry point (already present behind the !defined
guard), and distribute. No code in the integration files needs to change.
https://claude.ai/code/session_01DU3r3kT7GqH7w7jeadV2DT
…from core
slashed.php previously defined SLASHED_BRICKS_* and SLASHED_GUTENBERG_*
constant aliases at the core level, meaning every install — even a
Gutenberg-only setup — had Bricks constants in its environment. This
commit moves all builder-specific concerns out of the core plugin.
includes/class-css-loader.php (new)
Builder-agnostic Slashed_CSS_Loader class with three static methods:
- get_bundle(): reads from shared slashed_settings.css_bundle
- get_url(): CDN URL from SLASHED_DIST_SHA + SLASHED_PATH local fallback
- get_version(): mtime for local files, SLASHED_VERSION for CDN
Used by every integration. Adding a future integration (Elementor, etc.)
never requires touching this file.
slashed.php
Removed all SLASHED_BRICKS_* and SLASHED_GUTENBERG_* constant aliases.
Integration entry points define their own constants via plugin_dir_path(__FILE__),
which resolves correctly whether loaded standalone or included from here.
Bootstrap now uses SLASHED_PATH . 'integrations/{builder}/…' directly.
includes/class-settings.php
Added css_bundle field (allowed: essential / optimal / full, default optimal).
Added get_css_bundle() static method called by Slashed_CSS_Loader.
save() now persists css_bundle alongside integration flags.
includes/class-admin.php
Added CSS bundle radio selector to the settings form.
Integration entry points (slashed-bricks.php, slashed-gutenberg.php)
slashed_bricks_get_css_bundle() / slashed_gutenberg_get_css_bundle():
class_exists('Slashed_CSS_Loader') → delegate; else standalone logic.
slashed_bricks_get_css_url() / slashed_gutenberg_get_css_url():
same pattern — delegate then apply per-integration filter on top,
preserving the slashed_bricks/css_bundle_url and
slashed_gutenberg/css_bundle_url override hooks.
Integration enqueue classes (class-enqueue.php × 2)
Version detection delegates to Slashed_CSS_Loader::get_version() in
unified mode; standalone fallback preserved.
https://claude.ai/code/session_01DU3r3kT7GqH7w7jeadV2DT
|
Warning Review limit reached
More reviews will be available in 46 minutes and 21 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces a unified SLASHED WordPress plugin ( ChangesUnified SLASHED Plugin Architecture
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- scripts/zip-plugin.js: rewritten to produce dist/slashed.zip (unified plugin) containing slashed.php, includes/, and both integrations; drops the old Bricks-only zip - scripts/version-sync.js: add sync blocks for slashed.php (Version header, SLASHED_VERSION, SLASHED_CSS_REF) and slashed-gutenberg.php (Version header, SLASHED_GUTENBERG_VERSION, SLASHED_GUTENBERG_CSS_REF) - .github/workflows/version-sync.yml: update DIST_SHA sed step to patch all three PHP files; add slashed.php and slashed-gutenberg.php to git add; update header comment - .gitignore: track dist/slashed.zip instead of dist/slashed-bricks.zip https://claude.ai/code/session_01DU3r3kT7GqH7w7jeadV2DT
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
integrations/bricks/slashed-bricks.php (1)
42-57: ⚡ Quick winStale duplicate docblock.
Two docblocks now precede
slashed_bricks_get_css_bundle(); the first (lines 42-49) is the old description and is superseded by the new one (50-57). Only the block immediately above the function applies, so the orphaned one just adds confusion.🧹 Remove the orphaned docblock
-/** - * Get the configured CSS bundle type (essential / optimal / full). - * - * Reads from plugin settings; falls back to "optimal". Used both for - * URL resolution and for local-file version-stamp lookups. - * - * `@return` string One of 'essential', 'optimal', 'full'. - */ /** * Get the configured CSS bundle variant. * * Delegates to the shared Slashed_CSS_Loader when running under the unified * plugin; falls back to the Bricks token store in standalone mode. * * `@return` string One of 'essential', 'optimal', 'full'. */ function slashed_bricks_get_css_bundle() {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@integrations/bricks/slashed-bricks.php` around lines 42 - 57, There are two docblocks preceding slashed_bricks_get_css_bundle(), leaving an old/stale duplicate that doesn't apply; remove the orphaned/first docblock (the one describing "Get the configured CSS bundle type (essential / optimal / full).") so only the current docblock (the delegation description to Slashed_CSS_Loader/Bricks token store) remains directly above the slashed_bricks_get_css_bundle() function.includes/class-css-loader.php (1)
26-41: ⚡ Quick winBundle list is now triplicated (DRY).
ALLOWED_BUNDLESis duplicated here, inSlashed_Settings::ALLOWED_BUNDLES, and in the Bricks token store (ALLOWED_CSS_BUNDLES). SinceSlashed_Settings::get_css_bundle()already validates and falls back tooptimal, this constant and the re-validation inget_bundle()are redundant and risk diverging when the bundle set changes.♻️ Drop the redundant copy and rely on the shared validation
- const ALLOWED_BUNDLES = array( 'essential', 'optimal', 'full' ); - /** * Get the configured CSS bundle variant. * * Reads from the shared slashed_settings option. Defaults to 'optimal'. * * `@return` string One of 'essential', 'optimal', 'full'. */ public static function get_bundle() { - $bundle = Slashed_Settings::get_css_bundle(); - if ( ! in_array( $bundle, self::ALLOWED_BUNDLES, true ) ) { - return 'optimal'; - } - return $bundle; + // Slashed_Settings::get_css_bundle() already validates against the + // canonical allowlist and falls back to 'optimal'. + return Slashed_Settings::get_css_bundle(); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@includes/class-css-loader.php` around lines 26 - 41, Remove the redundant ALLOWED_BUNDLES constant and the duplicate validation in get_bundle(): rely on Slashed_Settings::get_css_bundle() (which already validates and falls back to 'optimal') by returning its value directly from the get_bundle() method; ensure no remaining references to ALLOWED_BUNDLES exist in this class and update get_bundle() to simply call and return Slashed_Settings::get_css_bundle().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/version-sync.yml:
- Around line 111-122: The workflow step "Update DIST_SHA constants in PHP"
currently injects the output into the shell via DIST_SHA="${{
steps.dist.outputs.sha }}" which risks shell interpolation; move the value into
the step's env (set env: DIST_SHA: ${{ steps.dist.outputs.sha }}) and remove the
inline assignment, then let the existing sed commands use the $DIST_SHA
environment variable as they already do (referencing the step name "Update
DIST_SHA constants in PHP" and the DIST_SHA variable and sed lines targeting
slashed.php, integrations/bricks/slashed-bricks.php, and
integrations/gutenberg/slashed-gutenberg.php).
In `@integrations/bricks/slashed-bricks.php`:
- Around line 22-33: The file comment above the SLASHED_BRICKS_* constants is
misleading about how the unified plugin works; update the comment to state that
slashed.php does not predefine SLASHED_BRICKS_* and that each integration
(including this file) defines its own constants using plugin_dir_path(__FILE__),
and clarify that the !defined() guard exists solely to prevent redefinition when
both the standalone Bricks plugin and the unified SLASHED plugin are loaded;
reference the existing symbols SLASHED_BRICKS_VERSION, SLASHED_BRICKS_PATH,
SLASHED_BRICKS_URL, SLASHED_BRICKS_CSS_REF, SLASHED_BRICKS_DIST_SHA and the
unified entry point slashed.php when making the comment correction.
In `@integrations/gutenberg/includes/class-color-palette.php`:
- Around line 41-45: The constructor currently only calls
add_theme_support('editor-color-palette', $this->build_palette()), which won't
apply for block/FSE themes driven by theme.json; update the class (in the
__construct method) to keep add_theme_support for non-block themes but also,
when wp_is_block_theme() is true, add a filter on 'wp_theme_json_data_theme' to
inject the palette into the theme.json data under settings.color.palette using
the array returned by $this->build_palette(); reference the __construct method,
build_palette(), add_theme_support(), and the 'wp_theme_json_data_theme' filter
when making the change.
---
Nitpick comments:
In `@includes/class-css-loader.php`:
- Around line 26-41: Remove the redundant ALLOWED_BUNDLES constant and the
duplicate validation in get_bundle(): rely on Slashed_Settings::get_css_bundle()
(which already validates and falls back to 'optimal') by returning its value
directly from the get_bundle() method; ensure no remaining references to
ALLOWED_BUNDLES exist in this class and update get_bundle() to simply call and
return Slashed_Settings::get_css_bundle().
In `@integrations/bricks/slashed-bricks.php`:
- Around line 42-57: There are two docblocks preceding
slashed_bricks_get_css_bundle(), leaving an old/stale duplicate that doesn't
apply; remove the orphaned/first docblock (the one describing "Get the
configured CSS bundle type (essential / optimal / full).") so only the current
docblock (the delegation description to Slashed_CSS_Loader/Bricks token store)
remains directly above the slashed_bricks_get_css_bundle() function.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5dedb373-2268-4ec9-a10a-318dc9c66eb4
📒 Files selected for processing (15)
.github/workflows/version-sync.yml.gitignoredocs/roadmap.mdincludes/class-admin.phpincludes/class-css-loader.phpincludes/class-settings.phpintegrations/bricks/includes/class-admin-page-svelte.phpintegrations/bricks/includes/class-enqueue.phpintegrations/bricks/slashed-bricks.phpintegrations/gutenberg/includes/class-color-palette.phpintegrations/gutenberg/includes/class-enqueue.phpintegrations/gutenberg/slashed-gutenberg.phpscripts/version-sync.jsscripts/zip-plugin.jsslashed.php
- version-sync.yml: pass DIST_SHA via step env instead of inline shell interpolation (prevents template-injection zizmor warning) - slashed-bricks.php: correct misleading plugin-constants docblock (the unified plugin does not pre-define SLASHED_BRICKS_* constants; each integration owns its own constants via plugin_dir_path(__FILE__)); also remove the orphaned stale docblock above slashed_bricks_get_css_bundle() - class-css-loader.php: remove redundant ALLOWED_BUNDLES constant and duplicate validation in get_bundle(); Slashed_Settings::get_css_bundle() already validates and falls back to 'optimal' - class-color-palette.php: add wp_theme_json_data_theme filter so the SLASHED palette is injected into block/FSE themes where add_theme_support is overridden by theme.json; update_with() merges by slug so the theme's own palette entries are preserved alongside SLASHED's slashed-* slugs https://claude.ai/code/session_01DU3r3kT7GqH7w7jeadV2DT
Three files, zero Bricks dependencies — designed to be severable into an
independent plugin at any time:
integrations/gutenberg/slashed-gutenberg.php: entry point with its own
constants (VERSION, PATH, URL, CSS_REF, DIST_SHA), CSS URL resolution
(CDN → local fallback, slashed_gutenberg/css_bundle_url filter), and
bootstrap hook.
integrations/gutenberg/includes/class-enqueue.php: loads the SLASHED CSS
bundle via enqueue_block_editor_assets (editor canvas) and wp_enqueue_scripts
(frontend). Adds an inline dark-mode bridge that maps
html[data-wp-dark-mode-active] (WP 6.4+) into SLASHED's color-scheme system.
integrations/gutenberg/includes/class-color-palette.php: registers 21 SLASHED
tokens with add_theme_support('editor-color-palette'). Each entry references
var(--sf-color-*) so swatches resolve live from the loaded CSS — no hardcoded
hex values. Slugs use single dashes (slashed-text-secondary) while the CSS var
reference retains the canonical double-dash form (--sf-color-text--secondary).
Also updates docs/roadmap.md: marks Gutenberg integration as in-progress,
corrects the original "hard / 2-3 weeks" framing, and documents what is
explicitly out of scope for v1 (theme.json --wp--custom--* mapping, token
override UI, reBEMer parity).
https://claude.ai/code/session_01DU3r3kT7GqH7w7jeadV2DT
Summary by CodeRabbit
New Features
Chores