LocalPluginResourceStorage.php
1 year ago
LocalThemeResourceStorage.php
1 year ago
OrgPluginResourceStorage.php
1 year ago
OrgThemeResourceStorage.php
1 year ago
ResourceStorage.php
1 year ago
OrgThemeResourceStorage.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Blueprint\ResourceStorages; |
| 4 | |
| 5 | /** |
| 6 | * Class OrgThemeResourceStorage |
| 7 | */ |
| 8 | class OrgThemeResourceStorage extends OrgPluginResourceStorage { |
| 9 | /** |
| 10 | * Get the download link. |
| 11 | * |
| 12 | * @param string $slug The slug of the theme to be downloaded. |
| 13 | * |
| 14 | * @return string|null The download link. |
| 15 | */ |
| 16 | protected function get_download_link( $slug ): ?string { |
| 17 | $info = $this->wp_themes_api( |
| 18 | 'theme_information', |
| 19 | array( |
| 20 | 'slug' => $slug, |
| 21 | 'fields' => array( |
| 22 | 'sections' => false, |
| 23 | ), |
| 24 | ) |
| 25 | ); |
| 26 | |
| 27 | if ( is_wp_error( $info ) ) { |
| 28 | return null; |
| 29 | } |
| 30 | |
| 31 | if ( isset( $info->download_link ) ) { |
| 32 | return $info->download_link; |
| 33 | } |
| 34 | |
| 35 | return null; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Get the supported resource. |
| 40 | * |
| 41 | * @return string The supported resource. |
| 42 | */ |
| 43 | public function get_supported_resource(): string { |
| 44 | return 'wordpress.org/themes'; |
| 45 | } |
| 46 | } |
| 47 |