Repository navigation
Make banner layouts and their positions filterable - #31
Conversation
The Layout select was hard-coded to bar/box/popup, so an add-on could not offer its own banner presentation there. Add CookieNotice::get_layouts() (frcn_cookie_notice_layouts) and CookieNotice::get_layout_positions() (frcn_cookie_notice_layout_positions) and use them to render the Layout and Position selects and to sanitize the saved values. Positions are validated against the selected layout. The settings script rebuilds the Position options when the layout changes, and the preview shows an add-on layout as the bar. The frontend keeps rendering an unknown layout as the bar, so an add-on layout still has a usable fallback banner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 67171ea8a6
ℹ️ 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".
|
|
||
| $sanitized['cookie_notice_position'] = is_string( $value['cookie_notice_position'] ) && isset( $allowed_positions[ $value['cookie_notice_position'] ] ) | ||
| ? $value['cookie_notice_position'] | ||
| : (string) array_key_first( $allowed_positions ); |
There was a problem hiding this comment.
Replace the PHP 7.3-only array_key_first call
On supported PHP 7.0–7.2 installations, saving settings for a layout with a submitted Position field (such as box) reaches this branch and fatals because array_key_first() was introduced in PHP 7.3. Use a PHP 7.0-compatible way to obtain the first allowed position so these users can save the settings page.
AGENTS.md reference: AGENTS.md:L11-L12
Useful? React with 👍 / 👎.
Summary
FrontConsent PRO needs to add a Compact banner to the existing Layout setting (closemarketing/frontconsent-pro#11). That select was hard-coded to bar/box/popup, so this PR makes it filterable.
CookieNotice::get_layouts()→ filterfrcn_cookie_notice_layouts(slug => label).CookieNotice::get_layout_positions()→ filterfrcn_cookie_notice_layout_positions(layout => position slug => label). The first position is the default. A layout with no entry has no Position field.sanitize_settings()checks the layout againstget_layouts()and the position against the selected layout's positions.settings.jsrebuilds the Position options when the layout changes. The preview shows an add-on layout as the bar.Test plan
tests/Unit/CookieNoticeLayoutsTest.php: built-in lists, a filtered layout is saved, an unregistered layout falls back tobar, unsupported positions fall back to the layout's first position, and a non-array filter result is ignored.composer lint,composer phpstan,composer test(138 tests) pass.