View mode option logic moved to appropriate post-type class
This commit is contained in:
parent
1ee2b431a3
commit
abe2f108f9
|
@ -101,6 +101,9 @@ class WC_Admin_Post_Types {
|
|||
// Disable DFW feature pointer
|
||||
add_action( 'admin_footer', array( $this, 'disable_dfw_feature_pointer' ) );
|
||||
|
||||
// Disable post type view mode options
|
||||
add_filter( 'view_mode_post_types', array( $this, 'disable_view_mode_options' ) );
|
||||
|
||||
// If first time editing, disable columns by default.
|
||||
if ( false === get_user_option( 'manageedit-shop_ordercolumnshidden' ) ) {
|
||||
$user = wp_get_current_user();
|
||||
|
@ -2269,6 +2272,20 @@ class WC_Admin_Post_Types {
|
|||
remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp410_dfw' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes products, orders, and coupons from the list of post types that support "View Mode" switching.
|
||||
* View mode is seen on posts where you can switch between list or excerpt. Our post types don't support
|
||||
* it, so we want to hide the useless UI from the screen options tab.
|
||||
*
|
||||
* @since 2.6
|
||||
* @param array $post_types Array of post types supporting view mode
|
||||
* @return array Array of post types supporting view mode, without products, orders, and coupons
|
||||
*/
|
||||
public function disable_view_mode_options( $post_types ) {
|
||||
unset( $post_types['product'], $post_types['shop_order'], $post_types['shop_coupon'] );
|
||||
return $post_types;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
|
|
@ -29,7 +29,6 @@ class WC_Admin {
|
|||
add_action( 'admin_init', array( $this, 'admin_redirects' ) );
|
||||
add_action( 'admin_footer', 'wc_print_js', 25 );
|
||||
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
|
||||
add_filter( 'view_mode_post_types', array( $this, 'remove_post_types_from_view_mode' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -209,21 +208,6 @@ class WC_Admin {
|
|||
|
||||
return $footer_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes products, orders, and coupons from the list of post types that support "View Mode" switching.
|
||||
* View mode is seen on posts where you can switch between list or excerpt. Our post types don't support
|
||||
* it, so we want to hide the useless UI from the screen options tab.
|
||||
*
|
||||
* @since 2.6
|
||||
* @param array $post_types Array of post types supporting view mode
|
||||
* @return array Array of post types supporting view mode, without products, orders, and coupons
|
||||
*/
|
||||
public function remove_post_types_from_view_mode( $post_types ) {
|
||||
unset( $post_types['product'], $post_types['shop_order'], $post_types['shop_coupon'] );
|
||||
return $post_types;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new WC_Admin();
|
||||
|
|
Loading…
Reference in New Issue