feat(bricks): consolidate Bricks options into a tabbed settings page - #68
Conversation
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
📝 WalkthroughWalkthroughTwo standalone admin pages ( ChangesBricks Settings Consolidation and Container Mode Removal
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
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 docstrings
🧪 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 |
…t-bem-names-agzxk7 # Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
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 winRemoving the default key alone does not purge legacy
rebemer_container_modefrom 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/settingsresponses and subsequent writes. Whitelist stored/update keys toPLUGIN_SETTING_DEFAULTSso 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
📒 Files selected for processing (18)
CHANGELOG.mdSLASHED-for-WP/includes/class-admin.phpSLASHED-for-WP/includes/class-bricks-settings-page.phpSLASHED-for-WP/includes/class-hooks-page.phpSLASHED-for-WP/includes/class-rebemer-page.phpSLASHED-for-WP/includes/class-rest-controller.phpSLASHED-for-WP/includes/class-tab-registry.phpSLASHED-for-WP/includes/class-token-store.phpSLASHED-for-WP/integrations/bricks/admin-app/src/components/RebemerTab.svelteSLASHED-for-WP/integrations/bricks/assets/admin-app/app.cssSLASHED-for-WP/integrations/bricks/assets/admin-app/app.jsSLASHED-for-WP/integrations/bricks/assets/editor-app/app.jsSLASHED-for-WP/integrations/bricks/editor-app/src/components/BemPanel.svelteSLASHED-for-WP/integrations/bricks/editor-app/src/lib/element-types.jsSLASHED-for-WP/integrations/bricks/includes/class-editor-data.phpSLASHED-for-WP/slashed.phpdocs/rebemer.mdtests/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
- 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
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 page —
includes/class-bricks-settings-page.php(
Slashed_Bricks_Settings_Page), registered as "Bricks settings" afterManual CSS, only when Bricks is active. Tabs via the standard WP
nav-tab-wrapper:old page (
BUILTIN_DEFAULTS/elements()/default_for()), persisted viaSlashed_REST_Controller::sanitize_rebemer_element_map.(read-merge-write so siblings are preserved).
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 / Brickssettings 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/genericmodes and
rebemer_container_modefromelement-types.js,BemPanel.svelte, thestandalone
RebemerTab.svelte, the token store, the REST allow-list +save/import paths, and the editor payload.
Retired
class-hooks-page.phpandclass-rebemer-page.php; updatedslashed.phpwiring,docs/rebemer.md, andCHANGELOG.md. Rebuilt theeditor-app and standalone Bricks admin-app bundles.
Testing
node --test tests/*.test.js→ 128 pass, 0 fail (3 pre-existing skips);the element-types suite was rewritten for the new type-only signature.
php -lclean on all touched/new PHP files (WordPress PHPCS standards run inCI; code mirrors the existing pages' style).
removed
rebemer_container_mode/getContainerModesymbols 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
Bug Fixes
rebemer_container_mode) on read/write.suggestContainerNamenow only applies to layout container types, trims input, and falls back to "item" for unknown types.Written for commit c6e754e. Summary will update on new commits.
Summary by CodeRabbit
New Features
Improvements
Removals