attributes were found or category is invalid, otherwise array of attributes. */ public function get_attributes_with_fallback_to_parent_category( $category_id ) { if ( ! $this->is_category( $category_id ) ) { return null; } $attributes = $this->get_attributes( $category_id ); if ( $attributes ) { return $attributes; } facebook_for_woocommerce()->log( sprintf( 'Google Product Category to Facebook attributes mapping for category with id: %s not found', $category_id ) ); // Category has no attributes entry - it should be added but for now check parent category. if ( $this->is_root_category( $category_id ) ) { return null; } $parent_category_id = GoogleProductTaxonomy::TAXONOMY[ $category_id ]['parent']; $parent_category_attributes = $this->get_attributes( $parent_category_id ); if ( $parent_category_attributes ) { return $parent_category_attributes; } // We could check further as we have 3 levels of product categories. // This would meant that we have a big problem with mapping - let this fail and log the problem. facebook_for_woocommerce()->log( sprintf( 'Google Product Category to Facebook attributes mapping for parent category with id: %s not found', $parent_category_id ) ); return null; } /** * Checks if given category id is valid. * * @param string $category_id Id of the category which we check. * * @return boolean Is the id a valid category id. */ public function is_category( $category_id ) { return isset( GoogleProductTaxonomy::TAXONOMY[ $category_id ] ); } /** * Get all categories. * * @return array All categories data. */ public function get_categories() { return GoogleProductTaxonomy::TAXONOMY; } /** * Get category attribute field by it's hash. * * @param string $hash * * @return array|null */ protected function get_attribute_field_by_hash( $hash ) { $fields_data = $this->get_raw_attributes_fields_data(); if ( isset( $fields_data[ $hash ] ) ) { return $fields_data[ $hash ]; } else { return null; } } /** * Get the raw category attributes data from the JSON file. * * @return array */ protected function get_raw_attributes_data() { static $data = null; if ( null === $data ) { $contents = file_get_contents( facebook_for_woocommerce()->get_plugin_path() . '/data/google_category_to_attribute_mapping.json' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents if ( $contents ) { $data = json_decode( $contents, true ); } else { $data = array(); facebook_for_woocommerce()->log( 'Error reading category attributes JSON data.' ); } } return $data; } /** * Get the raw category attributes fields data from the JSON file. * * @retrun array */ protected function get_raw_attributes_fields_data() { static $data = null; if ( null === $data ) { $contents = file_get_contents( facebook_for_woocommerce()->get_plugin_path() . '/data/google_category_to_attribute_mapping_fields.json' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents if ( $contents ) { $data = json_decode( $contents, true ); } else { $data = array(); facebook_for_woocommerce()->log( 'Error reading category attributes fields JSON data.' ); } } return $data; } }
Fatal error: Uncaught Error: Class "WooCommerce\Facebook\Products\FBCategories" not found in /htdocs/wp-content/plugins/facebook-for-woocommerce/class-wc-facebookcommerce.php:194 Stack trace: #0 /htdocs/wp-content/plugins/facebook-for-woocommerce/class-wc-facebookcommerce.php(132): WC_Facebookcommerce->init() #1 /htdocs/wp-content/plugins/facebook-for-woocommerce/class-wc-facebookcommerce.php(813): WC_Facebookcommerce->__construct() #2 /htdocs/wp-content/plugins/facebook-for-woocommerce/class-wc-facebookcommerce.php(857): WC_Facebookcommerce::instance() #3 /htdocs/wp-content/plugins/facebook-for-woocommerce/facebook-for-woocommerce.php(142): facebook_for_woocommerce() #4 /htdocs/wp-includes/class-wp-hook.php(324): WC_Facebook_Loader->init_plugin('') #5 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #6 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #7 /htdocs/wp-settings.php(555): do_action('plugins_loaded') #8 /htdocs/wp-config.php(93): require_once('/htdocs/wp-sett...') #9 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #10 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #11 /htdocs/index.php(17): require('/htdocs/wp-blog...') #12 {main} thrown in /htdocs/wp-content/plugins/facebook-for-woocommerce/class-wc-facebookcommerce.php on line 194