[Support request] edit function.php

Home Forums Support edit function.php

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #937051
    Criativy

    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
    } );

    #937117
    David
    Staff
    Customer Support

    Hi there,

    i did reply directly to your email – this article explains how to add PHP:

    https://docs.generatepress.com/article/adding-php/

    The Code Snippets plugin that the article mentions is the easiest method.

    If you wish to use a child theme then you can read about that here:

    https://docs.generatepress.com/article/using-child-theme/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.