Мне нужно создать файл JSON, чтобы сохранить в нем список. Этот код должен находиться внутри файла Wordpress functions.php. Как я могу это сделать?
function ProgramarBorrado(){
?>
<script type="text/javascript">
var day = (new Date).getDate(); //Get today
var month = (new Date).getMonth()+1; //Get this month
var year = (new Date).getFullYear(); //Get this year
var lista = [];
if ((day == 1) && (month == 4) && (year==2019)) { //Push ID on a list
lista.push('#borrar22marc');
}
if ((day == 6) && (month == 4) && (year==2019)) {
lista.push('#borrar6abril');
}
if ((day == 5) && (month == 5) && (year==2019)) {
lista.push('#borrar5maig');
}
if ((day == 19) && (month == 5) && (year==2019)) {
lista.push('#borrar19maig');
}
if ((day == 8) && (month == 6) && (year==2019)) {
lista.push('#borrar8juny');
}
if ((day == 10) && (month == 8) && (year==2019)) {
lista.push('#borrar10agost');
}
lista.forEach(function(element) {
jQuery(element).addClass('borrar-programado');// For each element on the list add a class on the ID
});
</script>
<?php
}
add_action('wp_footer', 'ProgramarBorrado');
код должен быть похож на этот. Сохраните переменную "lista" в файле JSON