Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions js/plugin-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,28 @@ jQuery(document).ready( function( $ ){
};

jQuery.post( ajaxurl, data, function(response) {
// parse the response
const obj = JSON.parse(response);
// replace the temporary table row with the new data
$('#plugin-report-table .plugin-report-row-temp-' + slug ).replaceWith( obj.html );
// on to the next...
try {
const obj = JSON.parse(response);
$('#plugin-report-table .plugin-report-row-temp-' + slug ).replaceWith( obj.html );
} catch (e) {
rtpr_replace_with_error( slug );
}
rtpr_process_next_plugin();
}).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(
'<tr class="pluginreport-row-error"><td colspan="' + cols + '">' + msg + '</td></tr>'
);
}

// kick things off
rtpr_process_next_plugin();

Expand Down
2 changes: 2 additions & 0 deletions rt-plugin-report.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,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.
Expand Down
Loading