Completed
Pull Request — trunk (#541)
by Justin
20:13 queued 05:52
created
includes/CMB2_Ajax.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 	public function oembed_handler() {
29 29
 
30 30
 		// Verify our nonce
31
-		if ( ! ( isset( $_REQUEST['cmb2_ajax_nonce'], $_REQUEST['oembed_url'] ) && wp_verify_nonce( $_REQUEST['cmb2_ajax_nonce'], 'ajax_nonce' ) ) ) {
31
+		if ( ! ( isset( $_REQUEST[ 'cmb2_ajax_nonce' ], $_REQUEST[ 'oembed_url' ] ) && wp_verify_nonce( $_REQUEST[ 'cmb2_ajax_nonce' ], 'ajax_nonce' ) ) ) {
32 32
 			die();
33 33
 		}
34 34
 
35 35
 		// Sanitize our search string
36
-		$oembed_string = sanitize_text_field( $_REQUEST['oembed_url'] );
36
+		$oembed_string = sanitize_text_field( $_REQUEST[ 'oembed_url' ] );
37 37
 
38 38
 		// Send back error if empty
39 39
 		if ( empty( $oembed_string ) ) {
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		}
42 42
 
43 43
 		// Set width of embed
44
-		$embed_width = isset( $_REQUEST['oembed_width'] ) && intval( $_REQUEST['oembed_width'] ) < 640 ? intval( $_REQUEST['oembed_width'] ) : '640';
44
+		$embed_width = isset( $_REQUEST[ 'oembed_width' ] ) && intval( $_REQUEST[ 'oembed_width' ] ) < 640 ? intval( $_REQUEST[ 'oembed_width' ] ) : '640';
45 45
 
46 46
 		// Set url
47 47
 		$oembed_url = esc_url( $oembed_string );
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 		// Get embed code (or fallback link)
55 55
 		$html = $this->get_oembed( array(
56 56
 			'url'         => $oembed_url,
57
-			'object_id'   => $_REQUEST['object_id'],
58
-			'object_type' => isset( $_REQUEST['object_type'] ) ? $_REQUEST['object_type'] : 'post',
57
+			'object_id'   => $_REQUEST[ 'object_id' ],
58
+			'object_type' => isset( $_REQUEST[ 'object_type' ] ) ? $_REQUEST[ 'object_type' ] : 'post',
59 59
 			'oembed_args' => $embed_args,
60
-			'field_id'    => $_REQUEST['field_id'],
60
+			'field_id'    => $_REQUEST[ 'field_id' ],
61 61
 		) );
62 62
 
63 63
 		wp_send_json_success( $html );
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 
74 74
 		global $wp_embed;
75 75
 
76
-		$oembed_url = esc_url( $args['url'] );
76
+		$oembed_url = esc_url( $args[ 'url' ] );
77 77
 
78 78
 		// Sanitize object_id
79
-		$this->object_id = is_numeric( $args['object_id'] ) ? absint( $args['object_id'] ) : sanitize_text_field( $args['object_id'] );
79
+		$this->object_id = is_numeric( $args[ 'object_id' ] ) ? absint( $args[ 'object_id' ] ) : sanitize_text_field( $args[ 'object_id' ] );
80 80
 
81 81
 		$args = wp_parse_args( $args, array(
82 82
 			'object_type' => 'post',
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			'cache_key'   => false,
86 86
 		) );
87 87
 
88
-		$this->embed_args =& $args;
88
+		$this->embed_args = & $args;
89 89
 
90 90
 
91 91
 		/**
@@ -95,20 +95,20 @@  discard block
 block discarded – undo
95 95
 		$wp_embed->post_ID = $this->object_id;
96 96
 
97 97
 		// Special scenario if NOT a post object
98
-		if ( isset( $args['object_type'] ) && 'post' != $args['object_type'] ) {
98
+		if ( isset( $args[ 'object_type' ] ) && 'post' != $args[ 'object_type' ] ) {
99 99
 
100
-			if ( 'options-page' == $args['object_type'] ) {
100
+			if ( 'options-page' == $args[ 'object_type' ] ) {
101 101
 
102 102
 				// Bogus id to pass some numeric checks. Issue with a VERY large WP install?
103 103
 				$wp_embed->post_ID = 1987645321;
104 104
 
105 105
 				// Use our own cache key to correspond to this field (vs one cache key per url)
106
-				$args['cache_key'] = $args['field_id'] . '_cache';
106
+				$args[ 'cache_key' ] = $args[ 'field_id' ] . '_cache';
107 107
 			}
108 108
 
109 109
 			// Ok, we need to hijack the oembed cache system
110 110
 			$this->hijack = true;
111
-			$this->object_type = $args['object_type'];
111
+			$this->object_type = $args[ 'object_type' ];
112 112
 
113 113
 			// Gets ombed cache from our object's meta (vs postmeta)
114 114
 			add_filter( 'get_post_metadata', array( $this, 'hijack_oembed_cache_get' ), 10, 3 );
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
 		$embed_args = '';
122 122
 
123
-		foreach ( $args['oembed_args'] as $key => $val ) {
123
+		foreach ( $args[ 'oembed_args' ] as $key => $val ) {
124 124
 			$embed_args .= " $key=\"$val\"";
125 125
 		}
126 126
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
 		// Send back our embed
134 134
 		if ( $check_embed && $check_embed != $fallback ) {
135
-			return '<div class="embed-status">' . $check_embed . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . $args['field_id'] . '">' . __( 'Remove Embed', 'cmb2' ) . '</a></p></div>';
135
+			return '<div class="embed-status">' . $check_embed . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . $args[ 'field_id' ] . '">' . __( 'Remove Embed', 'cmb2' ) . '</a></p></div>';
136 136
 		}
137 137
 
138 138
 		// Otherwise, send back error info that no oEmbeds were found
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
 		// Get cached data
164 164
 		return ( 'options-page' === $this->object_type )
165
-			? cmb2_options( $this->object_id )->get( $this->embed_args['cache_key'] )
165
+			? cmb2_options( $this->object_id )->get( $this->embed_args[ 'cache_key' ] )
166 166
 			: get_metadata( $this->object_type, $this->object_id, $meta_key, true );
167 167
 
168 168
 	}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		// Cache the result to our metadata
203 203
 		return ( 'options-page' !== $this->object_type )
204 204
 			? update_metadata( $this->object_type, $this->object_id, $meta_key, $meta_value )
205
-			: cmb2_options( $this->object_id )->update( $this->embed_args['cache_key'], $meta_value, true );
205
+			: cmb2_options( $this->object_id )->update( $this->embed_args[ 'cache_key' ], $meta_value, true );
206 206
 	}
207 207
 
208 208
 }
Please login to merge, or discard this patch.
includes/CMB2_JS.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,17 +51,17 @@
 block discarded – undo
51 51
 		$dependencies = apply_filters( 'cmb2_script_dependencies', self::$dependencies );
52 52
 
53 53
 		// if colorpicker
54
-		if ( ! is_admin() && isset( $dependencies['wp-color-picker'] ) ) {
54
+		if ( ! is_admin() && isset( $dependencies[ 'wp-color-picker' ] ) ) {
55 55
 			self::colorpicker_frontend();
56 56
 		}
57 57
 
58 58
 		// if file/file_list
59
-		if ( isset( $dependencies['media-editor'] ) ) {
59
+		if ( isset( $dependencies[ 'media-editor' ] ) ) {
60 60
 			wp_enqueue_media();
61 61
 		}
62 62
 
63 63
 		// if timepicker
64
-		if ( isset( $dependencies['jquery-ui-datetimepicker'] ) ) {
64
+		if ( isset( $dependencies[ 'jquery-ui-datetimepicker' ] ) ) {
65 65
 			wp_register_script( 'jquery-ui-datetimepicker', cmb2_utils()->url( 'js/jquery-ui-timepicker-addon.min.js' ), array( 'jquery-ui-slider' ), CMB2_VERSION );
66 66
 		}
67 67
 
Please login to merge, or discard this patch.
includes/CMB2_Options.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
 
132 132
 			if ( ! $single ) {
133 133
 				// If multiple, add to array
134
-				$this->options[ $field_id ][] = $value;
134
+				$this->options[ $field_id ][ ] = $value;
135 135
 			} else {
136 136
 				$this->options[ $field_id ] = $value;
137 137
 			}
Please login to merge, or discard this patch.
includes/CMB2_Sanitize.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 				}
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
 	 */
410 410
 	public function _new_supporting_field( $new_field_id ) {
411 411
 		$args = $this->field->args();
412
-		unset( $args['_id'], $args['_name'] );
412
+		unset( $args[ '_id' ], $args[ '_name' ] );
413 413
 
414
-		$args['id'] = $new_field_id;
415
-		$args['sanitization_cb'] = false;
414
+		$args[ 'id' ] = $new_field_id;
415
+		$args[ 'sanitization_cb' ] = false;
416 416
 
417 417
 		// And get new field object
418 418
 		return new CMB2_Field( array(
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 			if ( $this->value ) {
443 443
 				$val = $this->$method( true );
444 444
 				if ( ! empty( $val ) ) {
445
-					$new_value[] = $val;
445
+					$new_value[ ] = $val;
446 446
 				}
447 447
 			}
448 448
 		}
Please login to merge, or discard this patch.
includes/CMB2_Show_Filters.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	 * @return mixed                show_on key or false
28 28
 	 */
29 29
 	private static function get_show_on_key( $meta_box_args ) {
30
-		$show_on = isset( $meta_box_args['show_on'] ) ? (array) $meta_box_args['show_on'] : false;
30
+		$show_on = isset( $meta_box_args[ 'show_on' ] ) ? (array) $meta_box_args[ 'show_on' ] : false;
31 31
 		if ( $show_on && is_array( $show_on ) ) {
32 32
 
33 33
 			if ( array_key_exists( 'key', $show_on ) ) {
34
-				return $show_on['key'];
34
+				return $show_on[ 'key' ];
35 35
 			}
36 36
 
37 37
 			$keys = array_keys( $show_on );
38
-			return $keys[0];
38
+			return $keys[ 0 ];
39 39
 		}
40 40
 
41 41
 		return false;
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
 	 * @return mixed                show_on value or false
52 52
 	 */
53 53
 	private static function get_show_on_value( $meta_box_args ) {
54
-		$show_on = isset( $meta_box_args['show_on'] ) ? (array) $meta_box_args['show_on'] : false;
54
+		$show_on = isset( $meta_box_args[ 'show_on' ] ) ? (array) $meta_box_args[ 'show_on' ] : false;
55 55
 
56 56
 		if ( $show_on && is_array( $show_on ) ) {
57 57
 
58 58
 			if ( array_key_exists( 'value', $show_on ) ) {
59
-				return $show_on['value'];
59
+				return $show_on[ 'value' ];
60 60
 			}
61 61
 
62 62
 			$keys = array_keys( $show_on );
63 63
 
64
-			return $show_on[ $keys[0] ];
64
+			return $show_on[ $keys[ 0 ] ];
65 65
 		}
66 66
 
67 67
 		return array();
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		if ( is_admin() ) {
142 142
 
143 143
 			// If there is no 'page' query var, our filter isn't applicable
144
-			if ( ! isset( $_GET['page'] ) ) {
144
+			if ( ! isset( $_GET[ 'page' ] ) ) {
145 145
 				return $display;
146 146
 			}
147 147
 
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 
154 154
 			if ( is_array( $show_on ) ) {
155 155
 				foreach ( $show_on as $page ) {
156
-					if ( $_GET['page'] == $page ) {
156
+					if ( $_GET[ 'page' ] == $page ) {
157 157
 						return true;
158 158
 					}
159 159
 				}
160 160
 			} else {
161
-				if ( $_GET['page'] == $show_on ) {
161
+				if ( $_GET[ 'page' ] == $show_on ) {
162 162
 					return true;
163 163
 				}
164 164
 			}
Please login to merge, or discard this patch.
includes/CMB2_Utils.php 1 patch
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 "&#39;" . str_replace( '\\', '', $value[0] ) . "&#39;";
281
+		return "&#39;" . str_replace( '\\', '', $value[ 0 ] ) . "&#39;";
283 282
 	}
284 283
 
285 284
 	/**
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.
example-functions.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	$cmb_demo = new_cmb2_box( array(
79 79
 		'id'              => $prefix . 'metabox',
80 80
 		'title'           => __( 'Test Metabox', 'cmb2' ),
81
-		'object_types'    => array( 'page', ), // Post type
81
+		'object_types'    => array( 'page',), // Post type
82 82
 		// 'show_on_cb'   => 'yourprefix_show_if_front_page', // function should return a bool value
83 83
 		// 'context'      => 'normal',
84 84
 		// 'priority'     => 'high',
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		'desc'    => __( 'field description (optional)', 'cmb2' ),
323 323
 		'id'      => $prefix . 'wysiwyg',
324 324
 		'type'    => 'wysiwyg',
325
-		'options' => array( 'textarea_rows' => 5, ),
325
+		'options' => array( 'textarea_rows' => 5,),
326 326
 	) );
327 327
 
328 328
 	$cmb_demo->add_field( array(
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
 	$cmb_about_page = new_cmb2_box( array(
375 375
 		'id'           => $prefix . 'metabox',
376 376
 		'title'        => __( 'About Page Metabox', 'cmb2' ),
377
-		'object_types' => array( 'page', ), // Post type
377
+		'object_types' => array( 'page',), // Post type
378 378
 		'context'      => 'normal',
379 379
 		'priority'     => 'high',
380 380
 		'show_names'   => true, // Show field names on the left
381
-		'show_on'      => array( 'id' => array( 2, ) ), // Specific post IDs to display this metabox
381
+		'show_on'      => array( 'id' => array( 2,) ), // Specific post IDs to display this metabox
382 382
 	) );
383 383
 
384 384
 	$cmb_about_page->add_field( array(
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	$cmb_group = new_cmb2_box( array(
404 404
 		'id'           => $prefix . 'metabox',
405 405
 		'title'        => __( 'Repeating Field Group', 'cmb2' ),
406
-		'object_types' => array( 'page', ),
406
+		'object_types' => array( 'page',),
407 407
 	) );
408 408
 
409 409
 	// $group_field_id is the field id string, so in this case: $prefix . 'demo'
Please login to merge, or discard this patch.
includes/CMB2.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -121,19 +121,19 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function __construct( $meta_box, $object_id = 0 ) {
123 123
 
124
-		if ( empty( $meta_box['id'] ) ) {
124
+		if ( empty( $meta_box[ 'id' ] ) ) {
125 125
 			wp_die( __( 'Metabox configuration is required to have an ID parameter', 'cmb2' ) );
126 126
 		}
127 127
 
128 128
 		$this->meta_box = wp_parse_args( $meta_box, $this->mb_defaults );
129
-		$this->meta_box['fields'] = array();
129
+		$this->meta_box[ 'fields' ] = array();
130 130
 
131 131
 		$this->object_id( $object_id );
132 132
 		$this->mb_object_type();
133
-		$this->cmb_id = $meta_box['id'];
133
+		$this->cmb_id = $meta_box[ 'id' ];
134 134
 
135
-		if ( ! empty( $meta_box['fields'] ) && is_array( $meta_box['fields'] ) ) {
136
-			$this->add_fields( $meta_box['fields'] );
135
+		if ( ! empty( $meta_box[ 'fields' ] ) && is_array( $meta_box[ 'fields' ] ) ) {
136
+			$this->add_fields( $meta_box[ 'fields' ] );
137 137
 		}
138 138
 
139 139
 		CMB2_Boxes::add( $this );
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 	 * @return mixed CMB2_Field object if successful.
265 265
 	 */
266 266
 	public function render_field( $field_args ) {
267
-		$field_args['context'] = $this->prop( 'context' );
267
+		$field_args[ 'context' ] = $this->prop( 'context' );
268 268
 
269
-		if ( 'group' == $field_args['type'] ) {
269
+		if ( 'group' == $field_args[ 'type' ] ) {
270 270
 
271
-			if ( ! isset( $field_args['show_names'] ) ) {
272
-				$field_args['show_names'] = $this->prop( 'show_names' );
271
+			if ( ! isset( $field_args[ 'show_names' ] ) ) {
272
+				$field_args[ 'show_names' ] = $this->prop( 'show_names' );
273 273
 			}
274 274
 			$field = $this->render_group( $field_args );
275 275
 
276
-		} elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) {
276
+		} elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) {
277 277
 			// Save rendering for after the metabox
278 278
 			$field = $this->add_hidden_field( array(
279 279
 				'field_args'  => $field_args,
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
 		} else {
285 285
 
286
-			$field_args['show_names'] = $this->prop( 'show_names' );
286
+			$field_args[ 'show_names' ] = $this->prop( 'show_names' );
287 287
 
288 288
 			// Render default fields
289 289
 			$field = $this->get_field( $field_args )->render_field();
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	public function render_group( $args ) {
301 301
 
302
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
302
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
303 303
 			return;
304 304
 		}
305 305
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 			<div class="inside cmb-td cmb-nested cmb-field-list">';
382 382
 				// Loop and render repeatable group fields
383 383
 				foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) {
384
-					if ( 'hidden' == $field_args['type'] ) {
384
+					if ( 'hidden' == $field_args[ 'type' ] ) {
385 385
 
386 386
 						// Save rendering for after the metabox
387 387
 						$this->add_hidden_field( array(
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 
392 392
 					} else {
393 393
 
394
-						$field_args['show_names'] = $field_group->args( 'show_names' );
395
-						$field_args['context']    = $field_group->args( 'context' );
394
+						$field_args[ 'show_names' ] = $field_group->args( 'show_names' );
395
+						$field_args[ 'context' ]    = $field_group->args( 'context' );
396 396
 
397 397
 						$field = $this->get_field( $field_args, $field_group )->render_field();
398 398
 					}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 */
422 422
 	public function add_hidden_field( $args ) {
423 423
 		$field = new CMB2_Field( $args );
424
-		$this->hidden_fields[] = new CMB2_Types( $field );
424
+		$this->hidden_fields[ ] = new CMB2_Types( $field );
425 425
 
426 426
 		return $field;
427 427
 	}
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
 	 */
519 519
 	public function process_field( $field_args ) {
520 520
 
521
-		switch ( $field_args['type'] ) {
521
+		switch ( $field_args[ 'type' ] ) {
522 522
 
523 523
 			case 'group':
524 524
 				if ( $this->save_group( $field_args ) ) {
525
-					$this->updated[] = $field_args['id'];
525
+					$this->updated[ ] = $field_args[ 'id' ];
526 526
 				}
527 527
 
528 528
 				break;
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 				) );
542 542
 
543 543
 				if ( $field->save_field_from_data( $this->data_to_save ) ) {
544
-					$this->updated[] = $field->id();
544
+					$this->updated[ ] = $field->id();
545 545
 				}
546 546
 
547 547
 				break;
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 * @return mixed        Return of CMB2_Field::update_data()
609 609
 	 */
610 610
 	public function save_group( $args ) {
611
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
611
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
612 612
 			return;
613 613
 		}
614 614
 
@@ -662,16 +662,16 @@  discard block
 block discarded – undo
662 662
 						$_new_val = array();
663 663
 						foreach ( $new_val as $group_index => $grouped_data ) {
664 664
 							// Add the supporting data to the $saved array stack
665
-							$saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value'];
665
+							$saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ];
666 666
 							// Reset var to the actual value
667
-							$_new_val[ $group_index ] = $grouped_data['value'];
667
+							$_new_val[ $group_index ] = $grouped_data[ 'value' ];
668 668
 						}
669 669
 						$new_val = $_new_val;
670 670
 					} else {
671 671
 						// Add the supporting data to the $saved array stack
672
-						$saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value'];
672
+						$saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ];
673 673
 						// Reset var to the actual value
674
-						$new_val = $new_val['value'];
674
+						$new_val = $new_val[ 'value' ];
675 675
 					}
676 676
 				}
677 677
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 				$is_removed = ( empty( $new_val ) && ! empty( $old_val ) );
685 685
 				// Compare values and add to `$updated` array
686 686
 				if ( $is_updated || $is_removed ) {
687
-					$this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id;
687
+					$this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id;
688 688
 				}
689 689
 
690 690
 				// Add to `$saved` array
@@ -719,22 +719,22 @@  discard block
 block discarded – undo
719 719
 		// Try to get our object ID from the global space
720 720
 		switch ( $this->object_type() ) {
721 721
 			case 'user':
722
-				$object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id;
723
-				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id;
722
+				$object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id;
723
+				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id;
724 724
 				break;
725 725
 
726 726
 			case 'comment':
727
-				$object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id;
728
-				$object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id;
727
+				$object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id;
728
+				$object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id;
729 729
 				break;
730 730
 
731 731
 			case 'term':
732
-				$object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id;
732
+				$object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id;
733 733
 				break;
734 734
 
735 735
 			default:
736
-				$object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id;
737
-				$object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id;
736
+				$object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id;
737
+				$object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id;
738 738
 				break;
739 739
 		}
740 740
 
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 	 * @return boolean True/False
807 807
 	 */
808 808
 	public function is_options_page_mb() {
809
-		return ( isset( $this->meta_box['show_on']['key'] ) && 'options-page' === $this->meta_box['show_on']['key'] || array_key_exists( 'options-page', $this->meta_box['show_on'] ) );
809
+		return ( isset( $this->meta_box[ 'show_on' ][ 'key' ] ) && 'options-page' === $this->meta_box[ 'show_on' ][ 'key' ] || array_key_exists( 'options-page', $this->meta_box[ 'show_on' ] ) );
810 810
 	}
811 811
 
812 812
 	/**
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 			return $field;
873 873
 		}
874 874
 
875
-		$field_id = is_string( $field ) ? $field : $field['id'];
875
+		$field_id = is_string( $field ) ? $field : $field[ 'id' ];
876 876
 
877 877
 		$parent_field_id = ! empty( $field_group ) ? $field_group->id() : '';
878 878
 		$ids = $this->get_field_ids( $field_id, $parent_field_id, true );
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 		if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) {
909 909
 
910 910
 			// Update the fields array w/ any modified properties inherited from the group field
911
-			$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args;
911
+			$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args;
912 912
 
913 913
 			return array(
914 914
 				'field_args'  => $field_args,
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
 		}
919 919
 
920 920
 		if ( is_array( $field_args ) ) {
921
-			$this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] );
921
+			$this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] );
922 922
 		}
923 923
 
924 924
 		return array(
925
-			'field_args'  => $this->meta_box['fields'][ $field_id ],
925
+			'field_args'  => $this->meta_box[ 'fields' ][ $field_id ],
926 926
 			'object_type' => $this->object_type(),
927 927
 			'object_id'   => $this->object_id(),
928 928
 		);
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
 
940 940
 			$sub_fields = false;
941 941
 			if ( array_key_exists( 'fields', $field ) ) {
942
-				$sub_fields = $field['fields'];
943
-				unset( $field['fields'] );
942
+				$sub_fields = $field[ 'fields' ];
943
+				unset( $field[ 'fields' ] );
944 944
 			}
945 945
 
946 946
 			$field_id = $parent_field_id
@@ -967,11 +967,11 @@  discard block
 block discarded – undo
967 967
 
968 968
 		$this->_add_field_to_array(
969 969
 			$field,
970
-			$this->meta_box['fields'],
970
+			$this->meta_box[ 'fields' ],
971 971
 			$position
972 972
 		);
973 973
 
974
-		return $field['id'];
974
+		return $field[ 'id' ];
975 975
 	}
976 976
 
977 977
 	/**
@@ -983,27 +983,27 @@  discard block
 block discarded – undo
983 983
 	 * @return mixed                   Array of parent/field ids or false
984 984
 	 */
985 985
 	public function add_group_field( $parent_field_id, array $field, $position = 0 ) {
986
-		if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) {
986
+		if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) {
987 987
 			return false;
988 988
 		}
989 989
 
990
-		$parent_field = $this->meta_box['fields'][ $parent_field_id ];
990
+		$parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ];
991 991
 
992
-		if ( 'group' !== $parent_field['type'] ) {
992
+		if ( 'group' !== $parent_field[ 'type' ] ) {
993 993
 			return false;
994 994
 		}
995 995
 
996
-		if ( ! isset( $parent_field['fields'] ) ) {
997
-			$this->meta_box['fields'][ $parent_field_id ]['fields'] = array();
996
+		if ( ! isset( $parent_field[ 'fields' ] ) ) {
997
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array();
998 998
 		}
999 999
 
1000 1000
 		$this->_add_field_to_array(
1001 1001
 			$field,
1002
-			$this->meta_box['fields'][ $parent_field_id ]['fields'],
1002
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ],
1003 1003
 			$position
1004 1004
 		);
1005 1005
 
1006
-		return array( $parent_field_id, $field['id'] );
1006
+		return array( $parent_field_id, $field[ 'id' ] );
1007 1007
 	}
1008 1008
 
1009 1009
 	/**
@@ -1015,9 +1015,9 @@  discard block
 block discarded – undo
1015 1015
 	 */
1016 1016
 	protected function _add_field_to_array( $field, &$fields, $position = 0 ) {
1017 1017
 		if ( $position ) {
1018
-			cmb2_utils()->array_insert( $fields, array( $field['id'] => $field ), $position );
1018
+			cmb2_utils()->array_insert( $fields, array( $field[ 'id' ] => $field ), $position );
1019 1019
 		} else {
1020
-			$fields[ $field['id'] ] = $field;
1020
+			$fields[ $field[ 'id' ] ] = $field;
1021 1021
 		}
1022 1022
 	}
1023 1023
 
@@ -1040,12 +1040,12 @@  discard block
 block discarded – undo
1040 1040
 		unset( $this->fields[ implode( '', $ids ) ] );
1041 1041
 
1042 1042
 		if ( ! $sub_field_id ) {
1043
-			unset( $this->meta_box['fields'][ $field_id ] );
1043
+			unset( $this->meta_box[ 'fields' ][ $field_id ] );
1044 1044
 			return true;
1045 1045
 		}
1046 1046
 
1047
-		unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] );
1048
-		unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] );
1047
+		unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] );
1048
+		unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] );
1049 1049
 		return true;
1050 1050
 	}
1051 1051
 
@@ -1068,11 +1068,11 @@  discard block
 block discarded – undo
1068 1068
 		list( $field_id, $sub_field_id ) = $ids;
1069 1069
 
1070 1070
 		if ( ! $sub_field_id ) {
1071
-			$this->meta_box['fields'][ $field_id ][ $property ] = $value;
1071
+			$this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value;
1072 1072
 			return $field_id;
1073 1073
 		}
1074 1074
 
1075
-		$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value;
1075
+		$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value;
1076 1076
 		return $field_id;
1077 1077
 	}
1078 1078
 
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 	public function get_field_ids( $field_id, $parent_field_id = '' ) {
1087 1087
 		$sub_field_id = $parent_field_id ? $field_id : '';
1088 1088
 		$field_id     = $parent_field_id ? $parent_field_id : $field_id;
1089
-		$fields       =& $this->meta_box['fields'];
1089
+		$fields       = & $this->meta_box[ 'fields' ];
1090 1090
 
1091 1091
 		if ( ! array_key_exists( $field_id, $fields ) ) {
1092 1092
 			$field_id = $this->search_old_school_array( $field_id, $fields );
@@ -1100,12 +1100,12 @@  discard block
 block discarded – undo
1100 1100
 			return array( $field_id, $sub_field_id );
1101 1101
 		}
1102 1102
 
1103
-		if ( 'group' !== $fields[ $field_id ]['type'] ) {
1103
+		if ( 'group' !== $fields[ $field_id ][ 'type' ] ) {
1104 1104
 			return false;
1105 1105
 		}
1106 1106
 
1107
-		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) {
1108
-			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] );
1107
+		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) {
1108
+			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] );
1109 1109
 		}
1110 1110
 
1111 1111
 		return false === $sub_field_id ? false : array( $field_id, $sub_field_id );
Please login to merge, or discard this patch.