I see the following error message when i try to add_fliter to reorder my tabs.
Here is what i am doing in my child-themes’ functions.php
PHP Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in wp-contentthemessalientwoocommercesingle-producttabstabs.php on line 47
Line 47 in tabs.php points to this –
<?php foreach ( $tabs as $key => $tab ) : ?>
<div class="panel entry-content" id="tab-<?php echo esc_attr( $key ); ?>">
<?php call_user_func( $tab['callback'], $key, $tab ); ?>
</div>
<?php endforeach; ?>
add filter am trying to use is this –
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
$tabs['additional_information']['priority'] = 15; // Additional information third
return $tabs;
}
I am unable to figure what is wrong. Please help indentify the issue and fix.
I had removed the
$tabs['additional_information']
entry in the struc, and i was referencing it in this function. Printing out the$tabs
content provided the necessary debug step to fix the warning message.There was no change needed in the reordering function, it was just a case of bad ref to non-existent entry in the array.
Yes, this works as you remove a tab that will be never used. But it is no solution for Reviews tab. The reviews is showed when there are some and hidden when there are not any.
The problem starts as you start doing stuff with reordering tab (just declare that tab). Then woocommerce starts expecting it every time and throws an error when product page does not have any reviews.
i faced the same issue before.
you have to create different functions for renaming, removing, re-ordering or adding tabs with their filters :
Like :