Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
Conditional filter of Json Data for Javascript booking Calendar

I have a Javascript function that enables dates to be blocked out from a WP Forms (Wordpress Plugin) Calendar. The data is taken from a JSon feed of artists and events.

Currently the function is blocking out dates from all artists in the feed. However, I would like to create a filter to select the date information by the artist - ( "artist" in the Json feed).

So, in effect, I would have a different script for each artist.

The working script is below and the booking form is here - https://www.jonnyrossmusic.com/booking-calendar-test-date-picker/


function wpf_limit_date_picker() {
  
$json = file_get_contents('https://feeds.overturehq.com/feeds/76682d6d/0/208/bookings.json');
$events = json_decode($json, true);
$dates = array();
        
foreach ($events as $event) {
    if (isset($event['date'])) {
             // Assign end date if it exists otherwise set end date as start date
            $end_date = !empty($event['endDate']) ? $event['endDate'] : $event['date'];
              
               // Add date range to date array
             $dates[] = array(
                 "from" => $event['date'],
                     "to" => $end_date,
                );       
        }
}

    ?>
    <script type="text/javascript">
        var d = new Date();
        window.wpforms_70442_4 = window.wpforms_70442_4 || {};
        window.wpforms_70442_4.datepicker = {
            disableMobile: true,
            // Don't allow users to pick specific range of dates
            disable: <?php echo json_encode($dates); ?>
        }
    </script>
    

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda