Completed
Pull Request — trunk (#541)
by Justin
22:39 queued 06:07
created
includes/types/CMB2_Type_Radio.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 	}
47 47
 
48 48
 	protected function ul( $a ) {
49
-		return sprintf( '<ul class="%s">%s</ul>%s', $a['class'], $a['options'], $a['desc'] );
49
+		return sprintf( '<ul class="%s">%s</ul>%s', $a[ 'class' ], $a[ 'options' ], $a[ 'desc' ] );
50 50
 	}
51 51
 
52 52
 }
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Textarea_Code.php 1 patch
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 	/**
16 16
 	 * Handles outputting a 'wysiwyg' element
17 17
 	 * @since  1.1.0
18
-	 * @param  array  $args Override arguments
19 18
 	 * @return string       Form wysiwyg element
20 19
 	 */
21 20
 	public function render() {
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Multi_Base.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @return string       Generated option element html
20 20
 	 */
21 21
 	public function select_option( $args = array() ) {
22
-		return sprintf( "\t" . '<option value="%s" %s>%s</option>', $args['value'], selected( isset( $args['checked'] ) && $args['checked'], true, false ), $args['label'] ) . "\n";
22
+		return sprintf( "\t" . '<option value="%s" %s>%s</option>', $args[ 'value' ], selected( isset( $args[ 'checked' ] ) && $args[ 'checked' ], true, false ), $args[ 'label' ] ) . "\n";
23 23
 	}
24 24
 
25 25
 	/**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 			'label' => '',
40 40
 		), $args );
41 41
 
42
-		return sprintf( "\t" . '<li><input%s/> <label for="%s">%s</label></li>' . "\n", $this->concat_attrs( $a, array( 'label' ) ), $a['id'], $a['label'] );
42
+		return sprintf( "\t" . '<li><input%s/> <label for="%s">%s</label></li>' . "\n", $this->concat_attrs( $a, array( 'label' ) ), $a[ 'id' ], $a[ 'label' ] );
43 43
 	}
44 44
 
45 45
 	/**
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function list_input_checkbox( $args, $i ) {
53 53
 		$saved_value = $this->field->escaped_value();
54
-		if ( is_array( $saved_value ) && in_array( $args['value'], $saved_value ) ) {
55
-			$args['checked'] = 'checked';
54
+		if ( is_array( $saved_value ) && in_array( $args[ 'value' ], $saved_value ) ) {
55
+			$args[ 'checked' ] = 'checked';
56 56
 		}
57
-		$args['type'] = 'checkbox';
57
+		$args[ 'type' ] = 'checkbox';
58 58
 		return $this->list_input( $args, $i );
59 59
 	}
60 60
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	public function concat_items( $args = array() ) {
68 68
 		$field = $this->field;
69 69
 
70
-		$method = isset( $args['method'] ) ? $args['method'] : 'select_option';
71
-		unset( $args['method'] );
70
+		$method = isset( $args[ 'method' ] ) ? $args[ 'method' ] : 'select_option';
71
+		unset( $args[ 'method' ] );
72 72
 
73 73
 		$value = $field->escaped_value()
74 74
 			? $field->escaped_value()
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 			// Clone args & modify for just this item
87 87
 			$a = $args;
88 88
 
89
-			$a['value'] = $opt_value;
90
-			$a['label'] = $opt_label;
89
+			$a[ 'value' ] = $opt_value;
90
+			$a[ 'label' ] = $opt_label;
91 91
 
92 92
 			// Check if this option is the value of the input
93 93
 			if ( $value == $opt_value ) {
94
-				$a['checked'] = 'checked';
94
+				$a[ 'checked' ] = 'checked';
95 95
 			}
96 96
 
97 97
 			$concatenated_items .= $this->$method( $a, $i++ );
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Select.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 		$attrs = $this->concat_attrs( $a, array( 'desc', 'options' ) );
25 25
 
26 26
 		return $this->rendered(
27
-			sprintf( '<select%s>%s</select>%s', $attrs, $a['options'], $a['desc'] )
27
+			sprintf( '<select%s>%s</select>%s', $attrs, $a[ 'options' ], $a[ 'desc' ] )
28 28
 		);
29 29
 	}
30 30
 }
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Textarea.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 		), $args );
32 32
 
33 33
 		return $this->rendered(
34
-			sprintf( '<textarea%s>%s</textarea>%s', $this->concat_attrs( $a, array( 'desc', 'value' ) ), $a['value'], $a['desc'] )
34
+			sprintf( '<textarea%s>%s</textarea>%s', $this->concat_attrs( $a, array( 'desc', 'value' ) ), $a[ 'value' ], $a[ 'desc' ] )
35 35
 		);
36 36
 	}
37 37
 }
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Text_Datetime_Timestamp_Timezone.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 			'select_timezone'         => array(),
23 23
 		) );
24 24
 
25
-		$args['value'] = $field->escaped_value();
26
-		if ( is_array( $args['value'] ) ) {
27
-			$args['value'] = '';
25
+		$args[ 'value' ] = $field->escaped_value();
26
+		if ( is_array( $args[ 'value' ] ) ) {
27
+			$args[ 'value' ] = '';
28 28
 		}
29 29
 
30
-		$datetime = maybe_unserialize( $args['value'] );
30
+		$datetime = maybe_unserialize( $args[ 'value' ] );
31 31
 		$value = $tzstring = '';
32 32
 
33 33
 		if ( $datetime && $datetime instanceof DateTime ) {
@@ -36,19 +36,19 @@  discard block
 block discarded – undo
36 36
 			$value    = $datetime->getTimestamp();
37 37
 		}
38 38
 
39
-		$timestamp_args = wp_parse_args( $args['text_datetime_timestamp'], array(
39
+		$timestamp_args = wp_parse_args( $args[ 'text_datetime_timestamp' ], array(
40 40
 			'desc'     => '',
41 41
 			'value'    => $value,
42 42
 			'rendered' => true,
43 43
 		) );
44 44
 		$datetime_timestamp = $this->types->text_datetime_timestamp( $timestamp_args );
45 45
 
46
-		$timezone_select_args = wp_parse_args( $args['select_timezone'], array(
46
+		$timezone_select_args = wp_parse_args( $args[ 'select_timezone' ], array(
47 47
 			'class'    => 'cmb2_select cmb2-select-timezone',
48 48
 			'name'     => $this->_name( '[timezone]' ),
49 49
 			'id'       => $this->_id( '_timezone' ),
50 50
 			'options'  => wp_timezone_choice( $tzstring ),
51
-			'desc'     => $args['desc'],
51
+			'desc'     => $args[ 'desc' ],
52 52
 			'rendered' => true,
53 53
 		) );
54 54
 		$select = $this->types->select( $timezone_select_args );
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Text.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
includes/types/CMB2_Type_File.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		$output     = '';
22 22
 
23 23
 		// if options array and 'url' => false, then hide the url field
24
-		$input_type = array_key_exists( 'url', $options ) && false === $options['url'] ? 'hidden' : 'text';
24
+		$input_type = array_key_exists( 'url', $options ) && false === $options[ 'url' ] ? 'hidden' : 'text';
25 25
 
26 26
 		$output .= parent::render( array(
27 27
 			'type'  => $input_type,
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 				if ( $_id_value ) {
72 72
 					$image = wp_get_attachment_image( $_id_value, $img_size, null, array( 'class' => 'cmb-file-field-image' ) );
73 73
 				} else {
74
-					$size = is_array( $img_size ) ? $img_size[0] : 350;
74
+					$size = is_array( $img_size ) ? $img_size[ 0 ] : 350;
75 75
 					$image = '<img style="max-width: ' . absint( $size ) . 'px; width: 100%; height: auto;" src="' . $meta_value . '" alt="" />';
76 76
 				}
77 77
 
Please login to merge, or discard this patch.
includes/helper-functions.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -317,8 +317,8 @@
 block discarded – undo
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
 	 */
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	$oembed = cmb2_ajax()->get_oembed_no_edit( $args );
87 87
 
88 88
 	// Send back our embed
89
-	if ( $oembed['embed'] && $oembed['embed'] != $oembed['fallback'] ) {
90
-		return '<div class="cmb2-oembed">' . $oembed['embed'] . '</div>';
89
+	if ( $oembed[ 'embed' ] && $oembed[ 'embed' ] != $oembed[ 'fallback' ] ) {
90
+		return '<div class="cmb2-oembed">' . $oembed[ 'embed' ] . '</div>';
91 91
 	}
92 92
 
93 93
 	$error = sprintf(
94 94
 		/* translators: 1: results for. 2: link to codex.wordpress.org/Embeds */
95 95
 		esc_html__( 'No oEmbed Results Found for %1$s. View more info at %2$s.', 'cmb2' ),
96
-		$oembed['fallback'],
96
+		$oembed[ 'fallback' ],
97 97
 		'<a href="https://codex.wordpress.org/Embeds" target="_blank">codex.wordpress.org/Embeds</a>'
98 98
 	);
99 99
 
100
-	if ( isset( $args['wp_error'] ) && $args['wp_error'] ) {
100
+	if ( isset( $args[ 'wp_error' ] ) && $args[ 'wp_error' ] ) {
101 101
 		return new WP_Error( 'cmb2_get_oembed_result', $wp_error, compact( 'oembed', 'args' ) );
102 102
 	}
103 103
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		$cmb = CMB2_Boxes::get( $meta_box );
213 213
 	} else {
214 214
 		// See if we already have an instance of this metabox
215
-		$cmb = CMB2_Boxes::get( $meta_box['id'] );
215
+		$cmb = CMB2_Boxes::get( $meta_box[ 'id' ] );
216 216
 		// If not, we'll initate a new metabox
217 217
 		$cmb = $cmb ? $cmb : new CMB2( $meta_box, $object_id );
218 218
 	}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	) );
289 289
 
290 290
 	// Set object type explicitly (rather than trying to guess from context)
291
-	$cmb->object_type( $args['object_type'] );
291
+	$cmb->object_type( $args[ 'object_type' ] );
292 292
 
293 293
 	// Save the metabox if it's been submitted
294 294
 	// check permissions
@@ -296,32 +296,32 @@  discard block
 block discarded – undo
296 296
 	if (
297 297
 		$cmb->prop( 'save_fields' )
298 298
 		// check nonce
299
-		&& isset( $_POST['submit-cmb'], $_POST['object_id'], $_POST[ $cmb->nonce() ] )
299
+		&& isset( $_POST[ 'submit-cmb' ], $_POST[ 'object_id' ], $_POST[ $cmb->nonce() ] )
300 300
 		&& wp_verify_nonce( $_POST[ $cmb->nonce() ], $cmb->nonce() )
301
-		&& $object_id && $_POST['object_id'] == $object_id
301
+		&& $object_id && $_POST[ 'object_id' ] == $object_id
302 302
 	) {
303 303
 		$cmb->save_fields( $object_id, $cmb->object_type(), $_POST );
304 304
 	}
305 305
 
306 306
 	// Enqueue JS/CSS
307
-	if ( $args['cmb_styles'] ) {
307
+	if ( $args[ 'cmb_styles' ] ) {
308 308
 		CMB2_hookup::enqueue_cmb_css();
309 309
 	}
310 310
 
311
-	if ( $args['enqueue_js'] ) {
311
+	if ( $args[ 'enqueue_js' ] ) {
312 312
 		CMB2_hookup::enqueue_cmb_js();
313 313
 	}
314 314
 
315
-	$form_format = apply_filters( 'cmb2_get_metabox_form_format', $args['form_format'], $object_id, $cmb );
315
+	$form_format = apply_filters( 'cmb2_get_metabox_form_format', $args[ 'form_format' ], $object_id, $cmb );
316 316
 
317 317
 	$format_parts = explode( '%3$s', $form_format );
318 318
 
319 319
 	// Show cmb form
320
-	printf( $format_parts[0], $cmb->cmb_id, $object_id );
320
+	printf( $format_parts[ 0 ], $cmb->cmb_id, $object_id );
321 321
 	$cmb->show_form();
322 322
 
323
-	if ( isset( $format_parts[1] ) && $format_parts[1] ) {
324
-		printf( str_ireplace( '%4$s', '%1$s', $format_parts[1] ), $args['save_button'] );
323
+	if ( isset( $format_parts[ 1 ] ) && $format_parts[ 1 ] ) {
324
+		printf( str_ireplace( '%4$s', '%1$s', $format_parts[ 1 ] ), $args[ 'save_button' ] );
325 325
 	}
326 326
 
327 327
 }
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
  * @param  array   $args      Optional arguments array
335 335
  */
336 336
 function cmb2_metabox_form( $meta_box, $object_id = 0, $args = array() ) {
337
-	if ( ! isset( $args['echo'] ) || $args['echo'] ) {
337
+	if ( ! isset( $args[ 'echo' ] ) || $args[ 'echo' ] ) {
338 338
 		cmb2_print_metabox_form( $meta_box, $object_id, $args );
339 339
 	} else {
340 340
 		return cmb2_get_metabox_form( $meta_box, $object_id, $args );
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 
357 357
 		$schedule_format = str_replace(
358 358
 			array( 'M', 'Y', 'm', 'd', 'H', 'i', 'a' ),
359
-			array('%b', '%Y', '%m', '%d', '%H', '%M', '%p' ),
359
+			array( '%b', '%Y', '%m', '%d', '%H', '%M', '%p' ),
360 360
 			$date_format
361 361
 		);
362 362
 
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
 			 * 4 or 2 characters, as needed
374 374
 			 */
375 375
 			'%04d-%02d-%02d %02d:%02d:%02d',
376
-			$parsed_time['tm_year'] + 1900,  // This will be "111", so we need to add 1900.
377
-			$parsed_time['tm_mon'] + 1,      // This will be the month minus one, so we add one.
378
-			$parsed_time['tm_mday'],
379
-			$parsed_time['tm_hour'],
380
-			$parsed_time['tm_min'],
381
-			$parsed_time['tm_sec']
376
+			$parsed_time[ 'tm_year' ] + 1900, // This will be "111", so we need to add 1900.
377
+			$parsed_time[ 'tm_mon' ] + 1, // This will be the month minus one, so we add one.
378
+			$parsed_time[ 'tm_mday' ],
379
+			$parsed_time[ 'tm_hour' ],
380
+			$parsed_time[ 'tm_min' ],
381
+			$parsed_time[ 'tm_sec' ]
382 382
 		);
383 383
 
384
-		return new DateTime($ymd);
384
+		return new DateTime( $ymd );
385 385
 	}
386 386
 }
Please login to merge, or discard this patch.