woocommerce_sort_product_tabs()WC 1.0

Sort tabs by priority.

Хуков нет.

Возвращает

Массив.

Использование

woocommerce_sort_product_tabs( $tabs );
$tabs(массив)
Array of tabs.
По умолчанию: array()

Код woocommerce_sort_product_tabs() WC 8.7.0

function woocommerce_sort_product_tabs( $tabs = array() ) {

	// Make sure the $tabs parameter is an array.
	if ( ! is_array( $tabs ) ) {
		// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
		trigger_error( 'Function woocommerce_sort_product_tabs() expects an array as the first parameter. Defaulting to empty array.' );
		$tabs = array();
	}

	// Re-order tabs by priority.
	if ( ! function_exists( '_sort_priority_callback' ) ) {
		/**
		 * Sort Priority Callback Function
		 *
		 * @param array $a Comparison A.
		 * @param array $b Comparison B.
		 * @return bool
		 */
		function _sort_priority_callback( $a, $b ) {
			if ( ! isset( $a['priority'], $b['priority'] ) || $a['priority'] === $b['priority'] ) {
				return 0;
			}
			return ( $a['priority'] < $b['priority'] ) ? -1 : 1;
		}
	}

	uasort( $tabs, '_sort_priority_callback' );

	return $tabs;
}