From 99ae5c6a53a44724e6bb18ecf17c95c0b068589e Mon Sep 17 00:00:00 2001 From: shivapoudel Date: Sun, 8 Feb 2015 20:25:19 +0545 Subject: [PATCH 1/5] Specify custom bulk actions messages for a post type --- includes/admin/class-wc-admin-post-types.php | 37 +++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index 8a1428c420c..7383cff4405 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -26,6 +26,7 @@ class WC_Admin_Post_Types { */ public function __construct() { add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); + add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_post_updated_messages' ), 10, 2 ); add_action( 'admin_print_scripts', array( $this, 'disable_autosave' ) ); // WP List table columns. Defined here so they are always available for events such as inline editing. @@ -1672,7 +1673,6 @@ class WC_Admin_Post_Types { /** * Change messages when a post type is updated. - * * @param array $messages * @return array */ @@ -1728,6 +1728,41 @@ class WC_Admin_Post_Types { return $messages; } + /** + * Specify custom bulk actions messages for a post type. + * @param array $bulk_messages + * @param array $bulk_counts + * @return array + */ + public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) { + + $bulk_messages['product'] = array( + 'updated' => _n( '%s product updated.', '%s products updated.', $bulk_counts['updated'] ), + 'locked' => _n( '%s product not updated, somebody is editing it.', '%s products not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'deleted' => _n( '%s product permanently deleted.', '%s products permanently deleted.', $bulk_counts['deleted'] ), + 'trashed' => _n( '%s product moved to the Trash.', '%s products moved to the Trash.', $bulk_counts['trashed'] ), + 'untrashed' => _n( '%s product restored from the Trash.', '%s products restored from the Trash.', $bulk_counts['untrashed'] ), + ); + + $bulk_messages['shop_order'] = array( + 'updated' => _n( '%s order updated.', '%s orders updated.', $bulk_counts['updated'] ), + 'locked' => _n( '%s order not updated, somebody is editing it.', '%s orders not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'deleted' => _n( '%s order permanently deleted.', '%s orders permanently deleted.', $bulk_counts['deleted'] ), + 'trashed' => _n( '%s order moved to the Trash.', '%s orders moved to the Trash.', $bulk_counts['trashed'] ), + 'untrashed' => _n( '%s order restored from the Trash.', '%s orders restored from the Trash.', $bulk_counts['untrashed'] ), + ); + + $bulk_messages['shop_coupon'] = array( + 'updated' => _n( '%s coupon updated.', '%s coupons updated.', $bulk_counts['updated'] ), + 'locked' => _n( '%s coupon not updated, somebody is editing it.', '%s coupons not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'deleted' => _n( '%s coupon permanently deleted.', '%s coupons permanently deleted.', $bulk_counts['deleted'] ), + 'trashed' => _n( '%s coupon moved to the Trash.', '%s coupons moved to the Trash.', $bulk_counts['trashed'] ), + 'untrashed' => _n( '%s coupon restored from the Trash.', '%s coupons restored from the Trash.', $bulk_counts['untrashed'] ), + ); + + return $bulk_messages; + } + /** * Disable the auto-save functionality for Orders. */ From 7fad3e9428cb9edf58a28038ca28b495ff718e75 Mon Sep 17 00:00:00 2001 From: shivapoudel Date: Sun, 8 Feb 2015 20:27:48 +0545 Subject: [PATCH 2/5] Move the {post|bulk_post}_updated_messages methods to top --- includes/admin/class-wc-admin-post-types.php | 184 +++++++++---------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index 7383cff4405..17cd8486a85 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -92,6 +92,98 @@ class WC_Admin_Post_Types { add_action( 'woocommerce_process_product_file_download_paths', array( $this, 'process_product_file_download_paths' ), 10, 3 ); } + /** + * Change messages when a post type is updated. + * @param array $messages + * @return array + */ + public function post_updated_messages( $messages ) { + global $post, $post_ID; + + $messages['product'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => sprintf( __( 'Product updated. View Product', 'woocommerce' ), esc_url( get_permalink( $post_ID ) ) ), + 2 => __( 'Custom field updated.', 'woocommerce' ), + 3 => __( 'Custom field deleted.', 'woocommerce' ), + 4 => __( 'Product updated.', 'woocommerce' ), + 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Product restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => sprintf( __( 'Product published. View Product', 'woocommerce' ), esc_url( get_permalink( $post_ID ) ) ), + 7 => __( 'Product saved.', 'woocommerce' ), + 8 => sprintf( __( 'Product submitted. Preview Product', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), + 9 => sprintf( __( 'Product scheduled for: %1$s. Preview Product', 'woocommerce' ), + date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), + 10 => sprintf( __( 'Product draft updated. Preview Product', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), + ); + + $messages['shop_order'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => __( 'Order updated.', 'woocommerce' ), + 2 => __( 'Custom field updated.', 'woocommerce' ), + 3 => __( 'Custom field deleted.', 'woocommerce' ), + 4 => __( 'Order updated.', 'woocommerce' ), + 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Order restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => __( 'Order updated.', 'woocommerce' ), + 7 => __( 'Order saved.', 'woocommerce' ), + 8 => __( 'Order submitted.', 'woocommerce' ), + 9 => sprintf( __( 'Order scheduled for: %1$s.', 'woocommerce' ), + date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ), + 10 => __( 'Order draft updated.', 'woocommerce' ), + 11 => __( 'Order updated and email sent.', 'woocommerce' ) + ); + + $messages['shop_coupon'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => __( 'Coupon updated.', 'woocommerce' ), + 2 => __( 'Custom field updated.', 'woocommerce' ), + 3 => __( 'Custom field deleted.', 'woocommerce' ), + 4 => __( 'Coupon updated.', 'woocommerce' ), + 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Coupon restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => __( 'Coupon updated.', 'woocommerce' ), + 7 => __( 'Coupon saved.', 'woocommerce' ), + 8 => __( 'Coupon submitted.', 'woocommerce' ), + 9 => sprintf( __( 'Coupon scheduled for: %1$s.', 'woocommerce' ), + date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ), + 10 => __( 'Coupon draft updated.', 'woocommerce' ) + ); + + return $messages; + } + + /** + * Specify custom bulk actions messages for a post type. + * @param array $bulk_messages + * @param array $bulk_counts + * @return array + */ + public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) { + + $bulk_messages['product'] = array( + 'updated' => _n( '%s product updated.', '%s products updated.', $bulk_counts['updated'] ), + 'locked' => _n( '%s product not updated, somebody is editing it.', '%s products not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'deleted' => _n( '%s product permanently deleted.', '%s products permanently deleted.', $bulk_counts['deleted'] ), + 'trashed' => _n( '%s product moved to the Trash.', '%s products moved to the Trash.', $bulk_counts['trashed'] ), + 'untrashed' => _n( '%s product restored from the Trash.', '%s products restored from the Trash.', $bulk_counts['untrashed'] ), + ); + + $bulk_messages['shop_order'] = array( + 'updated' => _n( '%s order updated.', '%s orders updated.', $bulk_counts['updated'] ), + 'locked' => _n( '%s order not updated, somebody is editing it.', '%s orders not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'deleted' => _n( '%s order permanently deleted.', '%s orders permanently deleted.', $bulk_counts['deleted'] ), + 'trashed' => _n( '%s order moved to the Trash.', '%s orders moved to the Trash.', $bulk_counts['trashed'] ), + 'untrashed' => _n( '%s order restored from the Trash.', '%s orders restored from the Trash.', $bulk_counts['untrashed'] ), + ); + + $bulk_messages['shop_coupon'] = array( + 'updated' => _n( '%s coupon updated.', '%s coupons updated.', $bulk_counts['updated'] ), + 'locked' => _n( '%s coupon not updated, somebody is editing it.', '%s coupons not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'deleted' => _n( '%s coupon permanently deleted.', '%s coupons permanently deleted.', $bulk_counts['deleted'] ), + 'trashed' => _n( '%s coupon moved to the Trash.', '%s coupons moved to the Trash.', $bulk_counts['trashed'] ), + 'untrashed' => _n( '%s coupon restored from the Trash.', '%s coupons restored from the Trash.', $bulk_counts['untrashed'] ), + ); + + return $bulk_messages; + } + /** * Define custom columns for products * @param array $existing_columns @@ -1671,98 +1763,6 @@ class WC_Admin_Post_Types { return $where; } - /** - * Change messages when a post type is updated. - * @param array $messages - * @return array - */ - public function post_updated_messages( $messages ) { - global $post, $post_ID; - - $messages['product'] = array( - 0 => '', // Unused. Messages start at index 1. - 1 => sprintf( __( 'Product updated. View Product', 'woocommerce' ), esc_url( get_permalink( $post_ID ) ) ), - 2 => __( 'Custom field updated.', 'woocommerce' ), - 3 => __( 'Custom field deleted.', 'woocommerce' ), - 4 => __( 'Product updated.', 'woocommerce' ), - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Product restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, - 6 => sprintf( __( 'Product published. View Product', 'woocommerce' ), esc_url( get_permalink( $post_ID ) ) ), - 7 => __( 'Product saved.', 'woocommerce' ), - 8 => sprintf( __( 'Product submitted. Preview Product', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), - 9 => sprintf( __( 'Product scheduled for: %1$s. Preview Product', 'woocommerce' ), - date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), - 10 => sprintf( __( 'Product draft updated. Preview Product', 'woocommerce' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), - ); - - $messages['shop_order'] = array( - 0 => '', // Unused. Messages start at index 1. - 1 => __( 'Order updated.', 'woocommerce' ), - 2 => __( 'Custom field updated.', 'woocommerce' ), - 3 => __( 'Custom field deleted.', 'woocommerce' ), - 4 => __( 'Order updated.', 'woocommerce' ), - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Order restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, - 6 => __( 'Order updated.', 'woocommerce' ), - 7 => __( 'Order saved.', 'woocommerce' ), - 8 => __( 'Order submitted.', 'woocommerce' ), - 9 => sprintf( __( 'Order scheduled for: %1$s.', 'woocommerce' ), - date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ), - 10 => __( 'Order draft updated.', 'woocommerce' ), - 11 => __( 'Order updated and email sent.', 'woocommerce' ) - ); - - $messages['shop_coupon'] = array( - 0 => '', // Unused. Messages start at index 1. - 1 => __( 'Coupon updated.', 'woocommerce' ), - 2 => __( 'Custom field updated.', 'woocommerce' ), - 3 => __( 'Custom field deleted.', 'woocommerce' ), - 4 => __( 'Coupon updated.', 'woocommerce' ), - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Coupon restored to revision from %s', 'woocommerce' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, - 6 => __( 'Coupon updated.', 'woocommerce' ), - 7 => __( 'Coupon saved.', 'woocommerce' ), - 8 => __( 'Coupon submitted.', 'woocommerce' ), - 9 => sprintf( __( 'Coupon scheduled for: %1$s.', 'woocommerce' ), - date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $post->post_date ) ) ), - 10 => __( 'Coupon draft updated.', 'woocommerce' ) - ); - - return $messages; - } - - /** - * Specify custom bulk actions messages for a post type. - * @param array $bulk_messages - * @param array $bulk_counts - * @return array - */ - public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) { - - $bulk_messages['product'] = array( - 'updated' => _n( '%s product updated.', '%s products updated.', $bulk_counts['updated'] ), - 'locked' => _n( '%s product not updated, somebody is editing it.', '%s products not updated, somebody is editing them.', $bulk_counts['locked'] ), - 'deleted' => _n( '%s product permanently deleted.', '%s products permanently deleted.', $bulk_counts['deleted'] ), - 'trashed' => _n( '%s product moved to the Trash.', '%s products moved to the Trash.', $bulk_counts['trashed'] ), - 'untrashed' => _n( '%s product restored from the Trash.', '%s products restored from the Trash.', $bulk_counts['untrashed'] ), - ); - - $bulk_messages['shop_order'] = array( - 'updated' => _n( '%s order updated.', '%s orders updated.', $bulk_counts['updated'] ), - 'locked' => _n( '%s order not updated, somebody is editing it.', '%s orders not updated, somebody is editing them.', $bulk_counts['locked'] ), - 'deleted' => _n( '%s order permanently deleted.', '%s orders permanently deleted.', $bulk_counts['deleted'] ), - 'trashed' => _n( '%s order moved to the Trash.', '%s orders moved to the Trash.', $bulk_counts['trashed'] ), - 'untrashed' => _n( '%s order restored from the Trash.', '%s orders restored from the Trash.', $bulk_counts['untrashed'] ), - ); - - $bulk_messages['shop_coupon'] = array( - 'updated' => _n( '%s coupon updated.', '%s coupons updated.', $bulk_counts['updated'] ), - 'locked' => _n( '%s coupon not updated, somebody is editing it.', '%s coupons not updated, somebody is editing them.', $bulk_counts['locked'] ), - 'deleted' => _n( '%s coupon permanently deleted.', '%s coupons permanently deleted.', $bulk_counts['deleted'] ), - 'trashed' => _n( '%s coupon moved to the Trash.', '%s coupons moved to the Trash.', $bulk_counts['trashed'] ), - 'untrashed' => _n( '%s coupon restored from the Trash.', '%s coupons restored from the Trash.', $bulk_counts['untrashed'] ), - ); - - return $bulk_messages; - } - /** * Disable the auto-save functionality for Orders. */ From 8db46ced4df7b9a802003b992f9086dc2390158a Mon Sep 17 00:00:00 2001 From: shivapoudel Date: Sun, 8 Feb 2015 20:30:19 +0545 Subject: [PATCH 3/5] Clean docblock statement for bulk messages --- includes/admin/class-wc-admin-post-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index 17cd8486a85..afa98522ba8 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -150,7 +150,7 @@ class WC_Admin_Post_Types { } /** - * Specify custom bulk actions messages for a post type. + * Specify custom bulk actions messages for different post types. * @param array $bulk_messages * @param array $bulk_counts * @return array From cdce6835f5a8222f7831ef721b0a0ee97d195184 Mon Sep 17 00:00:00 2001 From: shivapoudel Date: Sun, 8 Feb 2015 21:30:08 +0545 Subject: [PATCH 4/5] Comment for Disable Auto Save --- includes/admin/class-wc-admin-post-types.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index afa98522ba8..70a610566f3 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -27,6 +27,8 @@ class WC_Admin_Post_Types { public function __construct() { add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_post_updated_messages' ), 10, 2 ); + + // Disable Auto Save add_action( 'admin_print_scripts', array( $this, 'disable_autosave' ) ); // WP List table columns. Defined here so they are always available for events such as inline editing. From 85976ddcfb50f9278a464e6da46584653b82d08d Mon Sep 17 00:00:00 2001 From: shivapoudel Date: Sun, 8 Feb 2015 21:32:47 +0545 Subject: [PATCH 5/5] Comment for Meta-Box Class --- includes/admin/class-wc-admin-post-types.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index 70a610566f3..744e46a71ba 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -88,6 +88,7 @@ class WC_Admin_Post_Types { include( 'class-wc-admin-duplicate-product.php' ); } + // Meta-Box Class include_once( 'class-wc-admin-meta-boxes.php' ); // Download permissions