woocommerce_sort_product_tabs

Sort tabs by priority.

Description

(array) woocommerce_sort_product_tabs( (array) $tabs = array() ); 

Returns (array)

Parameters (1)

0. $tabs — Optional. (array) => array()
The tabs.

Usage

  1. if ( !function_exists( 'woocommerce_sort_product_tabs' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-template-functions.php'; 
  3.  
  4. // The tabs. 
  5. $tabs = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = woocommerce_sort_product_tabs($tabs); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-template-functions.php  
  1. function woocommerce_sort_product_tabs( $tabs = array() ) { 
  2.  
  3. // Make sure the $tabs parameter is an array 
  4. if ( ! is_array( $tabs ) ) { 
  5. trigger_error( "Function woocommerce_sort_product_tabs() expects an array as the first parameter. Defaulting to empty array." ); 
  6. $tabs = array(); 
  7.  
  8. // Re-order tabs by priority 
  9. if ( ! function_exists( '_sort_priority_callback' ) ) { 
  10. function _sort_priority_callback( $a, $b ) { 
  11. if ( $a['priority'] === $b['priority'] ) 
  12. return 0; 
  13. return ( $a['priority'] < $b['priority'] ) ? -1 : 1; 
  14.  
  15. uasort( $tabs, '_sort_priority_callback' ); 
  16.  
  17. return $tabs;