微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 WooCommerce 状态仪表板小部件中重命名单词

如何解决在 WooCommerce 状态仪表板小部件中重命名单词

我想重命名 WooCommerce 状态仪表板小部件中的单词(见屏幕截图)。

我使用以下代码,它适用于小部件的标题,但不适用于标记的单词。这可能是什么原因?

jQuery( document ).ready(function() {
    jQuery("#woocommerce_dashboard_status .wc_status_list li.processing-orders").text(function () {
       return jQuery(this).text().replace("awaiting","Websites:"); 
    });
});

enter image description here


我也试过这个,但结果不好。它不仅会覆盖文本,还会覆盖用于链接的 HTML。

{{1}}

enter image description here

有什么建议吗?

解决方法

我宁愿避免的解决方案,但这将是最快/最简单的解决方案之一。

使用jQuery。确保要替换的文本完全匹配。例如,如果这已经被翻译,你也应该像这样应用

所以你得到:

// Prints scripts or data before the default footer scripts.
// This hook is for admin only and can’t be used to add anything on the front end.
function action_admin_footer() {
    ?>
    <script>
        jQuery(document).ready(function($) {
            $( 'ul.wc_status_list .processing-orders a' ).html( function( index,text ) {
                return text.replace( 'awaiting processing','first new text' );
            });
            
            $( 'ul.wc_status_list .on-hold-orders a' ).html( function( index,text ) {
                return text.replace( 'on-hold','second new text' );
            });
        });
    </script>
    <?php
}
add_action( 'admin_footer','action_admin_footer' );

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。