WooCommerce更改加载微调图标 [英] WooCommerce change loading spinner icon

查看:53
本文介绍了WooCommerce更改加载微调图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IM试图更改WooCommerce加载微调器图标.它在woocommerce.css中定义:

  .woocommerce .blockUI.blockOverlay :: before {高度:1em;宽度:1em;显示:块;位置:绝对;最高:50%;左:50%;左边距:-.5em;边距最高:-.5em;内容: '';-webkit-animation:旋转1s缓入无限;动画:旋转1s缓入无限;背景:url(../images/icons/loader.svg)中心居中;背景尺寸:封面;行高:1;文本对齐:居中;字号:2em;颜色:rgba(0,0,0,.75);} 

我尝试使用自定义CSS更改loader.svg:

  .woocommerce .blockUI.blockOverlay :: before {背景:url(http://www.localhost.de/wp-content/uploads/custom-loader.svg)center center!important;} 

但是图标不会改变.所以我已经在Google上搜索了一下,并在这里找到了它:

  add_filter('woocommerce_ajax_loader_url','custom_loader_icon',10,1);函数custom_loader_icon(){返回__(get_home_path().'wp-content/uploads/custom-loader.svg','woocommerce');} 

但是加载微调器图标仍然相同.我该怎么做才能改变它?我不知道该怎么办...

解决方案

以下代码CSS规则适用于Woocommerce的最新版本.我将它们嵌入到 wp_head 挂钩中,因为它很容易测试:

您将使用

IM trying to change the WooCommerce loading spinner icon. It's defined in the woocommerce.css:

.woocommerce .blockUI.blockOverlay::before {
    height: 1em;
    width: 1em;
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -.5em;
    margin-top: -.5em;
    content: '';
    -webkit-animation: spin 1s ease-in-out infinite;
    animation: spin 1s ease-in-out infinite;
    background: url(../images/icons/loader.svg) center center;
    background-size: cover;
    line-height: 1;
    text-align: center;
    font-size: 2em;
    color: rgba(0,0,0,.75);
}

I've tried changing the loader.svg with a custom css:

.woocommerce .blockUI.blockOverlay::before {
     background: url(http://www.localhost.de/wp-content/uploads/custom-loader.svg) center center !important;
}

But the icon will not change. So I've googled a bit and found this here:

add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
function custom_loader_icon() {
    return __( get_home_path() . 'wp-content/uploads/custom-loader.svg', 'woocommerce' );
}

But the loading spinner icon is still the same. What can I do to change it? I don't know what I should try now...

解决方案

The following code css rules work in Woocommerce last version. I have embedded them in the wp_head hook as it's easy for testing:

You will use this icon for testing, that you will put in your active child theme under an "img" directory, renaming the file my_spinner.gif.

If you use a theme instead of a child theme, you will use get_template_directory_uri() function instead of get_stylesheet_directory_uri() in the code.

The code:

add_action('wp_head', 'custom_ajax_spinner', 1000 );
function custom_ajax_spinner() {
    ?>
    <style>
    .woocommerce .blockUI.blockOverlay:before,
    .woocommerce .loader:before {
        height: 3em;
        width: 3em;
        position: absolute;
        top: 50%;
        left: 50%;
        margin-left: -.5em;
        margin-top: -.5em;
        display: block;
        content: "";
        -webkit-animation: none;
        -moz-animation: none;
        animation: none;
        background-image:url('<?php echo get_stylesheet_directory_uri() . "/img/my_spinner.gif"; ?>') !important;
        background-position: center center;
        background-size: cover;
        line-height: 1;
        text-align: center;
        font-size: 2em;
    }
    </style>
    <?php
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

这篇关于WooCommerce更改加载微调图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆