Skip to content

feat(bricks): consolidate Bricks options into a tabbed settings page - #68

Merged
jackgranatowski merged 3 commits into
mainfrom
claude/rebemer-default-bem-names-agzxk7
Jun 21, 2026
Merged

feat(bricks): consolidate Bricks options into a tabbed settings page#68
jackgranatowski merged 3 commits into
mainfrom
claude/rebemer-default-bem-names-agzxk7

Conversation

@jackgranatowski

@jackgranatowski jackgranatowski commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Bricks-related configuration was scattered across three admin pages: the reBEMer
element-name page (#67), the Class hints toggle on Plugin Settings, and a
standalone Filter Hooks reference page. reBEMer's layout-container naming also
exposed three modes when only one was wanted.

This PR gathers every Bricks-specific setting into a single tabbed Bricks
settings
subpage and simplifies container naming.

Changes

New tabbed pageincludes/class-bricks-settings-page.php
(Slashed_Bricks_Settings_Page), registered as "Bricks settings" after
Manual CSS, only when Bricks is active. Tabs via the standard WP
nav-tab-wrapper:

  • Element names (default) — the reBEMer BEM-name table, carried over from the
    old page (BUILTIN_DEFAULTS / elements() / default_for()), persisted via
    Slashed_REST_Controller::sanitize_rebemer_element_map.
  • Options — the Class hints toggle, moved off Plugin Settings
    (read-merge-write so siblings are preserved).
  • Filter hooks — the Bricks hook reference, folded in from the old standalone
    Filter Hooks page.

Plugin Settings trimmed (class-admin.php) — removed the Class hints row;
handle_save() is now read-merge-write so reBEMer / Manual CSS / Bricks
settings are no longer clobbered. General settings (CSS bundle, delivery,
integration toggles, HTML font-size) stay put.

Container naming simplified — layout containers (section / container / div /
block) are always named after their own Bricks type. Removed the role/generic
modes and rebemer_container_mode from element-types.js, BemPanel.svelte, the
standalone RebemerTab.svelte, the token store, the REST allow-list +
save/import paths, and the editor payload.

Retired class-hooks-page.php and class-rebemer-page.php; updated
slashed.php wiring, docs/rebemer.md, and CHANGELOG.md. Rebuilt the
editor-app and standalone Bricks admin-app bundles.

Testing

  • node --test tests/*.test.js128 pass, 0 fail (3 pre-existing skips);
    the element-types suite was rewritten for the new type-only signature.
  • php -l clean on all touched/new PHP files (WordPress PHPCS standards run in
    CI; code mirrors the existing pages' style).
  • Rebuilt both affected Vite bundles; verified no source/asset references to the
    removed rebemer_container_mode / getContainerMode symbols remain.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HtPN4CvQjMTdvPLALAW3GE


Generated by Claude Code


Summary by cubic

Consolidates all Bricks settings into one tabbed “Bricks settings” admin subpage and simplifies reBEMer container naming to always use the Bricks type. Also hardens settings handling to purge retired keys and preserve overrides for temporarily missing elements.

  • New Features

    • Added a tabbed Bricks settings page with Element names, Options, and Filter hooks.
    • Moved the Class hints toggle off Plugin Settings.
  • Bug Fixes

    • Token store now whitelists to defaults and purges retired keys (e.g. rebemer_container_mode) on read/write.
    • Bricks settings page seeds from stored overrides and reconciles only rendered rows, so saves don’t drop overrides for deactivated elements.
    • suggestContainerName now only applies to layout container types, trims input, and falls back to "item" for unknown types.
    • Plugin Settings uses read-merge-write so Bricks/reBEMer/Manual CSS settings aren’t clobbered.

Written for commit c6e754e. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added unified Bricks settings admin page with tabbed interface for element names, options, and filter hooks documentation
  • Improvements

    • Consolidated Bricks-specific controls and filter hooks into single admin location
    • Simplified reBEMer layout container naming—now always uses container's Bricks type
  • Removals

    • Removed "Class hints" display option from Plugin Settings
    • Removed container naming mode selector

Gather every Bricks-specific setting into one new "Bricks settings" admin
subpage (Slashed_Bricks_Settings_Page), placed after Manual CSS, with the
options organized in tabs:

- Element names — the reBEMer default BEM-name table (carried over from the
  old reBEMer page), saved via read-merge-write.
- Options — the Class hints toggle, moved off Plugin Settings.
- Filter hooks — the Bricks filter-hook reference, folded in from the old
  standalone Filter Hooks page.

Plugin Settings now keeps only general settings; its save path is read-
merge-write so Bricks/reBEMer/Manual-CSS settings are never clobbered.

reBEMer also drops the role/generic container-naming modes: layout
containers are always named after their own Bricks type. Removes
rebemer_container_mode from the settings store, REST allow-list,
import/save paths, and editor payload, plus the container-mode selects in
both the PHP page and the standalone admin SPA.

Deletes class-hooks-page.php and class-rebemer-page.php; rebuilds the
editor-app and standalone Bricks admin-app bundles.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HtPN4CvQjMTdvPLALAW3GE
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Two standalone admin pages (Slashed_Hooks_Page, Slashed_ReBEMer_Page) are replaced by a single tabbed Slashed_Bricks_Settings_Page with Element names, Options, and Filter hooks tabs. rebemer_container_mode is removed from the entire stack: PHP defaults, REST controller, editor localization, and Svelte admin tab. suggestContainerName is simplified to return the container's own Bricks type directly.

Changes

Bricks Settings Consolidation and Container Mode Removal

Layer / File(s) Summary
element-types.js: remove container mode, add LAYOUT_CONTAINER_TYPES helpers
SLASHED-for-WP/integrations/bricks/editor-app/src/lib/element-types.js, tests/element-types.test.js
Removes CONTAINER_MODES and getContainerMode; adds LAYOUT_CONTAINER_TYPES, suggestElementName, isLayoutContainer; rewrites suggestContainerName to return the container's own type (or 'item'). Tests are updated to match the new simplified contract.
BemPanel.svelte Pass 2: use suggestContainerName directly
SLASHED-for-WP/integrations/bricks/editor-app/src/components/BemPanel.svelte
Removes getContainerMode import and call; Pass 2 container naming now calls suggestContainerName(el.name) directly instead of inspecting children/position.
Remove rebemer_container_mode from PHP backend
SLASHED-for-WP/includes/class-token-store.php, SLASHED-for-WP/includes/class-rest-controller.php, SLASHED-for-WP/integrations/bricks/includes/class-editor-data.php
Removes rebemer_container_mode from PLUGIN_SETTING_DEFAULTS, REST /settings argument schema and save_settings() logic, import_tokens() payload handling, and the localized slashedBricksEditor script data.
New Slashed_Bricks_Settings_Page
SLASHED-for-WP/includes/class-bricks-settings-page.php
Adds the complete Slashed_Bricks_Settings_Page class with constants, admin hook wiring, tab URL/element-list helpers, Element names save handler (sparse override map, sanitization, persistence), Options save handler (show_class_hints), render_page() dispatcher, all three tab renderers, and the static get_hooks() data.
Admin bootstrap swap, class-admin.php cleanup, RebemerTab.svelte, and compiled CSS
SLASHED-for-WP/slashed.php, SLASHED-for-WP/includes/class-admin.php, SLASHED-for-WP/integrations/bricks/admin-app/src/components/RebemerTab.svelte, SLASHED-for-WP/integrations/bricks/assets/admin-app/app.css, SLASHED-for-WP/includes/class-tab-registry.php
slashed.php replaces Slashed_Hooks_Page/Slashed_ReBEMer_Page instantiation with Slashed_Bricks_Settings_Page; class-admin.php removes show_class_hints from its save handler and UI; RebemerTab.svelte drops containerMode state, removes the container mode <select>, and updates save/reset; compiled app.css is regenerated.
Changelog and docs
CHANGELOG.md, docs/rebemer.md
CHANGELOG documents the UI consolidation and container mode removal; rebemer.md updates the configurable-defaults section to reference Slashed_Bricks_Settings_Page and the always-type-based container naming.

Sequence Diagram(s)

sequenceDiagram
  participant Admin as WP Admin Browser
  participant AdminPost as wp-admin/admin-post.php
  participant BricksPage as Slashed_Bricks_Settings_Page
  participant TokenStore as Slashed_Token_Store
  participant REST as Slashed_REST_Controller

  rect rgba(100, 149, 237, 0.5)
    Note over Admin,TokenStore: Element names tab save
    Admin->>AdminPost: POST rebemer_map[] + nonce
    AdminPost->>BricksPage: handle_save_names()
    BricksPage->>BricksPage: check_admin_referer, current_user_can
    BricksPage->>TokenStore: get_plugin_settings()
    TokenStore-->>BricksPage: existing settings
    BricksPage->>REST: sanitize_rebemer_element_map(overrides)
    REST-->>BricksPage: sanitized map
    BricksPage->>TokenStore: update_plugin_settings(merged)
    BricksPage->>Admin: wp_redirect(?tab=names&saved=1)
  end

  rect rgba(144, 238, 144, 0.5)
    Note over Admin,TokenStore: Options tab save
    Admin->>AdminPost: POST show_class_hints + nonce
    AdminPost->>BricksPage: handle_save_options()
    BricksPage->>TokenStore: get_plugin_settings()
    TokenStore-->>BricksPage: existing settings
    BricksPage->>TokenStore: update_plugin_settings(merged)
    BricksPage->>Admin: wp_redirect(?tab=options&saved=1)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • codeslash-dev/SLASHED-Plugins#63: Adds REST/store/UI support for rebemer_container_mode and mode-aware suggestContainerName—the exact feature this PR removes from the full stack.
  • codeslash-dev/SLASHED-Plugins#67: Adds Slashed_ReBEMer_Page with container-mode persistence and rebemer_element_map coverage, which this PR replaces with Slashed_Bricks_Settings_Page and eliminates.
  • codeslash-dev/SLASHED-Plugins#30: Adds and activates Slashed_Manual_CSS_Page; this PR inserts Slashed_Bricks_Settings_Page directly after it in the admin bootstrap sequence in slashed.php.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% 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
Title check ✅ Passed The title accurately and specifically summarizes the main change: consolidating Bricks-related options (previously scattered across multiple admin pages) into a single tabbed settings page.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/rebemer-default-bem-names-agzxk7

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.

…t-bem-names-agzxk7

# Conflicts:
#	CHANGELOG.md

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
SLASHED-for-WP/includes/class-token-store.php (1)

122-132: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Removing the default key alone does not purge legacy rebemer_container_mode from stored settings.

Because settings are merged from the raw option map, upgraded sites can still carry rebemer_container_mode, and that stale key can keep flowing through /settings responses and subsequent writes. Whitelist stored/update keys to PLUGIN_SETTING_DEFAULTS so retired keys are actually removed.

Proposed fix
 public static function get_plugin_settings() {
 	$stored = get_option( self::SETTINGS_OPTION_NAME, array() );
-	$stored = is_array( $stored ) ? $stored : array();
+	$stored = is_array( $stored ) ? $stored : array();
+	$stored = array_intersect_key( $stored, self::PLUGIN_SETTING_DEFAULTS );
 	$merged = array_merge( self::PLUGIN_SETTING_DEFAULTS, $stored );
@@
 public static function update_plugin_settings( array $settings ) {
+	$settings = array_intersect_key( $settings, self::PLUGIN_SETTING_DEFAULTS );
 	if ( isset( $settings['css_bundle'] ) && class_exists( 'Slashed_Settings' ) ) {
 		Slashed_Settings::set_css_bundle( $settings['css_bundle'] );
 		unset( $settings['css_bundle'] );
 	}
 	update_option( self::SETTINGS_OPTION_NAME, $settings );
 }
🤖 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 `@SLASHED-for-WP/includes/class-token-store.php` around lines 122 - 132, The
issue is that legacy settings keys like rebemer_container_mode can persist in
stored options even after being removed from PLUGIN_SETTING_DEFAULTS, because
settings are merged from raw option maps without filtering. To fix this, locate
the methods in the class-token-store.php file that handle storing and retrieving
settings, and implement a whitelist filter that only allows keys that are
explicitly defined in the PLUGIN_SETTING_DEFAULTS constant to be saved or
returned. This ensures that when settings are merged or updated, any retired
keys not present in PLUGIN_SETTING_DEFAULTS are stripped out completely,
preventing stale data from flowing through settings responses and subsequent
writes.
🤖 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 `@SLASHED-for-WP/includes/class-bricks-settings-page.php`:
- Around line 225-250: The issue is that the $overrides variable is initialized
as an empty array on line 226 and then rebuilt only from the posted data in
$posted_map, which causes any previously stored custom-element overrides not
present in the current $posted_map to be deleted. To fix this, instead of
starting with an empty array, first load the existing overrides from the current
plugin settings (before the foreach loop that processes $posted_map), then
update those existing overrides with the new values from the posted data. This
way, custom elements that aren't currently in the form will be preserved in the
final $overrides that gets passed to the sanitizer and saved via
Slashed_Token_Store::update_plugin_settings.

In `@SLASHED-for-WP/integrations/bricks/editor-app/src/lib/element-types.js`:
- Around line 193-207: The suggestContainerName function currently returns any
non-empty string value, which violates its documented behavior of falling back
to 'item' for unknown types. Modify the function to define a set of known
layout-container types (such as 'container', 'section', 'div', 'block'), trim
the incoming containerType parameter, and only return the containerType if it
exists in the known types list and is not empty; otherwise return the fallback
value 'item' to ensure only valid layout-container names are returned.

---

Outside diff comments:
In `@SLASHED-for-WP/includes/class-token-store.php`:
- Around line 122-132: The issue is that legacy settings keys like
rebemer_container_mode can persist in stored options even after being removed
from PLUGIN_SETTING_DEFAULTS, because settings are merged from raw option maps
without filtering. To fix this, locate the methods in the class-token-store.php
file that handle storing and retrieving settings, and implement a whitelist
filter that only allows keys that are explicitly defined in the
PLUGIN_SETTING_DEFAULTS constant to be saved or returned. This ensures that when
settings are merged or updated, any retired keys not present in
PLUGIN_SETTING_DEFAULTS are stripped out completely, preventing stale data from
flowing through settings responses and subsequent writes.
🪄 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: d01be9b9-8fee-41c9-804e-31b5bbce5364

📥 Commits

Reviewing files that changed from the base of the PR and between ec8cfdb and 4e64ff9.

📒 Files selected for processing (18)
  • CHANGELOG.md
  • SLASHED-for-WP/includes/class-admin.php
  • SLASHED-for-WP/includes/class-bricks-settings-page.php
  • SLASHED-for-WP/includes/class-hooks-page.php
  • SLASHED-for-WP/includes/class-rebemer-page.php
  • SLASHED-for-WP/includes/class-rest-controller.php
  • SLASHED-for-WP/includes/class-tab-registry.php
  • SLASHED-for-WP/includes/class-token-store.php
  • SLASHED-for-WP/integrations/bricks/admin-app/src/components/RebemerTab.svelte
  • SLASHED-for-WP/integrations/bricks/assets/admin-app/app.css
  • SLASHED-for-WP/integrations/bricks/assets/admin-app/app.js
  • SLASHED-for-WP/integrations/bricks/assets/editor-app/app.js
  • SLASHED-for-WP/integrations/bricks/editor-app/src/components/BemPanel.svelte
  • SLASHED-for-WP/integrations/bricks/editor-app/src/lib/element-types.js
  • SLASHED-for-WP/integrations/bricks/includes/class-editor-data.php
  • SLASHED-for-WP/slashed.php
  • docs/rebemer.md
  • tests/element-types.test.js
💤 Files with no reviewable changes (2)
  • SLASHED-for-WP/includes/class-hooks-page.php
  • SLASHED-for-WP/includes/class-rebemer-page.php

Comment thread SLASHED-for-WP/includes/class-bricks-settings-page.php
Comment thread SLASHED-for-WP/integrations/bricks/editor-app/src/lib/element-types.js Outdated
- token-store: whitelist plugin settings to PLUGIN_SETTING_DEFAULTS on read
  and write so retired keys (the removed rebemer_container_mode) are purged
  from upgraded sites instead of leaking through /settings and re-saves.
- Bricks settings page: seed the element-name override map from stored
  settings and only reconcile rendered rows, so saving never drops overrides
  for elements whose plugin is temporarily deactivated.
- element-types: gate suggestContainerName to LAYOUT_CONTAINER_TYPES (and
  trim input) so unknown types honor the documented 'item' fallback; add
  tests for the fallback + trimming.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HtPN4CvQjMTdvPLALAW3GE
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