@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function __construct( CMB2_Types $types, $args = array() ) { |
| 40 | 40 | $this->types = $types; |
| 41 | - $args['rendered'] = isset( $args['rendered'] ) ? (bool) $args['rendered'] : true; |
|
| 41 | + $args[ 'rendered' ] = isset( $args[ 'rendered' ] ) ? (bool) $args[ 'rendered' ] : true; |
|
| 42 | 42 | $this->args = $args; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @return string|CMB2_Type_Base Rendered output or this object. |
| 57 | 57 | */ |
| 58 | 58 | public function rendered( $rendered ) { |
| 59 | - if ( $this->args['rendered'] ) { |
|
| 59 | + if ( $this->args[ 'rendered' ] ) { |
|
| 60 | 60 | return is_a( $rendered, __CLASS__ ) ? $rendered->rendered : $rendered; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * Stores the rendered field output. |
| 59 | 59 | * |
| 60 | 60 | * @since 2.2.2 |
| 61 | - * @param string|CMB2_Type_Base $rendered Rendered output. |
|
| 61 | + * @param string $rendered Rendered output. |
|
| 62 | 62 | * @return string|CMB2_Type_Base Rendered output or this object. |
| 63 | 63 | */ |
| 64 | 64 | public function rendered( $rendered ) { |
@@ -117,7 +117,6 @@ discard block |
||
| 117 | 117 | /** |
| 118 | 118 | * Fall back to CMB2_Types methods |
| 119 | 119 | * |
| 120 | - * @param string $field |
|
| 121 | 120 | * @throws Exception Throws an exception if the field is invalid. |
| 122 | 121 | * @return mixed |
| 123 | 122 | */ |
@@ -139,7 +138,7 @@ discard block |
||
| 139 | 138 | * |
| 140 | 139 | * @param string $field |
| 141 | 140 | * @throws Exception Throws an exception if the field is invalid. |
| 142 | - * @return mixed |
|
| 141 | + * @return CMB2_Field |
|
| 143 | 142 | */ |
| 144 | 143 | public function __get( $field ) { |
| 145 | 144 | switch ( $field ) { |
@@ -50,12 +50,12 @@ |
||
| 50 | 50 | 'js_dependencies' => array(), |
| 51 | 51 | ), $args ); |
| 52 | 52 | |
| 53 | - if ( ! empty( $a['js_dependencies'] ) ) { |
|
| 54 | - $this->field->add_js_dependencies( $a['js_dependencies'] ); |
|
| 53 | + if ( ! empty( $a[ 'js_dependencies' ] ) ) { |
|
| 54 | + $this->field->add_js_dependencies( $a[ 'js_dependencies' ] ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return $this->rendered( |
| 58 | - sprintf( '<input%s/>%s', $this->concat_attrs( $a, array( 'desc', 'js_dependencies' ) ), $a['desc'] ) |
|
| 58 | + sprintf( '<input%s/>%s', $this->concat_attrs( $a, array( 'desc', 'js_dependencies' ) ), $a[ 'desc' ] ) |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | global $wp_locale; |
| 174 | 174 | |
| 175 | - $search = array( $wp_locale->number_format['thousands_sep'], $wp_locale->number_format['decimal_point'] ); |
|
| 175 | + $search = array( $wp_locale->number_format[ 'thousands_sep' ], $wp_locale->number_format[ 'decimal_point' ] ); |
|
| 176 | 176 | $replace = array( '', '.' ); |
| 177 | 177 | |
| 178 | 178 | // for repeatable |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | return $repeat_value; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( isset( $this->value['date'], $this->value['time'] ) ) { |
|
| 219 | - $this->value = $this->field->get_timestamp_from_value( $this->value['date'] . ' ' . $this->value['time'] ); |
|
| 218 | + if ( isset( $this->value[ 'date' ], $this->value[ 'time' ] ) ) { |
|
| 219 | + $this->value = $this->field->get_timestamp_from_value( $this->value[ 'date' ] . ' ' . $this->value[ 'time' ] ); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | if ( $tz_offset = $this->field->field_timezone_offset() ) { |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $tzstring = null; |
| 255 | 255 | |
| 256 | 256 | if ( is_array( $this->value ) && array_key_exists( 'timezone', $this->value ) ) { |
| 257 | - $tzstring = $this->value['timezone']; |
|
| 257 | + $tzstring = $this->value[ 'timezone' ]; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | if ( empty( $tzstring ) ) { |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | $tzstring = false !== $tzstring ? $tzstring : timezone_name_from_abbr( '', 0, 0 ); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $full_format = $this->field->args['date_format'] . ' ' . $this->field->args['time_format']; |
|
| 278 | - $full_date = $this->value['date'] . ' ' . $this->value['time']; |
|
| 277 | + $full_format = $this->field->args[ 'date_format' ] . ' ' . $this->field->args[ 'time_format' ]; |
|
| 278 | + $full_date = $this->value[ 'date' ] . ' ' . $this->value[ 'time' ]; |
|
| 279 | 279 | |
| 280 | 280 | try { |
| 281 | 281 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | } else { |
| 299 | 299 | // Save the utc timestamp supporting field |
| 300 | 300 | if ( $repeat ) { |
| 301 | - $utc_values[ $utc_key ][] = $utc_stamp; |
|
| 301 | + $utc_values[ $utc_key ][ ] = $utc_stamp; |
|
| 302 | 302 | } else { |
| 303 | 303 | $this->_save_utc_value( $utc_key, $utc_stamp ); |
| 304 | 304 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | if ( $this->value ) { |
| 434 | 434 | $val = $this->$method( true ); |
| 435 | 435 | if ( ! empty( $val ) ) { |
| 436 | - $new_value[] = $val; |
|
| 436 | + $new_value[ ] = $val; |
|
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | } |
@@ -433,6 +433,7 @@ discard block |
||
| 433 | 433 | * Gets the values for the `file` field type from the data being saved. |
| 434 | 434 | * |
| 435 | 435 | * @since 2.2.0 |
| 436 | + * @param string $id_key |
|
| 436 | 437 | */ |
| 437 | 438 | public function _get_group_file_value_array( $id_key ) { |
| 438 | 439 | $alldata = $this->field->group->data_to_save; |
@@ -460,6 +461,7 @@ discard block |
||
| 460 | 461 | * Peforms saving of `file` attachement's ID |
| 461 | 462 | * |
| 462 | 463 | * @since 1.1.0 |
| 464 | + * @param string $file_id_key |
|
| 463 | 465 | */ |
| 464 | 466 | public function _save_file_id_value( $file_id_key ) { |
| 465 | 467 | $id_field = $this->_new_supporting_field( $file_id_key ); |
@@ -481,6 +483,7 @@ discard block |
||
| 481 | 483 | * Peforms saving of `text_datetime_timestamp_timezone` utc timestamp |
| 482 | 484 | * |
| 483 | 485 | * @since 2.2.0 |
| 486 | + * @param string $utc_key |
|
| 484 | 487 | */ |
| 485 | 488 | public function _save_utc_value( $utc_key, $utc_stamp ) { |
| 486 | 489 | return $this->_new_supporting_field( $utc_key )->save_field( $utc_stamp ); |
@@ -317,8 +317,8 @@ |
||
| 317 | 317 | * Reimplementation of DateTime::createFromFormat for PHP < 5.3. :( |
| 318 | 318 | * Borrowed from http://stackoverflow.com/questions/5399075/php-datetimecreatefromformat-in-5-2 |
| 319 | 319 | * |
| 320 | - * @param $date_format |
|
| 321 | - * @param $date_value |
|
| 320 | + * @param string $date_format |
|
| 321 | + * @param string $date_value |
|
| 322 | 322 | * |
| 323 | 323 | * @return DateTime |
| 324 | 324 | */ |
@@ -96,18 +96,18 @@ discard block |
||
| 96 | 96 | $oembed = cmb2_ajax()->get_oembed_no_edit( $args ); |
| 97 | 97 | |
| 98 | 98 | // Send back our embed |
| 99 | - if ( $oembed['embed'] && $oembed['embed'] != $oembed['fallback'] ) { |
|
| 100 | - return '<div class="cmb2-oembed">' . $oembed['embed'] . '</div>'; |
|
| 99 | + if ( $oembed[ 'embed' ] && $oembed[ 'embed' ] != $oembed[ 'fallback' ] ) { |
|
| 100 | + return '<div class="cmb2-oembed">' . $oembed[ 'embed' ] . '</div>'; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $error = sprintf( |
| 104 | 104 | /* translators: 1: results for. 2: link to codex.wordpress.org/Embeds */ |
| 105 | 105 | esc_html__( 'No oEmbed Results Found for %1$s. View more info at %2$s.', 'cmb2' ), |
| 106 | - $oembed['fallback'], |
|
| 106 | + $oembed[ 'fallback' ], |
|
| 107 | 107 | '<a href="https://codex.wordpress.org/Embeds" target="_blank">codex.wordpress.org/Embeds</a>' |
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | - if ( isset( $args['wp_error'] ) && $args['wp_error'] ) { |
|
| 110 | + if ( isset( $args[ 'wp_error' ] ) && $args[ 'wp_error' ] ) { |
|
| 111 | 111 | return new WP_Error( 'cmb2_get_oembed_result', $error, compact( 'oembed', 'args' ) ); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $cmb = CMB2_Boxes::get( $meta_box ); |
| 230 | 230 | } else { |
| 231 | 231 | // See if we already have an instance of this metabox |
| 232 | - $cmb = CMB2_Boxes::get( $meta_box['id'] ); |
|
| 232 | + $cmb = CMB2_Boxes::get( $meta_box[ 'id' ] ); |
|
| 233 | 233 | // If not, we'll initate a new metabox |
| 234 | 234 | $cmb = $cmb ? $cmb : new CMB2( $meta_box, $object_id ); |
| 235 | 235 | } |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | ) ); |
| 308 | 308 | |
| 309 | 309 | // Set object type explicitly (rather than trying to guess from context) |
| 310 | - $cmb->object_type( $args['object_type'] ); |
|
| 310 | + $cmb->object_type( $args[ 'object_type' ] ); |
|
| 311 | 311 | |
| 312 | 312 | // Save the metabox if it's been submitted |
| 313 | 313 | // check permissions |
@@ -315,32 +315,32 @@ discard block |
||
| 315 | 315 | if ( |
| 316 | 316 | $cmb->prop( 'save_fields' ) |
| 317 | 317 | // check nonce |
| 318 | - && isset( $_POST['submit-cmb'], $_POST['object_id'], $_POST[ $cmb->nonce() ] ) |
|
| 318 | + && isset( $_POST[ 'submit-cmb' ], $_POST[ 'object_id' ], $_POST[ $cmb->nonce() ] ) |
|
| 319 | 319 | && wp_verify_nonce( $_POST[ $cmb->nonce() ], $cmb->nonce() ) |
| 320 | - && $object_id && $_POST['object_id'] == $object_id |
|
| 320 | + && $object_id && $_POST[ 'object_id' ] == $object_id |
|
| 321 | 321 | ) { |
| 322 | 322 | $cmb->save_fields( $object_id, $cmb->object_type(), $_POST ); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // Enqueue JS/CSS |
| 326 | - if ( $args['cmb_styles'] ) { |
|
| 326 | + if ( $args[ 'cmb_styles' ] ) { |
|
| 327 | 327 | CMB2_hookup::enqueue_cmb_css(); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if ( $args['enqueue_js'] ) { |
|
| 330 | + if ( $args[ 'enqueue_js' ] ) { |
|
| 331 | 331 | CMB2_hookup::enqueue_cmb_js(); |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - $form_format = apply_filters( 'cmb2_get_metabox_form_format', $args['form_format'], $object_id, $cmb ); |
|
| 334 | + $form_format = apply_filters( 'cmb2_get_metabox_form_format', $args[ 'form_format' ], $object_id, $cmb ); |
|
| 335 | 335 | |
| 336 | 336 | $format_parts = explode( '%3$s', $form_format ); |
| 337 | 337 | |
| 338 | 338 | // Show cmb form |
| 339 | - printf( $format_parts[0], $cmb->cmb_id, $object_id ); |
|
| 339 | + printf( $format_parts[ 0 ], $cmb->cmb_id, $object_id ); |
|
| 340 | 340 | $cmb->show_form(); |
| 341 | 341 | |
| 342 | - if ( isset( $format_parts[1] ) && $format_parts[1] ) { |
|
| 343 | - printf( str_ireplace( '%4$s', '%1$s', $format_parts[1] ), $args['save_button'] ); |
|
| 342 | + if ( isset( $format_parts[ 1 ] ) && $format_parts[ 1 ] ) { |
|
| 343 | + printf( str_ireplace( '%4$s', '%1$s', $format_parts[ 1 ] ), $args[ 'save_button' ] ); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @param array $args Optional arguments array |
| 355 | 355 | */ |
| 356 | 356 | function cmb2_metabox_form( $meta_box, $object_id = 0, $args = array() ) { |
| 357 | - if ( ! isset( $args['echo'] ) || $args['echo'] ) { |
|
| 357 | + if ( ! isset( $args[ 'echo' ] ) || $args[ 'echo' ] ) { |
|
| 358 | 358 | cmb2_print_metabox_form( $meta_box, $object_id, $args ); |
| 359 | 359 | } else { |
| 360 | 360 | return cmb2_get_metabox_form( $meta_box, $object_id, $args ); |
@@ -393,12 +393,12 @@ discard block |
||
| 393 | 393 | * 4 or 2 characters, as needed |
| 394 | 394 | */ |
| 395 | 395 | '%04d-%02d-%02d %02d:%02d:%02d', |
| 396 | - $parsed_time['tm_year'] + 1900, // This will be "111", so we need to add 1900. |
|
| 397 | - $parsed_time['tm_mon'] + 1, // This will be the month minus one, so we add one. |
|
| 398 | - $parsed_time['tm_mday'], |
|
| 399 | - $parsed_time['tm_hour'], |
|
| 400 | - $parsed_time['tm_min'], |
|
| 401 | - $parsed_time['tm_sec'] |
|
| 396 | + $parsed_time[ 'tm_year' ] + 1900, // This will be "111", so we need to add 1900. |
|
| 397 | + $parsed_time[ 'tm_mon' ] + 1, // This will be the month minus one, so we add one. |
|
| 398 | + $parsed_time[ 'tm_mday' ], |
|
| 399 | + $parsed_time[ 'tm_hour' ], |
|
| 400 | + $parsed_time[ 'tm_min' ], |
|
| 401 | + $parsed_time[ 'tm_sec' ] |
|
| 402 | 402 | ); |
| 403 | 403 | |
| 404 | 404 | return new DateTime( $ymd ); |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | public function oembed_handler() { |
| 60 | 60 | |
| 61 | 61 | // Verify our nonce |
| 62 | - if ( ! ( isset( $_REQUEST['cmb2_ajax_nonce'], $_REQUEST['oembed_url'] ) && wp_verify_nonce( $_REQUEST['cmb2_ajax_nonce'], 'ajax_nonce' ) ) ) { |
|
| 62 | + if ( ! ( isset( $_REQUEST[ 'cmb2_ajax_nonce' ], $_REQUEST[ 'oembed_url' ] ) && wp_verify_nonce( $_REQUEST[ 'cmb2_ajax_nonce' ], 'ajax_nonce' ) ) ) { |
|
| 63 | 63 | die(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Sanitize our search string |
| 67 | - $oembed_string = sanitize_text_field( $_REQUEST['oembed_url'] ); |
|
| 67 | + $oembed_string = sanitize_text_field( $_REQUEST[ 'oembed_url' ] ); |
|
| 68 | 68 | |
| 69 | 69 | // Send back error if empty |
| 70 | 70 | if ( empty( $oembed_string ) ) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Set width of embed |
| 75 | - $embed_width = isset( $_REQUEST['oembed_width'] ) && intval( $_REQUEST['oembed_width'] ) < 640 ? intval( $_REQUEST['oembed_width'] ) : '640'; |
|
| 75 | + $embed_width = isset( $_REQUEST[ 'oembed_width' ] ) && intval( $_REQUEST[ 'oembed_width' ] ) < 640 ? intval( $_REQUEST[ 'oembed_width' ] ) : '640'; |
|
| 76 | 76 | |
| 77 | 77 | // Set url |
| 78 | 78 | $oembed_url = esc_url( $oembed_string ); |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | // Get embed code (or fallback link) |
| 86 | 86 | $html = $this->get_oembed( array( |
| 87 | 87 | 'url' => $oembed_url, |
| 88 | - 'object_id' => $_REQUEST['object_id'], |
|
| 89 | - 'object_type' => isset( $_REQUEST['object_type'] ) ? $_REQUEST['object_type'] : 'post', |
|
| 88 | + 'object_id' => $_REQUEST[ 'object_id' ], |
|
| 89 | + 'object_type' => isset( $_REQUEST[ 'object_type' ] ) ? $_REQUEST[ 'object_type' ] : 'post', |
|
| 90 | 90 | 'oembed_args' => $embed_args, |
| 91 | - 'field_id' => $_REQUEST['field_id'], |
|
| 91 | + 'field_id' => $_REQUEST[ 'field_id' ], |
|
| 92 | 92 | ) ); |
| 93 | 93 | |
| 94 | 94 | wp_send_json_success( $html ); |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | public function get_oembed_no_edit( $args ) { |
| 104 | 104 | global $wp_embed; |
| 105 | 105 | |
| 106 | - $oembed_url = esc_url( $args['url'] ); |
|
| 106 | + $oembed_url = esc_url( $args[ 'url' ] ); |
|
| 107 | 107 | |
| 108 | 108 | // Sanitize object_id |
| 109 | - $this->object_id = is_numeric( $args['object_id'] ) ? absint( $args['object_id'] ) : sanitize_text_field( $args['object_id'] ); |
|
| 109 | + $this->object_id = is_numeric( $args[ 'object_id' ] ) ? absint( $args[ 'object_id' ] ) : sanitize_text_field( $args[ 'object_id' ] ); |
|
| 110 | 110 | |
| 111 | 111 | $args = wp_parse_args( $args, array( |
| 112 | 112 | 'object_type' => 'post', |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | 'wp_error' => false, |
| 116 | 116 | ) ); |
| 117 | 117 | |
| 118 | - $this->embed_args =& $args; |
|
| 118 | + $this->embed_args = & $args; |
|
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * Set the post_ID so oEmbed won't fail |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | $wp_embed->post_ID = $this->object_id; |
| 125 | 125 | |
| 126 | 126 | // Special scenario if NOT a post object |
| 127 | - if ( isset( $args['object_type'] ) && 'post' != $args['object_type'] ) { |
|
| 127 | + if ( isset( $args[ 'object_type' ] ) && 'post' != $args[ 'object_type' ] ) { |
|
| 128 | 128 | |
| 129 | - if ( 'options-page' == $args['object_type'] ) { |
|
| 129 | + if ( 'options-page' == $args[ 'object_type' ] ) { |
|
| 130 | 130 | |
| 131 | 131 | // Bogus id to pass some numeric checks. Issue with a VERY large WP install? |
| 132 | 132 | $wp_embed->post_ID = 1987645321; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | // Ok, we need to hijack the oembed cache system |
| 136 | 136 | $this->hijack = true; |
| 137 | - $this->object_type = $args['object_type']; |
|
| 137 | + $this->object_type = $args[ 'object_type' ]; |
|
| 138 | 138 | |
| 139 | 139 | // Gets ombed cache from our object's meta (vs postmeta) |
| 140 | 140 | add_filter( 'get_post_metadata', array( $this, 'hijack_oembed_cache_get' ), 10, 3 ); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $embed_args = ''; |
| 148 | 148 | |
| 149 | - foreach ( $args['oembed_args'] as $key => $val ) { |
|
| 149 | + foreach ( $args[ 'oembed_args' ] as $key => $val ) { |
|
| 150 | 150 | $embed_args .= " $key=\"$val\""; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -169,8 +169,8 @@ discard block |
||
| 169 | 169 | $oembed = $this->get_oembed_no_edit( $args ); |
| 170 | 170 | |
| 171 | 171 | // Send back our embed |
| 172 | - if ( $oembed['embed'] && $oembed['embed'] != $oembed['fallback'] ) { |
|
| 173 | - return '<div class="cmb2-oembed embed-status">' . $oembed['embed'] . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . $oembed['args']['field_id'] . '">' . esc_html__( 'Remove Embed', 'cmb2' ) . '</a></p></div>'; |
|
| 172 | + if ( $oembed[ 'embed' ] && $oembed[ 'embed' ] != $oembed[ 'fallback' ] ) { |
|
| 173 | + return '<div class="cmb2-oembed embed-status">' . $oembed[ 'embed' ] . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . $oembed[ 'args' ][ 'field_id' ] . '">' . esc_html__( 'Remove Embed', 'cmb2' ) . '</a></p></div>'; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // Otherwise, send back error info that no oEmbeds were found |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | sprintf( |
| 180 | 180 | /* translators: 1: results for. 2: link to codex.wordpress.org/Embeds */ |
| 181 | 181 | esc_html__( 'No oEmbed Results Found for %1$s. View more info at %2$s.', 'cmb2' ), |
| 182 | - $oembed['fallback'], |
|
| 182 | + $oembed[ 'fallback' ], |
|
| 183 | 183 | '<a href="https://codex.wordpress.org/Embeds" target="_blank">codex.wordpress.org/Embeds</a>' |
| 184 | 184 | ) |
| 185 | 185 | ); |
@@ -244,15 +244,15 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | protected function cache_action( $meta_key ) { |
| 246 | 246 | $func_args = func_get_args(); |
| 247 | - $action = isset( $func_args[1] ) ? 'update' : 'get'; |
|
| 247 | + $action = isset( $func_args[ 1 ] ) ? 'update' : 'get'; |
|
| 248 | 248 | |
| 249 | 249 | if ( 'options-page' === $this->object_type ) { |
| 250 | 250 | |
| 251 | 251 | $args = array( $meta_key ); |
| 252 | 252 | |
| 253 | 253 | if ( 'update' === $action ) { |
| 254 | - $args[] = $func_args[1]; |
|
| 255 | - $args[] = true; |
|
| 254 | + $args[ ] = $func_args[ 1 ]; |
|
| 255 | + $args[ ] = true; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | // Cache the result to our options |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } else { |
| 261 | 261 | |
| 262 | 262 | $args = array( $this->object_type, $this->object_id, $meta_key ); |
| 263 | - $args[] = 'update' === $action ? $func_args : true; |
|
| 263 | + $args[ ] = 'update' === $action ? $func_args : true; |
|
| 264 | 264 | |
| 265 | 265 | // Cache the result to our metadata |
| 266 | 266 | $status = call_user_func_array( $action . '_metadata', $args ); |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | return $this->rendered( |
| 29 | 29 | sprintf( |
| 30 | 30 | '<%1$s %2$s>%3$s</%1$s>%4$s', |
| 31 | - $a['tag'], |
|
| 31 | + $a[ 'tag' ], |
|
| 32 | 32 | $this->concat_attrs( $a, array( 'tag', 'name', 'desc' ) ), |
| 33 | - $a['name'], |
|
| 34 | - $a['desc'] |
|
| 33 | + $a[ 'name' ], |
|
| 34 | + $a[ 'desc' ] |
|
| 35 | 35 | ) |
| 36 | 36 | ); |
| 37 | 37 | } |
@@ -52,9 +52,9 @@ |
||
| 52 | 52 | |
| 53 | 53 | // Get object hash.. This bypasses issues with serializing closures. |
| 54 | 54 | if ( is_object( $hook ) ) { |
| 55 | - $args[1] = spl_object_hash( $args[1] ); |
|
| 56 | - } elseif ( is_array( $hook ) && is_object( $hook[0] ) ) { |
|
| 57 | - $args[1][0] = spl_object_hash( $hook[0] ); |
|
| 55 | + $args[ 1 ] = spl_object_hash( $args[ 1 ] ); |
|
| 56 | + } elseif ( is_array( $hook ) && is_object( $hook[ 0 ] ) ) { |
|
| 57 | + $args[ 1 ][ 0 ] = spl_object_hash( $hook[ 0 ] ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $key = md5( serialize( $args ) ); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * @return WP_REST_Response $response |
| 227 | 227 | */ |
| 228 | 228 | public function prepare_item_for_response( $data, $request = null ) { |
| 229 | - $data = $this->filter_response_by_context( $data, $this->request['context'] ); |
|
| 229 | + $data = $this->filter_response_by_context( $data, $this->request[ 'context' ] ); |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Filter the prepared CMB2 item response. |
@@ -297,12 +297,12 @@ discard block |
||
| 297 | 297 | |
| 298 | 298 | } else { |
| 299 | 299 | |
| 300 | - if ( isset( $this->request['object_id'] ) ) { |
|
| 301 | - $this->rest_box->cmb->object_id( sanitize_text_field( $this->request['object_id'] ) ); |
|
| 300 | + if ( isset( $this->request[ 'object_id' ] ) ) { |
|
| 301 | + $this->rest_box->cmb->object_id( sanitize_text_field( $this->request[ 'object_id' ] ) ); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if ( isset( $this->request['object_type'] ) ) { |
|
| 305 | - $this->rest_box->cmb->object_type( sanitize_text_field( $this->request['object_type'] ) ); |
|
| 304 | + if ( isset( $this->request[ 'object_type' ] ) ) { |
|
| 305 | + $this->rest_box->cmb->object_type( sanitize_text_field( $this->request[ 'object_type' ] ) ); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -320,8 +320,8 @@ discard block |
||
| 320 | 320 | public function initiate_request( $request, $request_type ) { |
| 321 | 321 | $this->request = $request; |
| 322 | 322 | |
| 323 | - if ( ! isset( $this->request['context'] ) || empty( $this->request['context'] ) ) { |
|
| 324 | - $this->request['context'] = 'view'; |
|
| 323 | + if ( ! isset( $this->request[ 'context' ] ) || empty( $this->request[ 'context' ] ) ) { |
|
| 324 | + $this->request[ 'context' ] = 'view'; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | if ( ! self::$request_type ) { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @since 2.2.3 |
| 206 | 206 | * |
| 207 | 207 | * @param mixed $cb Callable function/method. |
| 208 | - * @return mixed Results of output buffer after calling function/method. |
|
| 208 | + * @return string Results of output buffer after calling function/method. |
|
| 209 | 209 | */ |
| 210 | 210 | public function get_cb_results( $cb ) { |
| 211 | 211 | $args = func_get_args(); |
@@ -221,7 +221,6 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @since 2.2.3 |
| 223 | 223 | * |
| 224 | - * @param mixed $item WordPress representation of the item. |
|
| 225 | 224 | * @param WP_REST_Request $request Request object. |
| 226 | 225 | * @return WP_REST_Response $response |
| 227 | 226 | */ |
@@ -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 | |