| Server IP : 151.101.66.159 / Your IP : 216.73.216.66 Web Server : Flywheel/5.1.0 System : Linux wordpress 6.12.113+ #1 SMP Thu Oct 22 02:38:20 UTC 2026 x86_64 User : root ( ) PHP Version : 7.4.33.18 Disable Function : disk_free_space,diskfreespace,dl,exec,fpassthru,getmypid,getmyuid,highlight_file,link,opcache_compile_file,opcache_get_configuration,opcache_is_script_cached,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifcontinued,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,phpinfo,popen,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,socket_listen,source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wp-content/plugins/pods/classes/fields/ |
Upload File : |
<?php
// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* @package Pods\Fields
*/
class PodsField_Date extends PodsField_DateTime {
/**
* {@inheritdoc}
*/
public static $group = 'Date / Time';
/**
* {@inheritdoc}
*/
public static $type = 'date';
/**
* {@inheritdoc}
*/
public static $label = 'Date';
/**
* {@inheritdoc}
*/
public static $prepare = '%s';
/**
* {@inheritdoc}
*/
public static $storage_format = 'Y-m-d';
/**
* {@inheritdoc}
*/
public static $empty_value = '0000-00-00';
/**
* {@inheritdoc}
*/
public function setup() {
static::$group = __( 'Date / Time', 'pods' );
static::$label = __( 'Date', 'pods' );
}
/**
* {@inheritdoc}
*/
public function options() {
$options = [
static::$type . '_type' => [
'label' => __( 'Date Format Type', 'pods' ),
'default' => 'format',
// Backwards compatibility
'type' => 'pick',
'help' => __( 'WordPress Default is the format used in Settings, General under "Date Format".', 'pods' ) . '<br>' . __( 'Predefined Format will allow you to select from a list of commonly used date formats.', 'pods' ) . '<br>' . __( 'Custom will allow you to enter your own using PHP Date/Time Strings.', 'pods' ),
'data' => [
'wp' => __( 'WordPress default', 'pods' ) . ': ' . date_i18n( get_option( 'date_format' ) ),
'format' => __( 'Predefined format', 'pods' ),
'custom' => __( 'Custom format', 'pods' ),
],
'pick_format_single' => 'dropdown',
'pick_show_select_text' => 0,
'dependency' => true,
],
static::$type . '_format_custom' => [
'label' => __( 'Date format for display', 'pods' ),
'depends-on' => [ static::$type . '_type' => 'custom' ],
'default' => '',
'type' => 'text',
'help' => sprintf(
'<a href="http://php.net/manual/function.date.php" target="_blank" rel="noopener noreferrer">%s</a>',
esc_html__( 'PHP date documentation', 'pods' )
),
],
static::$type . '_format_custom_js' => [
'label' => __( 'Date format for input', 'pods' ),
'depends-on' => [ static::$type . '_type' => 'custom' ],
'default' => '',
'type' => 'text',
'help' => sprintf(
'<a href="https://api.jqueryui.com/datepicker/" target="_blank" rel="noopener noreferrer">%1$s</a><br />%2$s',
esc_html__( 'jQuery UI datepicker documentation', 'pods' ),
esc_html__( 'Leave empty to auto-generate from PHP format.', 'pods' )
),
],
static::$type . '_format' => [
'label' => __( 'Date Format', 'pods' ),
'depends-on' => [ static::$type . '_type' => 'format' ],
'default' => 'mdy',
'type' => 'pick',
'data' => [
'mdy' => date_i18n( 'm/d/Y' ),
'mdy_dash' => date_i18n( 'm-d-Y' ),
'mdy_dot' => date_i18n( 'm.d.Y' ),
'ymd_slash' => date_i18n( 'Y/m/d' ),
'ymd_dash' => date_i18n( 'Y-m-d' ),
'ymd_dot' => date_i18n( 'Y.m.d' ),
'fjy' => date_i18n( 'F j, Y' ),
'fjsy' => date_i18n( 'F jS, Y' ),
'y' => date_i18n( 'Y' ),
],
'pick_format_single' => 'dropdown',
'pick_show_select_text' => 0,
'dependency' => true,
],
static::$type . '_year_range_custom' => [
'label' => __( 'Year range', 'pods' ),
'default' => '',
'type' => 'text',
'help' => sprintf(
'%1$s<br /><a href="https://api.jqueryui.com/datepicker/#option-yearRange" target="_blank" rel="noopener noreferrer">%2$s</a>',
sprintf(
// translators: %1$s is an example of hard coded year range, %2$s is an example of relative year range.
esc_html__( 'Example: %1$s for specifying a hard coded year range or %2$s for the last and next 10 years.', 'pods' ),
'<code>2010:2030</code>',
'<code>-10:+10</code>'
),
esc_html__( 'jQuery UI datepicker documentation', 'pods' )
),
],
static::$type . '_allow_empty' => [
'label' => __( 'Allow empty value', 'pods' ),
'default' => 1,
'type' => 'boolean',
],
static::$type . '_html5' => [
'label' => __( 'Enable HTML5 Input Field', 'pods' ),
'default' => apply_filters( 'pods_form_ui_field_html5', 0, static::$type ),
'type' => 'boolean',
],
];
// Check if PHP DateTime::createFromFormat exists for additional supported formats
if ( method_exists( 'DateTime', 'createFromFormat' ) || apply_filters( 'pods_form_ui_field_datetime_custom_formatter', false ) ) {
$options[ static::$type . '_format' ]['data'] = array_merge(
$options[ static::$type . '_format' ]['data'], [
'dmy' => date_i18n( 'd/m/Y' ),
'dmy_dash' => date_i18n( 'd-m-Y' ),
'dmy_dot' => date_i18n( 'd.m.Y' ),
'dMy' => date_i18n( 'd/M/Y' ),
'dMy_dash' => date_i18n( 'd-M-Y' ),
]
);
}
$options[ static::$type . '_format' ]['data'] = apply_filters( 'pods_form_ui_field_date_format_options', $options[ static::$type . '_format' ]['data'] );
$options[ static::$type . '_format' ]['default'] = apply_filters( 'pods_form_ui_field_date_format_default', $options[ static::$type . '_format' ]['default'] );
return $options;
}
/**
* {@inheritdoc}
*/
public function schema( $options = null ) {
$schema = 'DATE NOT NULL default \'0000-00-00\'';
return $schema;
}
/**
* {@inheritdoc}
*/
public function format_display( $options, $js = false ) {
if ( $js && 'custom' === pods_v( static::$type . '_type', $options, 'format' ) ) {
$format = $this->format_datetime( $options, $js );
return $this->convert_format( $format, [ 'source' => 'jquery_ui', 'type' => 'date' ] );
}
return parent::format_display( $options, $js );
}
/**
* {@inheritdoc}
*/
public function format_datetime( $options, $js = false ) {
return $this->format_date( $options, $js );
}
}