definition class name. */ private static function log_replaced_reserved_ability( string $ability_name, string $class_name ): void { if ( ! function_exists( 'wc_get_logger' ) ) { return; } wc_get_logger()->warning( 'WooCommerce unregistered a previously registered ability before registering its canonical definition.', array( 'source' => self::LOG_SOURCE, 'ability_name' => $ability_name, 'definition_class' => $class_name, 'reserved_prefix' => 'woocommerce/', ) ); } /** * Check whether an ability definition class is provided by WooCommerce core. * * @param class-string $class_name Ability definition class name. * @return bool */ private static function is_core_ability_definition_class( string $class_name ): bool { return in_array( $class_name, self::CORE_ABILITY_DEFINITION_CLASSES, true ); } /** * Check whether an ability name uses WooCommerce's reserved namespace. * * @param string $ability_name Ability name. * @return bool */ private static function is_reserved_woocommerce_ability_name( string $ability_name ): bool { return 0 === strpos( $ability_name, 'woocommerce/' ); } /** * Get all ability definition classes that should be loaded. * * @return array */ private static function get_ability_definition_classes(): array { /** * Filter WooCommerce ability definition classes. * * Extensions can append autoloadable classes that implement * {@see AbilityDefinition}. The loader will call get_name() and * get_registration_args() on each definition class and register the ability on the * Abilities API init hook. Returning a subset will not unregister core abilities; * core classes are always retained. * * @since 10.9.0 * * @param array $classes Ability definition class names. */ $classes = apply_filters( 'woocommerce_ability_definition_classes', self::CORE_ABILITY_DEFINITION_CLASSES ); if ( ! is_array( $classes ) ) { $classes = array(); } return array_values( array_unique( array_filter( array_merge( self::CORE_ABILITY_DEFINITION_CLASSES, $classes ), 'is_string' ) ) ); } }