1jQuery(function ($) { 2 3 $(document).on('click', '.load-more', function () { 4 const button = $(this); 5 let page = parseInt(button.data('page')) + 1; 6 const max = parseInt(button.data('max')); 7 8 // Recupera gli ID già caricati dal bottone (come stringa o array) 9 let loaded_ids = []; 10 const stored_ids = button.attr('data-loaded-ids'); 11 if (stored_ids) { 12 try { 13 loaded_ids = JSON.parse(stored_ids); 14 } catch(e) { 15 // Se non è JSON, prova come stringa separata da virgole 16 loaded_ids = stored_ids.split(',').map(id => parseInt(id.trim())).filter(id => !isNaN(id)); 17 } 18 } 19 20 $.ajax({ 21 url: loadmore_params.ajaxurl, 22 type: 'POST', 23 data: { 24 action: 'load_more_posts', 25 post_type: button.data('post-type'), 26 taxonomy: button.data('taxonomy'), 27 term: button.data('term'), 28 country: button.data('country'), 29 loaded_ids: loaded_ids, 30 page: page, 31 }, 32 beforeSend: function () { 33 button.text('Loading...'); 34 }, 35 success: function (response) { 36 if (response) { 37 button.closest('.tab-pane').find('.posts-wrapper').append(response); 38 39 // Estrai gli ID dai nuovi post (cerca attributi data-post-id o simili) 40 const $response = $(response); 41 const new_ids = []; 42 43 $response.each(function() { 44 const post_id = $(this).data('post-id') || $(this).attr('data-post-id') || $(this).find('[data-post-id]').first().data('post-id'); 45 if (post_id) { 46 new_ids.push(parseInt(post_id)); 47 } 48 }); 49 50 // Aggiungi i nuovi ID a quelli già caricati 51 loaded_ids = loaded_ids.concat(new_ids); 52 button.attr('data-loaded-ids', JSON.stringify(loaded_ids)); 53 54 button.data('page', page); 55 56 if (page >= max) { 57 button.remove(); 58 } else { 59 button.text('Load more'); 60 } 61 62 console.log(response); 63 } else { 64 button.remove(); 65 } 66 } 67 }); 68 }); 69});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.