| 1 |
/** |
| 2 |
* This file is enqueued from admin/class-plugin-notes-plus-admin.php |
| 3 |
* on the update-core.php page only. |
| 4 |
*/ |
| 5 |
|
| 6 |
(function($) { |
| 7 |
$(document).ready(function () { |
| 8 |
|
| 9 |
$('#update-plugins-table thead tr, #update-plugins-table tfoot tr').append( '<td id="pnp_plugin_notes_col">'+ labels.col_title +'</td>' ); |
| 10 |
|
| 11 |
var notes_for_plugin_updates = $.parseJSON(updates); |
| 12 |
|
| 13 |
var i = 0; |
| 14 |
|
| 15 |
$('#update-plugins-table .plugins tr').each(function() { |
| 16 |
|
| 17 |
var plugin_notes = notes_for_plugin_updates[i]; |
| 18 |
|
| 19 |
if (plugin_notes === undefined || plugin_notes.length === 0) { |
| 20 |
|
| 21 |
$(this).append( '<td>'+ labels.no_note +'</td>' ); |
| 22 |
|
| 23 |
} else { |
| 24 |
|
| 25 |
var values = Object.values(plugin_notes); |
| 26 |
|
| 27 |
var noteMarkup = '<div class="pnp-wrapper">'; |
| 28 |
|
| 29 |
for (const value of values) { |
| 30 |
|
| 31 |
// Convert time to readable format |
| 32 |
var d = new Date(value.time * 1000); |
| 33 |
var month = ("0" + (d.getMonth() + 1)).slice(-2); |
| 34 |
var date = ("0" + d.getDate()).slice(-2); |
| 35 |
var year = d.getFullYear(); |
| 36 |
var formattedDate = year + '-' + month + '-' + date; |
| 37 |
|
| 38 |
noteMarkup += '<div class="pnp-plugin-note">'; |
| 39 |
noteMarkup += '<span class="dashicons '+ value.icon +'"></span>'; |
| 40 |
noteMarkup += value.note; |
| 41 |
noteMarkup += '<p class="pnp-note-meta">'+ value.user +' | <span class="pnp-note-time">'+ formattedDate +'</span></p>'; |
| 42 |
noteMarkup += '</div>'; |
| 43 |
|
| 44 |
} |
| 45 |
noteMarkup += '</div>'; |
| 46 |
|
| 47 |
$(this).append( '<td>'+ noteMarkup +'</td>' ); |
| 48 |
} |
| 49 |
|
| 50 |
i++; |
| 51 |
}); |
| 52 |
|
| 53 |
// Add target="_blank" to all links |
| 54 |
$('.pnp-plugin-note a').each(function(){ |
| 55 |
$(this).attr( 'target', '_blank' ); |
| 56 |
}); |
| 57 |
|
| 58 |
}); |
| 59 |
})(jQuery); |