WP core到底使用了什么css缩微器?

时间:2016-02-22 作者:sootsnoot

WordPress core以源代码和精简形式提供css文件。E、 g。wp-includes/css/admin-bar.csswp-includes/css/admin-bar.min.css. 有人确切地知道他们使用什么工具来进行缩小吗?我刚刚试着在cssminifier.comadmin-bar.css 文件,并从admin-bar.min.css 4.4.2附带的文件。我想对css进行一些更改,首先要验证我是否可以像WordPress那样缩小源代码,然后再对源代码进行更改,然后缩小结果。

请不要对不更改核心文件发表评论。我对它了如指掌,从3.7版到4.4.2版,我一直在git中维护少量的核心文件更改(除了大量的过滤器和操作)。我强烈倾向于定制“正确的方式”,但有时并不可行:-)

1 个回复
最合适的回答,由SO网友:Adam 整理而成

之前:

enter image description here

add_action(\'admin_head\', function(){

?>

    <style type="text/css">

    #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon::before {
        content: "LOL";
        top: 2px;
    }   

    </style>

<?php 

});

之后:

enter image description here

您也可以使用admin_enqueue_scripts 行动挂钩:

function my_enqueue($hook) {

    wp_enqueue_style( \'my_custom_script\', plugin_dir_url( __FILE__ ) . \'my-style.css\' );
}

add_action( \'admin_enqueue_scripts\', \'my_enqueue\' );
参见https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts。。。甚至不需要破解核心文件。

这应该会让你走上正轨。

关于您对多站点“我的站点”的评论:

enter image description here

我改变了什么?

#wpadminbar .quicklinks li .blavatar::before {
    content: "??";
    display: inline-block;
    height: 16px;
    margin: 6px 8px 0 -2px;
    width: 16px;
}
您只需在Firefox中使用Chrome开发工具或Firebug/Web检查器检查DOM,具体取决于您的首选方法,找到负责的选择器并进行修改以满足您的需要。

您可以将上述代码段添加到前面显示的示例中。

相关推荐