Add 'priority' support to product data tabs
This commit is contained in:
parent
376c069f47
commit
097309a0c8
|
@ -75,43 +75,64 @@ class WC_Meta_Box_Product_Data {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function get_product_data_tabs() {
|
private static function get_product_data_tabs() {
|
||||||
return apply_filters( 'woocommerce_product_data_tabs', array(
|
$tabs = apply_filters( 'woocommerce_product_data_tabs', array(
|
||||||
'general' => array(
|
'general' => array(
|
||||||
'label' => __( 'General', 'woocommerce' ),
|
'label' => __( 'General', 'woocommerce' ),
|
||||||
'target' => 'general_product_data',
|
'target' => 'general_product_data',
|
||||||
'class' => array( 'hide_if_grouped' ),
|
'class' => array( 'hide_if_grouped' ),
|
||||||
|
'priority' => 10,
|
||||||
),
|
),
|
||||||
'inventory' => array(
|
'inventory' => array(
|
||||||
'label' => __( 'Inventory', 'woocommerce' ),
|
'label' => __( 'Inventory', 'woocommerce' ),
|
||||||
'target' => 'inventory_product_data',
|
'target' => 'inventory_product_data',
|
||||||
'class' => array( 'show_if_simple', 'show_if_variable', 'show_if_grouped', 'show_if_external' ),
|
'class' => array( 'show_if_simple', 'show_if_variable', 'show_if_grouped', 'show_if_external' ),
|
||||||
|
'priority' => 20,
|
||||||
),
|
),
|
||||||
'shipping' => array(
|
'shipping' => array(
|
||||||
'label' => __( 'Shipping', 'woocommerce' ),
|
'label' => __( 'Shipping', 'woocommerce' ),
|
||||||
'target' => 'shipping_product_data',
|
'target' => 'shipping_product_data',
|
||||||
'class' => array( 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' ),
|
'class' => array( 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' ),
|
||||||
|
'priority' => 30,
|
||||||
),
|
),
|
||||||
'linked_product' => array(
|
'linked_product' => array(
|
||||||
'label' => __( 'Linked Products', 'woocommerce' ),
|
'label' => __( 'Linked Products', 'woocommerce' ),
|
||||||
'target' => 'linked_product_data',
|
'target' => 'linked_product_data',
|
||||||
'class' => array(),
|
'class' => array(),
|
||||||
|
'priority' => 40,
|
||||||
),
|
),
|
||||||
'attribute' => array(
|
'attribute' => array(
|
||||||
'label' => __( 'Attributes', 'woocommerce' ),
|
'label' => __( 'Attributes', 'woocommerce' ),
|
||||||
'target' => 'product_attributes',
|
'target' => 'product_attributes',
|
||||||
'class' => array(),
|
'class' => array(),
|
||||||
|
'priority' => 50,
|
||||||
),
|
),
|
||||||
'variations' => array(
|
'variations' => array(
|
||||||
'label' => __( 'Variations', 'woocommerce' ),
|
'label' => __( 'Variations', 'woocommerce' ),
|
||||||
'target' => 'variable_product_options',
|
'target' => 'variable_product_options',
|
||||||
'class' => array( 'variations_tab', 'show_if_variable' ),
|
'class' => array( 'variations_tab', 'show_if_variable' ),
|
||||||
|
'priority' => 60,
|
||||||
),
|
),
|
||||||
'advanced' => array(
|
'advanced' => array(
|
||||||
'label' => __( 'Advanced', 'woocommerce' ),
|
'label' => __( 'Advanced', 'woocommerce' ),
|
||||||
'target' => 'advanced_product_data',
|
'target' => 'advanced_product_data',
|
||||||
'class' => array(),
|
'class' => array(),
|
||||||
|
'priority' => 70,
|
||||||
),
|
),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
// Sort tabs based on priority
|
||||||
|
uasort( $tabs, array( __CLASS__, 'product_data_tabs_sort' ) );
|
||||||
|
|
||||||
|
return $tabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback to sort product data tabs on priority.
|
||||||
|
*/
|
||||||
|
private static function product_data_tabs_sort( $a, $b ) {
|
||||||
|
if ( ! isset( $a['priority'], $b['priority'] ) ) return -1;
|
||||||
|
if ( $a['priority'] == $b['priority'] ) return 0;
|
||||||
|
return $a['priority'] < $b['priority'] ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue