I’ve always used this code in a must-use plugin to remove the whole color schemes section:
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
Unfortunately, with WordPress 6.0 this does not work anymore. I’ve found that Core’s add_action( 'admin_color_...
was recently moved from default-filters.php
file to the admin-filters.php
file, but I am unsure why and how I’d have to update the above snippet to make it work again.
2
Answers
You can use the other part of the if statement in
user-edit.php
to remove the ability to change the color scheme.From
user-edit.php
Although not a direct solution to using the remove action function, you can set the
$_wp_admin_css_colors
global to an empty array…For a
remove_action()
call to be effective, it needs to be called after the action you want to remove has been added, and before the action runs.WordPress adds the
admin_color_scheme_picker
action in admin-filters.php and then runs the action in the user-edit.php admin page template.To remove the
admin_color_scheme_picker
action right before it is called on the user profile page, you can run theremove_action()
call using theadmin_head-profile.php
hook:Note that the
admin_head-{$hook_suffix}
hook fires in the head section for a specific admin page. In the example above replacing$hook_suffix
withprofile.php
in the hook name makes it run on the user admin profile page.