Atenção!

Este artigo contém código PHP e JavaScript e destina-se a desenvolvedores. Oferecemos este código como uma cortesia, mas não fornecemos suporte para personalizações de código ou desenvolvimento de terceiros.

Para orientação extra, consulte o tutorial do WPBeginner sobre como adicionar código personalizado.

Dispensar

Descrição

The wpforms_form_pages_footer action is triggered at the end of the page load for the template used for the Form Pages addon.

Parâmetros

Esta ação não aceita nenhum parâmetro.

Mais Informações

This action works much like the standard WordPress wp_footer action. It will run at the end of the page load, but specifically for the wpforms_form_pages_footer action, it will only fire on the form page template.

This is especially useful if you have any custom JavaScript for the template used with the Form Page addon.

Fonte

wpforms-form-pages/src/Frontend.php

Exemplos

The example below will show you how to disable past times from a time picker inside your Form Pages form.

/**
 * Action to be called once Form Page has completely loaded
 *
 * @link https://wpforms.com/developers/wpforms_form_pages_footer/
 */
  
function wpf_dev_form_pages_script() {
    ?>
 
       <script type="text/javascript">
  
      // Find out the current time
      var now = new Date();
  
      // Take that current time and round it up so we have an even number on the interval
      now.setHours( now.getHours() + Math.round(date.getMinutes()/90) );
         
      // Run only on form ID 999 field ID 8
      window.wpforms_999_8 = window.wpforms_999_8 || {};
      window.wpforms_999_8.timepicker = {
         forceRoundTime: true,
  
         // Disable any times that have passed already and return the new time selections
         minTime: now.toLocaleTimeString()
      };
  
  
   </script>
 
    <?php
}
add_action( 'wpforms_form_pages_footer', 'wpf_dev_form_pages_script', 30 );

Article Reference: How to Add JavaScript to a Page When Using the Form Pages Addon