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_Time extends PodsField_DateTime { |
||
8 | |||
9 | /** |
||
10 | * {@inheritdoc} |
||
11 | */ |
||
12 | public static $group = 'Date / Time'; |
||
13 | |||
14 | /** |
||
15 | * {@inheritdoc} |
||
16 | */ |
||
17 | public static $type = 'time'; |
||
18 | |||
19 | /** |
||
20 | * {@inheritdoc} |
||
21 | */ |
||
22 | public static $label = 'Time'; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | public static $prepare = '%s'; |
||
28 | |||
29 | /** |
||
30 | * Storage format. |
||
31 | * |
||
32 | * @var string |
||
33 | * @since 2.7 |
||
34 | */ |
||
35 | public static $storage_format = 'H:i:s'; |
||
36 | |||
37 | /** |
||
38 | * The default empty value (database) |
||
39 | * |
||
40 | * @var string |
||
41 | * @since 2.7 |
||
42 | */ |
||
43 | public static $empty_value = '00:00:00'; |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | public function setup() { |
||
49 | |||
50 | static::$label = __( 'Time', 'pods' ); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function options() { |
||
57 | |||
58 | $options = array( |
||
59 | static::$type . '_repeatable' => array( |
||
60 | 'label' => __( 'Repeatable Field', 'pods' ), |
||
61 | 'default' => 0, |
||
62 | 'type' => 'boolean', |
||
63 | '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' ), |
||
64 | 'boolean_yes_label' => '', |
||
65 | 'dependency' => true, |
||
66 | 'developer_mode' => true, |
||
67 | ), |
||
68 | static::$type . '_type' => array( |
||
69 | 'label' => __( 'Time Format Type', 'pods' ), |
||
70 | 'default' => '12', |
||
71 | // Backwards compatibility |
||
72 | 'type' => 'pick', |
||
73 | 'help' => __( 'WordPress Default is the format used in Settings, General under "Time Format".', 'pods' ) . '<br>' . __( '12/24 hour will allow you to select from a list of commonly used time formats.', 'pods' ) . '<br>' . __( 'Custom will allow you to enter your own using PHP Date/Time Strings.', 'pods' ), |
||
74 | 'data' => array( |
||
75 | 'wp' => __( 'WordPress default', 'pods' ) . ': ' . date_i18n( get_option( 'time_format' ) ), |
||
76 | '12' => __( '12 hour', 'pods' ), |
||
77 | '24' => __( '24 hour', 'pods' ), |
||
78 | 'custom' => __( 'Custom format', 'pods' ), |
||
79 | ), |
||
80 | 'dependency' => true, |
||
81 | ), |
||
82 | static::$type . '_format_custom' => array( |
||
83 | 'label' => __( 'Time format for display', 'pods' ), |
||
84 | 'depends-on' => array( static::$type . '_type' => 'custom' ), |
||
85 | 'default' => '', |
||
86 | 'type' => 'text', |
||
87 | 'help' => sprintf( |
||
88 | '<a href="http://php.net/manual/function.date.php" target="_blank">%s</a>', |
||
89 | esc_html__( 'PHP date documentation', 'pods' ) |
||
90 | ), |
||
91 | ), |
||
92 | static::$type . '_format_custom_js' => array( |
||
93 | 'label' => __( 'Time format for input', 'pods' ), |
||
94 | 'depends-on' => array( static::$type . '_type' => 'custom' ), |
||
95 | 'default' => '', |
||
96 | 'type' => 'text', |
||
97 | 'help' => sprintf( |
||
98 | '<a href="http://trentrichardson.com/examples/timepicker/#tp-formatting" target="_blank">%1$s</a><br />%2$s', |
||
99 | esc_html__( 'jQuery UI timepicker documentation', 'pods' ), |
||
100 | esc_html__( 'Leave empty to auto-generate from PHP format.', 'pods' ) |
||
101 | ), |
||
102 | ), |
||
103 | static::$type . '_format' => array( |
||
104 | 'label' => __( 'Time Format', 'pods' ), |
||
105 | 'depends-on' => array( static::$type . '_type' => '12' ), |
||
106 | 'default' => 'h_mma', |
||
107 | 'type' => 'pick', |
||
108 | 'data' => array( |
||
109 | 'h_mm_A' => date_i18n( 'g:i A' ), |
||
110 | 'h_mm_ss_A' => date_i18n( 'g:i:s A' ), |
||
111 | 'hh_mm_A' => date_i18n( 'h:i A' ), |
||
112 | 'hh_mm_ss_A' => date_i18n( 'h:i:s A' ), |
||
113 | 'h_mma' => date_i18n( 'g:ia' ), |
||
114 | 'hh_mma' => date_i18n( 'h:ia' ), |
||
115 | 'h_mm' => date_i18n( 'g:i' ), |
||
116 | 'h_mm_ss' => date_i18n( 'g:i:s' ), |
||
117 | 'hh_mm' => date_i18n( 'h:i' ), |
||
118 | 'hh_mm_ss' => date_i18n( 'h:i:s' ), |
||
119 | ), |
||
120 | 'dependency' => true, |
||
121 | ), |
||
122 | static::$type . '_format_24' => array( |
||
123 | 'label' => __( 'Time Format', 'pods' ), |
||
124 | 'depends-on' => array( static::$type . '_type' => '24' ), |
||
125 | 'default' => 'hh_mm', |
||
126 | 'type' => 'pick', |
||
127 | 'data' => array( |
||
128 | 'hh_mm' => date_i18n( 'H:i' ), |
||
129 | 'hh_mm_ss' => date_i18n( 'H:i:s' ), |
||
130 | ), |
||
131 | ), |
||
132 | static::$type . '_allow_empty' => array( |
||
133 | 'label' => __( 'Allow empty value?', 'pods' ), |
||
134 | 'default' => 1, |
||
135 | 'type' => 'boolean', |
||
136 | ), |
||
137 | static::$type . '_html5' => array( |
||
138 | 'label' => __( 'Enable HTML5 Input Field?', 'pods' ), |
||
139 | 'default' => apply_filters( 'pods_form_ui_field_html5', 0, static::$type ), |
||
140 | 'type' => 'boolean', |
||
141 | ), |
||
142 | ); |
||
143 | |||
144 | $options[ static::$type . '_type' ]['default'] = apply_filters( 'pods_form_ui_field_time_format_type_default', $options[ static::$type . '_type' ]['default'] ); |
||
145 | $options[ static::$type . '_format' ]['data'] = apply_filters( 'pods_form_ui_field_time_format_options', $options[ static::$type . '_format' ]['data'] ); |
||
146 | $options[ static::$type . '_format' ]['default'] = apply_filters( 'pods_form_ui_field_time_format_default', $options[ static::$type . '_format' ]['default'] ); |
||
147 | $options[ static::$type . '_format_24' ]['data'] = apply_filters( 'pods_form_ui_field_time_format_24_options', $options[ static::$type . '_format_24' ]['data'] ); |
||
148 | $options[ static::$type . '_format_24' ]['default'] = apply_filters( 'pods_form_ui_field_time_format_24_default', $options[ static::$type . '_format_24' ]['default'] ); |
||
149 | |||
150 | return $options; |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * {@inheritdoc} |
||
155 | */ |
||
156 | public function schema( $options = null ) { |
||
157 | |||
158 | $schema = 'TIME NOT NULL default "00:00:00"'; |
||
159 | |||
160 | return $schema; |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * {@inheritdoc} |
||
165 | */ |
||
166 | public function format_datetime( $options, $js = false ) { |
||
0 ignored issues
–
show
|
|||
167 | |||
168 | return $this->format_time( $options, $js ); |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * Build time format string based on options |
||
173 | * |
||
174 | * @param array $options Field options. |
||
175 | * @param bool $js Return formatted from jQuery UI format? (only for custom formats). |
||
176 | * |
||
177 | * @return string |
||
178 | * @since 2.7 |
||
179 | */ |
||
180 | public function format_time( $options, $js = false ) { |
||
0 ignored issues
–
show
|
|||
181 | |||
182 | switch ( (string) pods_v( static::$type . '_type', $options, '12', true ) ) { |
||
183 | case '12': |
||
184 | $time_format = $this->get_time_formats( $js ); |
||
185 | $format = $time_format[ pods_v( static::$type . '_format', $options, 'hh_mm', true ) ]; |
||
186 | break; |
||
187 | case '24': |
||
188 | $time_format_24 = $this->get_time_formats_24( $js ); |
||
189 | $format = $time_format_24[ pods_v( static::$type . '_format_24', $options, 'hh_mm', true ) ]; |
||
190 | break; |
||
191 | case 'custom': |
||
192 | if ( ! $js ) { |
||
193 | $format = pods_v( static::$type . '_format_custom', $options, '' ); |
||
194 | } else { |
||
195 | $format = pods_v( static::$type . '_format_custom_js', $options, '' ); |
||
196 | if ( empty( $format ) ) { |
||
197 | $format = pods_v( static::$type . '_format_custom', $options, '' ); |
||
198 | $format = $this->convert_format( $format, array( 'source' => 'php' ) ); |
||
199 | } |
||
200 | } |
||
201 | break; |
||
202 | default: |
||
203 | $format = get_option( 'time_format' ); |
||
204 | if ( $js ) { |
||
205 | $format = $this->convert_format( $format, array( 'source' => 'php' ) ); |
||
206 | } |
||
207 | break; |
||
208 | }//end switch |
||
209 | |||
210 | return $format; |
||
211 | } |
||
212 | } |
||
213 |
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.