admin_color_scheme_picker() - WordPress 函数参考中文文档

返回介绍

admin_color_scheme_picker()

发布于 2017-09-10 字数3400 浏览 1130 评论 0

admin_color_scheme_picker( int $user_id )

Display the default admin color scheme picker (Used in user-edit.php)


描述


参数

$user_id

(int)
(Required)
User ID.


源代码

File: 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' => '' ), $_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
}

更新日志

Version 描述
3.0.0 Introduced.

相关函数

Uses

  • wp-includes/functions.php:
    wp_json_encode()
  • wp-includes/l10n.php:
    _e()
  • wp-includes/formatting.php:
    esc_attr()
  • wp-includes/formatting.php:
    esc_url()
  • wp-includes/formatting.php:
    esc_html()
  • wp-includes/general-template.php:
    checked()
  • wp-includes/functions.php:
    wp_nonce_field()
  • wp-includes/user.php:
    get_user_option()
  • Show 3 more uses
    Hide more uses


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!