Attention !

Cet article contient du code PHP et est destiné aux développeurs. Nous fournissons ce code à titre de courtoisie, mais nous n'offrons pas de support pour les personnalisations de code ou le développement tiers.

Pour obtenir de l'aide supplémentaire, veuillez consulter le tutoriel de WPBeginner sur l'ajout de code personnalisé.

Ignorer

Description

The wpforms_datetime_time_intervals filter is used to add additional time intervals available for the Time field Invervals dropdown.

Paramètres

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

Source

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

Plus d'informations

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' ].

Exemples

/*
 * 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 );

Articles de référence

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