Skip to content

fix(admin): prevent PHP 8.1+ deprecation notices and undefined key warnings in Admin::enqueue_scripts() #549

Open

Description

@shamiulbishal

Describe the Bug

In includes/Admin/Admin.php (lines 1190–1197), enqueue_scripts() calls get_option() for fb_copy_paste_style, fb_automatic_block_recovery, and fb_enable_quick_action_bar, and passes the return value directly to trim():

$automatic_block_recovery = get_option('fb_automatic_block_recovery');
$enable_quick_action_bar = get_option('fb_enable_quick_action_bar');

$copy_paste_style = get_option('fb_copy_paste_style');
$copy_paste_style = trim($copy_paste_style, '"');

$automatic_block_recovery = trim($automatic_block_recovery, '"');
$enable_quick_action_bar = trim($enable_quick_action_bar, '"');

On a fresh installation (or before those options are saved), get_option() returns false (or null if filtered). Additionally, lines 1237–1245 access $theme_json['color']['defaultGradients'] without isset() / !empty(). On PHP 8.1+, passing non-string values to trim() or reading undefined array keys emits deprecation notices and warnings in wp-admin.

Steps to Reproduce

  1. Enable WP_DEBUG on PHP 8.1, 8.2, or 8.3 on a site where fb_copy_paste_style / fb_automatic_block_recovery / fb_enable_quick_action_bar have not yet been saved.
  2. Visit the WordPress Admin or Block Editor.
  3. Check the PHP error log for trim() / undefined array key notices from includes/Admin/Admin.php.

Expected Behavior

Cast get_option(..., '') to (string) before calling trim(), and guard !empty($theme_json['color']['defaultGradients']) && isset($theme_json['color']['gradients']['default']) with isset() / is_array() checks so zero PHP warnings or deprecations are emitted on PHP 8.1+.

Affected Block or Component

Core Plugin / General

WordPress Version

6.7

PHP Version

8.2

Activity

  1. added
    focus: admin-dashboard
    type: bug
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

focus: admin-dashboardtype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions