wc_parse_relative_date_option()
Parse a relative date option from the settings API into a standard format.
Хуков нет.
Возвращает
Массив. Nicely formatted array with number and unit values.
Использование
wc_parse_relative_date_option( $raw_value );
- $raw_value(разное) (обязательный)
- Value stored in DB.
Список изменений
| С версии 3.4.0 | Введена. |
Код wc_parse_relative_date_option() wc parse relative date option WC 10.8.1
function wc_parse_relative_date_option( $raw_value ) {
$periods = array(
'days' => __( 'Day(s)', 'woocommerce' ),
'weeks' => __( 'Week(s)', 'woocommerce' ),
'months' => __( 'Month(s)', 'woocommerce' ),
'years' => __( 'Year(s)', 'woocommerce' ),
);
$value = wp_parse_args(
(array) $raw_value,
array(
'number' => '',
'unit' => 'days',
)
);
$value['number'] = ! empty( $value['number'] ) ? absint( $value['number'] ) : '';
if ( ! in_array( $value['unit'], array_keys( $periods ), true ) ) {
$value['unit'] = 'days';
}
return $value;
}