@@ -143,30 +143,30 @@ discard block |
||
143 | 143 | foreach ( self::$boxes as $cmb_id => $rest_box ) { |
144 | 144 | $types = array_flip( $rest_box->cmb->box_types() ); |
145 | 145 | |
146 | - if ( isset( $types['user'] ) ) { |
|
147 | - unset( $types['user'] ); |
|
148 | - self::$type_boxes['user'][ $cmb_id ] = $cmb_id; |
|
146 | + if ( isset( $types[ 'user' ] ) ) { |
|
147 | + unset( $types[ 'user' ] ); |
|
148 | + self::$type_boxes[ 'user' ][ $cmb_id ] = $cmb_id; |
|
149 | 149 | } |
150 | 150 | |
151 | - if ( isset( $types['comment'] ) ) { |
|
152 | - unset( $types['comment'] ); |
|
153 | - self::$type_boxes['comment'][ $cmb_id ] = $cmb_id; |
|
151 | + if ( isset( $types[ 'comment' ] ) ) { |
|
152 | + unset( $types[ 'comment' ] ); |
|
153 | + self::$type_boxes[ 'comment' ][ $cmb_id ] = $cmb_id; |
|
154 | 154 | } |
155 | 155 | |
156 | - if ( isset( $types['term'] ) ) { |
|
157 | - unset( $types['term'] ); |
|
156 | + if ( isset( $types[ 'term' ] ) ) { |
|
157 | + unset( $types[ 'term' ] ); |
|
158 | 158 | |
159 | 159 | $taxonomies = array_merge( |
160 | 160 | $taxonomies, |
161 | 161 | CMB2_Utils::ensure_array( $rest_box->cmb->prop( 'taxonomies' ) ) |
162 | 162 | ); |
163 | 163 | |
164 | - self::$type_boxes['term'][ $cmb_id ] = $cmb_id; |
|
164 | + self::$type_boxes[ 'term' ][ $cmb_id ] = $cmb_id; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | if ( ! empty( $types ) ) { |
168 | 168 | $alltypes = array_merge( $alltypes, array_flip( $types ) ); |
169 | - self::$type_boxes['post'][ $cmb_id ] = $cmb_id; |
|
169 | + self::$type_boxes[ 'post' ][ $cmb_id ] = $cmb_id; |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | self::register_rest_field( $alltypes, 'post' ); |
177 | 177 | } |
178 | 178 | |
179 | - if ( ! empty( self::$type_boxes['user'] ) ) { |
|
179 | + if ( ! empty( self::$type_boxes[ 'user' ] ) ) { |
|
180 | 180 | self::register_rest_field( 'user', 'user' ); |
181 | 181 | } |
182 | 182 | |
183 | - if ( ! empty( self::$type_boxes['comment'] ) ) { |
|
183 | + if ( ! empty( self::$type_boxes[ 'comment' ] ) ) { |
|
184 | 184 | self::register_rest_field( 'comment', 'comment' ); |
185 | 185 | } |
186 | 186 | |
187 | - if ( ! empty( self::$type_boxes['term'] ) ) { |
|
187 | + if ( ! empty( self::$type_boxes[ 'term' ] ) ) { |
|
188 | 188 | self::register_rest_field( $taxonomies, 'term' ); |
189 | 189 | } |
190 | 190 | } |
@@ -217,18 +217,18 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function declare_read_edit_fields() { |
219 | 219 | foreach ( $this->cmb->prop( 'fields' ) as $field ) { |
220 | - $show_in_rest = isset( $field['show_in_rest'] ) ? $field['show_in_rest'] : null; |
|
220 | + $show_in_rest = isset( $field[ 'show_in_rest' ] ) ? $field[ 'show_in_rest' ] : null; |
|
221 | 221 | |
222 | 222 | if ( false === $show_in_rest ) { |
223 | 223 | continue; |
224 | 224 | } |
225 | 225 | |
226 | 226 | if ( $this->can_read( $show_in_rest ) ) { |
227 | - $this->read_fields[] = $field['id']; |
|
227 | + $this->read_fields[ ] = $field[ 'id' ]; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | if ( $this->can_edit( $show_in_rest ) ) { |
231 | - $this->edit_fields[] = $field['id']; |
|
231 | + $this->edit_fields[ ] = $field[ 'id' ]; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @return mixed |
360 | 360 | */ |
361 | 361 | protected static function get_rest_values( $object, $request, $object_type, $main_object_type = 'post' ) { |
362 | - if ( ! isset( $object['id'] ) ) { |
|
362 | + if ( ! isset( $object[ 'id' ] ) ) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | $rest_box = self::$boxes[ $cmb_id ]; |
371 | 371 | |
372 | 372 | foreach ( $rest_box->read_fields as $field_id ) { |
373 | - $rest_box->cmb->object_id( $object['id'] ); |
|
373 | + $rest_box->cmb->object_id( $object[ 'id' ] ); |
|
374 | 374 | $rest_box->cmb->object_type( $main_object_type ); |
375 | 375 | |
376 | 376 | $field = $rest_box->cmb->get_field( $field_id ); |
377 | 377 | |
378 | - $field->object_id( $object['id'] ); |
|
378 | + $field->object_id( $object[ 'id' ] ); |
|
379 | 379 | $field->object_type( $main_object_type ); |
380 | 380 | |
381 | 381 | $values[ $cmb_id ][ $field->id( true ) ] = $field->get_data(); |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | return intval( $object->comment_ID ); |
610 | 610 | } |
611 | 611 | case 'term': |
612 | - if ( is_array( $object ) && isset( $object['term_id'] ) ) { |
|
613 | - return intval( $object['term_id'] ); |
|
612 | + if ( is_array( $object ) && isset( $object[ 'term_id' ] ) ) { |
|
613 | + return intval( $object[ 'term_id' ] ); |
|
614 | 614 | } elseif ( isset( $object->term_id ) ) { |
615 | 615 | return intval( $object->term_id ); |
616 | 616 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'schema' => array( $this, 'get_item_schema' ), |
69 | 69 | ) ); |
70 | 70 | |
71 | - $args['_rendered'] = array( |
|
71 | + $args[ '_rendered' ] = array( |
|
72 | 72 | 'description' => __( 'Includes the fully rendered attributes, \'form_open\', \'form_close\', as well as the enqueued \'js_dependencies\' script handles, and \'css_dependencies\' stylesheet handles.', 'cmb2' ), |
73 | 73 | ); |
74 | 74 | |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | // And make sure current user can view this box. |
133 | 133 | && $this->get_item_permissions_check_filter( $this->request ) |
134 | 134 | ) { |
135 | - $boxes_data[] = $this->server->response_to_data( |
|
135 | + $boxes_data[ ] = $this->server->response_to_data( |
|
136 | 136 | $this->get_rest_box(), |
137 | - isset( $this->request['_embed'] ) |
|
137 | + isset( $this->request[ '_embed' ] ) |
|
138 | 138 | ); |
139 | 139 | } |
140 | 140 | } |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | |
211 | 211 | $boxes_data = $cmb->meta_box; |
212 | 212 | |
213 | - if ( isset( $this->request['_rendered'] ) && $this->namespace_base !== ltrim( CMB2_REST_Controller::get_intial_route(), '/' ) ) { |
|
214 | - $boxes_data['form_open'] = $this->get_cb_results( array( $cmb, 'render_form_open' ) ); |
|
215 | - $boxes_data['form_close'] = $this->get_cb_results( array( $cmb, 'render_form_close' ) ); |
|
213 | + if ( isset( $this->request[ '_rendered' ] ) && $this->namespace_base !== ltrim( CMB2_REST_Controller::get_intial_route(), '/' ) ) { |
|
214 | + $boxes_data[ 'form_open' ] = $this->get_cb_results( array( $cmb, 'render_form_open' ) ); |
|
215 | + $boxes_data[ 'form_close' ] = $this->get_cb_results( array( $cmb, 'render_form_close' ) ); |
|
216 | 216 | |
217 | 217 | global $wp_scripts, $wp_styles; |
218 | 218 | $before_css = $wp_styles->queue; |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | |
221 | 221 | CMB2_JS::enqueue(); |
222 | 222 | |
223 | - $boxes_data['js_dependencies'] = array_values( array_diff( $wp_scripts->queue, $before_js ) ); |
|
224 | - $boxes_data['css_dependencies'] = array_values( array_diff( $wp_styles->queue, $before_css ) ); |
|
223 | + $boxes_data[ 'js_dependencies' ] = array_values( array_diff( $wp_scripts->queue, $before_js ) ); |
|
224 | + $boxes_data[ 'css_dependencies' ] = array_values( array_diff( $wp_styles->queue, $before_css ) ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // TODO: look into 'embed' parameter. |
228 | 228 | // http://demo.wp-api.org/wp-json/wp/v2/posts?_embed |
229 | - unset( $boxes_data['fields'] ); |
|
229 | + unset( $boxes_data[ 'fields' ] ); |
|
230 | 230 | // Handle callable properties. |
231 | - unset( $boxes_data['show_on_cb'] ); |
|
231 | + unset( $boxes_data[ 'show_on_cb' ] ); |
|
232 | 232 | |
233 | 233 | $response = rest_ensure_response( $boxes_data ); |
234 | 234 |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | ) ); |
50 | 50 | |
51 | 51 | $delete_args = $args; |
52 | - $delete_args['object_id']['required'] = true; |
|
53 | - $delete_args['object_type']['required'] = true; |
|
52 | + $delete_args[ 'object_id' ][ 'required' ] = true; |
|
53 | + $delete_args[ 'object_type' ][ 'required' ] = true; |
|
54 | 54 | |
55 | 55 | // Returns specific field data. |
56 | 56 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<cmb_id>[\w-]+)/fields/(?P<field_id>[\w-]+)', array( |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | foreach ( $this->rest_box->cmb->prop( 'fields', array() ) as $field ) { |
123 | 123 | |
124 | 124 | // Make sure this field can be read. |
125 | - $this->field = $this->rest_box->field_can_read( $field['id'], true ); |
|
125 | + $this->field = $this->rest_box->field_can_read( $field[ 'id' ], true ); |
|
126 | 126 | |
127 | 127 | // And make sure current user can view this box. |
128 | 128 | if ( $this->field && $this->get_item_permissions_check_filter() ) { |
129 | - $fields[ $field['id'] ] = $this->server->response_to_data( |
|
129 | + $fields[ $field[ 'id' ] ] = $this->server->response_to_data( |
|
130 | 130 | $this->prepare_field_response(), |
131 | - isset( $this->request['_embed'] ) |
|
131 | + isset( $this->request[ '_embed' ] ) |
|
132 | 132 | ); |
133 | 133 | } |
134 | 134 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | public function update_item( $request ) { |
235 | 235 | $this->initiate_rest_read_box( $request, 'field_value_update' ); |
236 | 236 | |
237 | - if ( ! $this->request['value'] ) { |
|
237 | + if ( ! $this->request[ 'value' ] ) { |
|
238 | 238 | return new WP_Error( 'cmb2_rest_update_field_error', __( 'CMB2 Field value cannot be updated without the value parameter specified.', 'cmb2' ), array( 'status' => 400 ) ); |
239 | 239 | } |
240 | 240 | |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @param string $activity The modification activity (updated or deleted). |
292 | 292 | * @return WP_Error|WP_REST_Response |
293 | 293 | */ |
294 | - public function modify_field_value( $activity) { |
|
294 | + public function modify_field_value( $activity ) { |
|
295 | 295 | |
296 | - if ( ! $this->request['object_id'] || ! $this->request['object_type'] ) { |
|
296 | + if ( ! $this->request[ 'object_id' ] || ! $this->request[ 'object_type' ] ) { |
|
297 | 297 | return new WP_Error( 'cmb2_rest_modify_field_value_error', __( 'CMB2 Field value cannot be modified without the object_id and object_type parameters specified.', 'cmb2' ), array( 'status' => 400 ) ); |
298 | 298 | } |
299 | 299 | |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | return new WP_Error( 'cmb2_rest_no_field_by_id_error', __( 'No field found by that id.', 'cmb2' ), array( 'status' => 403 ) ); |
311 | 311 | } |
312 | 312 | |
313 | - $this->field->args["value_{$activity}"] = (bool) 'deleted' === $activity |
|
313 | + $this->field->args[ "value_{$activity}" ] = (bool) 'deleted' === $activity |
|
314 | 314 | ? $this->field->remove_data() |
315 | - : $this->field->save_field( $this->request['value'] ); |
|
315 | + : $this->field->save_field( $this->request[ 'value' ] ); |
|
316 | 316 | |
317 | 317 | // If options page, save the $activity options |
318 | - if ( 'options-page' == $this->request['object_type'] ) { |
|
319 | - $this->field->args["value_{$activity}"] = cmb2_options( $this->request['object_id'] )->set(); |
|
318 | + if ( 'options-page' == $this->request[ 'object_type' ] ) { |
|
319 | + $this->field->args[ "value_{$activity}" ] = cmb2_options( $this->request[ 'object_id' ] )->set(); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | return $this->prepare_read_field( $this->field ); |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | $value = $field->options(); |
392 | 392 | } elseif ( in_array( $key, CMB2_Field::$callable_fields, true ) ) { |
393 | 393 | |
394 | - if ( isset( $this->request['_rendered'] ) ) { |
|
394 | + if ( isset( $this->request[ '_rendered' ] ) ) { |
|
395 | 395 | $value = $key === 'render_row_cb' ? $rendered : $field->get_param_callback_result( $key ); |
396 | 396 | } elseif ( is_array( $value ) ) { |
397 | 397 | // We need to rewrite callbacks as string as they will cause |
398 | 398 | // JSON recursion errors. |
399 | - $class = is_string( $value[0] ) ? $value[0] : get_class( $value[0] ); |
|
400 | - $value = $class . '::' . $value[1]; |
|
399 | + $class = is_string( $value[ 0 ] ) ? $value[ 0 ] : get_class( $value[ 0 ] ); |
|
400 | + $value = $class . '::' . $value[ 1 ]; |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | } |
411 | 411 | } |
412 | 412 | |
413 | - if ( $this->request['object_id'] && $this->request['object_type'] ) { |
|
414 | - $field_data['value'] = $field->get_data(); |
|
413 | + if ( $this->request[ 'object_id' ] && $this->request[ 'object_type' ] ) { |
|
414 | + $field_data[ 'value' ] = $field->get_data(); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | return $field_data; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $cmb_demo = new_cmb2_box( array( |
116 | 116 | 'id' => $prefix . 'metabox', |
117 | 117 | 'title' => esc_html__( 'Test Metabox', 'cmb2' ), |
118 | - 'object_types' => array( 'page', ), // Post type |
|
118 | + 'object_types' => array( 'page',), // Post type |
|
119 | 119 | // 'show_on_cb' => 'yourprefix_show_if_front_page', // function should return a bool value |
120 | 120 | // 'context' => 'normal', |
121 | 121 | // 'priority' => 'high', |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | 'desc' => esc_html__( 'field description (optional)', 'cmb2' ), |
386 | 386 | 'id' => $prefix . 'wysiwyg', |
387 | 387 | 'type' => 'wysiwyg', |
388 | - 'options' => array( 'textarea_rows' => 5, ), |
|
388 | + 'options' => array( 'textarea_rows' => 5,), |
|
389 | 389 | ) ); |
390 | 390 | |
391 | 391 | $cmb_demo->add_field( array( |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | $cmb_about_page = new_cmb2_box( array( |
442 | 442 | 'id' => $prefix . 'metabox', |
443 | 443 | 'title' => esc_html__( 'About Page Metabox', 'cmb2' ), |
444 | - 'object_types' => array( 'page', ), // Post type |
|
444 | + 'object_types' => array( 'page',), // Post type |
|
445 | 445 | 'context' => 'normal', |
446 | 446 | 'priority' => 'high', |
447 | 447 | 'show_names' => true, // Show field names on the left |
448 | - 'show_on' => array( 'id' => array( 2, ) ), // Specific post IDs to display this metabox |
|
448 | + 'show_on' => array( 'id' => array( 2,) ), // Specific post IDs to display this metabox |
|
449 | 449 | ) ); |
450 | 450 | |
451 | 451 | $cmb_about_page->add_field( array( |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | $cmb_group = new_cmb2_box( array( |
471 | 471 | 'id' => $prefix . 'metabox', |
472 | 472 | 'title' => esc_html__( 'Repeating Field Group', 'cmb2' ), |
473 | - 'object_types' => array( 'page', ), |
|
473 | + 'object_types' => array( 'page',), |
|
474 | 474 | ) ); |
475 | 475 | |
476 | 476 | // $group_field_id is the field id string, so in this case: $prefix . 'demo' |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | $cmb_rest = new_cmb2_box( array( |
700 | 700 | 'id' => $prefix . 'metabox', |
701 | 701 | 'title' => esc_html__( 'REST Test Box', 'cmb2' ), |
702 | - 'object_types' => array( 'page', ), // Post type |
|
702 | + 'object_types' => array( 'page',), // Post type |
|
703 | 703 | 'show_in_rest' => WP_REST_Server::ALLMETHODS, // WP_REST_Server::READABLE|WP_REST_Server::EDITABLE, // Determines which HTTP methods the box is visible in. |
704 | 704 | // Optional callback to limit box visibility. |
705 | 705 | // See: https://github.com/WebDevStudios/CMB2/wiki/REST-API#permissions |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | if ( ! $terms ) { |
25 | 25 | $options .= sprintf( '<li><label>%s</label></li>', esc_html( $this->_text( 'no_terms_text', esc_html__( 'No terms', 'cmb2' ) ) ) ); |
26 | 26 | } else { |
27 | - $option_none = $field->args( 'show_option_none' ); |
|
27 | + $option_none = $field->args( 'show_option_none' ); |
|
28 | 28 | if ( ! empty( $option_none ) ) { |
29 | 29 | |
30 | 30 | $field_id = $this->_id(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'label' => $option_none, |
55 | 55 | ); |
56 | 56 | if ( $saved_term == $option_none_value ) { |
57 | - $args['checked'] = 'checked'; |
|
57 | + $args[ 'checked' ] = 'checked'; |
|
58 | 58 | } |
59 | 59 | $options .= $this->list_input( $args, $i ); |
60 | 60 | $i++; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ); |
68 | 68 | |
69 | 69 | if ( $saved_term == $term->slug ) { |
70 | - $args['checked'] = 'checked'; |
|
70 | + $args[ 'checked' ] = 'checked'; |
|
71 | 71 | } |
72 | 72 | $options .= $this->list_input( $args, $i ); |
73 | 73 | $i++; |
@@ -26,15 +26,15 @@ |
||
26 | 26 | $img_size_data = $this->get_image_size_data( $img_size, 'large' ); |
27 | 27 | |
28 | 28 | // if options array and 'url' => false, then hide the url field |
29 | - $input_type = array_key_exists( 'url', $options ) && false === $options['url'] ? 'hidden' : 'text'; |
|
29 | + $input_type = array_key_exists( 'url', $options ) && false === $options[ 'url' ] ? 'hidden' : 'text'; |
|
30 | 30 | |
31 | 31 | $output .= parent::render( array( |
32 | 32 | 'type' => $input_type, |
33 | 33 | 'class' => 'cmb2-upload-file regular-text', |
34 | 34 | 'size' => 45, |
35 | 35 | 'desc' => '', |
36 | - 'data-previewsize' => sprintf( '[%d,%d]', $img_size_data['width'], $img_size_data['height'] ), |
|
37 | - 'data-sizename' => $img_size_data['name'], |
|
36 | + 'data-previewsize' => sprintf( '[%d,%d]', $img_size_data[ 'width' ], $img_size_data[ 'height' ] ), |
|
37 | + 'data-sizename' => $img_size_data[ 'name' ], |
|
38 | 38 | 'data-queryargs' => ! empty( $query_args ) ? json_encode( $query_args ) : '', |
39 | 39 | 'js_dependencies' => 'media-editor', |
40 | 40 | ) ); |
@@ -29,8 +29,8 @@ |
||
29 | 29 | 'type' => 'hidden', |
30 | 30 | 'class' => 'cmb2-upload-file cmb2-upload-list', |
31 | 31 | 'size' => 45, 'desc' => '', 'value' => '', |
32 | - 'data-previewsize' => sprintf( '[%d,%d]', $img_size_data['width'], $img_size_data['height'] ), |
|
33 | - 'data-sizename' => $img_size_data['name'], |
|
32 | + 'data-previewsize' => sprintf( '[%d,%d]', $img_size_data[ 'width' ], $img_size_data[ 'height' ] ), |
|
33 | + 'data-sizename' => $img_size_data[ 'name' ], |
|
34 | 34 | 'data-queryargs' => ! empty( $query_args ) ? json_encode( $query_args ) : '', |
35 | 35 | 'js_dependencies' => 'media-editor', |
36 | 36 | ) ); |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | $data = array(); |
69 | 69 | |
70 | 70 | if ( is_array( $img_size ) ) { |
71 | - $data['width'] = intval( $img_size[0] ); |
|
72 | - $data['height'] = intval( $img_size[1] ); |
|
73 | - $data['name'] = ''; |
|
71 | + $data[ 'width' ] = intval( $img_size[ 0 ] ); |
|
72 | + $data[ 'height' ] = intval( $img_size[ 1 ] ); |
|
73 | + $data[ 'name' ] = ''; |
|
74 | 74 | |
75 | 75 | // Try and get the closest named size from our array of dimensions |
76 | 76 | if ( $named_size = CMB2_Utils::get_named_size( $img_size ) ) { |
77 | - $data['name'] = $named_size; |
|
77 | + $data[ 'name' ] = $named_size; |
|
78 | 78 | } |
79 | 79 | } else { |
80 | 80 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | // Get image dimensions from named sizes |
94 | - $data['width'] = intval( $image_sizes[ $img_size ]['width'] ); |
|
95 | - $data['height'] = intval( $image_sizes[ $img_size ]['height'] ); |
|
96 | - $data['name'] = $img_size; |
|
94 | + $data[ 'width' ] = intval( $image_sizes[ $img_size ][ 'width' ] ); |
|
95 | + $data[ 'height' ] = intval( $image_sizes[ $img_size ][ 'height' ] ); |
|
96 | + $data[ 'name' ] = $img_size; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return $data; |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | |
118 | 118 | foreach ( $image_sizes as $size ) { |
119 | 119 | // registered image size exists for this attachment |
120 | - if ( isset( $meta['sizes'][ $size ] ) ) { |
|
120 | + if ( isset( $meta[ 'sizes' ][ $size ] ) ) { |
|
121 | 121 | |
122 | 122 | $attachment_url = wp_get_attachment_url( $attachment->ID ); |
123 | 123 | $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url ); |
124 | - $size_meta = $meta['sizes'][ $size ]; |
|
124 | + $size_meta = $meta[ 'sizes' ][ $size ]; |
|
125 | 125 | |
126 | - $response['sizes'][ $size ] = array( |
|
127 | - 'url' => $base_url . $size_meta['file'], |
|
128 | - 'height' => $size_meta['height'], |
|
129 | - 'width' => $size_meta['width'], |
|
130 | - 'orientation' => $size_meta['height'] > $size_meta['width'] ? 'portrait' : 'landscape', |
|
126 | + $response[ 'sizes' ][ $size ] = array( |
|
127 | + 'url' => $base_url . $size_meta[ 'file' ], |
|
128 | + 'height' => $size_meta[ 'height' ], |
|
129 | + 'width' => $size_meta[ 'width' ], |
|
130 | + 'orientation' => $size_meta[ 'height' ] > $size_meta[ 'width' ] ? 'portrait' : 'landscape', |
|
131 | 131 | ); |
132 | 132 | } |
133 | 133 | } |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function img_status_output( $args ) { |
145 | 145 | return sprintf( '<%1$s class="img-status cmb2-media-item">%2$s<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button"%3$s>%4$s</a></p>%5$s</%1$s>', |
146 | - $args['tag'], |
|
147 | - $args['image'], |
|
148 | - isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '', |
|
146 | + $args[ 'tag' ], |
|
147 | + $args[ 'image' ], |
|
148 | + isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '', |
|
149 | 149 | esc_html( $this->_text( 'remove_image_text', esc_html__( 'Remove Image', 'cmb2' ) ) ), |
150 | - isset( $args['id_input'] ) ? $args['id_input'] : '' |
|
150 | + isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : '' |
|
151 | 151 | ); |
152 | 152 | } |
153 | 153 | |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function file_status_output( $args ) { |
161 | 161 | return sprintf( '<%1$s class="file-status cmb2-media-item"><span>%2$s <strong>%3$s</strong></span> (<a href="%4$s" target="_blank" rel="external">%5$s</a> / <a href="#" class="cmb2-remove-file-button"%6$s>%7$s</a>)%8$s</%1$s>', |
162 | - $args['tag'], |
|
162 | + $args[ 'tag' ], |
|
163 | 163 | esc_html( $this->_text( 'file_text', esc_html__( 'File:', 'cmb2' ) ) ), |
164 | - CMB2_Utils::get_file_name_from_path( $args['value'] ), |
|
165 | - $args['value'], |
|
164 | + CMB2_Utils::get_file_name_from_path( $args[ 'value' ] ), |
|
165 | + $args[ 'value' ], |
|
166 | 166 | esc_html( $this->_text( 'file_download_text', esc_html__( 'Download', 'cmb2' ) ) ), |
167 | - isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '', |
|
167 | + isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '', |
|
168 | 168 | esc_html( $this->_text( 'remove_text', esc_html__( 'Remove', 'cmb2' ) ) ), |
169 | - isset( $args['id_input'] ) ? $args['id_input'] : '' |
|
169 | + isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : '' |
|
170 | 170 | ); |
171 | 171 | } |
172 | 172 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $dir = wp_upload_dir(); |
38 | 38 | |
39 | 39 | // Is URL in uploads directory? |
40 | - if ( false === strpos( $img_url, $dir['baseurl'] . '/' ) ) { |
|
40 | + if ( false === strpos( $img_url, $dir[ 'baseurl' ] . '/' ) ) { |
|
41 | 41 | return false; |
42 | 42 | } |
43 | 43 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | |
63 | 63 | foreach ( $query->posts as $post_id ) { |
64 | 64 | $meta = wp_get_attachment_metadata( $post_id ); |
65 | - $original_file = basename( $meta['file'] ); |
|
66 | - $cropped_image_files = isset( $meta['sizes'] ) ? wp_list_pluck( $meta['sizes'], 'file' ) : array(); |
|
65 | + $original_file = basename( $meta[ 'file' ] ); |
|
66 | + $cropped_image_files = isset( $meta[ 'sizes' ] ) ? wp_list_pluck( $meta[ 'sizes' ], 'file' ) : array(); |
|
67 | 67 | if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) { |
68 | 68 | $attachment_id = $post_id; |
69 | 69 | break; |
@@ -125,31 +125,31 @@ discard block |
||
125 | 125 | foreach ( $image_sizes as $_size => $data ) { |
126 | 126 | |
127 | 127 | // If there's an exact match to an existing image size, short circuit. |
128 | - if ( $data['width'] == $size[0] && $data['height'] == $size[1] ) { |
|
129 | - $candidates[ $data['width'] * $data['height'] ] = array( $_size, $data ); |
|
128 | + if ( $data[ 'width' ] == $size[ 0 ] && $data[ 'height' ] == $size[ 1 ] ) { |
|
129 | + $candidates[ $data[ 'width' ] * $data[ 'height' ] ] = array( $_size, $data ); |
|
130 | 130 | break; |
131 | 131 | } |
132 | 132 | |
133 | 133 | // If it's not an exact match, consider larger sizes with the same aspect ratio. |
134 | - if ( $data['width'] >= $size[0] && $data['height'] >= $size[1] ) { |
|
134 | + if ( $data[ 'width' ] >= $size[ 0 ] && $data[ 'height' ] >= $size[ 1 ] ) { |
|
135 | 135 | |
136 | 136 | /* |
137 | 137 | * To test for varying crops, we constrain the dimensions of the larger image |
138 | 138 | * to the dimensions of the smaller image and see if they match. |
139 | 139 | */ |
140 | - if ( $data['width'] > $size[0] ) { |
|
141 | - $constrained_size = wp_constrain_dimensions( $data['width'], $data['height'], $size[0] ); |
|
142 | - $expected_size = array( $size[0], $size[1] ); |
|
140 | + if ( $data[ 'width' ] > $size[ 0 ] ) { |
|
141 | + $constrained_size = wp_constrain_dimensions( $data[ 'width' ], $data[ 'height' ], $size[ 0 ] ); |
|
142 | + $expected_size = array( $size[ 0 ], $size[ 1 ] ); |
|
143 | 143 | } else { |
144 | - $constrained_size = wp_constrain_dimensions( $size[0], $size[1], $data['width'] ); |
|
145 | - $expected_size = array( $data['width'], $data['height'] ); |
|
144 | + $constrained_size = wp_constrain_dimensions( $size[ 0 ], $size[ 1 ], $data[ 'width' ] ); |
|
145 | + $expected_size = array( $data[ 'width' ], $data[ 'height' ] ); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // If the image dimensions are within 1px of the expected size, we consider it a match. |
149 | - $matched = ( abs( $constrained_size[0] - $expected_size[0] ) <= 1 && abs( $constrained_size[1] - $expected_size[1] ) <= 1 ); |
|
149 | + $matched = ( abs( $constrained_size[ 0 ] - $expected_size[ 0 ] ) <= 1 && abs( $constrained_size[ 1 ] - $expected_size[ 1 ] ) <= 1 ); |
|
150 | 150 | |
151 | 151 | if ( $matched ) { |
152 | - $candidates[ $data['width'] * $data['height'] ] = array( $_size, $data ); |
|
152 | + $candidates[ $data[ 'width' ] * $data[ 'height' ] ] = array( $_size, $data ); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | $data = array_shift( $candidates ); |
164 | - $data = $data[0]; |
|
164 | + $data = $data[ 0 ]; |
|
165 | 165 | /* |
166 | 166 | * When the size requested is smaller than the thumbnail dimensions, we |
167 | 167 | * fall back to the thumbnail size. |
168 | 168 | */ |
169 | - } elseif ( ! empty( $image_sizes['thumbnail'] ) && $image_sizes['thumbnail']['width'] >= $size[0] && $image_sizes['thumbnail']['width'] >= $size[1] ) { |
|
169 | + } elseif ( ! empty( $image_sizes[ 'thumbnail' ] ) && $image_sizes[ 'thumbnail' ][ 'width' ] >= $size[ 0 ] && $image_sizes[ 'thumbnail' ][ 'width' ] >= $size[ 1 ] ) { |
|
170 | 170 | $data = 'thumbnail'; |
171 | 171 | } else { |
172 | 172 | return false; |
@@ -256,8 +256,7 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | return self::is_valid_time_stamp( $string ) |
259 | - ? (int) $string : |
|
260 | - strtotime( (string) $string ); |
|
259 | + ? (int) $string : strtotime( (string) $string ); |
|
261 | 260 | } |
262 | 261 | |
263 | 262 | /** |
@@ -288,7 +287,7 @@ discard block |
||
288 | 287 | * @param mixed $value Value to check |
289 | 288 | * @return bool True or false |
290 | 289 | */ |
291 | - public static function notempty( $value ){ |
|
290 | + public static function notempty( $value ) { |
|
292 | 291 | return null !== $value && '' !== $value && false !== $value && array() !== $value; |
293 | 292 | } |
294 | 293 | |
@@ -446,24 +445,24 @@ discard block |
||
446 | 445 | |
447 | 446 | // order is relevant here, since the replacement will be done sequentially. |
448 | 447 | $supported_options = array( |
449 | - 'd' => 'dd', // Day, leading 0 |
|
450 | - 'j' => 'd', // Day, no 0 |
|
451 | - 'z' => 'o', // Day of the year, no leading zeroes, |
|
448 | + 'd' => 'dd', // Day, leading 0 |
|
449 | + 'j' => 'd', // Day, no 0 |
|
450 | + 'z' => 'o', // Day of the year, no leading zeroes, |
|
452 | 451 | // 'D' => 'D', // Day name short, not sure how it'll work with translations |
453 | 452 | // 'l' => 'DD', // Day name full, idem before |
454 | - 'm' => 'mm', // Month of the year, leading 0 |
|
455 | - 'n' => 'm', // Month of the year, no leading 0 |
|
453 | + 'm' => 'mm', // Month of the year, leading 0 |
|
454 | + 'n' => 'm', // Month of the year, no leading 0 |
|
456 | 455 | // 'M' => 'M', // Month, Short name |
457 | 456 | // 'F' => 'MM', // Month, full name, |
458 | - 'y' => 'y', // Year, two digit |
|
459 | - 'Y' => 'yy', // Year, full |
|
460 | - 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
461 | - 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
462 | - 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
463 | - 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
464 | - 'i' => 'mm', // Minute with leading 0, |
|
465 | - 's' => 'ss', // Second with leading 0, |
|
466 | - 'a' => 'tt', // am/pm |
|
457 | + 'y' => 'y', // Year, two digit |
|
458 | + 'Y' => 'yy', // Year, full |
|
459 | + 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
460 | + 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
461 | + 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
462 | + 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
463 | + 'i' => 'mm', // Minute with leading 0, |
|
464 | + 's' => 'ss', // Second with leading 0, |
|
465 | + 'a' => 'tt', // am/pm |
|
467 | 466 | 'A' => 'TT' // AM/PM |
468 | 467 | ); |
469 | 468 | |
@@ -484,7 +483,7 @@ discard block |
||
484 | 483 | * @return string Modified value |
485 | 484 | */ |
486 | 485 | public static function wrap_escaped_chars( $value ) { |
487 | - return "'" . str_replace( '\\', '', $value[0] ) . "'"; |
|
486 | + return "'" . str_replace( '\\', '', $value[ 0 ] ) . "'"; |
|
488 | 487 | } |
489 | 488 | |
490 | 489 | /** |
@@ -543,7 +542,7 @@ discard block |
||
543 | 542 | * @return string String of attributes for form element. |
544 | 543 | */ |
545 | 544 | public static function concat_attrs( $attrs, $attr_exclude = array() ) { |
546 | - $attr_exclude[] = 'rendered'; |
|
545 | + $attr_exclude[ ] = 'rendered'; |
|
547 | 546 | $attributes = ''; |
548 | 547 | foreach ( $attrs as $attr => $val ) { |
549 | 548 | $excluded = in_array( $attr, (array) $attr_exclude, true ); |