column ordering
This commit is contained in:
parent
4d8d82b941
commit
51903bb0c7
|
@ -10,8 +10,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom columns
|
* Columns for Coupons page
|
||||||
**/
|
**/
|
||||||
|
add_filter('manage_edit-shop_coupon_columns', 'woocommerce_edit_coupon_columns');
|
||||||
|
|
||||||
function woocommerce_edit_coupon_columns($columns){
|
function woocommerce_edit_coupon_columns($columns){
|
||||||
|
|
||||||
$columns = array();
|
$columns = array();
|
||||||
|
@ -26,7 +28,12 @@ function woocommerce_edit_coupon_columns($columns){
|
||||||
|
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
add_filter('manage_edit-shop_coupon_columns', 'woocommerce_edit_coupon_columns');
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Columns for Coupons page
|
||||||
|
**/
|
||||||
|
add_action('manage_shop_coupon_posts_custom_column', 'woocommerce_custom_coupon_columns', 2);
|
||||||
|
|
||||||
function woocommerce_custom_coupon_columns($column) {
|
function woocommerce_custom_coupon_columns($column) {
|
||||||
global $post;
|
global $post;
|
||||||
|
@ -56,7 +63,12 @@ function woocommerce_custom_coupon_columns($column) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('manage_shop_coupon_posts_custom_column', 'woocommerce_custom_coupon_columns', 2);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns for Variations page
|
||||||
|
**/
|
||||||
|
add_filter('manage_edit-product_variation_columns', 'woocommerce_edit_variation_columns');
|
||||||
|
|
||||||
function woocommerce_edit_variation_columns($columns){
|
function woocommerce_edit_variation_columns($columns){
|
||||||
|
|
||||||
|
@ -70,7 +82,12 @@ function woocommerce_edit_variation_columns($columns){
|
||||||
|
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
add_filter('manage_edit-product_variation_columns', 'woocommerce_edit_variation_columns');
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Columns for Variations page
|
||||||
|
**/
|
||||||
|
add_action('manage_product_variation_posts_custom_column', 'woocommerce_custom_variation_columns', 2);
|
||||||
|
|
||||||
function woocommerce_custom_variation_columns($column) {
|
function woocommerce_custom_variation_columns($column) {
|
||||||
global $post;
|
global $post;
|
||||||
|
@ -93,14 +110,19 @@ function woocommerce_custom_variation_columns($column) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('manage_product_variation_posts_custom_column', 'woocommerce_custom_variation_columns', 2);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns for Products page
|
||||||
|
**/
|
||||||
|
add_filter('manage_edit-product_columns', 'woocommerce_edit_product_columns');
|
||||||
|
|
||||||
function woocommerce_edit_product_columns($columns){
|
function woocommerce_edit_product_columns($columns){
|
||||||
|
|
||||||
$columns = array();
|
$columns = array();
|
||||||
|
|
||||||
$columns["cb"] = "<input type=\"checkbox\" />";
|
$columns["cb"] = "<input type=\"checkbox\" />";
|
||||||
$columns["thumb"] = __("Thumb", 'woothemes');
|
$columns["thumb"] = __("Image", 'woothemes');
|
||||||
$columns["title"] = __("Name", 'woothemes');
|
$columns["title"] = __("Name", 'woothemes');
|
||||||
$columns["product_type"] = __("Type", 'woothemes');
|
$columns["product_type"] = __("Type", 'woothemes');
|
||||||
$columns["sku"] = __("ID/SKU", 'woothemes');
|
$columns["sku"] = __("ID/SKU", 'woothemes');
|
||||||
|
@ -119,7 +141,12 @@ function woocommerce_edit_product_columns($columns){
|
||||||
|
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
add_filter('manage_edit-product_columns', 'woocommerce_edit_product_columns');
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Columns for Products page
|
||||||
|
**/
|
||||||
|
add_action('manage_product_posts_custom_column', 'woocommerce_custom_product_columns', 2);
|
||||||
|
|
||||||
function woocommerce_custom_product_columns($column) {
|
function woocommerce_custom_product_columns($column) {
|
||||||
global $post;
|
global $post;
|
||||||
|
@ -178,12 +205,68 @@ function woocommerce_custom_product_columns($column) {
|
||||||
case "product_type" :
|
case "product_type" :
|
||||||
echo ucwords($product->product_type);
|
echo ucwords($product->product_type);
|
||||||
break;
|
break;
|
||||||
case "id" :
|
|
||||||
echo '#'.$post->ID;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('manage_product_posts_custom_column', 'woocommerce_custom_product_columns', 2);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make product columns sortable
|
||||||
|
* https://gist.github.com/906872
|
||||||
|
**/
|
||||||
|
add_filter("manage_edit-product_sortable_columns", 'woocommerce_custom_product_sort');
|
||||||
|
|
||||||
|
function woocommerce_custom_product_sort($columns) {
|
||||||
|
$custom = array(
|
||||||
|
'inventory' => 'inventory',
|
||||||
|
'price' => 'price',
|
||||||
|
'featured' => 'featured',
|
||||||
|
'sku' => 'sku'
|
||||||
|
);
|
||||||
|
return wp_parse_args($custom, $columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Product column orderby
|
||||||
|
* http://scribu.net/wordpress/custom-sortable-columns.html#comment-4732
|
||||||
|
**/
|
||||||
|
add_filter( 'request', 'woocommerce_custom_product_orderby' );
|
||||||
|
|
||||||
|
function woocommerce_custom_product_orderby( $vars ) {
|
||||||
|
if (isset( $vars['orderby'] )) :
|
||||||
|
if ( 'inventory' == $vars['orderby'] ) :
|
||||||
|
$vars = array_merge( $vars, array(
|
||||||
|
'meta_key' => 'stock',
|
||||||
|
'orderby' => 'meta_value_num'
|
||||||
|
) );
|
||||||
|
endif;
|
||||||
|
if ( 'price' == $vars['orderby'] ) :
|
||||||
|
$vars = array_merge( $vars, array(
|
||||||
|
'meta_key' => 'price',
|
||||||
|
'orderby' => 'meta_value_num'
|
||||||
|
) );
|
||||||
|
endif;
|
||||||
|
if ( 'featured' == $vars['orderby'] ) :
|
||||||
|
$vars = array_merge( $vars, array(
|
||||||
|
'meta_key' => 'featured',
|
||||||
|
'orderby' => 'meta_value'
|
||||||
|
) );
|
||||||
|
endif;
|
||||||
|
if ( 'sku' == $vars['orderby'] ) :
|
||||||
|
$vars = array_merge( $vars, array(
|
||||||
|
'orderby' => 'id'
|
||||||
|
) );
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
return $vars;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns for order page
|
||||||
|
**/
|
||||||
|
add_filter('manage_edit-shop_order_columns', 'woocommerce_edit_order_columns');
|
||||||
|
|
||||||
function woocommerce_edit_order_columns($columns){
|
function woocommerce_edit_order_columns($columns){
|
||||||
|
|
||||||
|
@ -199,7 +282,12 @@ function woocommerce_edit_order_columns($columns){
|
||||||
|
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
add_filter('manage_edit-shop_order_columns', 'woocommerce_edit_order_columns');
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Columns for order page
|
||||||
|
**/
|
||||||
|
add_action('manage_shop_order_posts_custom_column', 'woocommerce_custom_order_columns', 2);
|
||||||
|
|
||||||
function woocommerce_custom_order_columns($column) {
|
function woocommerce_custom_order_columns($column) {
|
||||||
|
|
||||||
|
@ -274,11 +362,13 @@ function woocommerce_custom_order_columns($column) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('manage_shop_order_posts_custom_column', 'woocommerce_custom_order_columns', 2);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order page filters
|
* Order page filters
|
||||||
**/
|
**/
|
||||||
|
add_filter('views_edit-shop_order', 'woocommerce_custom_order_views');
|
||||||
|
|
||||||
function woocommerce_custom_order_views( $views ) {
|
function woocommerce_custom_order_views( $views ) {
|
||||||
|
|
||||||
$woocommerce_orders = &new woocommerce_orders();
|
$woocommerce_orders = &new woocommerce_orders();
|
||||||
|
@ -314,11 +404,13 @@ function woocommerce_custom_order_views( $views ) {
|
||||||
|
|
||||||
return $views;
|
return $views;
|
||||||
}
|
}
|
||||||
add_filter('views_edit-shop_order', 'woocommerce_custom_order_views');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order page actions
|
* Order page actions
|
||||||
**/
|
**/
|
||||||
|
add_filter( 'post_row_actions', 'woocommerce_remove_row_actions', 10, 1 );
|
||||||
|
|
||||||
function woocommerce_remove_row_actions( $actions ) {
|
function woocommerce_remove_row_actions( $actions ) {
|
||||||
if( get_post_type() === 'shop_order' ) :
|
if( get_post_type() === 'shop_order' ) :
|
||||||
unset( $actions['view'] );
|
unset( $actions['view'] );
|
||||||
|
@ -326,23 +418,26 @@ function woocommerce_remove_row_actions( $actions ) {
|
||||||
endif;
|
endif;
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
add_filter( 'post_row_actions', 'woocommerce_remove_row_actions', 10, 1 );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order page views
|
* Order page views
|
||||||
**/
|
**/
|
||||||
|
add_filter( 'bulk_actions-edit-shop_order', 'woocommerce_bulk_actions' );
|
||||||
|
|
||||||
function woocommerce_bulk_actions( $actions ) {
|
function woocommerce_bulk_actions( $actions ) {
|
||||||
|
|
||||||
if (isset($actions['edit'])) unset($actions['edit']);
|
if (isset($actions['edit'])) unset($actions['edit']);
|
||||||
|
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
add_filter( 'bulk_actions-edit-shop_order', 'woocommerce_bulk_actions' );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order messages
|
* Order messages
|
||||||
**/
|
**/
|
||||||
|
add_filter( 'post_updated_messages', 'woocommerce_post_updated_messages' );
|
||||||
|
|
||||||
function woocommerce_post_updated_messages( $messages ) {
|
function woocommerce_post_updated_messages( $messages ) {
|
||||||
if( get_post_type() === 'shop_order' ) :
|
if( get_post_type() === 'shop_order' ) :
|
||||||
|
|
||||||
|
@ -356,5 +451,3 @@ function woocommerce_post_updated_messages( $messages ) {
|
||||||
endif;
|
endif;
|
||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
add_filter( 'post_updated_messages', 'woocommerce_post_updated_messages' );
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ function woocommerce_post_type() {
|
||||||
'hierarchical' => true,
|
'hierarchical' => true,
|
||||||
'update_count_callback' => '_update_post_term_count',
|
'update_count_callback' => '_update_post_term_count',
|
||||||
'labels' => array(
|
'labels' => array(
|
||||||
'name' => __( 'Product Categories', 'woothemes'),
|
'name' => __( 'Categories', 'woothemes'),
|
||||||
'singular_name' => __( 'Product Category', 'woothemes'),
|
'singular_name' => __( 'Product Category', 'woothemes'),
|
||||||
'search_items' => __( 'Search Product Categories', 'woothemes'),
|
'search_items' => __( 'Search Product Categories', 'woothemes'),
|
||||||
'all_items' => __( 'All Product Categories', 'woothemes'),
|
'all_items' => __( 'All Product Categories', 'woothemes'),
|
||||||
|
@ -54,7 +54,7 @@ function woocommerce_post_type() {
|
||||||
array(
|
array(
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'labels' => array(
|
'labels' => array(
|
||||||
'name' => __( 'Product Tags', 'woothemes'),
|
'name' => __( 'Tags', 'woothemes'),
|
||||||
'singular_name' => __( 'Product Tag', 'woothemes'),
|
'singular_name' => __( 'Product Tag', 'woothemes'),
|
||||||
'search_items' => __( 'Search Product Tags', 'woothemes'),
|
'search_items' => __( 'Search Product Tags', 'woothemes'),
|
||||||
'all_items' => __( 'All Product Tags', 'woothemes'),
|
'all_items' => __( 'All Product Tags', 'woothemes'),
|
||||||
|
|
Loading…
Reference in New Issue