Automattic\WooCommerce\Blueprint\ResourceStorages

OrgPluginResourceStorage::get_download_linkprotectedWC 1.0

Get the download link for a plugin from wordpress.org.

Method of the class: OrgPluginResourceStorage{}

No Hooks.

Returns

String|null. The download link, or null if not found.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_download_link( $slug ): ?string;
$slug(string) (required)
The slug of the plugin.

OrgPluginResourceStorage::get_download_link() code WC 9.9.5

protected function get_download_link( $slug ): ?string {
	$info = $this->wp_plugins_api(
		'plugin_information',
		array(
			'slug'   => $slug,
			'fields' => array(
				'sections' => false,
			),
		)
	);

	if ( is_wp_error( $info ) ) {
		return null;
	}

	if ( is_object( $info ) && isset( $info->download_link ) ) {
		return $info->download_link;
	}

	return null;
}