WordPress功能函数admin_color_scheme_picker()

WordPress功能函数admin_color_scheme_picker(),显示默认的管理配色方案选择器(在user-edit.php中使用)

用法:

admin_color_scheme_picker( int $user_id )

参数:

$user_id

(int) (必需) 用户ID。

来源:

文件:wp-admin/includes/misc.php

function admin_color_scheme_picker( $user_id ) {

global $_wp_admin_css_colors;

ksort( $_wp_admin_css_colors );

if ( isset( $_wp_admin_css_colors[‘fresh’] ) ) {

// Set Default (‘fresh’) and Light should go first.

$_wp_admin_css_colors = array_filter(

array_merge(

array(

‘fresh’ => ”,

‘light’ => ”,

‘modern’ => ”,

),

$_wp_admin_css_colors

)

);

}

$current_color = get_user_option( ‘admin_color’, $user_id );

if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {

$current_color = ‘fresh’;

}

?>

<fieldset id=”color-picker” class=”scheme-list”>

<legend class=”screen-reader-text”><span><?php _e( ‘Admin Color Scheme’ ); ?></span></legend>

<?php

wp_nonce_field( ‘save-color-scheme’, ‘color-nonce’, false );

foreach ( $_wp_admin_css_colors as $color => $color_info ) :

?>

<div class=”color-option <?php echo ( $color == $current_color ) ? ‘selected’ : ”; ?>”>

<input name=”admin_color” id=”admin_color_<?php echo esc_attr( $color ); ?>” type=”radio” value=”<?php echo esc_attr( $color ); ?>” class=”tog” <?php checked( $color, $current_color ); ?> />

<input type=”hidden” class=”css_url” value=”<?php echo esc_url( $color_info->url ); ?>” />

<input type=”hidden” class=”icon_colors” value=”<?php echo esc_attr( wp_json_encode( array( ‘icons’ => $color_info->icon_colors ) ) ); ?>” />

<label for=”admin_color_<?php echo esc_attr( $color ); ?>”><?php echo esc_html( $color_info->name ); ?></label>

<table class=”color-palette”>

<tr>

<?php

foreach ( $color_info->colors as $html_color ) {

?>

<td style=”background-color: <?php echo esc_attr( $html_color ); ?>”>&nbsp;</td>

<?php

}

?>

</tr>

</table>

</div>

<?php

endforeach;

?>

</fieldset>

<?php

}

更新日志:

WordPress功能函数admin_color_scheme_picker() (https://www.wp-admin.cn/) WordPress开发教程 第1张

相关推荐

发表回复

房先生
我们将24小时内回复。
2024-10-16 04:55:25
您好,有任何疑问请与我们联系!
您的工单我们已经收到,我们将会尽快跟您联系!
[加我微信]
chaoneo
注:点击复制微信号并打开微信APP,添加好友后进行聊天。
[电话联系]
13585372227
[电子邮件]
chaoneo@163.com
取消

选择聊天工具: