Site logo

Archived topic

edit function.php

1 reply · Started by Criativy on June 21, 2019

Viewing posts 1–2 of 2

Gentlemen, good morning ...

I'm using google translate to communicate, I hope my request for help is clear.

I am not a programmer and so little code entry, but in Internet search I found the code below that allows the calendar to be translated into the format and language of my country that is Brazil. I've already performed the test by pasting this function's generate.php code, however when the code is updated and deleted.
I would like to know if there is any way this code will not be deleted when the theme is updated.
I use the Elementor ...
This code needs to be edited so that the page where the calendar to be translated is informed.

Here's the code:
add_action('wp_footer', function () {
if ( ! is_page( 1024 ) ) {
return;
}
?>
<script>
jQuery( document ).ready( function( $ ){
function waitForFlatpicker( callback ) {
if ( typeof window.flatpickr !== 'function' ) {
setTimeout( function() { waitForFlatpicker( callback ) }, 2 );
}
callback();
}
waitForFlatpicker( function(){
flatpickr.l10ns.pt = {
weekdays: {
shorthand: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"],
longhand: [
"Domingo",
"Segunda-feira",
"Terça-feira",
"Quarta-feira",
"Quinta-feira",
"Sexta-feira",
"Sábado",
],
},
months: {
shorthand: [
"Jan",
"Fev",
"Mar",
"Abr",
"Mai",
"Jun",
"Jul",
"Ago",
"Set",
"Out",
"Nov",
"Dez",
],
longhand: [
"Janeiro",
"Fevereiro",
"Março",
"Abril",
"Maio",
"Junho",
"Julho",
"Agosto",
"Setembro",
"Outubro",
"Novembro",
"Dezembro",
],
},
rangeSeparator: " até ",
};
//set translations
flatpickr.localize(flatpickr.l10ns.pt);
flatpickr('.elementor-date-field');
//set format
setTimeout( function(){
$('.elementor-date-field').each(function(){ flatpickr( $(this)[0] ).set('dateFormat', 'd/m/Y');});
}, 1000 );
});
});
</script>
<?php
} );

This archived topic is closed to new replies.