@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return mixed show_on key or false |
28 | 28 | */ |
29 | - private static function get_show_on_key( $meta_box_args ) { |
|
30 | - $show_on = isset( $meta_box_args['show_on'] ) ? (array) $meta_box_args['show_on'] : false; |
|
31 | - if ( $show_on && is_array( $show_on ) ) { |
|
29 | + private static function get_show_on_key($meta_box_args) { |
|
30 | + $show_on = isset($meta_box_args['show_on']) ? (array) $meta_box_args['show_on'] : false; |
|
31 | + if ($show_on && is_array($show_on)) { |
|
32 | 32 | |
33 | - if ( array_key_exists( 'key', $show_on ) ) { |
|
33 | + if (array_key_exists('key', $show_on)) { |
|
34 | 34 | return $show_on['key']; |
35 | 35 | } |
36 | 36 | |
37 | - $keys = array_keys( $show_on ); |
|
37 | + $keys = array_keys($show_on); |
|
38 | 38 | return $keys[0]; |
39 | 39 | } |
40 | 40 | |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return mixed show_on value or false |
52 | 52 | */ |
53 | - private static function get_show_on_value( $meta_box_args ) { |
|
54 | - $show_on = isset( $meta_box_args['show_on'] ) ? (array) $meta_box_args['show_on'] : false; |
|
53 | + private static function get_show_on_value($meta_box_args) { |
|
54 | + $show_on = isset($meta_box_args['show_on']) ? (array) $meta_box_args['show_on'] : false; |
|
55 | 55 | |
56 | - if ( $show_on && is_array( $show_on ) ) { |
|
56 | + if ($show_on && is_array($show_on)) { |
|
57 | 57 | |
58 | - if ( array_key_exists( 'value', $show_on ) ) { |
|
58 | + if (array_key_exists('value', $show_on)) { |
|
59 | 59 | return $show_on['value']; |
60 | 60 | } |
61 | 61 | |
62 | - $keys = array_keys( $show_on ); |
|
62 | + $keys = array_keys($show_on); |
|
63 | 63 | |
64 | - return $show_on[ $keys[0] ]; |
|
64 | + return $show_on[$keys[0]]; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | return array(); |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | * @param CMB2 $cmb The CMB2 instance. |
77 | 77 | * @return bool Whether to display this metabox on the current page. |
78 | 78 | */ |
79 | - public static function check_id( $display, $meta_box_args, $cmb ) { |
|
79 | + public static function check_id($display, $meta_box_args, $cmb) { |
|
80 | 80 | |
81 | - $key = self::get_show_on_key( $meta_box_args ); |
|
82 | - if ( ! $key || 'id' !== $key ) { |
|
81 | + $key = self::get_show_on_key($meta_box_args); |
|
82 | + if ( ! $key || 'id' !== $key) { |
|
83 | 83 | return $display; |
84 | 84 | } |
85 | 85 | |
86 | 86 | $object_id = is_admin() ? $cmb->object_id() : get_the_ID(); |
87 | 87 | |
88 | - if ( ! $object_id ) { |
|
88 | + if ( ! $object_id) { |
|
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
92 | 92 | // If current page id is in the included array, display the metabox. |
93 | - return in_array( $object_id, (array) self::get_show_on_value( $meta_box_args ) ); |
|
93 | + return in_array($object_id, (array) self::get_show_on_value($meta_box_args)); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -102,24 +102,24 @@ discard block |
||
102 | 102 | * @param CMB2 $cmb CMB2 object. |
103 | 103 | * @return bool Whether to display this metabox on the current page. |
104 | 104 | */ |
105 | - public static function check_page_template( $display, $meta_box_args, $cmb ) { |
|
105 | + public static function check_page_template($display, $meta_box_args, $cmb) { |
|
106 | 106 | |
107 | - $key = self::get_show_on_key( $meta_box_args ); |
|
108 | - if ( ! $key || 'page-template' !== $key ) { |
|
107 | + $key = self::get_show_on_key($meta_box_args); |
|
108 | + if ( ! $key || 'page-template' !== $key) { |
|
109 | 109 | return $display; |
110 | 110 | } |
111 | 111 | |
112 | 112 | $object_id = $cmb->object_id(); |
113 | 113 | |
114 | - if ( ! $object_id || 'post' !== $cmb->object_type() ) { |
|
114 | + if ( ! $object_id || 'post' !== $cmb->object_type()) { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Get current template. |
119 | - $current_template = get_post_meta( $object_id, '_wp_page_template', true ); |
|
119 | + $current_template = get_post_meta($object_id, '_wp_page_template', true); |
|
120 | 120 | |
121 | 121 | // See if there's a match. |
122 | - if ( $current_template && in_array( $current_template, (array) self::get_show_on_value( $meta_box_args ) ) ) { |
|
122 | + if ($current_template && in_array($current_template, (array) self::get_show_on_value($meta_box_args))) { |
|
123 | 123 | return true; |
124 | 124 | } |
125 | 125 | |
@@ -134,36 +134,36 @@ discard block |
||
134 | 134 | * @param array $meta_box_args Metabox config array. |
135 | 135 | * @return bool Whether to display this metabox on the current page. |
136 | 136 | */ |
137 | - public static function check_admin_page( $display, $meta_box_args ) { |
|
137 | + public static function check_admin_page($display, $meta_box_args) { |
|
138 | 138 | |
139 | - $key = self::get_show_on_key( $meta_box_args ); |
|
139 | + $key = self::get_show_on_key($meta_box_args); |
|
140 | 140 | // check if this is a 'options-page' metabox. |
141 | - if ( ! $key || 'options-page' !== $key ) { |
|
141 | + if ( ! $key || 'options-page' !== $key) { |
|
142 | 142 | return $display; |
143 | 143 | } |
144 | 144 | |
145 | 145 | // Enforce 'show_on' filter in the admin. |
146 | - if ( is_admin() ) { |
|
146 | + if (is_admin()) { |
|
147 | 147 | |
148 | 148 | // If there is no 'page' query var, our filter isn't applicable. |
149 | - if ( ! isset( $_GET['page'] ) ) { |
|
149 | + if ( ! isset($_GET['page'])) { |
|
150 | 150 | return $display; |
151 | 151 | } |
152 | 152 | |
153 | - $show_on = self::get_show_on_value( $meta_box_args ); |
|
153 | + $show_on = self::get_show_on_value($meta_box_args); |
|
154 | 154 | |
155 | - if ( empty( $show_on ) ) { |
|
155 | + if (empty($show_on)) { |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | |
159 | - if ( is_array( $show_on ) ) { |
|
160 | - foreach ( $show_on as $page ) { |
|
161 | - if ( $_GET['page'] == $page ) { |
|
159 | + if (is_array($show_on)) { |
|
160 | + foreach ($show_on as $page) { |
|
161 | + if ($_GET['page'] == $page) { |
|
162 | 162 | return true; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | } else { |
166 | - if ( $_GET['page'] == $show_on ) { |
|
166 | + if ($_GET['page'] == $show_on) { |
|
167 | 167 | return true; |
168 | 168 | } |
169 | 169 | } |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | * @param CMB2_Field $field Requested field type. |
36 | 36 | * @return CMB2_Field_Display |
37 | 37 | */ |
38 | - public static function get( CMB2_Field $field ) { |
|
38 | + public static function get(CMB2_Field $field) { |
|
39 | 39 | $fieldtype = $field->type(); |
40 | - $display_class_name = $field->args( 'display_class' ); |
|
40 | + $display_class_name = $field->args('display_class'); |
|
41 | 41 | |
42 | - if ( empty( $display_class_name ) ) { |
|
43 | - switch ( $fieldtype ) { |
|
42 | + if (empty($display_class_name)) { |
|
43 | + switch ($fieldtype) { |
|
44 | 44 | case 'text_url': |
45 | 45 | $display_class_name = 'CMB2_Display_Text_Url'; |
46 | 46 | break; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | }// End switch. |
108 | 108 | } |
109 | 109 | |
110 | - if ( has_action( "cmb2_display_class_{$fieldtype}" ) ) { |
|
110 | + if (has_action("cmb2_display_class_{$fieldtype}")) { |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Filters the custom field display class used for displaying the field. Class is required to extend CMB2_Type_Base. |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | * @param string $display_class_name The custom field display class to use. |
120 | 120 | * @param object $field The `CMB2_Field` object. |
121 | 121 | */ |
122 | - $display_class_name = apply_filters( "cmb2_display_class_{$fieldtype}", $display_class_name, $field ); |
|
122 | + $display_class_name = apply_filters("cmb2_display_class_{$fieldtype}", $display_class_name, $field); |
|
123 | 123 | } |
124 | 124 | |
125 | - return new $display_class_name( $field ); |
|
125 | + return new $display_class_name($field); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @since 2.2.2 |
132 | 132 | * @param CMB2_Field $field A CMB2 field object. |
133 | 133 | */ |
134 | - public function __construct( CMB2_Field $field ) { |
|
134 | + public function __construct(CMB2_Field $field) { |
|
135 | 135 | $this->field = $field; |
136 | 136 | $this->value = $this->field->value; |
137 | 137 | } |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function display() { |
146 | 146 | // If repeatable. |
147 | - if ( $this->field->args( 'repeatable' ) ) { |
|
147 | + if ($this->field->args('repeatable')) { |
|
148 | 148 | |
149 | 149 | // And has a repeatable value. |
150 | - if ( is_array( $this->field->value ) ) { |
|
150 | + if (is_array($this->field->value)) { |
|
151 | 151 | |
152 | 152 | // Then loop and output. |
153 | - echo '<ul class="cmb2-' . esc_attr( sanitize_html_class( str_replace( '_', '-', $this->field->type() ) ) ) . '">'; |
|
154 | - foreach ( $this->field->value as $val ) { |
|
153 | + echo '<ul class="cmb2-' . esc_attr(sanitize_html_class(str_replace('_', '-', $this->field->type()))) . '">'; |
|
154 | + foreach ($this->field->value as $val) { |
|
155 | 155 | $this->value = $val; |
156 | 156 | echo '<li>', $this->_display(), '</li>'; |
157 | 157 | ; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @since 2.2.2 |
170 | 170 | */ |
171 | 171 | protected function _display() { |
172 | - print_r( $this->value ); |
|
172 | + print_r($this->value); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @since 2.2.2 |
181 | 181 | */ |
182 | 182 | protected function _display() { |
183 | - echo make_clickable( esc_url( $this->value ) ); |
|
183 | + echo make_clickable(esc_url($this->value)); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function _display() { |
194 | 194 | $this->value = $this->value ? $this->value : '0'; |
195 | - echo ( ! $this->field->get_param_callback_result( 'before_field' ) ? '$' : ' ' ), $this->value; |
|
195 | + echo ( ! $this->field->get_param_callback_result('before_field') ? '$' : ' '), $this->value; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @since 2.2.2 |
204 | 204 | */ |
205 | 205 | protected function _display() { |
206 | - echo '<span class="cmb2-colorpicker-swatch"><span style="background-color:', esc_attr( $this->value ), '"></span> ', esc_html( $this->value ), '</span>'; |
|
206 | + echo '<span class="cmb2-colorpicker-swatch"><span style="background-color:', esc_attr($this->value), '"></span> ', esc_html($this->value), '</span>'; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -227,16 +227,16 @@ discard block |
||
227 | 227 | protected function _display() { |
228 | 228 | $options = $this->field->options(); |
229 | 229 | |
230 | - $fallback = $this->field->args( 'show_option_none' ); |
|
231 | - if ( ! $fallback && isset( $options[''] ) ) { |
|
230 | + $fallback = $this->field->args('show_option_none'); |
|
231 | + if ( ! $fallback && isset($options[''])) { |
|
232 | 232 | $fallback = $options['']; |
233 | 233 | } |
234 | - if ( ! $this->value && $fallback ) { |
|
234 | + if ( ! $this->value && $fallback) { |
|
235 | 235 | echo $fallback; |
236 | - } elseif ( isset( $options[ $this->value ] ) ) { |
|
237 | - echo $options[ $this->value ]; |
|
236 | + } elseif (isset($options[$this->value])) { |
|
237 | + echo $options[$this->value]; |
|
238 | 238 | } else { |
239 | - echo esc_attr( $this->value ); |
|
239 | + echo esc_attr($this->value); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
@@ -248,22 +248,22 @@ discard block |
||
248 | 248 | * @since 2.2.2 |
249 | 249 | */ |
250 | 250 | protected function _display() { |
251 | - if ( empty( $this->value ) || ! is_array( $this->value ) ) { |
|
251 | + if (empty($this->value) || ! is_array($this->value)) { |
|
252 | 252 | return; |
253 | 253 | } |
254 | 254 | |
255 | 255 | $options = $this->field->options(); |
256 | 256 | |
257 | 257 | $output = array(); |
258 | - foreach ( $this->value as $val ) { |
|
259 | - if ( isset( $options[ $val ] ) ) { |
|
260 | - $output[] = $options[ $val ]; |
|
258 | + foreach ($this->value as $val) { |
|
259 | + if (isset($options[$val])) { |
|
260 | + $output[] = $options[$val]; |
|
261 | 261 | } else { |
262 | - $output[] = esc_attr( $val ); |
|
262 | + $output[] = esc_attr($val); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | - echo implode( ', ', $output ); |
|
266 | + echo implode(', ', $output); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @since 2.2.2 |
275 | 275 | */ |
276 | 276 | protected function _display() { |
277 | - echo wpautop( wp_kses_post( $this->value ) ); |
|
277 | + echo wpautop(wp_kses_post($this->value)); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @since 2.2.2 |
286 | 286 | */ |
287 | 287 | protected function _display() { |
288 | - echo '<xmp class="cmb2-code">' . print_r( $this->value, true ) . '</xmp>'; |
|
288 | + echo '<xmp class="cmb2-code">' . print_r($this->value, true) . '</xmp>'; |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @since 2.2.2 |
297 | 297 | */ |
298 | 298 | protected function _display() { |
299 | - echo $this->field->get_timestamp_format( 'time_format', $this->value ); |
|
299 | + echo $this->field->get_timestamp_format('time_format', $this->value); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @since 2.2.2 |
308 | 308 | */ |
309 | 309 | protected function _display() { |
310 | - echo $this->field->get_timestamp_format( 'date_format', $this->value ); |
|
310 | + echo $this->field->get_timestamp_format('date_format', $this->value); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
@@ -320,23 +320,23 @@ discard block |
||
320 | 320 | protected function _display() { |
321 | 321 | $field = $this->field; |
322 | 322 | |
323 | - if ( empty( $this->value ) ) { |
|
323 | + if (empty($this->value)) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - $datetime = maybe_unserialize( $this->value ); |
|
327 | + $datetime = maybe_unserialize($this->value); |
|
328 | 328 | $this->value = $tzstring = ''; |
329 | 329 | |
330 | - if ( $datetime && $datetime instanceof DateTime ) { |
|
330 | + if ($datetime && $datetime instanceof DateTime) { |
|
331 | 331 | $tz = $datetime->getTimezone(); |
332 | 332 | $tzstring = $tz->getName(); |
333 | - $this->value = $datetime->getTimestamp(); |
|
333 | + $this->value = $datetime->getTimestamp(); |
|
334 | 334 | } |
335 | 335 | |
336 | - $date = $this->field->get_timestamp_format( 'date_format', $this->value ); |
|
337 | - $time = $this->field->get_timestamp_format( 'time_format', $this->value ); |
|
336 | + $date = $this->field->get_timestamp_format('date_format', $this->value); |
|
337 | + $time = $this->field->get_timestamp_format('time_format', $this->value); |
|
338 | 338 | |
339 | - echo $date, ( $time ? ' ' . $time : '' ), ( $tzstring ? ', ' . $tzstring : '' ); |
|
339 | + echo $date, ($time ? ' ' . $time : ''), ($tzstring ? ', ' . $tzstring : ''); |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
@@ -347,21 +347,21 @@ discard block |
||
347 | 347 | * @since 2.2.2 |
348 | 348 | */ |
349 | 349 | protected function _display() { |
350 | - $taxonomy = $this->field->args( 'taxonomy' ); |
|
351 | - $types = new CMB2_Types( $this->field ); |
|
352 | - $type = $types->get_new_render_type( $this->field->type(), 'CMB2_Type_Taxonomy_Radio' ); |
|
350 | + $taxonomy = $this->field->args('taxonomy'); |
|
351 | + $types = new CMB2_Types($this->field); |
|
352 | + $type = $types->get_new_render_type($this->field->type(), 'CMB2_Type_Taxonomy_Radio'); |
|
353 | 353 | $terms = $type->get_object_terms(); |
354 | 354 | $term = false; |
355 | 355 | |
356 | - if ( is_wp_error( $terms ) || empty( $terms ) && ( $default = $this->field->get_default() ) ) { |
|
357 | - $term = get_term_by( 'slug', $default, $taxonomy ); |
|
358 | - } elseif ( ! empty( $terms ) ) { |
|
359 | - $term = $terms[ key( $terms ) ]; |
|
356 | + if (is_wp_error($terms) || empty($terms) && ($default = $this->field->get_default())) { |
|
357 | + $term = get_term_by('slug', $default, $taxonomy); |
|
358 | + } elseif ( ! empty($terms)) { |
|
359 | + $term = $terms[key($terms)]; |
|
360 | 360 | } |
361 | 361 | |
362 | - if ( $term ) { |
|
363 | - $link = get_edit_term_link( $term->term_id, $taxonomy ); |
|
364 | - echo '<a href="', esc_url( $link ), '">', esc_html( $term->name ), '</a>'; |
|
362 | + if ($term) { |
|
363 | + $link = get_edit_term_link($term->term_id, $taxonomy); |
|
364 | + echo '<a href="', esc_url($link), '">', esc_html($term->name), '</a>'; |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | } |
@@ -373,32 +373,32 @@ discard block |
||
373 | 373 | * @since 2.2.2 |
374 | 374 | */ |
375 | 375 | protected function _display() { |
376 | - $taxonomy = $this->field->args( 'taxonomy' ); |
|
377 | - $types = new CMB2_Types( $this->field ); |
|
378 | - $type = $types->get_new_render_type( $this->field->type(), 'CMB2_Type_Taxonomy_Multicheck' ); |
|
376 | + $taxonomy = $this->field->args('taxonomy'); |
|
377 | + $types = new CMB2_Types($this->field); |
|
378 | + $type = $types->get_new_render_type($this->field->type(), 'CMB2_Type_Taxonomy_Multicheck'); |
|
379 | 379 | $terms = $type->get_object_terms(); |
380 | 380 | |
381 | - if ( is_wp_error( $terms ) || empty( $terms ) && ( $default = $this->field->get_default() ) ) { |
|
381 | + if (is_wp_error($terms) || empty($terms) && ($default = $this->field->get_default())) { |
|
382 | 382 | $terms = array(); |
383 | - if ( is_array( $default ) ) { |
|
384 | - foreach ( $default as $slug ) { |
|
385 | - $terms[] = get_term_by( 'slug', $slug, $taxonomy ); |
|
383 | + if (is_array($default)) { |
|
384 | + foreach ($default as $slug) { |
|
385 | + $terms[] = get_term_by('slug', $slug, $taxonomy); |
|
386 | 386 | } |
387 | 387 | } else { |
388 | - $terms[] = get_term_by( 'slug', $default, $taxonomy ); |
|
388 | + $terms[] = get_term_by('slug', $default, $taxonomy); |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | |
392 | - if ( is_array( $terms ) ) { |
|
392 | + if (is_array($terms)) { |
|
393 | 393 | |
394 | 394 | $links = array(); |
395 | - foreach ( $terms as $term ) { |
|
396 | - $link = get_edit_term_link( $term->term_id, $taxonomy ); |
|
397 | - $links[] = '<a href="' . esc_url( $link ) . '">' . esc_html( $term->name ) . '</a>'; |
|
395 | + foreach ($terms as $term) { |
|
396 | + $link = get_edit_term_link($term->term_id, $taxonomy); |
|
397 | + $links[] = '<a href="' . esc_url($link) . '">' . esc_html($term->name) . '</a>'; |
|
398 | 398 | } |
399 | 399 | // Then loop and output. |
400 | - echo '<div class="cmb2-taxonomy-terms-', esc_attr( sanitize_html_class( $taxonomy ) ), '">'; |
|
401 | - echo implode( ', ', $links ); |
|
400 | + echo '<div class="cmb2-taxonomy-terms-', esc_attr(sanitize_html_class($taxonomy)), '">'; |
|
401 | + echo implode(', ', $links); |
|
402 | 402 | echo '</div>'; |
403 | 403 | } |
404 | 404 | } |
@@ -411,48 +411,48 @@ discard block |
||
411 | 411 | * @since 2.2.2 |
412 | 412 | */ |
413 | 413 | protected function _display() { |
414 | - if ( empty( $this->value ) ) { |
|
414 | + if (empty($this->value)) { |
|
415 | 415 | return; |
416 | 416 | } |
417 | 417 | |
418 | - $this->value = esc_url_raw( $this->value ); |
|
418 | + $this->value = esc_url_raw($this->value); |
|
419 | 419 | |
420 | - $types = new CMB2_Types( $this->field ); |
|
421 | - $type = $types->get_new_render_type( $this->field->type(), 'CMB2_Type_File_Base' ); |
|
420 | + $types = new CMB2_Types($this->field); |
|
421 | + $type = $types->get_new_render_type($this->field->type(), 'CMB2_Type_File_Base'); |
|
422 | 422 | |
423 | - $id = $this->field->get_field_clone( array( |
|
424 | - 'id' => $this->field->_id( '', false ) . '_id', |
|
425 | - ) )->escaped_value( 'absint' ); |
|
423 | + $id = $this->field->get_field_clone(array( |
|
424 | + 'id' => $this->field->_id('', false) . '_id', |
|
425 | + ))->escaped_value('absint'); |
|
426 | 426 | |
427 | - $this->file_output( $this->value, $id, $type ); |
|
427 | + $this->file_output($this->value, $id, $type); |
|
428 | 428 | } |
429 | 429 | |
430 | - protected function file_output( $url_value, $id, CMB2_Type_File_Base $field_type ) { |
|
430 | + protected function file_output($url_value, $id, CMB2_Type_File_Base $field_type) { |
|
431 | 431 | // If there is no ID saved yet, try to get it from the url. |
432 | - if ( $url_value && ! $id ) { |
|
433 | - $id = CMB2_Utils::image_id_from_url( esc_url_raw( $url_value ) ); |
|
432 | + if ($url_value && ! $id) { |
|
433 | + $id = CMB2_Utils::image_id_from_url(esc_url_raw($url_value)); |
|
434 | 434 | } |
435 | 435 | |
436 | - if ( $field_type->is_valid_img_ext( $url_value ) ) { |
|
437 | - $img_size = $this->field->args( 'preview_size' ); |
|
436 | + if ($field_type->is_valid_img_ext($url_value)) { |
|
437 | + $img_size = $this->field->args('preview_size'); |
|
438 | 438 | |
439 | - if ( $id ) { |
|
440 | - $image = wp_get_attachment_image( $id, $img_size, null, array( |
|
439 | + if ($id) { |
|
440 | + $image = wp_get_attachment_image($id, $img_size, null, array( |
|
441 | 441 | 'class' => 'cmb-image-display', |
442 | - ) ); |
|
442 | + )); |
|
443 | 443 | } else { |
444 | - $size = is_array( $img_size ) ? $img_size[0] : 200; |
|
445 | - $image = '<img class="cmb-image-display" style="max-width: ' . absint( $size ) . 'px; width: 100%; height: auto;" src="' . esc_url( $url_value ) . '" alt="" />'; |
|
444 | + $size = is_array($img_size) ? $img_size[0] : 200; |
|
445 | + $image = '<img class="cmb-image-display" style="max-width: ' . absint($size) . 'px; width: 100%; height: auto;" src="' . esc_url($url_value) . '" alt="" />'; |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | echo $image; |
449 | 449 | |
450 | 450 | } else { |
451 | 451 | |
452 | - printf( '<div class="file-status"><span>%1$s <strong><a href="%2$s">%3$s</a></strong></span></div>', |
|
453 | - esc_html( $field_type->_text( 'file_text', __( 'File:', 'cmb2' ) ) ), |
|
454 | - esc_url( $url_value ), |
|
455 | - esc_html( CMB2_Utils::get_file_name_from_path( $url_value ) ) |
|
452 | + printf('<div class="file-status"><span>%1$s <strong><a href="%2$s">%3$s</a></strong></span></div>', |
|
453 | + esc_html($field_type->_text('file_text', __('File:', 'cmb2'))), |
|
454 | + esc_url($url_value), |
|
455 | + esc_html(CMB2_Utils::get_file_name_from_path($url_value)) |
|
456 | 456 | ); |
457 | 457 | |
458 | 458 | } |
@@ -466,16 +466,16 @@ discard block |
||
466 | 466 | * @since 2.2.2 |
467 | 467 | */ |
468 | 468 | protected function _display() { |
469 | - if ( empty( $this->value ) || ! is_array( $this->value ) ) { |
|
469 | + if (empty($this->value) || ! is_array($this->value)) { |
|
470 | 470 | return; |
471 | 471 | } |
472 | 472 | |
473 | - $types = new CMB2_Types( $this->field ); |
|
474 | - $type = $types->get_new_render_type( $this->field->type(), 'CMB2_Type_File_Base' ); |
|
473 | + $types = new CMB2_Types($this->field); |
|
474 | + $type = $types->get_new_render_type($this->field->type(), 'CMB2_Type_File_Base'); |
|
475 | 475 | |
476 | 476 | echo '<ul class="cmb2-display-file-list">'; |
477 | - foreach ( $this->value as $id => $fullurl ) { |
|
478 | - echo '<li>', $this->file_output( esc_url_raw( $fullurl ), $id, $type ), '</li>'; |
|
477 | + foreach ($this->value as $id => $fullurl) { |
|
478 | + echo '<li>', $this->file_output(esc_url_raw($fullurl), $id, $type), '</li>'; |
|
479 | 479 | } |
480 | 480 | echo '</ul>'; |
481 | 481 | } |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | * @since 2.2.2 |
489 | 489 | */ |
490 | 490 | protected function _display() { |
491 | - if ( ! $this->value ) { |
|
491 | + if ( ! $this->value) { |
|
492 | 492 | return; |
493 | 493 | } |
494 | 494 | |
495 | - cmb2_do_oembed( array( |
|
495 | + cmb2_do_oembed(array( |
|
496 | 496 | 'url' => $this->value, |
497 | 497 | 'object_id' => $this->field->object_id, |
498 | 498 | 'object_type' => $this->field->object_type, |
@@ -500,6 +500,6 @@ discard block |
||
500 | 500 | 'width' => '300', |
501 | 501 | ), |
502 | 502 | 'field_id' => $this->field->id(), |
503 | - ) ); |
|
503 | + )); |
|
504 | 504 | } |
505 | 505 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * @since 2.0.7 |
51 | 51 | * @param array|string $dependencies Array (or string) of dependencies to add. |
52 | 52 | */ |
53 | - public static function add_dependencies( $dependencies ) { |
|
54 | - foreach ( (array) $dependencies as $dependency ) { |
|
55 | - self::$dependencies[ $dependency ] = $dependency; |
|
53 | + public static function add_dependencies($dependencies) { |
|
54 | + foreach ((array) $dependencies as $dependency) { |
|
55 | + self::$dependencies[$dependency] = $dependency; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param CMB2_Field $field Field object. |
65 | 65 | */ |
66 | - public static function add_field_data( CMB2_Field $field ) { |
|
66 | + public static function add_field_data(CMB2_Field $field) { |
|
67 | 67 | $hash = $field->hash_id(); |
68 | - if ( ! isset( self::$fields[ $hash ] ) ) { |
|
69 | - self::$fields[ $hash ] = $field->js_data(); |
|
68 | + if ( ! isset(self::$fields[$hash])) { |
|
69 | + self::$fields[$hash] = $field->js_data(); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -77,57 +77,57 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public static function enqueue() { |
79 | 79 | // Filter required script dependencies. |
80 | - $dependencies = self::$dependencies = apply_filters( 'cmb2_script_dependencies', self::$dependencies ); |
|
80 | + $dependencies = self::$dependencies = apply_filters('cmb2_script_dependencies', self::$dependencies); |
|
81 | 81 | |
82 | 82 | // Only use minified files if SCRIPT_DEBUG is off. |
83 | - $debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; |
|
83 | + $debug = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG; |
|
84 | 84 | |
85 | 85 | $min = $debug ? '' : '.min'; |
86 | 86 | |
87 | 87 | // if colorpicker. |
88 | - if ( isset( $dependencies['wp-color-picker'] ) ) { |
|
89 | - if ( ! is_admin() ) { |
|
88 | + if (isset($dependencies['wp-color-picker'])) { |
|
89 | + if ( ! is_admin()) { |
|
90 | 90 | self::colorpicker_frontend(); |
91 | 91 | } |
92 | 92 | |
93 | - if ( isset( $dependencies['wp-color-picker-alpha'] ) ) { |
|
93 | + if (isset($dependencies['wp-color-picker-alpha'])) { |
|
94 | 94 | self::register_colorpicker_alpha(); |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | 98 | // if file/file_list. |
99 | - if ( isset( $dependencies['media-editor'] ) ) { |
|
99 | + if (isset($dependencies['media-editor'])) { |
|
100 | 100 | wp_enqueue_media(); |
101 | 101 | CMB2_Type_File_Base::output_js_underscore_templates(); |
102 | 102 | } |
103 | 103 | |
104 | 104 | // if timepicker. |
105 | - if ( isset( $dependencies['jquery-ui-datetimepicker'] ) ) { |
|
105 | + if (isset($dependencies['jquery-ui-datetimepicker'])) { |
|
106 | 106 | self::register_datetimepicker(); |
107 | 107 | } |
108 | 108 | |
109 | 109 | // if cmb2-wysiwyg. |
110 | - $enqueue_wysiwyg = isset( $dependencies['cmb2-wysiwyg'] ) && $debug; |
|
111 | - unset( $dependencies['cmb2-wysiwyg'] ); |
|
110 | + $enqueue_wysiwyg = isset($dependencies['cmb2-wysiwyg']) && $debug; |
|
111 | + unset($dependencies['cmb2-wysiwyg']); |
|
112 | 112 | |
113 | 113 | // if cmb2-char-counter. |
114 | - $enqueue_char_counter = isset( $dependencies['cmb2-char-counter'] ) && $debug; |
|
115 | - unset( $dependencies['cmb2-char-counter'] ); |
|
114 | + $enqueue_char_counter = isset($dependencies['cmb2-char-counter']) && $debug; |
|
115 | + unset($dependencies['cmb2-char-counter']); |
|
116 | 116 | |
117 | 117 | // Enqueue cmb JS. |
118 | - wp_enqueue_script( self::$handle, CMB2_Utils::url( "js/cmb2{$min}.js" ), array_values( $dependencies ), CMB2_VERSION, true ); |
|
118 | + wp_enqueue_script(self::$handle, CMB2_Utils::url("js/cmb2{$min}.js"), array_values($dependencies), CMB2_VERSION, true); |
|
119 | 119 | |
120 | 120 | // if SCRIPT_DEBUG, we need to enqueue separately. |
121 | - if ( $enqueue_wysiwyg ) { |
|
122 | - wp_enqueue_script( 'cmb2-wysiwyg', CMB2_Utils::url( 'js/cmb2-wysiwyg.js' ), array( 'jquery', 'wp-util' ), CMB2_VERSION ); |
|
121 | + if ($enqueue_wysiwyg) { |
|
122 | + wp_enqueue_script('cmb2-wysiwyg', CMB2_Utils::url('js/cmb2-wysiwyg.js'), array('jquery', 'wp-util'), CMB2_VERSION); |
|
123 | 123 | } |
124 | - if ( $enqueue_char_counter ) { |
|
125 | - wp_enqueue_script( 'cmb2-char-counter', CMB2_Utils::url( 'js/cmb2-char-counter.js' ), array( 'jquery', 'wp-util' ), CMB2_VERSION ); |
|
124 | + if ($enqueue_char_counter) { |
|
125 | + wp_enqueue_script('cmb2-char-counter', CMB2_Utils::url('js/cmb2-char-counter.js'), array('jquery', 'wp-util'), CMB2_VERSION); |
|
126 | 126 | } |
127 | 127 | |
128 | - self::localize( $debug ); |
|
128 | + self::localize($debug); |
|
129 | 129 | |
130 | - do_action( 'cmb2_footer_enqueue' ); |
|
130 | + do_action('cmb2_footer_enqueue'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return void |
141 | 141 | */ |
142 | - public static function register_colorpicker_alpha( $enqueue = false ) { |
|
142 | + public static function register_colorpicker_alpha($enqueue = false) { |
|
143 | 143 | // Only use minified files if SCRIPT_DEBUG is off. |
144 | - $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
144 | + $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
145 | 145 | $func = $enqueue ? 'wp_enqueue_script' : 'wp_register_script'; |
146 | - $func( 'wp-color-picker-alpha', CMB2_Utils::url( "js/wp-color-picker-alpha{$min}.js" ), array( 'wp-color-picker' ), '2.1.3' ); |
|
146 | + $func('wp-color-picker-alpha', CMB2_Utils::url("js/wp-color-picker-alpha{$min}.js"), array('wp-color-picker'), '2.1.3'); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public static function register_datetimepicker( $enqueue = false ) { |
|
158 | + public static function register_datetimepicker($enqueue = false) { |
|
159 | 159 | $func = $enqueue ? 'wp_enqueue_script' : 'wp_register_script'; |
160 | - $func( 'jquery-ui-datetimepicker', CMB2_Utils::url( 'js/jquery-ui-timepicker-addon.min.js' ), array( 'jquery-ui-slider' ), '1.5.0' ); |
|
160 | + $func('jquery-ui-datetimepicker', CMB2_Utils::url('js/jquery-ui-timepicker-addon.min.js'), array('jquery-ui-slider'), '1.5.0'); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | * @since 2.0.7 |
167 | 167 | */ |
168 | 168 | protected static function colorpicker_frontend() { |
169 | - wp_register_script( 'iris', admin_url( 'js/iris.min.js' ), array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), CMB2_VERSION ); |
|
170 | - wp_register_script( 'wp-color-picker', admin_url( 'js/color-picker.min.js' ), array( 'iris' ), CMB2_VERSION ); |
|
171 | - wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', array( |
|
172 | - 'clear' => esc_html__( 'Clear', 'cmb2' ), |
|
173 | - 'defaultString' => esc_html__( 'Default', 'cmb2' ), |
|
174 | - 'pick' => esc_html__( 'Select Color', 'cmb2' ), |
|
175 | - 'current' => esc_html__( 'Current Color', 'cmb2' ), |
|
176 | - ) ); |
|
169 | + wp_register_script('iris', admin_url('js/iris.min.js'), array('jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch'), CMB2_VERSION); |
|
170 | + wp_register_script('wp-color-picker', admin_url('js/color-picker.min.js'), array('iris'), CMB2_VERSION); |
|
171 | + wp_localize_script('wp-color-picker', 'wpColorPickerL10n', array( |
|
172 | + 'clear' => esc_html__('Clear', 'cmb2'), |
|
173 | + 'defaultString' => esc_html__('Default', 'cmb2'), |
|
174 | + 'pick' => esc_html__('Select Color', 'cmb2'), |
|
175 | + 'current' => esc_html__('Current Color', 'cmb2'), |
|
176 | + )); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param mixed $debug Whether or not we are debugging. |
185 | 185 | */ |
186 | - protected static function localize( $debug ) { |
|
186 | + protected static function localize($debug) { |
|
187 | 187 | static $localized = false; |
188 | - if ( $localized ) { |
|
188 | + if ($localized) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | 192 | $localized = true; |
193 | 193 | $l10n = array( |
194 | 194 | 'fields' => self::$fields, |
195 | - 'ajax_nonce' => wp_create_nonce( 'ajax_nonce' ), |
|
196 | - 'ajaxurl' => admin_url( '/admin-ajax.php' ), |
|
195 | + 'ajax_nonce' => wp_create_nonce('ajax_nonce'), |
|
196 | + 'ajaxurl' => admin_url('/admin-ajax.php'), |
|
197 | 197 | 'script_debug' => $debug, |
198 | 198 | 'up_arrow_class' => 'dashicons dashicons-arrow-up-alt2', |
199 | 199 | 'down_arrow_class' => 'dashicons dashicons-arrow-down-alt2', |
@@ -204,49 +204,49 @@ discard block |
||
204 | 204 | 'date_picker' => array( |
205 | 205 | 'changeMonth' => true, |
206 | 206 | 'changeYear' => true, |
207 | - 'dateFormat' => _x( 'mm/dd/yy', 'Valid formatDate string for jquery-ui datepicker', 'cmb2' ), |
|
208 | - 'dayNames' => explode( ',', esc_html__( 'Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday', 'cmb2' ) ), |
|
209 | - 'dayNamesMin' => explode( ',', esc_html__( 'Su, Mo, Tu, We, Th, Fr, Sa', 'cmb2' ) ), |
|
210 | - 'dayNamesShort' => explode( ',', esc_html__( 'Sun, Mon, Tue, Wed, Thu, Fri, Sat', 'cmb2' ) ), |
|
211 | - 'monthNames' => explode( ',', esc_html__( 'January, February, March, April, May, June, July, August, September, October, November, December', 'cmb2' ) ), |
|
212 | - 'monthNamesShort' => explode( ',', esc_html__( 'Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec', 'cmb2' ) ), |
|
213 | - 'nextText' => esc_html__( 'Next', 'cmb2' ), |
|
214 | - 'prevText' => esc_html__( 'Prev', 'cmb2' ), |
|
215 | - 'currentText' => esc_html__( 'Today', 'cmb2' ), |
|
216 | - 'closeText' => esc_html__( 'Done', 'cmb2' ), |
|
217 | - 'clearText' => esc_html__( 'Clear', 'cmb2' ), |
|
207 | + 'dateFormat' => _x('mm/dd/yy', 'Valid formatDate string for jquery-ui datepicker', 'cmb2'), |
|
208 | + 'dayNames' => explode(',', esc_html__('Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday', 'cmb2')), |
|
209 | + 'dayNamesMin' => explode(',', esc_html__('Su, Mo, Tu, We, Th, Fr, Sa', 'cmb2')), |
|
210 | + 'dayNamesShort' => explode(',', esc_html__('Sun, Mon, Tue, Wed, Thu, Fri, Sat', 'cmb2')), |
|
211 | + 'monthNames' => explode(',', esc_html__('January, February, March, April, May, June, July, August, September, October, November, December', 'cmb2')), |
|
212 | + 'monthNamesShort' => explode(',', esc_html__('Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec', 'cmb2')), |
|
213 | + 'nextText' => esc_html__('Next', 'cmb2'), |
|
214 | + 'prevText' => esc_html__('Prev', 'cmb2'), |
|
215 | + 'currentText' => esc_html__('Today', 'cmb2'), |
|
216 | + 'closeText' => esc_html__('Done', 'cmb2'), |
|
217 | + 'clearText' => esc_html__('Clear', 'cmb2'), |
|
218 | 218 | ), |
219 | 219 | 'time_picker' => array( |
220 | - 'timeOnlyTitle' => esc_html__( 'Choose Time', 'cmb2' ), |
|
221 | - 'timeText' => esc_html__( 'Time', 'cmb2' ), |
|
222 | - 'hourText' => esc_html__( 'Hour', 'cmb2' ), |
|
223 | - 'minuteText' => esc_html__( 'Minute', 'cmb2' ), |
|
224 | - 'secondText' => esc_html__( 'Second', 'cmb2' ), |
|
225 | - 'currentText' => esc_html__( 'Now', 'cmb2' ), |
|
226 | - 'closeText' => esc_html__( 'Done', 'cmb2' ), |
|
227 | - 'timeFormat' => _x( 'hh:mm TT', 'Valid formatting string, as per http://trentrichardson.com/examples/timepicker/', 'cmb2' ), |
|
220 | + 'timeOnlyTitle' => esc_html__('Choose Time', 'cmb2'), |
|
221 | + 'timeText' => esc_html__('Time', 'cmb2'), |
|
222 | + 'hourText' => esc_html__('Hour', 'cmb2'), |
|
223 | + 'minuteText' => esc_html__('Minute', 'cmb2'), |
|
224 | + 'secondText' => esc_html__('Second', 'cmb2'), |
|
225 | + 'currentText' => esc_html__('Now', 'cmb2'), |
|
226 | + 'closeText' => esc_html__('Done', 'cmb2'), |
|
227 | + 'timeFormat' => _x('hh:mm TT', 'Valid formatting string, as per http://trentrichardson.com/examples/timepicker/', 'cmb2'), |
|
228 | 228 | 'controlType' => 'select', |
229 | 229 | 'stepMinute' => 5, |
230 | 230 | ), |
231 | 231 | ), |
232 | 232 | 'strings' => array( |
233 | - 'upload_file' => esc_html__( 'Use this file', 'cmb2' ), |
|
234 | - 'upload_files' => esc_html__( 'Use these files', 'cmb2' ), |
|
235 | - 'remove_image' => esc_html__( 'Remove Image', 'cmb2' ), |
|
236 | - 'remove_file' => esc_html__( 'Remove', 'cmb2' ), |
|
237 | - 'file' => esc_html__( 'File:', 'cmb2' ), |
|
238 | - 'download' => esc_html__( 'Download', 'cmb2' ), |
|
239 | - 'check_toggle' => esc_html__( 'Select / Deselect All', 'cmb2' ), |
|
233 | + 'upload_file' => esc_html__('Use this file', 'cmb2'), |
|
234 | + 'upload_files' => esc_html__('Use these files', 'cmb2'), |
|
235 | + 'remove_image' => esc_html__('Remove Image', 'cmb2'), |
|
236 | + 'remove_file' => esc_html__('Remove', 'cmb2'), |
|
237 | + 'file' => esc_html__('File:', 'cmb2'), |
|
238 | + 'download' => esc_html__('Download', 'cmb2'), |
|
239 | + 'check_toggle' => esc_html__('Select / Deselect All', 'cmb2'), |
|
240 | 240 | ), |
241 | 241 | ); |
242 | 242 | |
243 | - if ( isset( self::$dependencies['code-editor'] ) && function_exists( 'wp_enqueue_code_editor' ) ) { |
|
244 | - $l10n['defaults']['code_editor'] = wp_enqueue_code_editor( array( |
|
243 | + if (isset(self::$dependencies['code-editor']) && function_exists('wp_enqueue_code_editor')) { |
|
244 | + $l10n['defaults']['code_editor'] = wp_enqueue_code_editor(array( |
|
245 | 245 | 'type' => 'text/html', |
246 | - ) ); |
|
246 | + )); |
|
247 | 247 | } |
248 | 248 | |
249 | - wp_localize_script( self::$handle, self::$js_variable, apply_filters( 'cmb2_localized_data', $l10n ) ); |
|
249 | + wp_localize_script(self::$handle, self::$js_variable, apply_filters('cmb2_localized_data', $l10n)); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | } |
@@ -12,51 +12,51 @@ |
||
12 | 12 | */ |
13 | 13 | class CMB2_Type_Text_Datetime_Timestamp_Timezone extends CMB2_Type_Base { |
14 | 14 | |
15 | - public function render( $args = array() ) { |
|
15 | + public function render($args = array()) { |
|
16 | 16 | $field = $this->field; |
17 | 17 | |
18 | 18 | $value = $field->escaped_value(); |
19 | - if ( empty( $value ) ) { |
|
19 | + if (empty($value)) { |
|
20 | 20 | $value = $field->get_default(); |
21 | 21 | } |
22 | 22 | |
23 | - $args = wp_parse_args( $this->args, array( |
|
23 | + $args = wp_parse_args($this->args, array( |
|
24 | 24 | 'value' => $value, |
25 | - 'desc' => $this->_desc( true ), |
|
25 | + 'desc' => $this->_desc(true), |
|
26 | 26 | 'text_datetime_timestamp' => array(), |
27 | 27 | 'select_timezone' => array(), |
28 | - ) ); |
|
28 | + )); |
|
29 | 29 | |
30 | 30 | $args['value'] = $value; |
31 | - if ( is_array( $args['value'] ) ) { |
|
31 | + if (is_array($args['value'])) { |
|
32 | 32 | $args['value'] = ''; |
33 | 33 | } |
34 | 34 | |
35 | - $datetime = maybe_unserialize( $args['value'] ); |
|
35 | + $datetime = maybe_unserialize($args['value']); |
|
36 | 36 | $value = $tzstring = ''; |
37 | 37 | |
38 | - if ( $datetime && $datetime instanceof DateTime ) { |
|
38 | + if ($datetime && $datetime instanceof DateTime) { |
|
39 | 39 | $tz = $datetime->getTimezone(); |
40 | 40 | $tzstring = $tz->getName(); |
41 | 41 | $value = $datetime->getTimestamp(); |
42 | 42 | } |
43 | 43 | |
44 | - $timestamp_args = wp_parse_args( $args['text_datetime_timestamp'], array( |
|
44 | + $timestamp_args = wp_parse_args($args['text_datetime_timestamp'], array( |
|
45 | 45 | 'desc' => '', |
46 | 46 | 'value' => $value, |
47 | 47 | 'rendered' => true, |
48 | - ) ); |
|
49 | - $datetime_timestamp = $this->types->text_datetime_timestamp( $timestamp_args ); |
|
48 | + )); |
|
49 | + $datetime_timestamp = $this->types->text_datetime_timestamp($timestamp_args); |
|
50 | 50 | |
51 | - $timezone_select_args = wp_parse_args( $args['select_timezone'], array( |
|
51 | + $timezone_select_args = wp_parse_args($args['select_timezone'], array( |
|
52 | 52 | 'class' => 'cmb2_select cmb2-select-timezone', |
53 | - 'name' => $this->_name( '[timezone]' ), |
|
54 | - 'id' => $this->_id( '_timezone' ), |
|
55 | - 'options' => wp_timezone_choice( $tzstring ), |
|
53 | + 'name' => $this->_name('[timezone]'), |
|
54 | + 'id' => $this->_id('_timezone'), |
|
55 | + 'options' => wp_timezone_choice($tzstring), |
|
56 | 56 | 'desc' => $args['desc'], |
57 | 57 | 'rendered' => true, |
58 | - ) ); |
|
59 | - $select = $this->types->select( $timezone_select_args ); |
|
58 | + )); |
|
59 | + $select = $this->types->select($timezone_select_args); |
|
60 | 60 | |
61 | 61 | return $this->rendered( |
62 | 62 | $datetime_timestamp . "\n" . $select |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | * @param array $args Array of arguments for the type. |
29 | 29 | * @param mixed $is_checked Whether or not the field is checked, or default value. |
30 | 30 | */ |
31 | - public function __construct( CMB2_Types $types, $args = array(), $is_checked = null ) { |
|
32 | - parent::__construct( $types, $args ); |
|
31 | + public function __construct(CMB2_Types $types, $args = array(), $is_checked = null) { |
|
32 | + parent::__construct($types, $args); |
|
33 | 33 | $this->is_checked = $is_checked; |
34 | 34 | } |
35 | 35 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param array $args Array of arguments for the rendering. |
42 | 42 | * @return CMB2_Type_Base|string |
43 | 43 | */ |
44 | - public function render( $args = array() ) { |
|
44 | + public function render($args = array()) { |
|
45 | 45 | $defaults = array( |
46 | 46 | 'type' => 'checkbox', |
47 | 47 | 'class' => 'cmb2-option cmb2-list', |
@@ -52,20 +52,20 @@ discard block |
||
52 | 52 | $meta_value = $this->field->escaped_value(); |
53 | 53 | |
54 | 54 | $is_checked = null === $this->is_checked |
55 | - ? ! empty( $meta_value ) |
|
55 | + ? ! empty($meta_value) |
|
56 | 56 | : $this->is_checked; |
57 | 57 | |
58 | - if ( $is_checked ) { |
|
58 | + if ($is_checked) { |
|
59 | 59 | $defaults['checked'] = 'checked'; |
60 | 60 | } |
61 | 61 | |
62 | - $args = $this->parse_args( 'checkbox', $defaults ); |
|
62 | + $args = $this->parse_args('checkbox', $defaults); |
|
63 | 63 | |
64 | 64 | return $this->rendered( |
65 | 65 | sprintf( |
66 | 66 | '%s <label for="%s">%s</label>', |
67 | - parent::render( $args ), |
|
68 | - $this->_id( '', false ), |
|
67 | + parent::render($args), |
|
68 | + $this->_id('', false), |
|
69 | 69 | $this->_desc() |
70 | 70 | ) |
71 | 71 | ); |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | * @param array $args Array of arguments for the type. |
29 | 29 | * @param string $value Value that the field type is currently set to, or default value. |
30 | 30 | */ |
31 | - public function __construct( CMB2_Types $types, $args = array(), $value = '' ) { |
|
32 | - parent::__construct( $types, $args ); |
|
31 | + public function __construct(CMB2_Types $types, $args = array(), $value = '') { |
|
32 | + parent::__construct($types, $args); |
|
33 | 33 | $this->value = $value ? $value : $this->value; |
34 | 34 | } |
35 | 35 | |
@@ -42,41 +42,41 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return CMB2_Type_Base|string |
44 | 44 | */ |
45 | - public function render( $args = array() ) { |
|
45 | + public function render($args = array()) { |
|
46 | 46 | $meta_value = $this->value ? $this->value : $this->field->escaped_value(); |
47 | 47 | |
48 | 48 | $hex_color = '(([a-fA-F0-9]){3}){1,2}$'; |
49 | - if ( preg_match( '/^' . $hex_color . '/i', $meta_value ) ) { |
|
49 | + if (preg_match('/^' . $hex_color . '/i', $meta_value)) { |
|
50 | 50 | // Value is just 123abc, so prepend #. |
51 | 51 | $meta_value = '#' . $meta_value; |
52 | 52 | } elseif ( |
53 | 53 | // If value doesn't match #123abc... |
54 | - ! preg_match( '/^#' . $hex_color . '/i', $meta_value ) |
|
54 | + ! preg_match('/^#' . $hex_color . '/i', $meta_value) |
|
55 | 55 | // And value doesn't match rgba()... |
56 | - && 0 !== strpos( trim( $meta_value ), 'rgba' ) |
|
56 | + && 0 !== strpos(trim($meta_value), 'rgba') |
|
57 | 57 | ) { |
58 | 58 | // Then sanitize to just #. |
59 | 59 | $meta_value = '#'; |
60 | 60 | } |
61 | 61 | |
62 | - wp_enqueue_style( 'wp-color-picker' ); |
|
62 | + wp_enqueue_style('wp-color-picker'); |
|
63 | 63 | |
64 | - $args = wp_parse_args( $args, array( |
|
64 | + $args = wp_parse_args($args, array( |
|
65 | 65 | 'class' => 'cmb2-text-small', |
66 | - ) ); |
|
66 | + )); |
|
67 | 67 | |
68 | 68 | $args['class'] .= ' cmb2-colorpicker'; |
69 | 69 | $args['value'] = $meta_value; |
70 | - $args['js_dependencies'] = array( 'wp-color-picker' ); |
|
70 | + $args['js_dependencies'] = array('wp-color-picker'); |
|
71 | 71 | |
72 | - if ( $this->field->options( 'alpha' ) ) { |
|
72 | + if ($this->field->options('alpha')) { |
|
73 | 73 | $args['js_dependencies'][] = 'wp-color-picker-alpha'; |
74 | 74 | $args['data-alpha'] = 'true'; |
75 | 75 | } |
76 | 76 | |
77 | - $args = wp_parse_args( $this->args, $args ); |
|
77 | + $args = wp_parse_args($this->args, $args); |
|
78 | 78 | |
79 | - return parent::render( $args ); |
|
79 | + return parent::render($args); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @since 2.2.6.2 |
86 | 86 | */ |
87 | 87 | public static function dequeue_rgba_colorpicker_script() { |
88 | - if ( wp_script_is( 'jw-cmb2-rgba-picker-js', 'enqueued' ) ) { |
|
89 | - wp_dequeue_script( 'jw-cmb2-rgba-picker-js' ); |
|
90 | - CMB2_JS::register_colorpicker_alpha( true ); |
|
88 | + if (wp_script_is('jw-cmb2-rgba-picker-js', 'enqueued')) { |
|
89 | + wp_dequeue_script('jw-cmb2-rgba-picker-js'); |
|
90 | + CMB2_JS::register_colorpicker_alpha(true); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 |
@@ -21,17 +21,17 @@ |
||
21 | 21 | |
22 | 22 | public function render() { |
23 | 23 | return $this->rendered( |
24 | - $this->types->radio( array( |
|
24 | + $this->types->radio(array( |
|
25 | 25 | 'options' => $this->get_term_options(), |
26 | - ), 'taxonomy_radio_hierarchical' ) |
|
26 | + ), 'taxonomy_radio_hierarchical') |
|
27 | 27 | ); |
28 | 28 | } |
29 | 29 | |
30 | - protected function list_term_input( $term, $saved_term ) { |
|
31 | - $options = parent::list_term_input( $term, $saved_term ); |
|
32 | - $children = $this->build_children( $term, $saved_term ); |
|
30 | + protected function list_term_input($term, $saved_term) { |
|
31 | + $options = parent::list_term_input($term, $saved_term); |
|
32 | + $children = $this->build_children($term, $saved_term); |
|
33 | 33 | |
34 | - if ( ! empty( $children ) ) { |
|
34 | + if ( ! empty($children)) { |
|
35 | 35 | $options .= $children; |
36 | 36 | } |
37 | 37 |
@@ -27,26 +27,26 @@ |
||
27 | 27 | * @param CMB2_Types $types |
28 | 28 | * @param array $args |
29 | 29 | */ |
30 | - public function __construct( CMB2_Types $types, $args = array(), $type = '' ) { |
|
31 | - parent::__construct( $types, $args ); |
|
30 | + public function __construct(CMB2_Types $types, $args = array(), $type = '') { |
|
31 | + parent::__construct($types, $args); |
|
32 | 32 | $this->type = $type ? $type : $this->type; |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function render() { |
36 | - $args = $this->parse_args( $this->type, array( |
|
36 | + $args = $this->parse_args($this->type, array( |
|
37 | 37 | 'class' => 'cmb2-radio-list cmb2-list', |
38 | - 'options' => $this->concat_items( array( |
|
38 | + 'options' => $this->concat_items(array( |
|
39 | 39 | 'label' => 'test', |
40 | 40 | 'method' => 'list_input', |
41 | - ) ), |
|
42 | - 'desc' => $this->_desc( true ), |
|
43 | - ) ); |
|
41 | + )), |
|
42 | + 'desc' => $this->_desc(true), |
|
43 | + )); |
|
44 | 44 | |
45 | - return $this->rendered( $this->ul( $args ) ); |
|
45 | + return $this->rendered($this->ul($args)); |
|
46 | 46 | } |
47 | 47 | |
48 | - protected function ul( $a ) { |
|
49 | - return sprintf( '<ul class="%s">%s</ul>%s', $a['class'], $a['options'], $a['desc'] ); |
|
48 | + protected function ul($a) { |
|
49 | + return sprintf('<ul class="%s">%s</ul>%s', $a['class'], $a['options'], $a['desc']); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | } |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | * @param array $args Arguments array containing value, label, and checked boolean |
20 | 20 | * @return string Generated option element html |
21 | 21 | */ |
22 | - public function select_option( $args = array() ) { |
|
23 | - return sprintf( "\t" . '<option value="%s" %s>%s</option>', $args['value'], selected( isset( $args['checked'] ) && $args['checked'], true, false ), $args['label'] ) . "\n"; |
|
22 | + public function select_option($args = array()) { |
|
23 | + return sprintf("\t" . '<option value="%s" %s>%s</option>', $args['value'], selected(isset($args['checked']) && $args['checked'], true, false), $args['label']) . "\n"; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | * @param int $i Iterator value |
32 | 32 | * @return string Gnerated list item html |
33 | 33 | */ |
34 | - public function list_input( $args = array(), $i ) { |
|
35 | - $a = $this->parse_args( 'list_input', array( |
|
34 | + public function list_input($args = array(), $i) { |
|
35 | + $a = $this->parse_args('list_input', array( |
|
36 | 36 | 'type' => 'radio', |
37 | 37 | 'class' => 'cmb2-option', |
38 | 38 | 'name' => $this->_name(), |
39 | - 'id' => $this->_id( $i ), |
|
39 | + 'id' => $this->_id($i), |
|
40 | 40 | 'value' => $this->field->escaped_value(), |
41 | 41 | 'label' => '', |
42 | - ), $args ); |
|
42 | + ), $args); |
|
43 | 43 | |
44 | - return sprintf( "\t" . '<li><input%s/> <label for="%s">%s</label></li>' . "\n", $this->concat_attrs( $a, array( 'label' ) ), $a['id'], $a['label'] ); |
|
44 | + return sprintf("\t" . '<li><input%s/> <label for="%s">%s</label></li>' . "\n", $this->concat_attrs($a, array('label')), $a['id'], $a['label']); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | * @param int $i Iterator value |
53 | 53 | * @return string Gnerated list item html |
54 | 54 | */ |
55 | - public function list_input_checkbox( $args, $i ) { |
|
55 | + public function list_input_checkbox($args, $i) { |
|
56 | 56 | $saved_value = $this->field->escaped_value(); |
57 | - if ( is_array( $saved_value ) && in_array( $args['value'], $saved_value ) ) { |
|
57 | + if (is_array($saved_value) && in_array($args['value'], $saved_value)) { |
|
58 | 58 | $args['checked'] = 'checked'; |
59 | 59 | } |
60 | 60 | $args['type'] = 'checkbox'; |
61 | - return $this->list_input( $args, $i ); |
|
61 | + return $this->list_input($args, $i); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,27 +68,27 @@ discard block |
||
68 | 68 | * @param array $args Optional arguments |
69 | 69 | * @return string Concatenated html items |
70 | 70 | */ |
71 | - public function concat_items( $args = array() ) { |
|
71 | + public function concat_items($args = array()) { |
|
72 | 72 | $field = $this->field; |
73 | 73 | |
74 | - $method = isset( $args['method'] ) ? $args['method'] : 'select_option'; |
|
75 | - unset( $args['method'] ); |
|
74 | + $method = isset($args['method']) ? $args['method'] : 'select_option'; |
|
75 | + unset($args['method']); |
|
76 | 76 | |
77 | 77 | $value = null !== $field->escaped_value() |
78 | 78 | ? $field->escaped_value() |
79 | 79 | : $field->get_default(); |
80 | 80 | |
81 | - $value = CMB2_Utils::normalize_if_numeric( $value ); |
|
81 | + $value = CMB2_Utils::normalize_if_numeric($value); |
|
82 | 82 | |
83 | 83 | $concatenated_items = ''; |
84 | 84 | $i = 1; |
85 | 85 | |
86 | 86 | $options = array(); |
87 | - if ( $option_none = $field->args( 'show_option_none' ) ) { |
|
87 | + if ($option_none = $field->args('show_option_none')) { |
|
88 | 88 | $options[''] = $option_none; |
89 | 89 | } |
90 | 90 | $options = $options + (array) $field->options(); |
91 | - foreach ( $options as $opt_value => $opt_label ) { |
|
91 | + foreach ($options as $opt_value => $opt_label) { |
|
92 | 92 | |
93 | 93 | // Clone args & modify for just this item |
94 | 94 | $a = $args; |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | $a['label'] = $opt_label; |
98 | 98 | |
99 | 99 | // Check if this option is the value of the input |
100 | - if ( $value === CMB2_Utils::normalize_if_numeric( $opt_value ) ) { |
|
100 | + if ($value === CMB2_Utils::normalize_if_numeric($opt_value)) { |
|
101 | 101 | $a['checked'] = 'checked'; |
102 | 102 | } |
103 | 103 | |
104 | - $concatenated_items .= $this->$method( $a, $i++ ); |
|
104 | + $concatenated_items .= $this->$method($a, $i++); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $concatenated_items; |