【发布时间】:2021-03-25 10:47:16
【问题描述】:
我使用原始的 sn-p 重新排序选项卡。 然后意识到如果我忘记放置描述或属性,这些选项卡是空的。 然后 sn -p 创建 php 错误。 这是原始代码和我的错误注释。 https://gist.github.com/woogists/abb8a37f8c708d712e46ce2d02ffdc43#file-wc-reorder-tabs-php
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
if ($tabs[''] !== undefined)
{
$tabs['additional_information']['priority'] = 1;
}
return $tabs;
}
然后我添加了 if empty 规则并像这样更改了代码。但这也会造成另一个错误。
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
if ($tabs[''] !== undefined)
{
$tabs['additional_information']['priority'] = 1;
}
return $tabs;
}
这是错误
PHP Warning: Use of undefined constant undefined - assumed 'undefined' (this will throw an Error in a future version of PHP) in /kunder/gaming_10908/devgam_14130/public/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()'d code on line 6
你有什么建议吗?
【问题讨论】:
标签: php wordpress woocommerce tabs