Completed
Pull Request — trunk (#848)
by
unknown
04:35
created
includes/helper-functions.php 1 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.
includes/CMB2_Ajax.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 );
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Wysiwyg.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		) );
29 29
 
30 30
 		if ( ! $field->group ) {
31
-			return $this->rendered( $this->get_wp_editor( $a ) . $a['desc'] );
31
+			return $this->rendered( $this->get_wp_editor( $a ) . $a[ 'desc' ] );
32 32
 		}
33 33
 
34 34
 		// wysiwyg fields in a group need some special handling.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 	protected function get_wp_editor( $args ) {
54 54
 		ob_start();
55
-		wp_editor( $args['value'], $args['id'], $args['options'] );
55
+		wp_editor( $args[ 'value' ], $args[ 'id' ], $args[ 'options' ] );
56 56
 		return ob_get_clean();
57 57
 	}
58 58
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		$group_id = $this->field->group->id();
61 61
 		$field_id = $this->field->id( true );
62 62
 		$options  = $this->field->options();
63
-		$options['textarea_name'] = 'cmb2_n_' . $group_id . $field_id;
63
+		$options[ 'textarea_name' ] = 'cmb2_n_' . $group_id . $field_id;
64 64
 
65 65
 		// Initate the editor with special id/value/name so we can retrieve the options in JS.
66 66
 		$editor = $this->get_wp_editor( array(
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		// And put the editor instance in a JS template wrapper.
84 84
 		echo '<script type="text/template" id="tmpl-cmb2-wysiwyg-' . $group_id . '-' . $field_id . '">';
85 85
 		// Need to wrap the template in a wrapper div w/ specific data attributes which will be used when adding/removing rows.
86
-		echo '<div class="cmb2-wysiwyg-inner-wrap" data-iterator="{{ data.iterator }}" data-groupid="'. $group_id .'" data-id="'. $field_id .'">'. $editor .'</div>';
86
+		echo '<div class="cmb2-wysiwyg-inner-wrap" data-iterator="{{ data.iterator }}" data-groupid="' . $group_id . '" data-id="' . $field_id . '">' . $editor . '</div>';
87 87
 		echo '</script>';
88 88
 	}
89 89
 
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Title.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
includes/CMB2_Utils.php 3 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,8 @@  discard block
 block discarded – undo
122 122
 			$tzstring = '';
123 123
 		}
124 124
 
125
-		if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
125
+		if ( empty( $tzstring ) ) {
126
+// Create a UTC+- zone if no timezone string exists
126 127
 			if ( 0 == $current_offset ) {
127 128
 				$tzstring = 'UTC+0';
128 129
 			} elseif ( $current_offset < 0 ) {
@@ -179,7 +180,7 @@  discard block
 block discarded – undo
179 180
 	 * @param  mixed $value Value to check
180 181
 	 * @return bool         True or false
181 182
 	 */
182
-	public static function notempty( $value ){
183
+	public static function notempty( $value ) {
183 184
 		return null !== $value && '' !== $value && false !== $value;
184 185
 	}
185 186
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -547,7 +547,7 @@
 block discarded – undo
547 547
 	 * @since  2.2.3
548 548
 	 *
549 549
 	 * @param  mixed $value   Value to ensure is array.
550
-	 * @param  array $default Default array. Defaults to empty array.
550
+	 * @param  string[] $default Default array. Defaults to empty array.
551 551
 	 *
552 552
 	 * @return array          The array.
553 553
 	 */
Please login to merge, or discard this patch.
Spacing   +28 added lines, -29 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,15 +125,15 @@  discard block
 block discarded – undo
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] ) {
135
-					if ( wp_image_matches_ratio( $data['width'], $data['height'], $size[0], $size[1] ) ) {
136
-						$candidates[ $data['width'] * $data['height'] ] = array( $_size, $data );
134
+				if ( $data[ 'width' ] >= $size[ 0 ] && $data[ 'height' ] >= $size[ 1 ] ) {
135
+					if ( wp_image_matches_ratio( $data[ 'width' ], $data[ 'height' ], $size[ 0 ], $size[ 1 ] ) ) {
136
+						$candidates[ $data[ 'width' ] * $data[ 'height' ] ] = array( $_size, $data );
137 137
 					}
138 138
 				}
139 139
 			}
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
 				}
146 146
 
147 147
 				$data = array_shift( $candidates );
148
-				$data = $data[0];
148
+				$data = $data[ 0 ];
149 149
 			/*
150 150
 			 * When the size requested is smaller than the thumbnail dimensions, we
151 151
 			 * fall back to the thumbnail size.
152 152
 			 */
153
-			} elseif ( ! empty( $image_sizes['thumbnail'] ) && $image_sizes['thumbnail']['width'] >= $size[0] && $image_sizes['thumbnail']['width'] >= $size[1] ) {
153
+			} elseif ( ! empty( $image_sizes[ 'thumbnail' ] ) && $image_sizes[ 'thumbnail' ][ 'width' ] >= $size[ 0 ] && $image_sizes[ 'thumbnail' ][ 'width' ] >= $size[ 1 ] ) {
154 154
 				$data = 'thumbnail';
155 155
 			} else {
156 156
 				return false;
@@ -240,8 +240,7 @@  discard block
 block discarded – undo
240 240
 		}
241 241
 
242 242
 		return self::is_valid_time_stamp( $string )
243
-			? (int) $string :
244
-			strtotime( (string) $string );
243
+			? (int) $string : strtotime( (string) $string );
245 244
 	}
246 245
 
247 246
 	/**
@@ -272,7 +271,7 @@  discard block
 block discarded – undo
272 271
 	 * @param  mixed $value Value to check
273 272
 	 * @return bool         True or false
274 273
 	 */
275
-	public static function notempty( $value ){
274
+	public static function notempty( $value ) {
276 275
 		return null !== $value && '' !== $value && false !== $value && array() !== $value;
277 276
 	}
278 277
 
@@ -430,24 +429,24 @@  discard block
 block discarded – undo
430 429
 
431 430
 		// order is relevant here, since the replacement will be done sequentially.
432 431
 		$supported_options = array(
433
-			'd' => 'dd',  // Day, leading 0
434
-			'j' => 'd',   // Day, no 0
435
-			'z' => 'o',   // Day of the year, no leading zeroes,
432
+			'd' => 'dd', // Day, leading 0
433
+			'j' => 'd', // Day, no 0
434
+			'z' => 'o', // Day of the year, no leading zeroes,
436 435
 			// 'D' => 'D',   // Day name short, not sure how it'll work with translations
437 436
 			// 'l' => 'DD',  // Day name full, idem before
438
-			'm' => 'mm',  // Month of the year, leading 0
439
-			'n' => 'm',   // Month of the year, no leading 0
437
+			'm' => 'mm', // Month of the year, leading 0
438
+			'n' => 'm', // Month of the year, no leading 0
440 439
 			// 'M' => 'M',   // Month, Short name
441 440
 			// 'F' => 'MM',  // Month, full name,
442
-			'y' => 'y',   // Year, two digit
443
-			'Y' => 'yy',  // Year, full
444
-			'H' => 'HH',  // Hour with leading 0 (24 hour)
445
-			'G' => 'H',   // Hour with no leading 0 (24 hour)
446
-			'h' => 'hh',  // Hour with leading 0 (12 hour)
447
-			'g' => 'h',   // Hour with no leading 0 (12 hour),
448
-			'i' => 'mm',  // Minute with leading 0,
449
-			's' => 'ss',  // Second with leading 0,
450
-			'a' => 'tt',  // am/pm
441
+			'y' => 'y', // Year, two digit
442
+			'Y' => 'yy', // Year, full
443
+			'H' => 'HH', // Hour with leading 0 (24 hour)
444
+			'G' => 'H', // Hour with no leading 0 (24 hour)
445
+			'h' => 'hh', // Hour with leading 0 (12 hour)
446
+			'g' => 'h', // Hour with no leading 0 (12 hour),
447
+			'i' => 'mm', // Minute with leading 0,
448
+			's' => 'ss', // Second with leading 0,
449
+			'a' => 'tt', // am/pm
451 450
 			'A' => 'TT'   // AM/PM
452 451
 		);
453 452
 
@@ -468,7 +467,7 @@  discard block
 block discarded – undo
468 467
 	 * @return string Modified value
469 468
 	 */
470 469
 	public static function wrap_escaped_chars( $value ) {
471
-		return "&#39;" . str_replace( '\\', '', $value[0] ) . "&#39;";
470
+		return "&#39;" . str_replace( '\\', '', $value[ 0 ] ) . "&#39;";
472 471
 	}
473 472
 
474 473
 	/**
@@ -527,7 +526,7 @@  discard block
 block discarded – undo
527 526
 	 * @return string               String of attributes for form element.
528 527
 	 */
529 528
 	public static function concat_attrs( $attrs, $attr_exclude = array() ) {
530
-		$attr_exclude[] = 'rendered';
529
+		$attr_exclude[ ] = 'rendered';
531 530
 		$attributes = '';
532 531
 		foreach ( $attrs as $attr => $val ) {
533 532
 			$excluded = in_array( $attr, (array) $attr_exclude, true );
Please login to merge, or discard this patch.
includes/types/CMB2_Type_File_Base.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function img_status_output( $args ) {
57 57
 		return sprintf( '<%1$s class="img-status">%2$s<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button"%3$s>%4$s</a></p>%5$s</%1$s>',
58
-			$args['tag'],
59
-			$args['image'],
60
-			isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '',
58
+			$args[ 'tag' ],
59
+			$args[ 'image' ],
60
+			isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '',
61 61
 			esc_html( $this->_text( 'remove_image_text', esc_html__( 'Remove Image', 'cmb2' ) ) ),
62
-			isset( $args['id_input'] ) ? $args['id_input'] : ''
62
+			isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : ''
63 63
 		);
64 64
 	}
65 65
 
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function file_status_output( $args ) {
73 73
 		return sprintf( '<%1$s class="file-status"><span>%2$s <strong>%3$s</strong></span>&nbsp;&nbsp; (<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>',
74
-			$args['tag'],
74
+			$args[ 'tag' ],
75 75
 			esc_html( $this->_text( 'file_text', esc_html__( 'File:', 'cmb2' ) ) ),
76
-			CMB2_Utils::get_file_name_from_path( $args['value'] ),
77
-			$args['value'],
76
+			CMB2_Utils::get_file_name_from_path( $args[ 'value' ] ),
77
+			$args[ 'value' ],
78 78
 			esc_html( $this->_text( 'file_download_text', esc_html__( 'Download', 'cmb2' ) ) ),
79
-			isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '',
79
+			isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '',
80 80
 			esc_html( $this->_text( 'remove_text', esc_html__( 'Remove', 'cmb2' ) ) ),
81
-			isset( $args['id_input'] ) ? $args['id_input'] : ''
81
+			isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : ''
82 82
 		);
83 83
 	}
84 84
 
Please login to merge, or discard this patch.
includes/CMB2_Base.php 4 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -370,15 +370,13 @@
 block discarded – undo
370 370
 			if ( function_exists( '__' ) ) {
371 371
 				if ( ! is_null( $message ) ) {
372 372
 					trigger_error( sprintf( __( '%1$s was called with a parameter that is <strong>deprecated</strong> since version %2$s! %3$s', 'cmb2' ), $function, $version, $message ) );
373
-				}
374
-				else {
373
+				} else {
375 374
 					trigger_error( sprintf( __( '%1$s was called with a parameter that is <strong>deprecated</strong> since version %2$s with no alternative available.', 'cmb2' ), $function, $version ) );
376 375
 				}
377 376
 			} else {
378 377
 				if ( ! is_null( $message ) ) {
379 378
 					trigger_error( sprintf( '%1$s was called with a parameter that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) );
380
-				}
381
-				else {
379
+				} else {
382 380
 					trigger_error( sprintf( '%1$s was called with a parameter that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
383 381
 				}
384 382
 			}
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -315,10 +315,10 @@
 block discarded – undo
315 315
 	 * which is callable. If so, it registers the callback, and if not,
316 316
 	 * converts the maybe-modified $val to a boolean for return.
317 317
 	 *
318
- 	 * The registered handlers will have a parameter name which matches the filter, except:
319
- 	 * - The 'cmb2_api' prefix will be removed
320
- 	 * - A '_cb' suffix will be added (to stay inline with other '*_cb' parameters).
321
- 	 *
318
+	 * The registered handlers will have a parameter name which matches the filter, except:
319
+	 * - The 'cmb2_api' prefix will be removed
320
+	 * - A '_cb' suffix will be added (to stay inline with other '*_cb' parameters).
321
+	 *
322 322
 	 * @since  2.2.3
323 323
 	 *
324 324
 	 * @param  string $hook_name     The hook name.
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		}
359 359
 
360 360
 		// Cast to bool.
361
-		return !! $val;
361
+		return ! ! $val;
362 362
 	}
363 363
 
364 364
 	/**
@@ -386,11 +386,11 @@  discard block
 block discarded – undo
386 386
 			switch ( $message ) {
387 387
 
388 388
 				case self::DEPRECATED_PARAM:
389
-					$message = sprintf( __( 'The "%s" field parameter has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[3], $args[4] );
389
+					$message = sprintf( __( 'The "%s" field parameter has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] );
390 390
 					break;
391 391
 
392 392
 				case self::DEPRECATED_CB_PARAM:
393
-					$message = sprintf( __( 'Using the "%s" field parameter as a callback has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[3], $args[4] );
393
+					$message = sprintf( __( 'Using the "%s" field parameter as a callback has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] );
394 394
 					break;
395 395
 
396 396
 				default:
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 	public function __call( $method, $args ) {
470 470
 		$object_class = strtolower( get_class( $this ) );
471 471
 
472
-		if ( ! has_filter(  "{$object_class}_inherit_{$method}" ) ) {
472
+		if ( ! has_filter( "{$object_class}_inherit_{$method}" ) ) {
473 473
 			throw new Exception( sprintf( esc_html__( 'Invalid %1$s method: %2$s', 'give' ), get_class( $this ), $method ) );
474 474
 		}
475 475
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@
 block discarded – undo
159 159
 	 * Get object property and optionally set a fallback
160 160
 	 * @since  2.0.0
161 161
 	 * @param  string $property Metabox config property to retrieve
162
-	 * @param  mixed  $fallback Fallback value to set if no value found
162
+	 * @param  boolean|null  $fallback Fallback value to set if no value found
163 163
 	 * @return mixed            Metabox config property value or false
164 164
 	 */
165 165
 	public function prop( $property, $fallback = null ) {
Please login to merge, or discard this patch.
includes/shim/WP_REST_Controller.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 		}
167 167
 
168 168
 		if ( ! empty( $links ) ) {
169
-			$data['_links'] = $links;
169
+			$data[ '_links' ] = $links;
170 170
 		}
171 171
 
172 172
 		return $data;
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$schema = $this->get_item_schema();
185 185
 		foreach ( $data as $key => $value ) {
186
-			if ( empty( $schema['properties'][ $key ] ) || empty( $schema['properties'][ $key ]['context'] ) ) {
186
+			if ( empty( $schema[ 'properties' ][ $key ] ) || empty( $schema[ 'properties' ][ $key ][ 'context' ] ) ) {
187 187
 				continue;
188 188
 			}
189 189
 
190
-			if ( ! in_array( $context, $schema['properties'][ $key ]['context'] ) ) {
190
+			if ( ! in_array( $context, $schema[ 'properties' ][ $key ][ 'context' ] ) ) {
191 191
 				unset( $data[ $key ] );
192 192
 				continue;
193 193
 			}
194 194
 
195
-			if ( 'object' === $schema['properties'][ $key ]['type'] && ! empty( $schema['properties'][ $key ]['properties'] ) ) {
196
-				foreach ( $schema['properties'][ $key ]['properties'] as $attribute => $details ) {
197
-					if ( empty( $details['context'] ) ) {
195
+			if ( 'object' === $schema[ 'properties' ][ $key ][ 'type' ] && ! empty( $schema[ 'properties' ][ $key ][ 'properties' ] ) ) {
196
+				foreach ( $schema[ 'properties' ][ $key ][ 'properties' ] as $attribute => $details ) {
197
+					if ( empty( $details[ 'context' ] ) ) {
198 198
 						continue;
199 199
 					}
200
-					if ( ! in_array( $context, $details['context'] ) ) {
200
+					if ( ! in_array( $context, $details[ 'context' ] ) ) {
201 201
 						if ( isset( $data[ $key ][ $attribute ] ) ) {
202 202
 							unset( $data[ $key ][ $attribute ] );
203 203
 						}
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 
228 228
 		$schema = $this->get_item_schema();
229 229
 
230
-		foreach ( $schema['properties'] as &$property ) {
231
-			if ( isset( $property['arg_options'] ) ) {
232
-				unset( $property['arg_options'] );
230
+		foreach ( $schema[ 'properties' ] as &$property ) {
231
+			if ( isset( $property[ 'arg_options' ] ) ) {
232
+				unset( $property[ 'arg_options' ] );
233 233
 			}
234 234
 		}
235 235
 
@@ -286,18 +286,18 @@  discard block
 block discarded – undo
286 286
 			'validate_callback'  => 'rest_validate_request_arg',
287 287
 		);
288 288
 		$schema = $this->get_item_schema();
289
-		if ( empty( $schema['properties'] ) ) {
289
+		if ( empty( $schema[ 'properties' ] ) ) {
290 290
 			return array_merge( $param_details, $args );
291 291
 		}
292 292
 		$contexts = array();
293
-		foreach ( $schema['properties'] as $attributes ) {
294
-			if ( ! empty( $attributes['context'] ) ) {
295
-				$contexts = array_merge( $contexts, $attributes['context'] );
293
+		foreach ( $schema[ 'properties' ] as $attributes ) {
294
+			if ( ! empty( $attributes[ 'context' ] ) ) {
295
+				$contexts = array_merge( $contexts, $attributes[ 'context' ] );
296 296
 			}
297 297
 		}
298 298
 		if ( ! empty( $contexts ) ) {
299
-			$param_details['enum'] = array_unique( $contexts );
300
-			rsort( $param_details['enum'] );
299
+			$param_details[ 'enum' ] = array_unique( $contexts );
300
+			rsort( $param_details[ 'enum' ] );
301 301
 		}
302 302
 		return array_merge( $param_details, $args );
303 303
 	}
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 
316 316
 		foreach ( $additional_fields as $field_name => $field_options ) {
317 317
 
318
-			if ( ! $field_options['get_callback'] ) {
318
+			if ( ! $field_options[ 'get_callback' ] ) {
319 319
 				continue;
320 320
 			}
321 321
 
322
-			$object[ $field_name ] = call_user_func( $field_options['get_callback'], $object, $field_name, $request, $this->get_object_type() );
322
+			$object[ $field_name ] = call_user_func( $field_options[ 'get_callback' ], $object, $field_name, $request, $this->get_object_type() );
323 323
 		}
324 324
 
325 325
 		return $object;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
 		foreach ( $additional_fields as $field_name => $field_options ) {
339 339
 
340
-			if ( ! $field_options['update_callback'] ) {
340
+			if ( ! $field_options[ 'update_callback' ] ) {
341 341
 				continue;
342 342
 			}
343 343
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 				continue;
347 347
 			}
348 348
 
349
-			call_user_func( $field_options['update_callback'], $request[ $field_name ], $object, $field_name, $request, $this->get_object_type() );
349
+			call_user_func( $field_options[ 'update_callback' ], $request[ $field_name ], $object, $field_name, $request, $this->get_object_type() );
350 350
 		}
351 351
 	}
352 352
 
@@ -358,23 +358,23 @@  discard block
 block discarded – undo
358 358
 	 * @param array $schema Schema array.
359 359
 	 */
360 360
 	protected function add_additional_fields_schema( $schema ) {
361
-		if ( empty( $schema['title'] ) ) {
361
+		if ( empty( $schema[ 'title' ] ) ) {
362 362
 			return $schema;
363 363
 		}
364 364
 
365 365
 		/**
366 366
 		 * Can't use $this->get_object_type otherwise we cause an inf loop.
367 367
 		 */
368
-		$object_type = $schema['title'];
368
+		$object_type = $schema[ 'title' ];
369 369
 
370 370
 		$additional_fields = $this->get_additional_fields( $object_type );
371 371
 
372 372
 		foreach ( $additional_fields as $field_name => $field_options ) {
373
-			if ( ! $field_options['schema'] ) {
373
+			if ( ! $field_options[ 'schema' ] ) {
374 374
 				continue;
375 375
 			}
376 376
 
377
-			$schema['properties'][ $field_name ] = $field_options['schema'];
377
+			$schema[ 'properties' ][ $field_name ] = $field_options[ 'schema' ];
378 378
 		}
379 379
 
380 380
 		return $schema;
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 	protected function get_object_type() {
414 414
 		$schema = $this->get_item_schema();
415 415
 
416
-		if ( ! $schema || ! isset( $schema['title'] ) ) {
416
+		if ( ! $schema || ! isset( $schema[ 'title' ] ) ) {
417 417
 			return null;
418 418
 		}
419 419
 
420
-		return $schema['title'];
420
+		return $schema[ 'title' ];
421 421
 	}
422 422
 
423 423
 	/**
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
 	public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
434 434
 
435 435
 		$schema                = $this->get_item_schema();
436
-		$schema_properties     = ! empty( $schema['properties'] ) ? $schema['properties'] : array();
436
+		$schema_properties     = ! empty( $schema[ 'properties' ] ) ? $schema[ 'properties' ] : array();
437 437
 		$endpoint_args = array();
438 438
 
439 439
 		foreach ( $schema_properties as $field_id => $params ) {
440 440
 
441 441
 			// Arguments specified as `readonly` are not allowed to be set.
442
-			if ( ! empty( $params['readonly'] ) ) {
442
+			if ( ! empty( $params[ 'readonly' ] ) ) {
443 443
 				continue;
444 444
 			}
445 445
 
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
 				'sanitize_callback' => 'rest_sanitize_request_arg',
449 449
 			);
450 450
 
451
-			if ( isset( $params['description'] ) ) {
452
-				$endpoint_args[ $field_id ]['description'] = $params['description'];
451
+			if ( isset( $params[ 'description' ] ) ) {
452
+				$endpoint_args[ $field_id ][ 'description' ] = $params[ 'description' ];
453 453
 			}
454 454
 
455
-			if ( WP_REST_Server::CREATABLE === $method && isset( $params['default'] ) ) {
456
-				$endpoint_args[ $field_id ]['default'] = $params['default'];
455
+			if ( WP_REST_Server::CREATABLE === $method && isset( $params[ 'default' ] ) ) {
456
+				$endpoint_args[ $field_id ][ 'default' ] = $params[ 'default' ];
457 457
 			}
458 458
 
459
-			if ( WP_REST_Server::CREATABLE === $method && ! empty( $params['required'] ) ) {
460
-				$endpoint_args[ $field_id ]['required'] = true;
459
+			if ( WP_REST_Server::CREATABLE === $method && ! empty( $params[ 'required' ] ) ) {
460
+				$endpoint_args[ $field_id ][ 'required' ] = true;
461 461
 			}
462 462
 
463 463
 			foreach ( array( 'type', 'format', 'enum' ) as $schema_prop ) {
@@ -467,14 +467,14 @@  discard block
 block discarded – undo
467 467
 			}
468 468
 
469 469
 			// Merge in any options provided by the schema property.
470
-			if ( isset( $params['arg_options'] ) ) {
470
+			if ( isset( $params[ 'arg_options' ] ) ) {
471 471
 
472 472
 				// Only use required / default from arg_options on CREATABLE endpoints.
473 473
 				if ( WP_REST_Server::CREATABLE !== $method ) {
474
-					$params['arg_options'] = array_diff_key( $params['arg_options'], array( 'required' => '', 'default' => '' ) );
474
+					$params[ 'arg_options' ] = array_diff_key( $params[ 'arg_options' ], array( 'required' => '', 'default' => '' ) );
475 475
 				}
476 476
 
477
-				$endpoint_args[ $field_id ] = array_merge( $endpoint_args[ $field_id ], $params['arg_options'] );
477
+				$endpoint_args[ $field_id ] = array_merge( $endpoint_args[ $field_id ], $params[ 'arg_options' ] );
478 478
 			}
479 479
 		}
480 480
 
Please login to merge, or discard this patch.
includes/CMB2_Hookup_Base.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@
 block discarded – undo
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 ) );
Please login to merge, or discard this patch.