Automattic\WooCommerce\Internal\Admin\Settings
PaymentProviders::enhance_extension_suggestion
Enhance a payment extension suggestion with additional information.
Method of the class: PaymentProviders{}
No Hooks.
Returns
Array
. The enhanced payment extension suggestion.
Usage
// private - for code of main (parent) class only $result = $this->enhance_extension_suggestion( $extension ): array;
- $extension(array) (required)
- The extension suggestion.
PaymentProviders::enhance_extension_suggestion() PaymentProviders::enhance extension suggestion code WC 9.9.4
private function enhance_extension_suggestion( array $extension ): array { // Determine the category of the extension. switch ( $extension['_type'] ) { case ExtensionSuggestions::TYPE_PSP: $extension['category'] = self::CATEGORY_PSP; break; case ExtensionSuggestions::TYPE_EXPRESS_CHECKOUT: $extension['category'] = self::CATEGORY_EXPRESS_CHECKOUT; break; case ExtensionSuggestions::TYPE_BNPL: $extension['category'] = self::CATEGORY_BNPL; break; case ExtensionSuggestions::TYPE_CRYPTO: $extension['category'] = self::CATEGORY_CRYPTO; break; default: $extension['category'] = ''; break; } // Determine the PES's plugin status. // Default to not installed. $extension['plugin']['status'] = self::EXTENSION_NOT_INSTALLED; // Put in the default plugin file. $extension['plugin']['file'] = ''; if ( ! empty( $extension['plugin']['slug'] ) ) { // This is a best-effort approach, as the plugin might be sitting under a directory (slug) that we can't handle. // Always try the official plugin slug first, then the testing variations. $plugin_slug_variations = Utils::generate_testing_plugin_slugs( $extension['plugin']['slug'], true ); foreach ( $plugin_slug_variations as $plugin_slug ) { if ( PluginsHelper::is_plugin_installed( $plugin_slug ) ) { // Make sure we put in the actual slug and file path that we found. $extension['plugin']['slug'] = $plugin_slug; $extension['plugin']['file'] = PluginsHelper::get_plugin_path_from_slug( $plugin_slug ); // Sanity check. if ( ! is_string( $extension['plugin']['file'] ) ) { $extension['plugin']['file'] = ''; } // Remove the .php extension from the file path. The WP API expects it without it. $extension['plugin']['file'] = Utils::trim_php_file_extension( $extension['plugin']['file'] ); $extension['plugin']['status'] = self::EXTENSION_INSTALLED; if ( PluginsHelper::is_plugin_active( $plugin_slug ) ) { $extension['plugin']['status'] = self::EXTENSION_ACTIVE; } break; } } } // Finally, allow the extension suggestion's matching provider to add further details. $gateway_provider = $this->get_payment_extension_suggestion_provider_instance( $extension['id'] ); $extension = $gateway_provider->enhance_extension_suggestion( $extension ); return $extension; }