【问题标题】:Setting the name of a WooCommerce Extra tab using php?使用 php 设置 WooCommerce Extra 选项卡的名称?
【发布时间】:2014-04-24 09:14:42
【问题描述】:

基本上我在 php 文件的顶部有几个设置:

$wooc_product_faq_name = 'FAQ'; // Set the tab name for the FAQs

我想让它在我的 WooCommerce 插件中更改以下选项卡名称:

add_filter( 'woocommerce_product_tabs', 'wooc_product_faq' );
function wooc_product_faq( $tabs ) {
    // Adds the new tab
    $tabs['FAQ'] = array(
        'title' => __( $wooc_product_faq_name , 'woocommerce' ),
        'priority' => 99, // Priority effects the order, 99 puts it at the end of the tabs
        'callback' => 'wooc_product_faq_content'
    );
    return $tabs;
}

但是它不会让我这样做。它只是不输出任何东西。如果我改变了

        'title' => __( $wooc_product_faq_name , 'woocommerce' ),

        'title' => __( '$wooc_product_faq_name' , 'woocommerce' ),

然后它输出正确,但选项卡名称中的文本是 $wooc_product_faq_name 不是所需的 FAQ

您可以在此处查看完整文件:https://github.com/VagishVela/woocommerce-product-faq-tab/blob/dev/woocommerce-product-faq-tab.php

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    你试过这个吗??

    // Configuration
    global $wooc_product_faq_name;
    $wooc_product_faq_name = 'FAQ'; // Set the tab name for the FAQs
    
    //* Add FAQ Tab Filter
    add_filter( 'woocommerce_product_tabs', 'wooc_product_faq' );
    function wooc_product_faq( $tabs )
    {
        global $wooc_product_faq_name;
        // Adds the new tab
        $tabs['FAQ'] = array(
                'title' => __( $wooc_product_faq_name , 'woocommerce' ),
                'priority' => 99, // Priority effects the order, 99 puts it at the end of the tabs
                'callback' => 'wooc_product_faq_content'
        );
        return $tabs;
    }
    

    也许这会对你有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-15
      • 1970-01-01
      • 1970-01-01
      • 2018-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-13
      相关资源
      最近更新 更多