lete( WC_Product $product, string $attribute_id ) { $this->validate( $product, $attribute_id ); $product->delete_meta_data( $this->prefix_meta_key( $attribute_id ) ); $product->save_meta_data(); } /** * Whether the attribute exists and has been set for the product. * * @param WC_Product $product * @param string $attribute_id * * @return bool * * @since 1.2.0 */ public function exists( WC_Product $product, string $attribute_id ): bool { return $product->meta_exists( $this->prefix_meta_key( $attribute_id ) ); } /** * Returns an array of attribute types for the given product * * @param WC_Product $product * * @return string[] of attribute classes mapped to attribute IDs */ public function get_attribute_types_for_product( WC_Product $product ): array { return $this->get_attribute_types_for_product_types( [ $product->get_type() ] ); } /** * Returns an array of attribute types for the given product types * * @param string[] $product_types array of WooCommerce product types * * @return string[] of attribute classes mapped to attribute IDs */ public function get_attribute_types_for_product_types( array $product_types ): array { // flip the product types array to have them as array keys $product_types_keys = array_flip( $product_types ); // intersect the product types with our stored attributes map to get arrays of attributes matching the given product types $match_attributes = array_intersect_key( $this->get_attribute_types_map(), $product_types_keys ); // re-index the attributes map array to avoid string ($product_type) array keys $match_attributes = array_values( $match_attributes ); if ( empty( $match_attributes ) ) { return []; } // merge all of the attribute arrays from the map (there might be duplicates) and return the results return array_merge( ...$match_attributes ); } /** * Returns all available attribute IDs. * * @return array * * @since 1.3.0 */ public static function get_available_attribute_ids(): array { $attributes = []; foreach ( self::get_available_attribute_types() as $attribute_type ) { if ( method_exists( $attribute_type, 'get_id' ) ) { $attribute_id = call_user_func( [ $attribute_type, 'get_id' ] ); $attributes[ $attribute_id ] = $attribute_id; } } return $attributes; } /** * Return an array of all available attribute class names. * * @return string[] Attribute class names * * @since 1.3.0 */ public static function get_available_attribute_types(): array { /** * Filters the list of available product attributes. * * @param string[] $attributes Array of attribute class names (FQN) */ return apply_filters( 'woocommerce_gla_product_attribute_types', self::ATTRIBUTES ); } /** * Returns an array of attribute types for all product types * * @return string[][] of attribute classes mapped to product types */ protected function get_attribute_types_map(): array { if ( ! isset( $this->attribute_types_map ) ) { $this->map_attribute_types(); } return $this->attribute_types_map; } /** * @param WC_Product $product * @param string $attribute_id * * @throws InvalidValue If the attribute type is invalid for the given product. */ protected function validate( WC_Product $product, string $attribute_id ) { $attribute_types = $this->get_attribute_types_for_product( $product ); if ( ! isset( $attribute_types[ $attribute_id ] ) ) { do_action( 'woocommerce_gla_error', sprintf( 'Attribute "%s" is not supported for a "%s" product (ID: %s).', $attribute_id, $product->get_type(), $product->get_id() ), __METHOD__ ); throw InvalidValue::not_in_allowed_list( 'attribute_id', array_keys( $attribute_types ) ); } } /** * @throws InvalidClass If any of the given attribute classes do not implement the AttributeInterface. */ protected function map_attribute_types(): void { $this->attribute_types_map = []; foreach ( self::get_available_attribute_types() as $attribute_type ) { $this->validate_interface( $attribute_type, AttributeInterface::class ); $attribute_id = call_user_func( [ $attribute_type, 'get_id' ] ); $applicable_types = call_user_func( [ $attribute_type, 'get_applicable_product_types' ] ); /** * Filters the list of applicable product types for each attribute. * * @param string[] $applicable_types Array of WooCommerce product types * @param string $attribute_type Attribute class name (FQN) */ $applicable_types = apply_filters( "woocommerce_gla_attribute_applicable_product_types_{$attribute_id}", $applicable_types, $attribute_type ); foreach ( $applicable_types as $product_type ) { $this->attribute_types_map[ $product_type ] = $this->attribute_types_map[ $product_type ] ?? []; $this->attribute_types_map[ $product_type ][ $attribute_id ] = $attribute_type; } } } }
Warning: class_implements(): Class Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes\AttributeManager does not exist and could not be loaded in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 119

Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, bool given in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php:120 Stack trace: #0 /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php(120): array_key_exists('Automattic\\WooC...', false) #1 /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/CoreServiceProvider.php(323): Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement\AbstractServiceProvider->conditionally_share_with_tags('Automattic\\WooC...') #2 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/ServiceProvider/ServiceProviderAggregate.php(102): Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement\CoreServiceProvider->register() #3 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(172): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\ServiceProvider\ServiceProviderAggregate->register('Automattic\\WooC...') #4 /htdocs/wp-content/plugins/google-listings-and-ads/src/Container.php(90): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->get('Automattic\\WooC...') #5 /htdocs/wp-content/plugins/google-listings-and-ads/src/Infrastructure/GoogleListingsAndAdsPlugin.php(130): Automattic\WooCommerce\GoogleListingsAndAds\Container->get('Automattic\\WooC...') #6 /htdocs/wp-content/plugins/google-listings-and-ads/src/Infrastructure/GoogleListingsAndAdsPlugin.php(91): Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\GoogleListingsAndAdsPlugin->maybe_register_services() #7 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\GoogleListingsAndAdsPlugin->Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\{closure}('') #8 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #9 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #10 /htdocs/wp-settings.php(559): do_action('plugins_loaded') #11 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #12 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #13 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #14 /htdocs/index.php(17): require('/htdocs/wp-blog...') #15 {main} thrown in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 120