我认为这是获取或设置当前管理员配色方案的简单方法,请参见代码:
Set the default admin color scheme:
<?php
/**
* Set the default admin color scheme for WordPress user.
*/
add_filter(\'get_user_option_admin_color\', \'set_default_admin_color\');
function set_default_admin_color($result)
{
// set new default admin color scheme
$result = \'midnight\';
// return the new default color
return $result;
}
Get the current admin color scheme:
/**
* Get the current admin color scheme from WordPress user.
*/
add_filter(\'get_user_option_admin_color\', \'get_current_admin_color\');
function get_current_admin_color($result)
{
global $_wp_admin_css_colors;
// get current admin color scheme name
$current_color_scheme = $result;
// get all available colors from scheme name
$colors = $_wp_admin_css_colors[$current_color_scheme];
// now you can use this colors or store it
// var_dump($colors);
// important: we should return the default color scheme
return $result;
}
Get all available admin colors schemes:
/**
* Get all available admin colors schemes from WordPress user.
*/
add_filter(\'get_user_option_admin_color\', \'get_all_admin_colors\');
function get_all_admin_colors($result)
{
global $_wp_admin_css_colors;
// get all available color schemes
$colors = $_wp_admin_css_colors;
// now you can use this color schemes or store it
// var_dump($colors);
// important: we should return the default color scheme
return $result;
}
@另见此处要点:
https://gist.github.com/mohamdio/bb9a1a18446aca257935846d217060e9