-
-
Notifications
You must be signed in to change notification settings - Fork 72
Add options for powered by #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
13e948c
9a624df
61cbcb4
812b53a
a9f4291
bd28d20
dc7ee72
a0397ae
a3223e0
5c47550
c1a6da6
34dff07
aa515f4
19548af
838f7be
484a3b8
1befc88
bac05be
8576621
0545898
bd60384
b4abebf
3a19ea4
2e123ad
182e578
dcd4fd2
d53a95f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -309,9 +309,9 @@ public function additional_on_page_load(): void { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| add_filter('wu_element_display_super_admin_notice', [$this, 'is_edit_mode']); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| add_action("get_user_option_meta-box-order_{$this->page_hook}", [$this, 'get_settings'], 10, 3); | ||||||||||||||||||||||||||||||||||
| add_filter("get_user_option_meta-box-order_{$this->page_hook}", [$this, 'get_settings'], 10, 3); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| add_action("get_user_option_screen_layout_{$this->page_hook}", [$this, 'get_settings'], 10, 3); | ||||||||||||||||||||||||||||||||||
| add_filter("get_user_option_screen_layout_{$this->page_hook}", [$this, 'get_settings'], 10, 3); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
Comment on lines
+312
to
315
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 🧩 Analysis chainFilters added correctly, but screen layout isn’t persisted and timing may be late
Proposed fix: persist both keys based on the meta key itself (not the request action) and ensure it’s for this page hook. --- a/inc/admin-pages/class-base-customer-facing-admin-page.php
+++ b/inc/admin-pages/class-base-customer-facing-admin-page.php
@@ -420,22 +420,22 @@
public function save_settings($meta_id, $user_id, $meta_key, $_meta_value): void {
-
- if ('meta-box-order' !== wu_request('action')) {
- return;
- }
-
- $is_this_page = str_contains((string) wu_request('page'), $this->id);
-
- if ( ! $is_this_page) {
- return;
- }
+ // Capture both meta-box-order_* and screen_layout_* updates for this page.
+ $relevant = (0 === strpos($meta_key, 'meta-box-order_')) || (0 === strpos($meta_key, 'screen_layout_'));
+ $for_this_page = false !== strpos($meta_key, '_' . $this->page_hook);
+ if ( ! $relevant || ! $for_this_page) {
+ return;
+ }
if ( ! user_can($user_id, $this->edit_capability)) {
return;
}
$meta_key = wu_replace_dashes($meta_key);
wu_save_setting($meta_key, $_meta_value);
}QA check to verify timing: open the target screen with a fresh user and confirm columns/layout reflect the global value on the first render (no reload). If not, register the two add_filter lines earlier (e.g., on current_screen) or unconditionally at init with guard logic inside get_settings. 🏁 Script executed: #!/bin/bash
# Locate filter registrations
rg -n "'add_filter" inc/admin-pages/class-base-customer-facing-admin-page.php
# Inspect get_settings implementation
rg -nP "function get_settings" -C5 inc/admin-pages/class-base-customer-facing-admin-page.php
# Inspect save_settings implementation
rg -nP "function save_settings" -C5 inc/admin-pages/class-base-customer-facing-admin-page.phpLength of output: 770 🏁 Script executed: #!/bin/bash
# Show filter registration and surrounding code
sed -n '280,360p' inc/admin-pages/class-base-customer-facing-admin-page.php
# Show get_settings and save_settings functions
sed -n '380,460p' inc/admin-pages/class-base-customer-facing-admin-page.php
# Find add_action hooking save_settings
rg -n "add_action.*save_settings" -C3 inc/admin-pages/class-base-customer-facing-admin-page.phpLength of output: 4089 Persist both
--- a/inc/admin-pages/class-base-customer-facing-admin-page.php
+++ b/inc/admin-pages/class-base-customer-facing-admin-page.php
@@ public function save_settings($meta_id, $user_id, $meta_key, $_meta_value): void {
- if ('meta-box-order' !== wu_request('action')) {
- return;
- }
+ // Only persist meta-box-order_* and screen_layout_* for this page hook
+ $pattern = '/^(meta-box-order|screen_layout)_' . preg_quote($this->page_hook, '/') . '$/';
+ if (! preg_match($pattern, $meta_key)) {
+ return;
+ }
Optional improvements:
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||
| * 'Hack-y' solution for the customer facing title problem... but good enough for now. | ||||||||||||||||||||||||||||||||||
|
|
@@ -338,7 +338,7 @@ function ($vars) { | |||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||
| public function add_additional_body_classes(): void { | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| add_action( | ||||||||||||||||||||||||||||||||||
| add_filter( | ||||||||||||||||||||||||||||||||||
| 'admin_body_class', | ||||||||||||||||||||||||||||||||||
| function ($classes) { | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.