From 44a226941d6a321f73f0eb94e9721ae0015705d6 Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Wed, 24 Jun 2020 19:39:11 +0530 Subject: [PATCH] Refactor `read_meta` into filter_raw_data for better re-usability. --- includes/data-stores/class-wc-data-store-wp.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/data-stores/class-wc-data-store-wp.php b/includes/data-stores/class-wc-data-store-wp.php index d8b5edfa477..3150fb0cb0f 100644 --- a/includes/data-stores/class-wc-data-store-wp.php +++ b/includes/data-stores/class-wc-data-store-wp.php @@ -94,7 +94,18 @@ class WC_Data_Store_WP { $object->get_id() ) ); + return $this->filter_raw_data( $object, $raw_meta_data ); + } + /** + * Helper method to filter internal meta keys from all meta data rows for the object. + * + * @param WC_Data $object WC_Data object. + * @param array $raw_meta_data Array of std object of meta data to be filtered. + * + * @return mixed|void + */ + public function filter_raw_data( &$object, $raw_meta_data ) { $this->internal_meta_keys = array_merge( array_map( array( $this, 'prefix_key' ), $object->get_data_keys() ), $this->internal_meta_keys ); $meta_data = array_filter( $raw_meta_data, array( $this, 'exclude_internal_meta_keys' ) ); return apply_filters( "woocommerce_data_store_wp_{$this->meta_type}_read_meta", $meta_data, $object, $this );