Removing views from the dropdown list

This JavaScript snippet will remove any views listed in the removableViews constant from the dropdown list on the front-end. It should be added on the page where the calendar is displayed via the WordPress editor or a snippet plugin.

var ready = (callback) => {
	if (document.readyState != "loading") callback();
	else document.addEventListener("DOMContentLoaded", callback);
}

ready(() => { 
	const removableViews = ['dayGridMonth', 'listMonth', 'timeGridWeek'];
	let options = document.querySelectorAll('.piecal-controls__view-chooser option');
	for( let option of options ) {
		if( removableViews.includes( option.getAttribute( 'value' ) ) ) option.remove();
	}
});
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.