Skip to content

feat(gutenberg): add standalone Gutenberg integration plugin (v1) - #168

Merged
jackgranatowski merged 5 commits into
mainfrom
claude/gutenberg-integration-scope-jSOZX
May 31, 2026
Merged

feat(gutenberg): add standalone Gutenberg integration plugin (v1)#168
jackgranatowski merged 5 commits into
mainfrom
claude/gutenberg-integration-scope-jSOZX

Conversation

@jackgranatowski

@jackgranatowski jackgranatowski commented May 31, 2026

Copy link
Copy Markdown
Contributor

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

    • Unified SLASHED plugin now manages Bricks and Gutenberg integrations from a single installation.
    • Added WordPress admin settings page to enable/disable integrations and select CSS bundle variants (Essential, Optimal, Full).
    • Launched Gutenberg integration with block editor color palette synchronization and dark mode support.
  • Chores

    • Updated release automation to sync version artifacts across unified plugin and integration modules.

claude added 3 commits May 31, 2026 04:27
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
@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jackgranatowski, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f6dff77-121d-4a2f-9315-91e1a90ce73b

📥 Commits

Reviewing files that changed from the base of the PR and between 6a046c8 and 529d14b.

📒 Files selected for processing (4)
  • .github/workflows/version-sync.yml
  • includes/class-css-loader.php
  • integrations/bricks/slashed-bricks.php
  • integrations/gutenberg/includes/class-color-palette.php
📝 Walkthrough

Walkthrough

This PR introduces a unified SLASHED WordPress plugin (slashed.php) that consolidates settings management, CSS bundle resolution, and integration loading into a single plugin entry point, while maintaining backward compatibility for the existing Bricks integration and adding full support for a new Gutenberg integration.

Changes

Unified SLASHED Plugin Architecture

Layer / File(s) Summary
Core infrastructure and settings management
slashed.php, includes/class-settings.php, includes/class-css-loader.php
The unified plugin bootstrap loads shared infrastructure: Slashed_Settings reads/persists per-integration enablement and CSS bundle choice, Slashed_CSS_Loader centralizes bundle URL resolution (local dist/ or CDN with dist SHA pinning), and the main plugin file conditionally loads integrations based on stored settings.
Admin settings interface
includes/class-admin.php
WordPress admin page (Slashed_Admin) registers a top-level SLASHED menu and exposes a settings form allowing users to enable/disable integrations (Bricks, Gutenberg) and select a CSS bundle variant (essential, optimal, full).
Bricks integration unified-plugin support
integrations/bricks/slashed-bricks.php, integrations/bricks/includes/class-admin-page-svelte.php, integrations/bricks/includes/class-enqueue.php
Bricks integration now supports both standalone and unified-plugin modes by conditionally defining constants and registering activation hooks (only in standalone), delegating CSS bundle/URL resolution to the shared Slashed_CSS_Loader when available, and registering its admin menu as a submenu under the unified SLASHED admin page when loaded via the unified plugin.
Gutenberg integration CSS and color palette
integrations/gutenberg/slashed-gutenberg.php, integrations/gutenberg/includes/class-enqueue.php, integrations/gutenberg/includes/class-color-palette.php
New Gutenberg integration that enqueues SLASHED CSS in the block editor and frontend (with a dark-mode bridge rule), registers a color palette from semantic tokens (var(--sf-color-*) CSS variables), and uses the shared CSS loader for URL/version resolution when available.
Release and build automation
scripts/version-sync.js, scripts/zip-plugin.js, .github/workflows/version-sync.yml, .gitignore, docs/roadmap.md
Version synchronization script now updates slashed.php and Gutenberg constants alongside Bricks, the zip builder creates a unified dist/slashed.zip (instead of slashed-bricks.zip) staging all integration files, and the release workflow syncs the dist SHA across all three constants on GitHub release.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • codeslash-dev/SLASHED#149: Version constant synchronization during releases via scripts/version-sync.js and release workflow triggers.
  • codeslash-dev/SLASHED#165: Prior dist SHA syncing pipeline for Bricks; this PR extends it to the unified plugin and shared loader.
  • codeslash-dev/SLASHED#77: Bricks CSS URL and ref handling; this PR refactors that into the shared Slashed_CSS_Loader and conditional delegation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a standalone Gutenberg integration as a v1 feature, which is the primary focus of the PR across multiple new files and documentation updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/gutenberg-integration-scope-jSOZX

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

❤️ Share

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

- 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
@jackgranatowski

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
integrations/bricks/slashed-bricks.php (1)

42-57: ⚡ Quick win

Stale 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 win

Bundle list is now triplicated (DRY).

ALLOWED_BUNDLES is duplicated here, in Slashed_Settings::ALLOWED_BUNDLES, and in the Bricks token store (ALLOWED_CSS_BUNDLES). Since Slashed_Settings::get_css_bundle() already validates and falls back to optimal, this constant and the re-validation in get_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

📥 Commits

Reviewing files that changed from the base of the PR and between b4d3a2c and 6a046c8.

📒 Files selected for processing (15)
  • .github/workflows/version-sync.yml
  • .gitignore
  • docs/roadmap.md
  • includes/class-admin.php
  • includes/class-css-loader.php
  • includes/class-settings.php
  • integrations/bricks/includes/class-admin-page-svelte.php
  • integrations/bricks/includes/class-enqueue.php
  • integrations/bricks/slashed-bricks.php
  • integrations/gutenberg/includes/class-color-palette.php
  • integrations/gutenberg/includes/class-enqueue.php
  • integrations/gutenberg/slashed-gutenberg.php
  • scripts/version-sync.js
  • scripts/zip-plugin.js
  • slashed.php

Comment thread .github/workflows/version-sync.yml
Comment thread integrations/bricks/slashed-bricks.php Outdated
Comment thread integrations/gutenberg/includes/class-color-palette.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants