Admin dashboard scheme

This commit is contained in:
root 2019-05-27 03:48:21 +08:00
parent da1304cfde
commit a0f479a334
4 changed files with 207 additions and 33 deletions

View File

@ -7,7 +7,7 @@
* @package Sakura * @package Sakura
*/ */
define( 'SAKURA_VERSION', '3.1.6' ); define( 'SAKURA_VERSION', '3.1.7' );
define( 'BUILD_VERSION', '1' ); define( 'BUILD_VERSION', '1' );
define( 'JSDELIVR_VERSION', '3.6.7' ); define( 'JSDELIVR_VERSION', '3.6.7' );
@ -1346,19 +1346,12 @@ add_filter('site_url', 'wpadmin_filter', 10, 3);
} }
*/ */
function admin_style() { function admin_ini() {
wp_enqueue_style('admin-styles-fix-icon', get_site_url() . '/wp-includes/css/dashicons.css'); wp_enqueue_style('admin-styles-fix-icon', get_site_url() . '/wp-includes/css/dashicons.css');
wp_enqueue_style('cus-styles-light', get_site_url() . '/wp-content/themes/Sakura/inc/css/dashboard-fix.css'); wp_enqueue_style('cus-styles-fit', get_site_url() . '/wp-content/themes/Sakura/inc/css/dashboard-fix.css');
if ( get_user_option( 'admin_color' ) == "light" ) { wp_enqueue_script( 'lazyload', 'https://cdn.jsdelivr.net/npm/lazyload@2.0.0-beta.2/lazyload.min.js' );
wp_enqueue_style('cus-styles-light', get_site_url() . '/wp-content/themes/Sakura/inc/css/dashboard-light.css');
}
} }
add_action('admin_enqueue_scripts', 'admin_style'); add_action('admin_enqueue_scripts', 'admin_ini');
function custom_register_admin_scripts() {
wp_enqueue_script( 'lazyload', 'https://cdn.jsdelivr.net/npm/lazyload@2.0.0-beta.2/lazyload.min.js' );
}
add_action( 'admin_enqueue_scripts', 'custom_register_admin_scripts' );
function custom_admin_js() { function custom_admin_js() {
echo '<script> echo '<script>
@ -1378,7 +1371,7 @@ add_action('admin_footer', 'custom_admin_js');
/* /*
* 后台通知 * 后台通知
*/ */
function recommend_light() { function scheme_tip() {
$msg = '<b>Strongly recommend "Light" Scheme.</b>'; $msg = '<b>Strongly recommend "Light" Scheme.</b>';
if ( get_user_locale( get_current_user_id() ) == "zh_CN") { if ( get_user_locale( get_current_user_id() ) == "zh_CN") {
$msg = '<b>管理界面配色方案建议使用“明亮”。</b>'; $msg = '<b>管理界面配色方案建议使用“明亮”。</b>';
@ -1398,9 +1391,8 @@ function recommend_light() {
echo '<div class="notice notice-success is-dismissible" id="scheme-tip"><p><b>'.$msg.'</b></p></div>'; echo '<div class="notice notice-success is-dismissible" id="scheme-tip"><p><b>'.$msg.'</b></p></div>';
} }
} }
if ( get_user_option( 'admin_color' ) != "light" ) {
add_action( 'admin_notices', 'recommend_light' ); add_action( 'admin_notices', 'scheme_tip' );
}
function scheme_tip_dismissed() { function scheme_tip_dismissed() {
$user_id = get_current_user_id(); $user_id = get_current_user_id();
@ -1409,6 +1401,59 @@ function scheme_tip_dismissed() {
} }
add_action( 'admin_init', 'scheme_tip_dismissed' ); add_action( 'admin_init', 'scheme_tip_dismissed' );
//dashboard scheme
function dash_scheme($key, $name, $col1, $col2, $col3, $col4, $base, $focus, $current, $rules=""){
$hash = "color_1=".str_replace("#","",$col1).
"&color_2=".str_replace("#","",$col2).
"&color_3=".str_replace("#","",$col3).
"&color_4=".str_replace("#","",$col4).
"&rules=".urlencode($rules);
wp_admin_css_color(
$key,
$name,
get_template_directory_uri()."/inc/dash-scheme.php?".$hash,
array( $col1, $col2, $col3, $col4 ),
array( 'base' => $base, 'focus' => $focus, 'current' => $current )
);
}
//Sakura
dash_scheme($key="sakura", $name="Sakura🌸",
$col1='#8fbbb1', $col2='#bfd8d2', $col3='#fedcd2', $col4='#df744a',
$base="#e5f8ff", $focus="#fff", $current="#fff",
$rules="#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#f3f2f1}body{background-image:url(https://view.moezx.cc/images/2018/01/29/FLOWER.jpg);background-attachment:fixed;}#wpcontent{background:rgba(255,255,255,.6)}");
//custom
dash_scheme($key="custom", $name="Custom",
$col1=akina_option('dash_scheme_color_a'), $col2=akina_option('dash_scheme_color_b'), $col3=akina_option('dash_scheme_color_c'), $col4=akina_option('dash_scheme_color_d'),
$base=akina_option('dash_scheme_color_base'), $focus=akina_option('dash_scheme_color_focus'), $current=akina_option('dash_scheme_color_current'),
$rules=akina_option('dash_scheme_css_rules'));
// WordPress Custom Font @ Admin
function custom_admin_open_sans_font() {
echo '<link href="https://fonts.googleapis.com/css?family=Noto+Serif+SC&display=swap" rel="stylesheet">' . PHP_EOL;
echo '<style>body, #wpadminbar *:not([class="ab-icon"]), .wp-core-ui, .media-menu, .media-frame *, .media-modal *{font-family:"Noto Serif SC","Source Han Serif SC","Source Han Serif","source-han-serif-sc","PT Serif","SongTi SC","MicroSoft Yahei",Georgia,serif !important;}</style>' . PHP_EOL;
}
add_action( 'admin_head', 'custom_admin_open_sans_font' );
// WordPress Custom Font @ Admin Frontend Toolbar
function custom_admin_open_sans_font_frontend_toolbar() {
if(current_user_can('administrator')) {
echo '<link href="https://fonts.googleapis.com/css?family=Noto+Serif+SC&display=swap" rel="stylesheet">' . PHP_EOL;
echo '<style>#wpadminbar *:not([class="ab-icon"]){font-family:"Noto Serif SC","Source Han Serif SC","Source Han Serif","source-han-serif-sc","PT Serif","SongTi SC","MicroSoft Yahei",Georgia,serif !important;}</style>' . PHP_EOL;
}
}
add_action( 'wp_head', 'custom_admin_open_sans_font_frontend_toolbar' );
// WordPress Custom Font @ Admin Login
function custom_admin_open_sans_font_login_page() {
if(stripos($_SERVER["SCRIPT_NAME"], strrchr(wp_login_url(), '/')) !== false) {
echo '<link href="https://fonts.googleapis.com/css?family=Noto+Serif+SC&display=swap" rel="stylesheet">' . PHP_EOL;
echo '<style>body{font-family:"Noto Serif SC","Source Han Serif SC","Source Han Serif","source-han-serif-sc","PT Serif","SongTi SC","MicroSoft Yahei",Georgia,serif !important;}</style>' . PHP_EOL;
}
}
add_action( 'login_head', 'custom_admin_open_sans_font_login_page' );
// 阻止垃圾注册 // 阻止垃圾注册
add_action( 'register_post', 'codecheese_register_post', 10, 3 ); add_action( 'register_post', 'codecheese_register_post', 10, 3 );

52
inc/dash-scheme.php Normal file

File diff suppressed because one or more lines are too long

View File

@ -687,11 +687,102 @@ function optionsframework_options() {
'std' => '', 'std' => '',
'type' => 'text'); 'type' => 'text');
//前台登录 //后台配置
$options[] = array( $options[] = array(
'name' => __('前台登录', 'options_framework_theme'), 'name' => __('后台配置', 'options_framework_theme'),
'type' => 'heading' ); 'type' => 'heading' );
//后台面板自定义配色方案
$options[] = array(
'name' => __('后台面板自定义配色方案', 'options_framework_theme'),
'desc' => __('你可以在下面自行设计后台面板(/wp-admin/)样式,不过在开始之前请到<a href="/wp-admin/profile.php">这里</a>将配色方案改为自定义Custom。<br><b>Tip: </b>如何搭配颜色?或许<a href="https://mashiro.top/color-thief/">这个</a>可以帮到你。', 'options_framework_theme'),
'id' => 'scheme_tip',
'std' => '',
'type' => 'typography ');
$options[] = array(
'name' => __("面板主色调A", 'akina'),
'id' => 'dash_scheme_color_a',
'std' => "#c6742b",
'desc' => __('', ''),
'type' => "color"
);
$options[] = array(
'name' => __("面板主色调B", 'akina'),
'id' => 'dash_scheme_color_b',
'std' => "#d88e4c",
'desc' => __('', ''),
'type' => "color"
);
$options[] = array(
'name' => __("面板主色调C", 'akina'),
'id' => 'dash_scheme_color_c',
'std' => "#695644",
'desc' => __('', ''),
'type' => "color"
);
$options[] = array(
'name' => __("面板主色调D", 'akina'),
'id' => 'dash_scheme_color_d',
'std' => "#a19780",
'desc' => __('', ''),
'type' => "color"
);
$options[] = array(
'name' => __("面板图标配色——base", 'akina'),
'id' => 'dash_scheme_color_base',
'std' => "#e5f8ff",
'desc' => __('', ''),
'type' => "color"
);
$options[] = array(
'name' => __("面板图标配色——focus", 'akina'),
'id' => 'dash_scheme_color_focus',
'std' => "#fff",
'desc' => __('', ''),
'type' => "color"
);
$options[] = array(
'name' => __("面板图标配色——current", 'akina'),
'id' => 'dash_scheme_color_current',
'std' => "#fff",
'desc' => __('', ''),
'type' => "color"
);
$options[] = array(
'name' => __('其他自定义面板样式(CSS)', 'options_framework_theme'),
'desc' => __('如果还需要对面板其他样式进行调整可以把style放到这里', 'options_framework_theme'),
'id' => 'dash_scheme_css_rules',
'std' => '#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#f3f2f1}body{background-image:url(https://view.moezx.cc/images/2019/04/21/windows10-2019-4-21-i3.jpg);background-size:cover;background-repeat:no-repeat;background-attachment:fixed;}#wpcontent{background:rgba(255,255,255,.8)}',
'type' => 'textarea');
$options[] = array(
'name' => __('后台登陆界面背景图', 'options_framework_theme'),
'desc' => __('该地址为空则使用默认图片', 'options_framework_theme'),
'id' => 'login_bg',
'type' => 'upload');
$options[] = array(
'name' => __('后台登陆界面logo', 'options_framework_theme'),
'desc' => __('用于登录界面显示', 'options_framework_theme'),
'id' => 'logo_img',
'std' => $imagepath.'mashiro-logo-s.png',
'type' => 'upload');
$options[] = array(
'name' => __('登陆/注册相关设定', 'options_framework_theme'),
'desc' => __('', 'options_framework_theme'),
'id' => 'login_tip',
'std' => '',
'type' => 'typography ');
$options[] = array( $options[] = array(
'name' => __('指定登录地址', 'options_framework_theme'), 'name' => __('指定登录地址', 'options_framework_theme'),
'desc' => __('强制不使用后台地址登陆,填写新建的登陆页面地址,比如 http://www.xxx.com/login【注意】填写前先测试下你新建的页面是可以正常打开的以免造成无法进入后台等情况', 'options_framework_theme'), 'desc' => __('强制不使用后台地址登陆,填写新建的登陆页面地址,比如 http://www.xxx.com/login【注意】填写前先测试下你新建的页面是可以正常打开的以免造成无法进入后台等情况', 'options_framework_theme'),
@ -882,19 +973,6 @@ function optionsframework_options() {
'std' => '0', 'std' => '0',
'type' => 'checkbox'); 'type' => 'checkbox');
$options[] = array(
'name' => __('后台登陆界面背景图', 'options_framework_theme'),
'desc' => __('该地址为空则使用默认图片', 'options_framework_theme'),
'id' => 'login_bg',
'type' => 'upload');
$options[] = array(
'name' => __('后台登陆界面logo', 'options_framework_theme'),
'desc' => __('用于登录界面显示', 'options_framework_theme'),
'id' => 'logo_img',
'std' => $imagepath.'mashiro-logo-s.png',
'type' => 'upload');
$options[] = array( $options[] = array(
'name' => __('时区调整', 'options_framework_theme'), 'name' => __('时区调整', 'options_framework_theme'),
'desc' => __('如果评论出现时差问题在这里调整,填入一个整数,计算方法:实际时间=显示错误的时间-你输入的整数(单位:小时)', 'options_framework_theme'), 'desc' => __('如果评论出现时差问题在这里调整,填入一个整数,计算方法:实际时间=显示错误的时间-你输入的整数(单位:小时)', 'options_framework_theme'),
@ -902,6 +980,5 @@ function optionsframework_options() {
'std' => '0', 'std' => '0',
'type' => 'text'); 'type' => 'text');
return $options; return $options;
} }

View File

@ -5,7 +5,7 @@ Theme URI: https://2heng.xin/theme-sakura/
Author: Mashiro, Louie, Fuzzz Author: Mashiro, Louie, Fuzzz
Author URI: http://2heng.xin Author URI: http://2heng.xin
Description: Akina主题分支原版地址 http://www.akina.pw/themeakina Description: Akina主题分支原版地址 http://www.akina.pw/themeakina
Version: 3.1.5 Version: 3.1.7
License: GNU General Public License v2 or later License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: akina Text Domain: akina