Atenção!

Este artigo contém código PHP 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_datetime_time_intervals filter is used to add additional time intervals available for the Time field Invervals dropdown.

Parâmetros

$intervals
(array) Array of time intervals for the Time field Invervals dropdown.

Fonte

wpforms/pro/includes/fields/class-date-time.php

Mais Informações

The filter is used to choose the time intervals for the Time field dropdown. It will utilize the time intervals in minutes. For example, if you want to add 2 hours, you would need to make the $intervals[ '120' ].

Exemplos

/*
 * Time intervals available for the Time field dropdown.
 *
 * @link https://wpforms.com/developers/wpforms_datetime_time_intervals/
 *
 * @param   array   $intervals   Used to determine the time intervals.
 * @return  array
*/

function wpf_dev_datetime_time_intervals( $intervals ) {
       
     // Add time interval
     $intervals[ '5' ] = esc_html__( '5 minutes', 'wpforms' );
     $intervals[ '120' ] = esc_html__( '2 hours', 'wpforms' );

     ksort( $intervals );
   
     return $intervals;
}

add_filter( 'wpforms_datetime_time_intervals' , 'wpf_dev_datetime_time_intervals', 1 );

Artigos de Referência

How to Create Additional Intervals for the Date Time Field Time Picker