| 1 |
<?php |
| 2 |
/** |
| 3 |
* Users — the admin colour scheme catalogue `<os-user-profile>`'s |
| 4 |
* picker offers, one of the profile facts both the Users app and the |
| 5 |
* User Edit app ship (`parts/facts.php`). |
| 6 |
* |
| 7 |
* @package OpenStation |
| 8 |
*/ |
| 9 |
|
| 10 |
defined( 'ABSPATH' ) || exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Build the admin colour scheme list with full colour tuples for |
| 14 |
* each scheme. Mirrors what WP core feeds the |
| 15 |
* `admin_color_scheme_picker` action: each entry carries the scheme |
| 16 |
* `name`, the stylesheet `url` (the live preview swap on self-edit |
| 17 |
* points `<link id="colors-css">` at it) and a `colors` tuple used |
| 18 |
* to render mini-swatch previews. |
| 19 |
* |
| 20 |
* @return array<string,array{name:string,url:string,colors:array<int,string>,icon_colors:array<string,string>}> |
| 21 |
*/ |
| 22 |
function openstation_user_edit_window_color_schemes() { |
| 23 |
$out = array(); |
| 24 |
// The registry lives in `wp-admin/includes/admin.php`, which an |
| 25 |
// app dispatch (a REST request) never loads on its own. |
| 26 |
if ( ! function_exists( 'register_admin_color_schemes' ) ) { |
| 27 |
$admin_inc = ABSPATH . 'wp-admin/includes/admin.php'; |
| 28 |
if ( is_readable( $admin_inc ) ) { |
| 29 |
require_once $admin_inc; |
| 30 |
} |
| 31 |
} |
| 32 |
if ( function_exists( 'register_admin_color_schemes' ) ) { |
| 33 |
register_admin_color_schemes(); |
| 34 |
} |
| 35 |
global $_wp_admin_css_colors; |
| 36 |
if ( is_array( $_wp_admin_css_colors ) ) { |
| 37 |
foreach ( $_wp_admin_css_colors as $slug => $info ) { |
| 38 |
$out[ (string) $slug ] = array( |
| 39 |
'name' => isset( $info->name ) ? (string) $info->name : (string) $slug, |
| 40 |
'url' => isset( $info->url ) ? esc_url_raw( (string) $info->url ) : '', |
| 41 |
'colors' => isset( $info->colors ) ? array_values( (array) $info->colors ) : array(), |
| 42 |
'icon_colors' => isset( $info->icon_colors ) ? (array) $info->icon_colors : array(), |
| 43 |
); |
| 44 |
} |
| 45 |
} |
| 46 |
if ( empty( $out ) ) { |
| 47 |
// Fallback so the picker still shows ONE option even when |
| 48 |
// the registry hasn't populated. |
| 49 |
$out['fresh'] = array( |
| 50 |
'name' => __( 'Default', 'desktop-mode' ), |
| 51 |
'url' => '', |
| 52 |
'colors' => array( '#1d2327', '#2c3338', '#2271b1', '#72aee6' ), |
| 53 |
'icon_colors' => array(), |
| 54 |
); |
| 55 |
} |
| 56 |
return $out; |
| 57 |
} |
| 58 |
|