您如何设置 ACF(高级自定义字段)Wordpress 插件的 admin/backend 样式?
How do you style the admin/backend of the ACF (Advanced Custom Fields) Wordpress plugin?
当您有很多选项时,ACF backend/admin 面板可能会变得非常混乱。我看到您可以在哪里更改宽度百分比并将您自己的 class 添加到自定义字段,但是您如何设置这些 class 的样式?仅将 class 个名称添加到 style.css 是行不通的!
您必须将此代码添加到您的 functions.php 文件中。
这里有一些 docs.
function my_acf_admin_head() {
?>
<style type="text/css">
/* css here */
</style>
<?php
}
add_action('acf/input/admin_head', 'my_acf_admin_head');
这是我使用的代码。它使 ACF 管理员看起来更漂亮:
function my_acf_admin_head() {
?>
<style type="text/css">
.acf-flexible-content .layout .acf-fc-layout-handle {
/*background-color: #00B8E4;*/
background-color: #202428;
color: #eee;
}
.acf-repeater.-row > table > tbody > tr > td,
.acf-repeater.-block > table > tbody > tr > td {
border-top: 2px solid #202428;
}
.acf-repeater .acf-row-handle {
vertical-align: top !important;
padding-top: 16px;
}
.acf-repeater .acf-row-handle span {
font-size: 20px;
font-weight: bold;
color: #202428;
}
.imageUpload img {
width: 75px;
}
.acf-repeater .acf-row-handle .acf-icon.-minus {
top: 30px;
}
</style>
<?php
}
add_action('acf/input/admin_head', 'my_acf_admin_head');
如果您想发疯(或停止发疯),您可以这样做并根据需要添加尽可能多的“n”。
.acf-repeater.-row > table > tbody > tr:nth-child(2n) > td,
.acf-repeater.-block > table > tbody > tr:nth-child(2n) > td,
.acf-repeater.-row > table > tbody > tr:nth-child(2n) > td tr > td,
.acf-repeater.-block > table > tbody > tr:nth-child(2n) > td tr > td {
border-top: 2px solid #46474A;
background: #ebebed;
}
.acf-repeater.-row > table > tbody > tr:nth-child(2n) .acf-row-handle span,
.acf-repeater.-block > table > tbody > tr:nth-child(2n) .acf-row-handle span,
.acf-repeater.-row > table > tbody > tr:nth-child(2n) > td .acf-row-handle span,
.acf-repeater.-block > table > tbody > tr:nth-child(2n) > td .acf-row-handle span{
color: #46474A;
}
作为对 Jesse 回答的完美补充,想分享我对 ACF Metabox 的 CSS 补充,Calendar 也有样式。
这是它的样子
尽情享受
function my_acf_admin_head() {
?>
<style type="text/css">
.acf-flexible-content .layout .acf-fc-layout-handle {
/*background-color: #00B8E4;*/
background-color: #202428;
color: #eee;
}
.acf-repeater.-row > table > tbody > tr > td,
.acf-repeater.-block > table > tbody > tr > td {
border-top: 2px solid #202428;
}
.acf-repeater .acf-row-handle {
vertical-align: top !important;
padding-top: 16px;
}
.acf-repeater .acf-row-handle span {
font-size: 20px;
font-weight: bold;
color: #202428;
}
.imageUpload img {
width: 75px;
}
.acf-repeater .acf-row-handle .acf-icon.-minus {
top: 30px;
}
.acf_postbox {
background-color: #0473AA;
border-radius: 5px;
}
.acf_postbox input[type=text],
.acf_postbox input[type=search],
.acf_postbox input[type=radio],
.acf_postbox input[type=tel],
.acf_postbox input[type=time],
.acf_postbox input[type=url],
.acf_postbox input[type=week],
.acf_postbox input[type=password],
.acf_postbox input[type=checkbox],
.acf_postbox input[type=color],
.acf_postbox input[type=date],
.acf_postbox input[type=datetime],
.acf_postbox input[type=datetime-local],
.acf_postbox input[type=email],
.acf_postbox input[type=month],
.acf_postbox input[type=number],
.acf_postbox select,
.acf_postbox textarea {
border-radius: 5px;
}
.acf_postbox p.label {
text-shadow: none;
}
.acf_postbox h2.hndle,
.acf_postbox p.label label,
.acf_postbox p.label,
.acf_postbox .toggle-indicator {
color: #ffffff;
}
/*---- Date Picker Style ----*/
.ui-acf .ui-datepicker select.ui-datepicker-month,
.ui-acf .ui-datepicker select.ui-datepicker-year {
border-radius: 5px;
}
.ui-acf .ui-state-default{
border: 1px solid #ffffff!important;
background: none!important;
}
.ui-acf .ui-datepicker .ui-state-active, .ui-acf .ui-state-default:hover {
background: #2EA2CC!important;
color: #ffffff;
}
.ui-acf .ui-widget-header {
background: #3e3e3e;
}
.ui-acf .ui-datepicker .ui-datepicker-buttonpane {
background: #0473AA;
border-top: none;
}
.ui-acf .ui-datepicker .ui-datepicker-buttonpane button {
text-shadow: none;
color: #ffffff;
text-decoration: underline;
border: none!important;
}
</style>
<?php
}
add_action('acf/input/admin_head', 'my_acf_admin_head');
当您有很多选项时,ACF backend/admin 面板可能会变得非常混乱。我看到您可以在哪里更改宽度百分比并将您自己的 class 添加到自定义字段,但是您如何设置这些 class 的样式?仅将 class 个名称添加到 style.css 是行不通的!
您必须将此代码添加到您的 functions.php 文件中。 这里有一些 docs.
function my_acf_admin_head() {
?>
<style type="text/css">
/* css here */
</style>
<?php
}
add_action('acf/input/admin_head', 'my_acf_admin_head');
这是我使用的代码。它使 ACF 管理员看起来更漂亮:
function my_acf_admin_head() {
?>
<style type="text/css">
.acf-flexible-content .layout .acf-fc-layout-handle {
/*background-color: #00B8E4;*/
background-color: #202428;
color: #eee;
}
.acf-repeater.-row > table > tbody > tr > td,
.acf-repeater.-block > table > tbody > tr > td {
border-top: 2px solid #202428;
}
.acf-repeater .acf-row-handle {
vertical-align: top !important;
padding-top: 16px;
}
.acf-repeater .acf-row-handle span {
font-size: 20px;
font-weight: bold;
color: #202428;
}
.imageUpload img {
width: 75px;
}
.acf-repeater .acf-row-handle .acf-icon.-minus {
top: 30px;
}
</style>
<?php
}
add_action('acf/input/admin_head', 'my_acf_admin_head');
如果您想发疯(或停止发疯),您可以这样做并根据需要添加尽可能多的“n”。
.acf-repeater.-row > table > tbody > tr:nth-child(2n) > td,
.acf-repeater.-block > table > tbody > tr:nth-child(2n) > td,
.acf-repeater.-row > table > tbody > tr:nth-child(2n) > td tr > td,
.acf-repeater.-block > table > tbody > tr:nth-child(2n) > td tr > td {
border-top: 2px solid #46474A;
background: #ebebed;
}
.acf-repeater.-row > table > tbody > tr:nth-child(2n) .acf-row-handle span,
.acf-repeater.-block > table > tbody > tr:nth-child(2n) .acf-row-handle span,
.acf-repeater.-row > table > tbody > tr:nth-child(2n) > td .acf-row-handle span,
.acf-repeater.-block > table > tbody > tr:nth-child(2n) > td .acf-row-handle span{
color: #46474A;
}
作为对 Jesse 回答的完美补充,想分享我对 ACF Metabox 的 CSS 补充,Calendar 也有样式。
这是它的样子
尽情享受
function my_acf_admin_head() {
?>
<style type="text/css">
.acf-flexible-content .layout .acf-fc-layout-handle {
/*background-color: #00B8E4;*/
background-color: #202428;
color: #eee;
}
.acf-repeater.-row > table > tbody > tr > td,
.acf-repeater.-block > table > tbody > tr > td {
border-top: 2px solid #202428;
}
.acf-repeater .acf-row-handle {
vertical-align: top !important;
padding-top: 16px;
}
.acf-repeater .acf-row-handle span {
font-size: 20px;
font-weight: bold;
color: #202428;
}
.imageUpload img {
width: 75px;
}
.acf-repeater .acf-row-handle .acf-icon.-minus {
top: 30px;
}
.acf_postbox {
background-color: #0473AA;
border-radius: 5px;
}
.acf_postbox input[type=text],
.acf_postbox input[type=search],
.acf_postbox input[type=radio],
.acf_postbox input[type=tel],
.acf_postbox input[type=time],
.acf_postbox input[type=url],
.acf_postbox input[type=week],
.acf_postbox input[type=password],
.acf_postbox input[type=checkbox],
.acf_postbox input[type=color],
.acf_postbox input[type=date],
.acf_postbox input[type=datetime],
.acf_postbox input[type=datetime-local],
.acf_postbox input[type=email],
.acf_postbox input[type=month],
.acf_postbox input[type=number],
.acf_postbox select,
.acf_postbox textarea {
border-radius: 5px;
}
.acf_postbox p.label {
text-shadow: none;
}
.acf_postbox h2.hndle,
.acf_postbox p.label label,
.acf_postbox p.label,
.acf_postbox .toggle-indicator {
color: #ffffff;
}
/*---- Date Picker Style ----*/
.ui-acf .ui-datepicker select.ui-datepicker-month,
.ui-acf .ui-datepicker select.ui-datepicker-year {
border-radius: 5px;
}
.ui-acf .ui-state-default{
border: 1px solid #ffffff!important;
background: none!important;
}
.ui-acf .ui-datepicker .ui-state-active, .ui-acf .ui-state-default:hover {
background: #2EA2CC!important;
color: #ffffff;
}
.ui-acf .ui-widget-header {
background: #3e3e3e;
}
.ui-acf .ui-datepicker .ui-datepicker-buttonpane {
background: #0473AA;
border-top: none;
}
.ui-acf .ui-datepicker .ui-datepicker-buttonpane button {
text-shadow: none;
color: #ffffff;
text-decoration: underline;
border: none!important;
}
</style>
<?php
}
add_action('acf/input/admin_head', 'my_acf_admin_head');