Reduce visual noise

This commit is contained in:
Mike Jolley 2017-05-16 15:05:11 +01:00
parent b1e509b5b9
commit 6949ee162e
5 changed files with 39 additions and 19 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -673,6 +673,10 @@ table.wc_status_table {
}
}
.edit-php.post-type-product .top .bulkactions {
display: none;
}
#woocommerce-fields.inline-edit-col {
clear: left;

View File

@ -51,7 +51,8 @@ class WC_Admin_Post_Types {
add_filter( 'post_row_actions', array( $this, 'row_actions' ), 2, 100 );
// Views
add_filter( 'views_edit-product', array( $this, 'product_sorting_link' ) );
add_filter( 'views_edit-product', array( $this, 'product_views' ) );
add_filter( 'disable_months_dropdown', array( $this, 'disable_months_dropdown' ), 10, 2 );
// Bulk / quick edit
add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit' ), 10, 2 );
@ -774,29 +775,43 @@ class WC_Admin_Post_Types {
}
/**
* Product sorting link.
*
* Based on Simple Page Ordering by 10up (https://wordpress.org/plugins/simple-page-ordering/).
* Change views on the edit product screen.
*
* @param array $views
* @return array
*/
public function product_sorting_link( $views ) {
global $post_type, $wp_query;
public function product_views( $views ) {
global $wp_query;
if ( ! current_user_can( 'edit_others_pages' ) ) {
return $views;
// Products do not have authors.
unset( $views['mine'] );
// Add sorting link.
if ( current_user_can( 'edit_others_pages' ) ) {
$class = ( isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) ? 'current' : '';
$query_string = remove_query_arg( array( 'orderby', 'order' ) );
$query_string = add_query_arg( 'orderby', urlencode( 'menu_order title' ), $query_string );
$query_string = add_query_arg( 'order', urlencode( 'ASC' ), $query_string );
$views['byorder'] = '<a href="' . esc_url( $query_string ) . '" class="' . esc_attr( $class ) . '">' . __( 'Sorting', 'woocommerce' ) . '</a>';
}
$class = ( isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) ? 'current' : '';
$query_string = remove_query_arg( array( 'orderby', 'order' ) );
$query_string = add_query_arg( 'orderby', urlencode( 'menu_order title' ), $query_string );
$query_string = add_query_arg( 'order', urlencode( 'ASC' ), $query_string );
$views['byorder'] = '<a href="' . esc_url( $query_string ) . '" class="' . esc_attr( $class ) . '">' . __( 'Sort products', 'woocommerce' ) . '</a>';
return $views;
}
/**
* @deprecated 3.1
*/
public function product_sorting_link( $views ) {
$this->product_views( $views );
}
/**
* Disable months dropdown on product screen.
*/
public function disable_months_dropdown( $bool, $post_type ) {
return 'product' === $post_type ? true : $bool;
}
/**
* Custom bulk edit - form.
*
@ -1442,12 +1457,12 @@ class WC_Admin_Post_Types {
global $wp_query;
// Category Filtering
wc_product_dropdown_categories();
wc_product_dropdown_categories( array( 'option_select_text' => __( 'Filter by category', 'woocommerce' ) ) );
// Type filtering
$terms = get_terms( 'product_type' );
$output = '<select name="product_type" id="dropdown_product_type">';
$output .= '<option value="">' . __( 'Show all product types', 'woocommerce' ) . '</option>';
$output .= '<option value="">' . __( 'Filter by product type', 'woocommerce' ) . '</option>';
foreach ( $terms as $term ) {
$output .= '<option value="' . sanitize_title( $term->name ) . '" ';

View File

@ -204,6 +204,7 @@ function wc_product_dropdown_categories( $args = array(), $deprecated_hierarchic
'orderby' => 'name',
'selected' => $current_product_cat,
'menu_order' => false,
'option_select_text' => __( 'Select a category', 'woocommerce' ),
);
$args = wp_parse_args( $args, $defaults );
@ -220,7 +221,7 @@ function wc_product_dropdown_categories( $args = array(), $deprecated_hierarchic
}
$output = "<select name='product_cat' class='dropdown_product_cat'>";
$output .= '<option value="" ' . selected( $current_product_cat, '', false ) . '>' . esc_html__( 'Select a category', 'woocommerce' ) . '</option>';
$output .= '<option value="" ' . selected( $current_product_cat, '', false ) . '>' . esc_html( $args['option_select_text'] ) . '</option>';
$output .= wc_walk_category_dropdown_tree( $terms, 0, $args );
if ( $args['show_uncategorized'] ) {
$output .= '<option value="0" ' . selected( $current_product_cat, '0', false ) . '>' . esc_html__( 'Uncategorized', 'woocommerce' ) . '</option>';