| @@ -63,10 +63,8 @@ | ||
| 63 | 63 | * @param $id |
| 64 | 64 | * @param array $options |
| 65 | 65 | * |
| 66 | 66 | * @return array|null |
| 67 | - * | |
| 68 | - * @throws WP_Error_Exception If kit is not found. | |
| 69 | 67 | */ |
| 70 | 68 | public function find( $id, $options = [] ) { |
| 71 | 69 | $options = wp_parse_args( $options, [ |
| 72 | 70 | 'manifest_included' => true, |
| @@ -86,9 +84,9 @@ | ||
| 86 | 84 | if ( $options['manifest_included'] ) { |
| 87 | 85 | $manifest = $this->api->get_manifest( $id ); |
| 88 | 86 | |
| 89 | 87 | if ( is_wp_error( $manifest ) ) { |
| 90 | - throw new WP_Error_Exception( esc_html( $manifest ) ); | |
| 88 | + throw new WP_Error_Exception( $manifest ); | |
| 91 | 89 | } |
| 92 | 90 | } |
| 93 | 91 | |
| 94 | 92 | return $this->transform_kit_api_response( $item, $manifest ); |
| @@ -124,16 +122,14 @@ | ||
| 124 | 122 | /** |
| 125 | 123 | * @param $id |
| 126 | 124 | * |
| 127 | 125 | * @return array |
| 128 | - * | |
| 129 | - * @throws WP_Error_Exception If download link retrieval fails or API errors occur. | |
| 130 | 126 | */ |
| 131 | 127 | public function get_download_link( $id ) { |
| 132 | 128 | $response = $this->api->download_link( $id ); |
| 133 | 129 | |
| 134 | 130 | if ( is_wp_error( $response ) ) { |
| 135 | - throw new WP_Error_Exception( esc_html( $response ) ); | |
| 131 | + throw new WP_Error_Exception( $response ); | |
| 136 | 132 | } |
| 137 | 133 | |
| 138 | 134 | return [ 'download_link' => $response->download_link ]; |
| 139 | 135 | } |
| @@ -141,10 +137,9 @@ | ||
| 141 | 137 | /** |
| 142 | 138 | * @param $id |
| 143 | 139 | * |
| 144 | 140 | * @return array |
| 145 | - * | |
| 146 | - * @throws Error_404 If kit is not found. | |
| 141 | + * @throws \Exception | |
| 147 | 142 | */ |
| 148 | 143 | public function add_to_favorites( $id ) { |
| 149 | 144 | $kit = $this->find( $id, [ 'manifest_included' => false ] ); |
| 150 | 145 | |
| @@ -162,10 +157,9 @@ | ||
| 162 | 157 | /** |
| 163 | 158 | * @param $id |
| 164 | 159 | * |
| 165 | 160 | * @return array |
| 166 | - * | |
| 167 | - * @throws Error_404 If kit is not found. | |
| 161 | + * @throws \Exception | |
| 168 | 162 | */ |
| 169 | 163 | public function remove_from_favorites( $id ) { |
| 170 | 164 | $kit = $this->find( $id, [ 'manifest_included' => false ] ); |
| 171 | 165 | |
| @@ -183,10 +177,8 @@ | ||
| 183 | 177 | /** |
| 184 | 178 | * @param bool $force_api_request |
| 185 | 179 | * |
| 186 | 180 | * @return Collection |
| 187 | - * | |
| 188 | - * @throws WP_Error_Exception If kits data retrieval fails. | |
| 189 | 181 | */ |
| 190 | 182 | private function get_kits_data( $force_api_request = false ) { |
| 191 | 183 | $data = get_transient( static::KITS_CACHE_KEY ); |
| 192 | 184 | |
| @@ -211,9 +203,9 @@ | ||
| 211 | 203 | |
| 212 | 204 | $data = $this->api->get_all( $args ); |
| 213 | 205 | |
| 214 | 206 | if ( is_wp_error( $data ) ) { |
| 215 | - throw new WP_Error_Exception( esc_html( $data ) ); | |
| 207 | + throw new WP_Error_Exception( $data ); | |
| 216 | 208 | } |
| 217 | 209 | |
| 218 | 210 | set_transient( static::KITS_CACHE_KEY, $data, static::KITS_CACHE_TTL_HOURS * HOUR_IN_SECONDS ); |
| 219 | 211 | } |
| @@ -224,10 +216,8 @@ | ||
| 224 | 216 | /** |
| 225 | 217 | * @param bool $force_api_request |
| 226 | 218 | * |
| 227 | 219 | * @return Collection |
| 228 | - * | |
| 229 | - * @throws WP_Error_Exception If taxonomies data retrieval fails. | |
| 230 | 220 | */ |
| 231 | 221 | private function get_taxonomies_data( $force_api_request = false ) { |
| 232 | 222 | $data = get_transient( static::KITS_TAXONOMIES_CACHE_KEY ); |
| 233 | 223 | |
| @@ -234,9 +224,9 @@ | ||
| 234 | 224 | if ( ! $data || $force_api_request ) { |
| 235 | 225 | $data = $this->api->get_taxonomies(); |
| 236 | 226 | |
| 237 | 227 | if ( is_wp_error( $data ) ) { |
| 238 | - throw new WP_Error_Exception( esc_html( $data ) ); | |
| 228 | + throw new WP_Error_Exception( $data ); | |
| 239 | 229 | } |
| 240 | 230 | |
| 241 | 231 | set_transient( static::KITS_TAXONOMIES_CACHE_KEY, $data, static::KITS_TAXONOMIES_CACHE_TTL_HOURS * HOUR_IN_SECONDS ); |
| 242 | 232 | } |
| @@ -285,8 +275,9 @@ | ||
| 285 | 275 | 'featured_index' => isset( $kit->featured_index ) ? $kit->featured_index : 0, |
| 286 | 276 | 'popularity_index' => isset( $kit->popularity_index ) ? $kit->popularity_index : 0, |
| 287 | 277 | 'created_at' => isset( $kit->created_at ) ? $kit->created_at : null, |
| 288 | 278 | 'updated_at' => isset( $kit->updated_at ) ? $kit->updated_at : null, |
| 279 | + // | |
| 289 | 280 | ], |
| 290 | 281 | $manifest ? $this->transform_manifest_api_response( $manifest ) : [] |
| 291 | 282 | ); |
| 292 | 283 | } |