This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | require_once PODS_DIR . 'classes/fields/datetime.php'; |
||
3 | |||
4 | /** |
||
5 | * @package Pods\Fields |
||
6 | */ |
||
7 | class PodsField_Date extends PodsField_DateTime { |
||
8 | |||
9 | /** |
||
10 | * {@inheritdoc} |
||
11 | */ |
||
12 | public static $group = 'Date / Time'; |
||
13 | |||
14 | /** |
||
15 | * {@inheritdoc} |
||
16 | */ |
||
17 | public static $type = 'date'; |
||
18 | |||
19 | /** |
||
20 | * {@inheritdoc} |
||
21 | */ |
||
22 | public static $label = 'Date'; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | public static $prepare = '%s'; |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | public static $storage_format = 'Y-m-d'; |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | public static $empty_value = '0000-00-00'; |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | public function setup() { |
||
43 | |||
44 | static::$label = __( 'Date', 'pods' ); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | public function options() { |
||
51 | |||
52 | $options = array( |
||
53 | static::$type . '_repeatable' => array( |
||
54 | 'label' => __( 'Repeatable Field', 'pods' ), |
||
55 | 'default' => 0, |
||
56 | 'type' => 'boolean', |
||
57 | 'help' => __( 'Making a field repeatable will add controls next to the field which allows users to Add/Remove/Reorder additional values. These values are saved in the database as an array, so searching and filtering by them may require further adjustments".', 'pods' ), |
||
58 | 'boolean_yes_label' => '', |
||
59 | 'dependency' => true, |
||
60 | 'developer_mode' => true, |
||
61 | ), |
||
62 | static::$type . '_type' => array( |
||
63 | 'label' => __( 'Date Format Type', 'pods' ), |
||
64 | 'default' => 'format', |
||
65 | // Backwards compatibility |
||
66 | 'type' => 'pick', |
||
67 | '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' ), |
||
68 | 'data' => array( |
||
69 | 'wp' => __( 'WordPress default', 'pods' ) . ': ' . date_i18n( get_option( 'date_format' ) ), |
||
70 | 'format' => __( 'Predefined format', 'pods' ), |
||
71 | 'custom' => __( 'Custom format', 'pods' ), |
||
72 | ), |
||
73 | 'dependency' => true, |
||
74 | ), |
||
75 | static::$type . '_format_custom' => array( |
||
76 | 'label' => __( 'Date format for display', 'pods' ), |
||
77 | 'depends-on' => array( static::$type . '_type' => 'custom' ), |
||
78 | 'default' => '', |
||
79 | 'type' => 'text', |
||
80 | 'help' => sprintf( |
||
81 | '<a href="http://php.net/manual/function.date.php" target="_blank">%s</a>', |
||
82 | esc_html__( 'PHP date documentation', 'pods' ) |
||
83 | ), |
||
84 | ), |
||
85 | static::$type . '_format_custom_js' => array( |
||
86 | 'label' => __( 'Date format for input', 'pods' ), |
||
87 | 'depends-on' => array( static::$type . '_type' => 'custom' ), |
||
88 | 'default' => '', |
||
89 | 'type' => 'text', |
||
90 | 'help' => sprintf( |
||
91 | '<a href="https://api.jqueryui.com/datepicker/" target="_blank">%1$s</a><br />%2$s', |
||
92 | esc_html__( 'jQuery UI datepicker documentation', 'pods' ), |
||
93 | esc_html__( 'Leave empty to auto-generate from PHP format.', 'pods' ) |
||
94 | ), |
||
95 | ), |
||
96 | static::$type . '_format' => array( |
||
97 | 'label' => __( 'Date Format', 'pods' ), |
||
98 | 'depends-on' => array( static::$type . '_type' => 'format' ), |
||
99 | 'default' => 'mdy', |
||
100 | 'type' => 'pick', |
||
101 | 'data' => array( |
||
102 | 'mdy' => date_i18n( 'm/d/Y' ), |
||
103 | 'mdy_dash' => date_i18n( 'm-d-Y' ), |
||
104 | 'mdy_dot' => date_i18n( 'm.d.Y' ), |
||
105 | 'ymd_slash' => date_i18n( 'Y/m/d' ), |
||
106 | 'ymd_dash' => date_i18n( 'Y-m-d' ), |
||
107 | 'ymd_dot' => date_i18n( 'Y.m.d' ), |
||
108 | 'fjy' => date_i18n( 'F j, Y' ), |
||
109 | 'fjsy' => date_i18n( 'F jS, Y' ), |
||
110 | 'y' => date_i18n( 'Y' ), |
||
111 | ), |
||
112 | 'dependency' => true, |
||
113 | ), |
||
114 | static::$type . '_allow_empty' => array( |
||
115 | 'label' => __( 'Allow empty value?', 'pods' ), |
||
116 | 'default' => 1, |
||
117 | 'type' => 'boolean', |
||
118 | ), |
||
119 | static::$type . '_html5' => array( |
||
120 | 'label' => __( 'Enable HTML5 Input Field?', 'pods' ), |
||
121 | 'default' => apply_filters( 'pods_form_ui_field_html5', 0, static::$type ), |
||
122 | 'type' => 'boolean', |
||
123 | ), |
||
124 | ); |
||
125 | |||
126 | // Check if PHP DateTime::createFromFormat exists for additional supported formats |
||
127 | if ( method_exists( 'DateTime', 'createFromFormat' ) || apply_filters( 'pods_form_ui_field_datetime_custom_formatter', false ) ) { |
||
128 | $options[ static::$type . '_format' ]['data'] = array_merge( |
||
129 | $options[ static::$type . '_format' ]['data'], array( |
||
130 | 'dmy' => date_i18n( 'd/m/Y' ), |
||
131 | 'dmy_dash' => date_i18n( 'd-m-Y' ), |
||
132 | 'dmy_dot' => date_i18n( 'd.m.Y' ), |
||
133 | 'dMy' => date_i18n( 'd/M/Y' ), |
||
134 | 'dMy_dash' => date_i18n( 'd-M-Y' ), |
||
135 | ) |
||
136 | ); |
||
137 | } |
||
138 | |||
139 | $options[ static::$type . '_format' ]['data'] = apply_filters( 'pods_form_ui_field_date_format_options', $options[ static::$type . '_format' ]['data'] ); |
||
140 | $options[ static::$type . '_format' ]['default'] = apply_filters( 'pods_form_ui_field_date_format_default', $options[ static::$type . '_format' ]['default'] ); |
||
141 | |||
142 | return $options; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * {@inheritdoc} |
||
147 | */ |
||
148 | public function schema( $options = null ) { |
||
149 | |||
150 | $schema = 'DATE NOT NULL default "0000-00-00"'; |
||
151 | |||
152 | return $schema; |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * {@inheritdoc} |
||
157 | */ |
||
158 | public function format_datetime( $options, $js = false ) { |
||
0 ignored issues
–
show
|
|||
159 | |||
160 | return $this->format_date( $options, $js ); |
||
161 | } |
||
162 | } |
||
163 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.