waitCodevz(() => {

	// Post views count.
	document.querySelectorAll('.xtra-post-views').forEach(el => {
		const url = document.body.dataset.ajax || window.ajaxurl;

		const params = new URLSearchParams({
			action: 'codevz_ajax_post_views',
			id: el.getAttribute('data-id'),
			nonce: el.getAttribute('data-nonce')
		});

		fetch(`${url}?${params.toString()}`)
		.then(response => {
			if (!response.ok) {
				throw new Error('Network response was not ok');
				return response.text();
			}
		})
		.then(data => {
            // Success: Post views count worked
		})
		.catch(error => console.error('Error:', error));
	});

});