Completed
Pull Request — trunk (#541)
by Justin
04:31
created
includes/CMB2_Utils.php 2 patches
Spacing   +19 added lines, -20 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		$dir = wp_upload_dir();
31 31
 
32 32
 		// Is URL in uploads directory?
33
-		if ( false === strpos( $img_url, $dir['baseurl'] . '/' ) ) {
33
+		if ( false === strpos( $img_url, $dir[ 'baseurl' ] . '/' ) ) {
34 34
 			return false;
35 35
 		}
36 36
 
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 
56 56
 			foreach ( $query->posts as $post_id ) {
57 57
 				$meta = wp_get_attachment_metadata( $post_id );
58
-				$original_file       = basename( $meta['file'] );
59
-				$cropped_image_files = isset( $meta['sizes'] ) ? wp_list_pluck( $meta['sizes'], 'file' ) : array();
58
+				$original_file       = basename( $meta[ 'file' ] );
59
+				$cropped_image_files = isset( $meta[ 'sizes' ] ) ? wp_list_pluck( $meta[ 'sizes' ], 'file' ) : array();
60 60
 				if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) {
61 61
 					$attachment_id = $post_id;
62 62
 					break;
@@ -135,8 +135,7 @@  discard block
 block discarded – undo
135 135
 		}
136 136
 
137 137
 		return $this->is_valid_time_stamp( $string )
138
-			? (int) $string :
139
-			strtotime( (string) $string );
138
+			? (int) $string : strtotime( (string) $string );
140 139
 	}
141 140
 
142 141
 	/**
@@ -241,24 +240,24 @@  discard block
 block discarded – undo
241 240
 
242 241
 		// order is relevant here, since the replacement will be done sequentially.
243 242
 		$supported_options = array(
244
-			'd' => 'dd',  // Day, leading 0
245
-			'j' => 'd',   // Day, no 0
246
-			'z' => 'o',   // Day of the year, no leading zeroes,
243
+			'd' => 'dd', // Day, leading 0
244
+			'j' => 'd', // Day, no 0
245
+			'z' => 'o', // Day of the year, no leading zeroes,
247 246
 			// 'D' => 'D',   // Day name short, not sure how it'll work with translations
248 247
 			// 'l' => 'DD',  // Day name full, idem before
249
-			'm' => 'mm',  // Month of the year, leading 0
250
-			'n' => 'm',   // Month of the year, no leading 0
248
+			'm' => 'mm', // Month of the year, leading 0
249
+			'n' => 'm', // Month of the year, no leading 0
251 250
 			// 'M' => 'M',   // Month, Short name
252 251
 			// 'F' => 'MM',  // Month, full name,
253
-			'y' => 'y',   // Year, two digit
254
-			'Y' => 'yy',  // Year, full
255
-			'H' => 'HH',  // Hour with leading 0 (24 hour)
256
-			'G' => 'H',   // Hour with no leading 0 (24 hour)
257
-			'h' => 'hh',  // Hour with leading 0 (12 hour)
258
-			'g' => 'h',   // Hour with no leading 0 (12 hour),
259
-			'i' => 'mm',  // Minute with leading 0,
260
-			's' => 'ss',  // Second with leading 0,
261
-			'a' => 'tt',  // am/pm
252
+			'y' => 'y', // Year, two digit
253
+			'Y' => 'yy', // Year, full
254
+			'H' => 'HH', // Hour with leading 0 (24 hour)
255
+			'G' => 'H', // Hour with no leading 0 (24 hour)
256
+			'h' => 'hh', // Hour with leading 0 (12 hour)
257
+			'g' => 'h', // Hour with no leading 0 (12 hour),
258
+			'i' => 'mm', // Minute with leading 0,
259
+			's' => 'ss', // Second with leading 0,
260
+			'a' => 'tt', // am/pm
262 261
 			'A' => 'TT'   // AM/PM
263 262
 		);
264 263
 
@@ -279,7 +278,7 @@  discard block
 block discarded – undo
279 278
 	 * @return string Modified value
280 279
 	 */
281 280
 	public function wrap_escaped_chars( $value ) {
282
-		return "'" . str_replace( '\\', '', $value[0] ) . "'";
281
+		return "'" . str_replace( '\\', '', $value[ 0 ] ) . "'";
283 282
 	}
284 283
 
285 284
 	/**
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -110,7 +110,8 @@
 block discarded – undo
110 110
 		$current_offset = get_option( 'gmt_offset' );
111 111
 		$tzstring       = get_option( 'timezone_string' );
112 112
 
113
-		if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
113
+		if ( empty( $tzstring ) ) {
114
+// Create a UTC+- zone if no timezone string exists
114 115
 			if ( 0 == $current_offset ) {
115 116
 				$tzstring = 'UTC+0';
116 117
 			} elseif ( $current_offset < 0 ) {
Please login to merge, or discard this patch.
includes/helper-functions.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		$cmb = CMB2_Boxes::get( $meta_box );
179 179
 	} else {
180 180
 		// See if we already have an instance of this metabox
181
-		$cmb = CMB2_Boxes::get( $meta_box['id'] );
181
+		$cmb = CMB2_Boxes::get( $meta_box[ 'id' ] );
182 182
 		// If not, we'll initate a new metabox
183 183
 		$cmb = $cmb ? $cmb : new CMB2( $meta_box, $object_id );
184 184
 	}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	) );
255 255
 
256 256
 	// Set object type explicitly (rather than trying to guess from context)
257
-	$cmb->object_type( $args['object_type'] );
257
+	$cmb->object_type( $args[ 'object_type' ] );
258 258
 
259 259
 	// Save the metabox if it's been submitted
260 260
 	// check permissions
@@ -262,32 +262,32 @@  discard block
 block discarded – undo
262 262
 	if (
263 263
 		$cmb->prop( 'save_fields' )
264 264
 		// check nonce
265
-		&& isset( $_POST['submit-cmb'], $_POST['object_id'], $_POST[ $cmb->nonce() ] )
265
+		&& isset( $_POST[ 'submit-cmb' ], $_POST[ 'object_id' ], $_POST[ $cmb->nonce() ] )
266 266
 		&& wp_verify_nonce( $_POST[ $cmb->nonce() ], $cmb->nonce() )
267
-		&& $object_id && $_POST['object_id'] == $object_id
267
+		&& $object_id && $_POST[ 'object_id' ] == $object_id
268 268
 	) {
269 269
 		$cmb->save_fields( $object_id, $cmb->object_type(), $_POST );
270 270
 	}
271 271
 
272 272
 	// Enqueue JS/CSS
273
-	if ( $args['cmb_styles'] ) {
273
+	if ( $args[ 'cmb_styles' ] ) {
274 274
 		CMB2_hookup::enqueue_cmb_css();
275 275
 	}
276 276
 
277
-	if ( $args['enqueue_js'] ) {
277
+	if ( $args[ 'enqueue_js' ] ) {
278 278
 		CMB2_hookup::enqueue_cmb_js();
279 279
 	}
280 280
 
281
-	$form_format = apply_filters( 'cmb2_get_metabox_form_format', $args['form_format'], $object_id, $cmb );
281
+	$form_format = apply_filters( 'cmb2_get_metabox_form_format', $args[ 'form_format' ], $object_id, $cmb );
282 282
 
283 283
 	$format_parts = explode( '%3$s', $form_format );
284 284
 
285 285
 	// Show cmb form
286
-	printf( $format_parts[0], $cmb->cmb_id, $object_id );
286
+	printf( $format_parts[ 0 ], $cmb->cmb_id, $object_id );
287 287
 	$cmb->show_form();
288 288
 
289
-	if ( isset( $format_parts[1] ) && $format_parts[1] ) {
290
-		printf( str_ireplace( '%4$s', '%1$s', $format_parts[1] ), $args['save_button'] );
289
+	if ( isset( $format_parts[ 1 ] ) && $format_parts[ 1 ] ) {
290
+		printf( str_ireplace( '%4$s', '%1$s', $format_parts[ 1 ] ), $args[ 'save_button' ] );
291 291
 	}
292 292
 
293 293
 }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
  * @param  array   $args      Optional arguments array
301 301
  */
302 302
 function cmb2_metabox_form( $meta_box, $object_id = 0, $args = array() ) {
303
-	if ( ! isset( $args['echo'] ) || $args['echo'] ) {
303
+	if ( ! isset( $args[ 'echo' ] ) || $args[ 'echo' ] ) {
304 304
 		cmb2_print_metabox_form( $meta_box, $object_id, $args );
305 305
 	} else {
306 306
 		return cmb2_get_metabox_form( $meta_box, $object_id, $args );
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 
323 323
 		$schedule_format = str_replace(
324 324
 			array( 'M', 'Y', 'm', 'd', 'H', 'i', 'a' ),
325
-			array('%b', '%Y', '%m', '%d', '%H', '%M', '%p' ),
325
+			array( '%b', '%Y', '%m', '%d', '%H', '%M', '%p' ),
326 326
 			$date_format
327 327
 		);
328 328
 
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 			 * 4 or 2 characters, as needed
340 340
 			 */
341 341
 			'%04d-%02d-%02d %02d:%02d:%02d',
342
-			$parsed_time['tm_year'] + 1900,  // This will be "111", so we need to add 1900.
343
-			$parsed_time['tm_mon'] + 1,      // This will be the month minus one, so we add one.
344
-			$parsed_time['tm_mday'],
345
-			$parsed_time['tm_hour'],
346
-			$parsed_time['tm_min'],
347
-			$parsed_time['tm_sec']
342
+			$parsed_time[ 'tm_year' ] + 1900, // This will be "111", so we need to add 1900.
343
+			$parsed_time[ 'tm_mon' ] + 1, // This will be the month minus one, so we add one.
344
+			$parsed_time[ 'tm_mday' ],
345
+			$parsed_time[ 'tm_hour' ],
346
+			$parsed_time[ 'tm_min' ],
347
+			$parsed_time[ 'tm_sec' ]
348 348
 		);
349 349
 
350
-		return new DateTime($ymd);
350
+		return new DateTime( $ymd );
351 351
 	}
352 352
 }
Please login to merge, or discard this patch.
includes/CMB2_Boxes.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
 	 * Retrieve all CMB2 instances that have the specified property set.
75 75
 	 * @since  2.2.0
76 76
 	 * @param  string $property Property name.
77
-	 * @param  mixed  $ignore   The value to ignore.
77
+	 * @param  boolean  $ignore   The value to ignore.
78 78
 	 * @return CMB2[]           Array of matching cmb2 instances.
79 79
 	 */
80 80
 	public static function get_by_property( $property, $ignore = null ) {
Please login to merge, or discard this patch.
includes/CMB2_REST_Access.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	/**
153 153
 	 * Handler for updating custom field data.
154 154
 	 * @since  2.2.0
155
-	 * @param  mixed    $value    The value of the field
155
+	 * @param  mixed    $values    The value of the field
156 156
 	 * @param  object   $object   The object from the response
157 157
 	 * @param  string   $field_id Name of field
158 158
 	 * @return bool|int
@@ -233,6 +233,9 @@  discard block
 block discarded – undo
233 233
 		return $protected;
234 234
 	}
235 235
 
236
+	/**
237
+	 * @param string $field_id
238
+	 */
236 239
 	public function field_can_update( $field_id ) {
237 240
 
238 241
 		$field        = $this->cmb->get_field( $field_id );
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 
89 89
 	protected function prepare_read_write_fields() {
90 90
 		foreach ( $this->cmb->prop( 'fields' ) as $field ) {
91
-			$show_in_rest = isset( $field['show_in_rest'] ) ? $field['show_in_rest'] : null;
91
+			$show_in_rest = isset( $field[ 'show_in_rest' ] ) ? $field[ 'show_in_rest' ] : null;
92 92
 
93 93
 			if ( false === $show_in_rest ) {
94 94
 				continue;
95 95
 			}
96 96
 
97
-			$this->maybe_add_read_field( $field['id'], $show_in_rest );
98
-			$this->maybe_add_write_field( $field['id'], $show_in_rest );
97
+			$this->maybe_add_read_field( $field[ 'id' ], $show_in_rest );
98
+			$this->maybe_add_write_field( $field[ 'id' ], $show_in_rest );
99 99
 		}
100 100
 	}
101 101
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			: in_array( $show_in_rest, array( 'read_and_write', 'read_only' ), true );
106 106
 
107 107
 		if ( $can_read ) {
108
-			self::$read_fields[ $this->cmb->cmb_id ][] = $field_id;
108
+			self::$read_fields[ $this->cmb->cmb_id ][ ] = $field_id;
109 109
 		}
110 110
 	}
111 111
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 			: in_array( $show_in_rest, array( 'read_and_write', 'write_only' ), true );
116 116
 
117 117
 		if ( $can_update ) {
118
-			self::$write_fields[ $this->cmb->cmb_id ][] = $field_id;
118
+			self::$write_fields[ $this->cmb->cmb_id ][ ] = $field_id;
119 119
 		}
120 120
 	}
121 121
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public static function get_restable_field_values( $object, $field_id, $request ) {
131 131
 		$values = array();
132
-		if ( ! isset( $object['id'] ) ) {
132
+		if ( ! isset( $object[ 'id' ] ) ) {
133 133
 			return;
134 134
 		}
135 135
 
136 136
 		foreach ( self::$read_fields as $cmb_id => $fields ) {
137 137
 			foreach ( $fields as $field_id ) {
138 138
 				$field = self::$boxes[ $cmb_id ]->get_field( $field_id );
139
-				$field->object_id = $object['id'];
139
+				$field->object_id = $object[ 'id' ];
140 140
 
141 141
 				if ( isset( $object->type ) ) {
142 142
 					$field->object_type = $object->type;
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 			return;
168 168
 		}
169 169
 
170
-		$object_id   = $data['object_id'];
171
-		$object_type = $data['object_type'];
170
+		$object_id   = $data[ 'object_id' ];
171
+		$object_type = $data[ 'object_type' ];
172 172
 		$updated     = array();
173 173
 
174 174
 		foreach ( self::$write_fields as $cmb_id => $fields ) {
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 		} elseif ( isset( $object->comment_ID ) ) {
253 253
 			$object_id   = intval( $object->comment_ID );
254 254
 			$object_type = 'comment';
255
-		} elseif ( is_array( $object ) && isset( $object['term_id'] ) ) {
256
-			$object_id   = intval( $object['term_id'] );
255
+		} elseif ( is_array( $object ) && isset( $object[ 'term_id' ] ) ) {
256
+			$object_id   = intval( $object[ 'term_id' ] );
257 257
 			$object_type = 'term';
258 258
 		} elseif ( isset( $object->term_id ) ) {
259 259
 			$object_id   = intval( $object->term_id );
Please login to merge, or discard this patch.
includes/CMB2_Hookup_Base.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 			return;
55 55
 		}
56 56
 
57
-		self::$hooks_completed[] = $key;
57
+		self::$hooks_completed[ ] = $key;
58 58
 		add_filter( $action, $hook, $priority, $accepted_args );
59 59
 	}
60 60
 
Please login to merge, or discard this patch.
includes/CMB2_REST_Endpoints.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -344,7 +344,6 @@
 block discarded – undo
344 344
 	 *
345 345
 	 * @since 2.2.0
346 346
 	 *
347
-	 * @param  mixed $data
348 347
 	 * @return array $data
349 348
 	 */
350 349
 	public function prepare_item( $post ) {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
 		if ( $cmb_id && ( $cmb = cmb2_get_metabox( $cmb_id ) ) ) {
157 157
 			$fields = array();
158 158
 			foreach ( $cmb->prop( 'fields', array() ) as $field ) {
159
-				$field = $this->get_rest_field( $cmb, $field['id'] );
159
+				$field = $this->get_rest_field( $cmb, $field[ 'id' ] );
160 160
 
161 161
 				if ( ! is_wp_error( $field ) ) {
162
-					$fields[ $field['id'] ] = $field;
162
+					$fields[ $field[ 'id' ] ] = $field;
163 163
 				} else {
164
-					$fields[ $field['id'] ] = array( 'error' => $field->get_error_message() );
164
+					$fields[ $field[ 'id' ] ] = array( 'error' => $field->get_error_message() );
165 165
 				}
166 166
 			}
167 167
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		// TODO: handle callable properties
184 184
 		$boxes_data = $cmb->meta_box;
185 185
 
186
-		unset( $boxes_data['fields'] );
186
+		unset( $boxes_data[ 'fields' ] );
187 187
 
188 188
 		$base = $this->namespace . '/boxes/' . $cmb->cmb_id;
189 189
 		$boxbase = $base . '/' . $cmb->cmb_id;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			),
202 202
 		) );
203 203
 
204
-		$boxes_data['_links'] = $response->get_links();
204
+		$boxes_data[ '_links' ] = $response->get_links();
205 205
 
206 206
 		return $boxes_data;
207 207
 	}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			if ( 'render_row_cb' === $key ) {
274 274
 				$value = '';
275 275
 				// TODO: Use request get object
276
-				if ( isset( $_GET['rendered'] ) && ( $cb = $field->maybe_callback( 'render_row_cb' ) ) ) {
276
+				if ( isset( $_GET[ 'rendered' ] ) && ( $cb = $field->maybe_callback( 'render_row_cb' ) ) ) {
277 277
 					// Ok, callback is good, let's run it.
278 278
 					ob_start();
279 279
 					call_user_func( $cb, $field->args(), $this );
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
 				$field_data[ $key ] = __( 'Value Error', 'cmb2' );
297 297
 			}
298 298
 		}
299
-		$field_data['value'] = $field->get_data();
299
+		$field_data[ 'value' ] = $field->get_data();
300 300
 
301 301
 		$base = $this->namespace . '/boxes/' . $cmb->cmb_id;
302 302
 
303 303
 		// Entity meta
304
-		$field_data['_links'] = array(
304
+		$field_data[ '_links' ] = array(
305 305
 			'self' => array(
306 306
 				'href' => rest_url( trailingslashit( $base ) . 'fields/' . $field->_id() ),
307 307
 			),
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 */
363 363
 	public function prepare_item_for_response( $data, $request ) {
364 364
 
365
-		$context = ! empty( $this->request['context'] ) ? $this->request['context'] : 'view';
365
+		$context = ! empty( $this->request[ 'context' ] ) ? $this->request[ 'context' ] : 'view';
366 366
 		$data = $this->filter_response_by_context( $data, $context );
367 367
 
368 368
 		/**
Please login to merge, or discard this patch.