Skip to content

Commit d9cc216

Browse files
committed
Safeguard against empty plugins data
1 parent 66d712e commit d9cc216

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

classes/models/FrmAddon.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,21 @@ public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
195195

196196
$item_id = $this->download_id;
197197

198-
if ( ! $item_id ) {
198+
if ( $item_id ) {
199+
$api = new FrmFormApi( $this->license );
200+
201+
// Force new API info so we can pull changelog data.
202+
// Change log data is intentionally omitted from the cached API response
203+
// to help reduce the size of the autoloaded option.
204+
$api->force_api_request();
205+
$plugins = $api->get_api_info();
206+
207+
if ( $plugins ) {
208+
$_data = $plugins[ $item_id ];
209+
}
210+
}
211+
212+
if ( empty( $plugins ) ) {
199213
$_data = array(
200214
'name' => $this->plugin_name,
201215
'excerpt' => '',
@@ -205,15 +219,6 @@ public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
205219
'low' => 'https://ps.w.org/formidable/assets/banner-1544x500.png',
206220
),
207221
);
208-
} else {
209-
$api = new FrmFormApi( $this->license );
210-
211-
// Force new API info so we can pull changelog data.
212-
// Change log data is intentionally omitted from the cached API response
213-
// to help reduce the size of the autoloaded option.
214-
$api->force_api_request();
215-
$plugins = $api->get_api_info();
216-
$_data = $plugins[ $item_id ];
217222
}
218223

219224
$_data['sections'] = array(

0 commit comments

Comments
 (0)