Automattic\WooCommerce\Internal\Admin\Suggestions

PaymentExtensionSuggestions::get_by_plugin_slug()publicWC 1.0

Get the base details of a payment extension by its plugin slug.

If there are multiple extensions with the same plugin slug, the first one found will be returned.

Метод класса: PaymentExtensionSuggestions{}

Хуков нет.

Возвращает

Массив|null. The extension details for the given plugin slug. Null if not found.

Использование

$PaymentExtensionSuggestions = new PaymentExtensionSuggestions();
$PaymentExtensionSuggestions->get_by_plugin_slug( $plugin_slug, $country_code, $context ): ?array;
$plugin_slug(строка) (обязательный)
The plugin slug.
$country_code(строка)
The two-letter country code for which the extension suggestion should be retrieved.
По умолчанию: ''
$context(строка)
The context ID of where this extension suggestion is being used.
По умолчанию: ''

Код PaymentExtensionSuggestions::get_by_plugin_slug() WC 9.6.0

public function get_by_plugin_slug( string $plugin_slug, string $country_code = '', string $context = '' ): ?array {
	$plugin_slug = sanitize_title( $plugin_slug );

	// If we have a country code, try to find a fully localized extension suggestion.
	if ( ! empty( $country_code ) ) {
		$extensions = $this->get_country_extensions( $country_code, $context );
		foreach ( $extensions as $extension_details ) {
			if ( isset( $extension_details['plugin']['slug'] ) &&
				$plugin_slug === $extension_details['plugin']['slug']
			) {
				// The extension details are already standardized.
				return $extension_details;
			}
		}
	}

	// Fallback to the base details.
	$extensions = $this->get_all_extensions_base_details();
	foreach ( $extensions as $extension_id => $extension_details ) {
		if ( isset( $extension_details['plugin']['slug'] ) &&
			$plugin_slug === $extension_details['plugin']['slug']
		) {
			$extension_details['id']        = $extension_id;
			$extension_details['_priority'] = 0;

			return $this->standardize_extension_details( $extension_details );
		}
	}

	return null;
}