diff --git a/class-plugin-report.php b/class-plugin-report.php index 97ff085..6b8791a 100644 --- a/class-plugin-report.php +++ b/class-plugin-report.php @@ -180,6 +180,8 @@ public function enqueue_assets( $hook ) { 'export_btn' => __( 'Export .csv file', 'plugin-report' ), 'plugin_url_header' => __( 'Plugin URL', 'plugin-report' ), 'author_url_header' => __( 'Author URL', 'plugin-report' ), + 'ajax_error' => __( 'Error fetching plugin info.', 'plugin-report' ), + 'cols_per_row' => self::COLS_PER_ROW, ); wp_localize_script( 'plugin-report-js', 'plugin_report_vars', $vars ); // Enqueue admin CSS file. diff --git a/js/plugin-report.js b/js/plugin-report.js index bf41640..a8d5b60 100644 --- a/js/plugin-report.js +++ b/js/plugin-report.js @@ -58,7 +58,19 @@ jQuery(document).ready( function( $ ){ $('#plugin-report-table .plugin-report-row-temp-' + slug ).replaceWith( response.html ); // on to the next... rtpr_process_next_plugin(); - }, 'json' ); + }, 'json' ).fail( function() { + rtpr_replace_with_error( slug ); + rtpr_process_next_plugin(); + } ); + } + + + function rtpr_replace_with_error( slug ){ + const cols = plugin_report_vars.cols_per_row || 9; + const msg = plugin_report_vars.ajax_error || 'Error'; + $('#plugin-report-table .plugin-report-row-temp-' + slug ).replaceWith( + '' + msg + '' + ); } // kick things off