dousu1900 2014-04-24 01:14
浏览 41
已采纳

使用php设置WooCommerce Extra选项卡的名称?

Basically I have a couple of settings at the top of a php file:

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

I want to allow it to change the tab name of the following in my WooCommerce plugin:

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;
}

However it won't let me do it. it just doesn't output anything. And if I change the

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

to

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

then it outputs correctly but the text in the tab name is $wooc_product_faq_name Not the desired FAQ.

You can see the full file here: https://github.com/VagishVela/woocommerce-product-faq-tab/blob/dev/woocommerce-product-faq-tab.php

  • 写回答

1条回答 默认 最新

  • doutongwei4380 2014-04-24 01:27
    关注

    Have you tried this ??

    // 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;
    }
    

    May be this will help you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 怎么实现数组的循环累加,simulink
  • ¥15 51单片机最小开发板系统,想让寻迹小车在全检测到黑线(寻迹模块代码在第一块板子上)时蜂鸣器响(在第二块板子上)
  • ¥15 pbootcms多选调用成列表
  • ¥15 51单片机oled显示时钟
  • ¥15 小规模TSP问题的动态规划求解
  • ¥25 kubelet.service: Failed with result 'exit-code'.
  • ¥15 bitvise黑框内一键部署v2ray提示账户没有root怎么解决
  • ¥15 车型识别以及相似度匹配中细节特征提取以及图像模糊问题
  • ¥15 怎么用鸿蒙的ArkTs写出来啊
  • ¥30 websocket服务端多线程通信
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部