自定义REDUX选项面板CSS

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' ,
         'http://urltomyfile' ,
         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' ,
     'http://urltomyfile' ,
     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命在你手了。

Related Articles

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值