function openDeleteConvertedFilesPopup() { var html = ''; html += '

To delete all converted files, click this button:
'; html += ''; html += '

'; html += '

Or perhaps, you only want to delete the converted PNGs? Then this button is for you:
'; html += ''; html += '

'; document.getElementById('purgecachecontent').innerHTML = html; tb_show('Purge cache', '#TB_inline?inlineId=purgecachepopup'); // purgeCache(); } function purgeCache(onlyPng) { var data = { 'action': 'webpexpress_purge_cache', 'nonce' : window.webpExpress['ajax-nonces']['purge-cache'], 'only-png': onlyPng }; jQuery.post(ajaxurl, data, function(response) { if ((typeof response == 'object') && (response['success'] == false)) { if (response['data'] && ((typeof response['data']) == 'string')) { alert(response['data']); } else { alert('Something failed'); } return; } var result = JSON.parse(response); //console.log(result); if (result['fail-count'] == 0) { if (result['delete-count'] == 0) { alert('No webp files were found, so none was deleted.'); } else { alert('Successfully deleted ' + result['delete-count'] + ' webp files'); } } else { if (result['delete-count'] == 0) { alert('Failed deleting ' + result['fail-count'] + ' webp files. None was deleted, in fact.'); } else { alert('Deleted ' + result['delete-count'] + ' webp files. However, failed deleting ' + result['fail-count'] + ' webp files.'); } } }); }