PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.11
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.11
1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 All 35 releases
desktop-mode / apps / users / parts / color-schemes.php

color-schemes.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.11, at apps/users/parts/color-schemes.php

58 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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