From 58b4cb9cf42fa62e653cc9a7293b054725c4e620 Mon Sep 17 00:00:00 2001 From: Justin Shreve Date: Tue, 22 Nov 2016 04:20:25 -0800 Subject: [PATCH] Make sure get_hook_prefix is present on all of our classes. And fix up an exclude internal keys call for the customer data store. --- includes/class-wc-coupon.php | 10 ++++++++++ includes/class-wc-customer.php | 17 ++++++----------- includes/class-wc-order-item.php | 10 ++++++++++ includes/class-wc-shipping-zone.php | 10 ++++++++++ .../class-wc-customer-data-store.php | 15 +++++++++++++++ 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/includes/class-wc-coupon.php b/includes/class-wc-coupon.php index b794ae8c8b9..839bc11c849 100644 --- a/includes/class-wc-coupon.php +++ b/includes/class-wc-coupon.php @@ -109,6 +109,16 @@ class WC_Coupon extends WC_Legacy_Coupon { return ( $this->get_discount_type() == $type || ( is_array( $type ) && in_array( $this->get_discount_type(), $type ) ) ); } + /** + * Prefix for action and filter hooks on data. + * + * @since 2.7.0 + * @return string + */ + protected function get_hook_prefix() { + return 'woocommerce_get_coupon_'; + } + /* |-------------------------------------------------------------------------- | Getters diff --git a/includes/class-wc-customer.php b/includes/class-wc-customer.php index 7d8002d26e7..45c25081d55 100644 --- a/includes/class-wc-customer.php +++ b/includes/class-wc-customer.php @@ -113,19 +113,14 @@ class WC_Customer extends WC_Legacy_Customer { } /** - * Callback to remove unwanted meta data. + * Prefix for action and filter hooks on data. * - * @param object $meta - * @return bool + * @since 2.7.0 + * @return string */ - protected function exclude_internal_meta_keys( $meta ) { - global $wpdb; - return ! in_array( $meta->meta_key, $this->get_internal_meta_keys() ) - && 0 !== strpos( $meta->meta_key, 'closedpostboxes_' ) - && 0 !== strpos( $meta->meta_key, 'metaboxhidden_' ) - && 0 !== strpos( $meta->meta_key, 'manageedit-' ) - && ! strstr( $meta->meta_key, $wpdb->prefix ); - } + protected function get_hook_prefix() { + return 'woocommerce_get_customer_'; + } /** * Delete a customer and reassign posts.. diff --git a/includes/class-wc-order-item.php b/includes/class-wc-order-item.php index b62c5cee10d..54faada60fd 100644 --- a/includes/class-wc-order-item.php +++ b/includes/class-wc-order-item.php @@ -69,6 +69,16 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { } } + /** + * Prefix for action and filter hooks on data. + * + * @since 2.7.0 + * @return string + */ + protected function get_hook_prefix() { + return 'woocommerce_get_order_item_'; + } + /* |-------------------------------------------------------------------------- | Getters diff --git a/includes/class-wc-shipping-zone.php b/includes/class-wc-shipping-zone.php index 9a6f9d6ad38..3a1babcbe51 100644 --- a/includes/class-wc-shipping-zone.php +++ b/includes/class-wc-shipping-zone.php @@ -56,6 +56,16 @@ class WC_Shipping_Zone extends WC_Legacy_Shipping_Zone { } } + /** + * Prefix for action and filter hooks on data. + * + * @since 2.7.0 + * @return string + */ + protected function get_hook_prefix() { + return 'woocommerce_get_shipping_zone_'; + } + /* |-------------------------------------------------------------------------- | Getters diff --git a/includes/data-stores/class-wc-customer-data-store.php b/includes/data-stores/class-wc-customer-data-store.php index 5dc1de9695e..de689fa7d08 100644 --- a/includes/data-stores/class-wc-customer-data-store.php +++ b/includes/data-stores/class-wc-customer-data-store.php @@ -63,6 +63,21 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat */ protected $meta_type = 'user'; + /** + * Callback to remove unwanted meta data. + * + * @param object $meta + * @return bool + */ + protected function exclude_internal_meta_keys( $meta ) { + global $wpdb; + return ! in_array( $meta->meta_key, $this->internal_meta_keys ) + && 0 !== strpos( $meta->meta_key, 'closedpostboxes_' ) + && 0 !== strpos( $meta->meta_key, 'metaboxhidden_' ) + && 0 !== strpos( $meta->meta_key, 'manageedit-' ) + && ! strstr( $meta->meta_key, $wpdb->prefix ); + } + /** * Method to create a new customer in the database. *