We understand customization is important to any developer. That’s why we’ve provided a few useful hooks to enqueue or dequeue our default CSS files. Interested? Read on!
我们的理解任何定制开发是重要的。这就是为什么我们已经提供了一些有用的enqueue钩到或从我们的默认的CSS文件。有兴趣吗?阅读在线!
Appending CSS 附加css
Let’s say you want to append some custom CSS to your panel. Here is how this is accomplished:
下面演示如何添加自定义CSS到面板。
01
02
03
04
05
06
07
08
09
10
11
12
|
function
addPanelCSS() {
wp_register_style(
'redux-custom-css'
,
array
(
'redux-admin-css'
),
// Be sure to include redux-admin-css so it's appended after the core css is applied
time(),
'all'
);
wp_enqueue_style(
'redux-custom-css'
);
}
// This example assumes your opt_name is set to redux_demo, replace with your opt_name value
add_action(
'redux/page/redux_demo/enqueue'
,
'addPanelCSS'
);
|
Replacing CSS 代换CSS
If you believe you have a better overall design, it’s easy to remove the Redux CSS file completely:
移除默认CSS
1
2
3
4
5
|
function
removePanelCSS() {
wp_dequeue_style(
'redux-admin-css'
);
}
// This example assumes your opt_name is set to redux_demo, replace with your opt_name value
add_action(
'redux/page/redux_demo/enqueue'
,
'removePanelCSS'
);
|
The Complete Solution 完整解决方案
The above functions may also be rolled together into a single function by doing the following:
上述功能也可以合并如下
01
02
03
04
05
06
07
08
09
10
11
12
13
|
function
addAndOverridePanelCSS() {
wp_dequeue_style(
'redux-admin-css'
);
wp_register_style(
'redux-custom-css'
,
array
(
'farbtastic'
),
// Notice redux-admin-css is removed and the wordpress standard farbtastic is included instead
time(),
'all'
);
wp_enqueue_style(
'redux-custom-css'
);
}
// This example assumes your opt_name is set to redux_demo, replace with your opt_name value
add_action(
'redux/page/redux_demo/enqueue'
,
'addAndOverridePanelCSS'
);
|
The power of full CSS override is now in your hands!
CSS命在你手了。