Menu ordering tweaks. Closes #322.
This commit is contained in:
parent
38153003f1
commit
9300f1bc9e
|
@ -120,8 +120,8 @@ function woocommerce_admin_scripts() {
|
|||
|
||||
endif;
|
||||
|
||||
// Term ordering
|
||||
if ($screen->id=='edit-product_cat' || strstr($screen->id, 'edit-pa_')) :
|
||||
// Term ordering - only when sorting by menu_order (our custom meta)
|
||||
if (($screen->id=='edit-product_cat' || strstr($screen->id, 'edit-pa_')) && !isset($_GET['orderby'])) :
|
||||
|
||||
wp_register_script( 'woocommerce_term_ordering', $woocommerce->plugin_url() . '/assets/js/admin/term-ordering.js', array('jquery-ui-sortable') );
|
||||
wp_enqueue_script( 'woocommerce_term_ordering' );
|
||||
|
|
|
@ -265,8 +265,21 @@ function woocommerce_set_term_order($term_id, $index, $taxonomy, $recursive=fals
|
|||
return $index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Description to shipping class page
|
||||
* Description for product_cat page
|
||||
*/
|
||||
add_action('product_cat_pre_add_form', 'woocommerce_product_cat_description');
|
||||
|
||||
function woocommerce_product_cat_description() {
|
||||
|
||||
echo wpautop(__('Product categories for your store can be managed here. To change the order of categories on the front-end you can drag and drop to sort them. To see more categories listed click the "screen options" link at the top of the page.', 'woothemes'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Description for shipping class page
|
||||
*/
|
||||
add_action('product_shipping_class_pre_add_form', 'woocommerce_shipping_class_description');
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
|
|||
* Enhanced Flat Rate shipping to give a flat rate to each shipping class
|
||||
* Made jquery UI optional and improved javascript
|
||||
* Javascript can be loaded in the footer
|
||||
* Reworked term ordering system to make it more flexible and easier to manage
|
||||
|
||||
= 1.3 - 01/12/2011 =
|
||||
* Minor bug fixes + localisations
|
||||
|
|
|
@ -377,6 +377,15 @@ add_filter( 'terms_clauses', 'woocommerce_terms_clauses', 10, 3);
|
|||
function woocommerce_terms_clauses($clauses, $taxonomies, $args ) {
|
||||
global $wpdb, $woocommerce;
|
||||
|
||||
// No sorting when menu_order is false
|
||||
if ( isset($args['menu_order']) && $args['menu_order'] == false ) return $clauses;
|
||||
|
||||
// No sorting when orderby is non default
|
||||
if ( isset($args['orderby']) && $args['orderby'] != 'name' ) return $clauses;
|
||||
|
||||
// No sorting in admin when sorting by a column
|
||||
if ( isset($_GET['orderby']) ) return $clauses;
|
||||
|
||||
// wordpress should give us the taxonomies asked when calling the get_terms function. Only apply to categories and pa_ attributes
|
||||
$found = false;
|
||||
foreach ((array) $taxonomies as $taxonomy) :
|
||||
|
@ -394,9 +403,6 @@ function woocommerce_terms_clauses($clauses, $taxonomies, $args ) {
|
|||
$meta_name = 'order';
|
||||
endif;
|
||||
|
||||
// query order
|
||||
if( isset($args['menu_order']) && !$args['menu_order']) return $clauses; // menu_order is false so we do not add order clause
|
||||
|
||||
// query fields
|
||||
if( strpos('COUNT(*)', $clauses['fields']) === false ) $clauses['fields'] .= ', tm.* ';
|
||||
|
||||
|
|
|
@ -1177,8 +1177,7 @@ function woocommerce_product_subcategories() {
|
|||
// NOTE: using child_of instead of parent - this is not ideal but due to a WP bug (http://core.trac.wordpress.org/ticket/15626) pad_counts won't work
|
||||
$args = array(
|
||||
'child_of' => $parent,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'menu_order' => 'ASC',
|
||||
'hide_empty' => 1,
|
||||
'hierarchical' => 1,
|
||||
'taxonomy' => 'product_cat',
|
||||
|
|
Loading…
Reference in New Issue