0

在 Wordpress UI 的“个人资料”页面 (../wp-admin/profile.php) 上,您可以选择八种默认的管理员配色方案作为选项: 在此处输入图像描述

我找到了创建这些方案的 CSS 的位置 (../wp-admin/css/colors/) 并使用 CSS 制作了我自己的文件夹以匹配。

首先,我什至无法在个人资料页面上显示我的配色方案,因此我可以对其进行测试。在 ../wp-admin/profile.php 中是这样的:

define('IS_PROFILE_PAGE', true);

/** Load User Editing Page */
require_once( dirname( __FILE__ ) . '/user-edit.php' );

在 ../wp-admin/user-edit.php 中,这是吐出配色方案的部分:

<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
<tr class="user-admin-color-wrap">
<th scope="row"><?php _e('Admin Color Scheme')?></th>
<td><?php
    /**
     * Fires in the 'Admin Color Scheme' section of the user editing screen.
     *
     * The section is only enabled if a callback is hooked to the action,
     * and if there is more than one defined color scheme for the admin.
     *
     * @since 3.0.0
     * @since 3.8.1 Added `$user_id` parameter.
     *
     * @param int $user_id The user ID.
     */
    do_action( 'admin_color_scheme_picker', $user_id );
?></td>
</tr>
<?php
endif; // $_wp_admin_css_colors

所以我的问题是:

  1. 如何让它在个人资料页面上显示我的配色方案,以便我可以对其进行测试和编辑?
  2. Once I'm satisfied with how it looks, how do I put the color scheme in my custom theme's functions.php file so I can import it with every theme install and not have to worry about WordPress erasing it with updates?
  3. How do I set this color scheme as the default one for users?

Let me know if I need to add further details, thanks for the help guys!

4

2 回答 2

1

Take a look at this article, it may help you: https://www.orionorigin.com/tutorials-and-snippets/define-wordpress-color-scheme-set-default-users/

add_filter( 'get_user_option_admin_color', function( $color_scheme ) {

$color_scheme = 'your_color_sheme_name';

return $color_scheme;

}, 5 );
于 2020-02-24T18:31:56.167 回答
0

For anyone who's wondering: I found an answer! Thanks to help from @Manas Khandelwal, I was able to locate a working site that generated a CSS file for me. It served as a great starting point and I edited it from the basic file it started out with.

这是该网站,我强烈推荐它:https ://wpadmincolors.com/

只需按照说明将其放入您的主题中即可。多谢你们!

于 2020-02-25T00:32:28.137 回答