Completed
Pull Request — master (#42)
by
unknown
02:29
created
tests/core/nav-menu-setting.php 1 patch
Spacing   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	function setUp() {
23 23
 		parent::setUp();
24
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
24
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
25 25
 		//require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
26
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
26
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
27 27
 
28 28
 		global $wp_customize;
29 29
 		$this->wp_customize = new WP_Customize_Manager();
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
 	 * @return array
46 46
 	 */
47 47
 	function get_nav_menu_items_option() {
48
-		return get_option( 'nav_menu_options', array( 'auto_add' => array() ) );
48
+		return get_option('nav_menu_options', array('auto_add' => array()));
49 49
 	}
50 50
 
51 51
 	/**
52 52
 	 * Test constants and statics.
53 53
 	 */
54 54
 	function test_constants() {
55
-		do_action( 'customize_register', $this->wp_customize );
56
-		$this->assertTrue( taxonomy_exists( WP_Customize_Nav_Menu_Setting::TAXONOMY ) );
55
+		do_action('customize_register', $this->wp_customize);
56
+		$this->assertTrue(taxonomy_exists(WP_Customize_Nav_Menu_Setting::TAXONOMY));
57 57
 	}
58 58
 
59 59
 	/**
@@ -62,49 +62,49 @@  discard block
 block discarded – undo
62 62
 	 * @see WP_Customize_Nav_Menu_Setting::__construct()
63 63
 	 */
64 64
 	function test_construct() {
65
-		do_action( 'customize_register', $this->wp_customize );
66
-
67
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[123]' );
68
-		$this->assertEquals( 'nav_menu', $setting->type );
69
-		$this->assertEquals( 'postMessage', $setting->transport );
70
-		$this->assertEquals( 123, $setting->term_id );
71
-		$this->assertNull( $setting->previous_term_id );
72
-		$this->assertNull( $setting->update_status );
73
-		$this->assertNull( $setting->update_error );
74
-		$this->assertInternalType( 'array', $setting->default );
75
-		foreach ( array( 'name', 'description', 'parent' ) as $key ) {
76
-			$this->assertArrayHasKey( $key, $setting->default );
65
+		do_action('customize_register', $this->wp_customize);
66
+
67
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, 'nav_menu[123]');
68
+		$this->assertEquals('nav_menu', $setting->type);
69
+		$this->assertEquals('postMessage', $setting->transport);
70
+		$this->assertEquals(123, $setting->term_id);
71
+		$this->assertNull($setting->previous_term_id);
72
+		$this->assertNull($setting->update_status);
73
+		$this->assertNull($setting->update_error);
74
+		$this->assertInternalType('array', $setting->default);
75
+		foreach (array('name', 'description', 'parent') as $key) {
76
+			$this->assertArrayHasKey($key, $setting->default);
77 77
 		}
78
-		$this->assertEquals( '', $setting->default['name'] );
79
-		$this->assertEquals( '', $setting->default['description'] );
80
-		$this->assertEquals( 0, $setting->default['parent'] );
78
+		$this->assertEquals('', $setting->default['name']);
79
+		$this->assertEquals('', $setting->default['description']);
80
+		$this->assertEquals(0, $setting->default['parent']);
81 81
 
82 82
 		$exception = null;
83 83
 		try {
84
-			$bad_setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'foo_bar_baz' );
85
-			unset( $bad_setting );
86
-		} catch ( Exception $e ) {
84
+			$bad_setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, 'foo_bar_baz');
85
+			unset($bad_setting);
86
+		} catch (Exception $e) {
87 87
 			$exception = $e;
88 88
 		}
89
-		$this->assertInstanceOf( 'Exception', $exception );
89
+		$this->assertInstanceOf('Exception', $exception);
90 90
 	}
91 91
 
92 92
 	/**
93 93
 	 * Test empty constructor.
94 94
 	 */
95 95
 	function test_construct_empty_menus() {
96
-		do_action( 'customize_register', $this->wp_customize );
96
+		do_action('customize_register', $this->wp_customize);
97 97
 		$_wp_customize = $this->wp_customize;
98
-		unset( $_wp_customize->nav_menus );
98
+		unset($_wp_customize->nav_menus);
99 99
 
100 100
 		$exception = null;
101 101
 		try {
102
-			$bad_setting = new WP_Customize_Nav_Menu_Setting( $_wp_customize, 'nav_menu_item[123]' );
103
-			unset( $bad_setting );
104
-		} catch ( Exception $e ) {
102
+			$bad_setting = new WP_Customize_Nav_Menu_Setting($_wp_customize, 'nav_menu_item[123]');
103
+			unset($bad_setting);
104
+		} catch (Exception $e) {
105 105
 			$exception = $e;
106 106
 		}
107
-		$this->assertInstanceOf( 'Exception', $exception );
107
+		$this->assertInstanceOf('Exception', $exception);
108 108
 	}
109 109
 
110 110
 	/**
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 	 * @see WP_Customize_Nav_Menu_Setting::__construct()
114 114
 	 */
115 115
 	function test_construct_placeholder() {
116
-		do_action( 'customize_register', $this->wp_customize );
116
+		do_action('customize_register', $this->wp_customize);
117 117
 		$default = array(
118 118
 			'name' => 'Lorem',
119 119
 			'description' => 'ipsum',
120 120
 			'parent' => 123,
121 121
 		);
122
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[-5]', compact( 'default' ) );
122
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, 'nav_menu[-5]', compact('default'));
123 123
 		$this->assertEquals( -5, $setting->term_id );
124
-		$this->assertEquals( $default, $setting->default );
124
+		$this->assertEquals($default, $setting->default);
125 125
 	}
126 126
 
127 127
 	/**
@@ -130,33 +130,33 @@  discard block
 block discarded – undo
130 130
 	 * @see WP_Customize_Nav_Menu_Setting::value()
131 131
 	 */
132 132
 	function test_value() {
133
-		do_action( 'customize_register', $this->wp_customize );
133
+		do_action('customize_register', $this->wp_customize);
134 134
 
135 135
 		$menu_name = 'Test 123';
136
-		$parent_menu_id = wp_create_nav_menu( "Parent $menu_name" );
136
+		$parent_menu_id = wp_create_nav_menu("Parent $menu_name");
137 137
 		$description = 'Hello my world.';
138
-		$menu_id = wp_update_nav_menu_object( 0, array(
138
+		$menu_id = wp_update_nav_menu_object(0, array(
139 139
 			'menu-name' => $menu_name,
140 140
 			'parent' => $parent_menu_id,
141 141
 			'description' => $description,
142
-		) );
142
+		));
143 143
 
144 144
 		$setting_id = "nav_menu[$menu_id]";
145
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
145
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
146 146
 
147 147
 		$value = $setting->value();
148
-		$this->assertInternalType( 'array', $value );
149
-		foreach ( array( 'name', 'description', 'parent' ) as $key ) {
150
-			$this->assertArrayHasKey( $key, $value );
148
+		$this->assertInternalType('array', $value);
149
+		foreach (array('name', 'description', 'parent') as $key) {
150
+			$this->assertArrayHasKey($key, $value);
151 151
 		}
152
-		$this->assertEquals( $menu_name, $value['name'] );
153
-		$this->assertEquals( $description, $value['description'] );
154
-		$this->assertEquals( $parent_menu_id, $value['parent'] );
152
+		$this->assertEquals($menu_name, $value['name']);
153
+		$this->assertEquals($description, $value['description']);
154
+		$this->assertEquals($parent_menu_id, $value['parent']);
155 155
 
156 156
 		$new_menu_name = 'Foo';
157
-		wp_update_nav_menu_object( $menu_id, array( 'menu-name' => $new_menu_name ) );
157
+		wp_update_nav_menu_object($menu_id, array('menu-name' => $new_menu_name));
158 158
 		$updated_value = $setting->value();
159
-		$this->assertEquals( $new_menu_name, $updated_value['name'] );
159
+		$this->assertEquals($new_menu_name, $updated_value['name']);
160 160
 	}
161 161
 
162 162
 	/**
@@ -165,18 +165,18 @@  discard block
 block discarded – undo
165 165
 	 * @see WP_Customize_Nav_Menu_Setting::preview()
166 166
 	 */
167 167
 	function test_preview_updated() {
168
-		do_action( 'customize_register', $this->wp_customize );
168
+		do_action('customize_register', $this->wp_customize);
169 169
 
170
-		$menu_id = wp_update_nav_menu_object( 0, array(
170
+		$menu_id = wp_update_nav_menu_object(0, array(
171 171
 			'menu-name' => 'Name 1',
172 172
 			'description' => 'Description 1',
173 173
 			'parent' => 0,
174
-		) );
174
+		));
175 175
 		$setting_id = "nav_menu[$menu_id]";
176
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
176
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
177 177
 
178 178
 		$nav_menu_options = $this->get_nav_menu_items_option();
179
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
179
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
180 180
 
181 181
 		$post_value = array(
182 182
 			'name' => 'Name 2',
@@ -184,41 +184,41 @@  discard block
 block discarded – undo
184 184
 			'parent' => 1,
185 185
 			'auto_add' => true,
186 186
 		);
187
-		$this->wp_customize->set_post_value( $setting_id, $post_value );
187
+		$this->wp_customize->set_post_value($setting_id, $post_value);
188 188
 
189 189
 		$value = $setting->value();
190
-		$this->assertEquals( 'Name 1', $value['name'] );
191
-		$this->assertEquals( 'Description 1', $value['description'] );
192
-		$this->assertEquals( 0, $value['parent'] );
190
+		$this->assertEquals('Name 1', $value['name']);
191
+		$this->assertEquals('Description 1', $value['description']);
192
+		$this->assertEquals(0, $value['parent']);
193 193
 
194
-		$term = (array) wp_get_nav_menu_object( $menu_id );
194
+		$term = (array) wp_get_nav_menu_object($menu_id);
195 195
 
196 196
 		$this->assertEqualSets(
197
-			wp_array_slice_assoc( $value, array( 'name', 'description', 'parent' ) ),
198
-			wp_array_slice_assoc( $term, array( 'name', 'description', 'parent' ) )
197
+			wp_array_slice_assoc($value, array('name', 'description', 'parent')),
198
+			wp_array_slice_assoc($term, array('name', 'description', 'parent'))
199 199
 		);
200 200
 
201 201
 		$setting->preview();
202 202
 		$value = $setting->value();
203
-		$this->assertEquals( 'Name 2', $value['name'] );
204
-		$this->assertEquals( 'Description 2', $value['description'] );
205
-		$this->assertEquals( 1, $value['parent'] );
206
-		$term = (array) wp_get_nav_menu_object( $menu_id );
207
-		$this->assertEqualSets( $value, wp_array_slice_assoc( $term, array_keys( $value ) ) );
203
+		$this->assertEquals('Name 2', $value['name']);
204
+		$this->assertEquals('Description 2', $value['description']);
205
+		$this->assertEquals(1, $value['parent']);
206
+		$term = (array) wp_get_nav_menu_object($menu_id);
207
+		$this->assertEqualSets($value, wp_array_slice_assoc($term, array_keys($value)));
208 208
 
209
-		$menu_object = wp_get_nav_menu_object( $menu_id );
210
-		$this->assertEquals( (object) $term, $menu_object );
211
-		$this->assertEquals( $post_value['name'], $menu_object->name );
209
+		$menu_object = wp_get_nav_menu_object($menu_id);
210
+		$this->assertEquals((object) $term, $menu_object);
211
+		$this->assertEquals($post_value['name'], $menu_object->name);
212 212
 
213
-		$nav_menu_options = get_option( 'nav_menu_options', array( 'auto_add' => array() ) );
214
-		$this->assertContains( $menu_id, $nav_menu_options['auto_add'] );
213
+		$nav_menu_options = get_option('nav_menu_options', array('auto_add' => array()));
214
+		$this->assertContains($menu_id, $nav_menu_options['auto_add']);
215 215
 
216 216
 		$menus = wp_get_nav_menus();
217
-		$menus_ids = wp_list_pluck( $menus, 'term_id' );
218
-		$i = array_search( $menu_id, $menus_ids );
219
-		$this->assertInternalType( 'int', $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' );
220
-		$filtered_menu = $menus[ $i ];
221
-		$this->assertEquals( 'Name 2', $filtered_menu->name );
217
+		$menus_ids = wp_list_pluck($menus, 'term_id');
218
+		$i = array_search($menu_id, $menus_ids);
219
+		$this->assertInternalType('int', $i, 'Update-previewed menu does not appear in wp_get_nav_menus()');
220
+		$filtered_menu = $menus[$i];
221
+		$this->assertEquals('Name 2', $filtered_menu->name);
222 222
 	}
223 223
 
224 224
 	/**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @see WP_Customize_Nav_Menu_Setting::preview()
228 228
 	 */
229 229
 	function test_preview_inserted() {
230
-		do_action( 'customize_register', $this->wp_customize );
230
+		do_action('customize_register', $this->wp_customize);
231 231
 
232 232
 		$menu_id = -123;
233 233
 		$post_value = array(
@@ -237,33 +237,33 @@  discard block
 block discarded – undo
237 237
 			'auto_add' => false,
238 238
 		);
239 239
 		$setting_id = "nav_menu[$menu_id]";
240
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
240
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
241 241
 
242
-		$this->wp_customize->set_post_value( $setting->id, $post_value );
242
+		$this->wp_customize->set_post_value($setting->id, $post_value);
243 243
 		$setting->preview();
244 244
 		$value = $setting->value();
245
-		$this->assertEquals( $post_value, $value );
245
+		$this->assertEquals($post_value, $value);
246 246
 
247
-		$term = (array) wp_get_nav_menu_object( $menu_id );
248
-		$this->assertNotEmpty( $term );
249
-		$this->assertNotInstanceOf( 'WP_Error', $term );
250
-		$this->assertEqualSets( $post_value, wp_array_slice_assoc( $term, array_keys( $value ) ) );
251
-		$this->assertEquals( $menu_id, $term['term_id'] );
252
-		$this->assertEquals( $menu_id, $term['term_taxonomy_id'] );
247
+		$term = (array) wp_get_nav_menu_object($menu_id);
248
+		$this->assertNotEmpty($term);
249
+		$this->assertNotInstanceOf('WP_Error', $term);
250
+		$this->assertEqualSets($post_value, wp_array_slice_assoc($term, array_keys($value)));
251
+		$this->assertEquals($menu_id, $term['term_id']);
252
+		$this->assertEquals($menu_id, $term['term_taxonomy_id']);
253 253
 
254
-		$menu_object = wp_get_nav_menu_object( $menu_id );
255
-		$this->assertEquals( (object) $term, $menu_object );
256
-		$this->assertEquals( $post_value['name'], $menu_object->name );
254
+		$menu_object = wp_get_nav_menu_object($menu_id);
255
+		$this->assertEquals((object) $term, $menu_object);
256
+		$this->assertEquals($post_value['name'], $menu_object->name);
257 257
 
258 258
 		$nav_menu_options = $this->get_nav_menu_items_option();
259
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
259
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
260 260
 
261 261
 		$menus = wp_get_nav_menus();
262
-		$menus_ids = wp_list_pluck( $menus, 'term_id' );
263
-		$i = array_search( $menu_id, $menus_ids );
264
-		$this->assertInternalType( 'int', $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' );
265
-		$filtered_menu = $menus[ $i ];
266
-		$this->assertEquals( 'New Menu Name 1', $filtered_menu->name );
262
+		$menus_ids = wp_list_pluck($menus, 'term_id');
263
+		$i = array_search($menu_id, $menus_ids);
264
+		$this->assertInternalType('int', $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()');
265
+		$filtered_menu = $menus[$i];
266
+		$this->assertEquals('New Menu Name 1', $filtered_menu->name);
267 267
 	}
268 268
 
269 269
 	/**
@@ -272,32 +272,32 @@  discard block
 block discarded – undo
272 272
 	 * @see WP_Customize_Nav_Menu_Setting::preview()
273 273
 	 */
274 274
 	function test_preview_deleted() {
275
-		do_action( 'customize_register', $this->wp_customize );
275
+		do_action('customize_register', $this->wp_customize);
276 276
 
277
-		$menu_id = wp_update_nav_menu_object( 0, array(
277
+		$menu_id = wp_update_nav_menu_object(0, array(
278 278
 			'menu-name' => 'Name 1',
279 279
 			'description' => 'Description 1',
280 280
 			'parent' => 0,
281
-		) );
281
+		));
282 282
 		$setting_id = "nav_menu[$menu_id]";
283
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
283
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
284 284
 		$nav_menu_options = $this->get_nav_menu_items_option();
285 285
 		$nav_menu_options['auto_add'][] = $menu_id;
286
-		update_option( 'nav_menu_options', $nav_menu_options );
286
+		update_option('nav_menu_options', $nav_menu_options);
287 287
 
288 288
 		$nav_menu_options = $this->get_nav_menu_items_option();
289
-		$this->assertContains( $menu_id, $nav_menu_options['auto_add'] );
289
+		$this->assertContains($menu_id, $nav_menu_options['auto_add']);
290 290
 
291
-		$this->wp_customize->set_post_value( $setting_id, false );
291
+		$this->wp_customize->set_post_value($setting_id, false);
292 292
 
293
-		$this->assertInternalType( 'array', $setting->value() );
294
-		$this->assertInternalType( 'object', wp_get_nav_menu_object( $menu_id ) );
293
+		$this->assertInternalType('array', $setting->value());
294
+		$this->assertInternalType('object', wp_get_nav_menu_object($menu_id));
295 295
 		$setting->preview();
296
-		$this->assertFalse( $setting->value() );
297
-		$this->assertFalse( wp_get_nav_menu_object( $menu_id ) );
296
+		$this->assertFalse($setting->value());
297
+		$this->assertFalse(wp_get_nav_menu_object($menu_id));
298 298
 
299 299
 		$nav_menu_options = $this->get_nav_menu_items_option();
300
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
300
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
301 301
 	}
302 302
 
303 303
 	/**
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 	 * @see WP_Customize_Nav_Menu_Setting::sanitize()
307 307
 	 */
308 308
 	function test_sanitize() {
309
-		do_action( 'customize_register', $this->wp_customize );
310
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[123]' );
309
+		do_action('customize_register', $this->wp_customize);
310
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, 'nav_menu[123]');
311 311
 
312
-		$this->assertNull( $setting->sanitize( 'not an array' ) );
313
-		$this->assertNull( $setting->sanitize( 123 ) );
312
+		$this->assertNull($setting->sanitize('not an array'));
313
+		$this->assertNull($setting->sanitize(123));
314 314
 
315 315
 		$value = array(
316 316
 			'name' => ' Hello <b>world</b> ',
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
 			'auto_add' => true,
320 320
 			'extra' => 'ignored',
321 321
 		);
322
-		$sanitized = $setting->sanitize( $value );
323
-		$this->assertEquals( 'Hello &lt;b&gt;world&lt;/b&gt;', $sanitized['name'] );
324
-		$this->assertEquals( 'New line', $sanitized['description'] );
325
-		$this->assertEquals( 0, $sanitized['parent'] );
326
-		$this->assertEquals( true, $sanitized['auto_add'] );
327
-		$this->assertEqualSets( array( 'name', 'description', 'parent', 'auto_add' ), array_keys( $sanitized ) );
322
+		$sanitized = $setting->sanitize($value);
323
+		$this->assertEquals('Hello &lt;b&gt;world&lt;/b&gt;', $sanitized['name']);
324
+		$this->assertEquals('New line', $sanitized['description']);
325
+		$this->assertEquals(0, $sanitized['parent']);
326
+		$this->assertEquals(true, $sanitized['auto_add']);
327
+		$this->assertEqualSets(array('name', 'description', 'parent', 'auto_add'), array_keys($sanitized));
328 328
 
329 329
 		$value['name'] = '    '; // Blank spaces.
330
-		$sanitized = $setting->sanitize( $value );
331
-		$this->assertEquals( '(unnamed)', $sanitized['name'] );
330
+		$sanitized = $setting->sanitize($value);
331
+		$this->assertEquals('(unnamed)', $sanitized['name']);
332 332
 	}
333 333
 
334 334
 	/**
@@ -337,19 +337,19 @@  discard block
 block discarded – undo
337 337
 	 * @see WP_Customize_Nav_Menu_Setting::update()
338 338
 	 */
339 339
 	function test_save_updated() {
340
-		do_action( 'customize_register', $this->wp_customize );
340
+		do_action('customize_register', $this->wp_customize);
341 341
 
342
-		$menu_id = wp_update_nav_menu_object( 0, array(
342
+		$menu_id = wp_update_nav_menu_object(0, array(
343 343
 			'menu-name' => 'Name 1',
344 344
 			'description' => 'Description 1',
345 345
 			'parent' => 0,
346
-		) );
346
+		));
347 347
 		$nav_menu_options = $this->get_nav_menu_items_option();
348 348
 		$nav_menu_options['auto_add'][] = $menu_id;
349
-		update_option( 'nav_menu_options', $nav_menu_options );
349
+		update_option('nav_menu_options', $nav_menu_options);
350 350
 
351 351
 		$setting_id = "nav_menu[$menu_id]";
352
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
352
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
353 353
 
354 354
 		$auto_add = false;
355 355
 		$new_value = array(
@@ -359,36 +359,36 @@  discard block
 block discarded – undo
359 359
 			'auto_add' => $auto_add,
360 360
 		);
361 361
 
362
-		$this->wp_customize->set_post_value( $setting_id, $new_value );
362
+		$this->wp_customize->set_post_value($setting_id, $new_value);
363 363
 		$setting->save();
364 364
 
365
-		$menu_object = wp_get_nav_menu_object( $menu_id );
366
-		foreach ( array( 'name', 'description', 'parent' ) as $key ) {
367
-			$this->assertEquals( $new_value[ $key ], $menu_object->$key );
365
+		$menu_object = wp_get_nav_menu_object($menu_id);
366
+		foreach (array('name', 'description', 'parent') as $key) {
367
+			$this->assertEquals($new_value[$key], $menu_object->$key);
368 368
 		}
369 369
 		$this->assertEqualSets(
370
-			wp_array_slice_assoc( $new_value, array( 'name', 'description', 'parent' ) ),
371
-			wp_array_slice_assoc( (array) $menu_object, array( 'name', 'description', 'parent' ) )
370
+			wp_array_slice_assoc($new_value, array('name', 'description', 'parent')),
371
+			wp_array_slice_assoc((array) $menu_object, array('name', 'description', 'parent'))
372 372
 		);
373
-		$this->assertEquals( $new_value, $setting->value() );
374
-
375
-		$save_response = apply_filters( 'customize_save_response', array() );
376
-		$this->assertArrayHasKey( 'nav_menu_updates', $save_response );
377
-		$update_result = array_shift( $save_response['nav_menu_updates'] );
378
-		$this->assertArrayHasKey( 'term_id', $update_result );
379
-		$this->assertArrayHasKey( 'previous_term_id', $update_result );
380
-		$this->assertArrayHasKey( 'error', $update_result );
381
-		$this->assertArrayHasKey( 'status', $update_result );
382
-		$this->assertArrayHasKey( 'saved_value', $update_result );
383
-		$this->assertEquals( $new_value, $update_result['saved_value'] );
384
-
385
-		$this->assertEquals( $menu_id, $update_result['term_id'] );
386
-		$this->assertNull( $update_result['previous_term_id'] );
387
-		$this->assertNull( $update_result['error'] );
388
-		$this->assertEquals( 'updated', $update_result['status'] );
373
+		$this->assertEquals($new_value, $setting->value());
374
+
375
+		$save_response = apply_filters('customize_save_response', array());
376
+		$this->assertArrayHasKey('nav_menu_updates', $save_response);
377
+		$update_result = array_shift($save_response['nav_menu_updates']);
378
+		$this->assertArrayHasKey('term_id', $update_result);
379
+		$this->assertArrayHasKey('previous_term_id', $update_result);
380
+		$this->assertArrayHasKey('error', $update_result);
381
+		$this->assertArrayHasKey('status', $update_result);
382
+		$this->assertArrayHasKey('saved_value', $update_result);
383
+		$this->assertEquals($new_value, $update_result['saved_value']);
384
+
385
+		$this->assertEquals($menu_id, $update_result['term_id']);
386
+		$this->assertNull($update_result['previous_term_id']);
387
+		$this->assertNull($update_result['error']);
388
+		$this->assertEquals('updated', $update_result['status']);
389 389
 
390 390
 		$nav_menu_options = $this->get_nav_menu_items_option();
391
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
391
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
392 392
 	}
393 393
 
394 394
 	/**
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 	 * @see WP_Customize_Nav_Menu_Setting::update()
398 398
 	 */
399 399
 	function test_save_inserted() {
400
-		do_action( 'customize_register', $this->wp_customize );
400
+		do_action('customize_register', $this->wp_customize);
401 401
 
402 402
 		$menu_id = -123;
403 403
 		$post_value = array(
@@ -407,37 +407,37 @@  discard block
 block discarded – undo
407 407
 			'auto_add' => true,
408 408
 		);
409 409
 		$setting_id = "nav_menu[$menu_id]";
410
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
410
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
411 411
 
412
-		$this->wp_customize->set_post_value( $setting->id, $post_value );
412
+		$this->wp_customize->set_post_value($setting->id, $post_value);
413 413
 
414
-		$this->assertNull( $setting->previous_term_id );
415
-		$this->assertLessThan( 0, $setting->term_id );
414
+		$this->assertNull($setting->previous_term_id);
415
+		$this->assertLessThan(0, $setting->term_id);
416 416
 		$setting->save();
417
-		$this->assertEquals( $menu_id, $setting->previous_term_id );
418
-		$this->assertGreaterThan( 0, $setting->term_id );
417
+		$this->assertEquals($menu_id, $setting->previous_term_id);
418
+		$this->assertGreaterThan(0, $setting->term_id);
419 419
 
420 420
 		$nav_menu_options = $this->get_nav_menu_items_option();
421
-		$this->assertContains( $setting->term_id, $nav_menu_options['auto_add'] );
422
-
423
-		$menu = wp_get_nav_menu_object( $setting->term_id );
424
-		unset( $post_value['auto_add'] );
425
-		$this->assertEqualSets( $post_value, wp_array_slice_assoc( (array) $menu, array_keys( $post_value ) ) );
426
-
427
-		$save_response = apply_filters( 'customize_save_response', array() );
428
-		$this->assertArrayHasKey( 'nav_menu_updates', $save_response );
429
-		$update_result = array_shift( $save_response['nav_menu_updates'] );
430
-		$this->assertArrayHasKey( 'term_id', $update_result );
431
-		$this->assertArrayHasKey( 'previous_term_id', $update_result );
432
-		$this->assertArrayHasKey( 'error', $update_result );
433
-		$this->assertArrayHasKey( 'status', $update_result );
434
-		$this->assertArrayHasKey( 'saved_value', $update_result );
435
-		$this->assertEquals( $setting->value(), $update_result['saved_value'] );
436
-
437
-		$this->assertEquals( $menu->term_id, $update_result['term_id'] );
438
-		$this->assertEquals( $menu_id, $update_result['previous_term_id'] );
439
-		$this->assertNull( $update_result['error'] );
440
-		$this->assertEquals( 'inserted', $update_result['status'] );
421
+		$this->assertContains($setting->term_id, $nav_menu_options['auto_add']);
422
+
423
+		$menu = wp_get_nav_menu_object($setting->term_id);
424
+		unset($post_value['auto_add']);
425
+		$this->assertEqualSets($post_value, wp_array_slice_assoc((array) $menu, array_keys($post_value)));
426
+
427
+		$save_response = apply_filters('customize_save_response', array());
428
+		$this->assertArrayHasKey('nav_menu_updates', $save_response);
429
+		$update_result = array_shift($save_response['nav_menu_updates']);
430
+		$this->assertArrayHasKey('term_id', $update_result);
431
+		$this->assertArrayHasKey('previous_term_id', $update_result);
432
+		$this->assertArrayHasKey('error', $update_result);
433
+		$this->assertArrayHasKey('status', $update_result);
434
+		$this->assertArrayHasKey('saved_value', $update_result);
435
+		$this->assertEquals($setting->value(), $update_result['saved_value']);
436
+
437
+		$this->assertEquals($menu->term_id, $update_result['term_id']);
438
+		$this->assertEquals($menu_id, $update_result['previous_term_id']);
439
+		$this->assertNull($update_result['error']);
440
+		$this->assertEquals('inserted', $update_result['status']);
441 441
 	}
442 442
 
443 443
 	/**
@@ -446,23 +446,23 @@  discard block
 block discarded – undo
446 446
 	 * @see WP_Customize_Nav_Menu_Setting::update()
447 447
 	 */
448 448
 	function test_save_inserted_conflicted_name() {
449
-		do_action( 'customize_register', $this->wp_customize );
449
+		do_action('customize_register', $this->wp_customize);
450 450
 
451 451
 		$menu_name = 'Foo';
452
-		wp_update_nav_menu_object( 0, array( 'menu-name' => $menu_name ) );
452
+		wp_update_nav_menu_object(0, array('menu-name' => $menu_name));
453 453
 
454 454
 		$menu_id = -123;
455 455
 		$setting_id = "nav_menu[$menu_id]";
456
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
457
-		$this->wp_customize->set_post_value( $setting->id, array( 'name' => $menu_name ) );
456
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
457
+		$this->wp_customize->set_post_value($setting->id, array('name' => $menu_name));
458 458
 		$setting->save();
459 459
 
460 460
 		$expected_resolved_menu_name = "$menu_name (2)";
461
-		$new_menu = wp_get_nav_menu_object( $setting->term_id );
462
-		$this->assertEquals( $expected_resolved_menu_name, $new_menu->name );
461
+		$new_menu = wp_get_nav_menu_object($setting->term_id);
462
+		$this->assertEquals($expected_resolved_menu_name, $new_menu->name);
463 463
 
464
-		$save_response = apply_filters( 'customize_save_response', array() );
465
-		$this->assertEquals( $expected_resolved_menu_name, $save_response['nav_menu_updates'][0]['saved_value']['name'] );
464
+		$save_response = apply_filters('customize_save_response', array());
465
+		$this->assertEquals($expected_resolved_menu_name, $save_response['nav_menu_updates'][0]['saved_value']['name']);
466 466
 	}
467 467
 
468 468
 	/**
@@ -471,41 +471,41 @@  discard block
 block discarded – undo
471 471
 	 * @see WP_Customize_Nav_Menu_Setting::update()
472 472
 	 */
473 473
 	function test_save_deleted() {
474
-		do_action( 'customize_register', $this->wp_customize );
474
+		do_action('customize_register', $this->wp_customize);
475 475
 
476 476
 		$menu_name = 'Lorem Ipsum';
477
-		$menu_id = wp_create_nav_menu( $menu_name );
477
+		$menu_id = wp_create_nav_menu($menu_name);
478 478
 		$setting_id = "nav_menu[$menu_id]";
479
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
479
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
480 480
 		$nav_menu_options = $this->get_nav_menu_items_option();
481 481
 		$nav_menu_options['auto_add'][] = $menu_id;
482
-		update_option( 'nav_menu_options', $nav_menu_options );
482
+		update_option('nav_menu_options', $nav_menu_options);
483 483
 
484
-		$menu = wp_get_nav_menu_object( $menu_id );
485
-		$this->assertEquals( $menu_name, $menu->name );
484
+		$menu = wp_get_nav_menu_object($menu_id);
485
+		$this->assertEquals($menu_name, $menu->name);
486 486
 
487
-		$this->wp_customize->set_post_value( $setting_id, false );
487
+		$this->wp_customize->set_post_value($setting_id, false);
488 488
 		$setting->save();
489 489
 
490
-		$this->assertFalse( wp_get_nav_menu_object( $menu_id ) );
490
+		$this->assertFalse(wp_get_nav_menu_object($menu_id));
491 491
 
492
-		$save_response = apply_filters( 'customize_save_response', array() );
493
-		$this->assertArrayHasKey( 'nav_menu_updates', $save_response );
494
-		$update_result = array_shift( $save_response['nav_menu_updates'] );
495
-		$this->assertArrayHasKey( 'term_id', $update_result );
496
-		$this->assertArrayHasKey( 'previous_term_id', $update_result );
497
-		$this->assertArrayHasKey( 'error', $update_result );
498
-		$this->assertArrayHasKey( 'status', $update_result );
499
-		$this->assertArrayHasKey( 'saved_value', $update_result );
500
-		$this->assertNull( $update_result['saved_value'] );
492
+		$save_response = apply_filters('customize_save_response', array());
493
+		$this->assertArrayHasKey('nav_menu_updates', $save_response);
494
+		$update_result = array_shift($save_response['nav_menu_updates']);
495
+		$this->assertArrayHasKey('term_id', $update_result);
496
+		$this->assertArrayHasKey('previous_term_id', $update_result);
497
+		$this->assertArrayHasKey('error', $update_result);
498
+		$this->assertArrayHasKey('status', $update_result);
499
+		$this->assertArrayHasKey('saved_value', $update_result);
500
+		$this->assertNull($update_result['saved_value']);
501 501
 
502
-		$this->assertEquals( $menu_id, $update_result['term_id'] );
503
-		$this->assertNull( $update_result['previous_term_id'] );
504
-		$this->assertNull( $update_result['error'] );
505
-		$this->assertEquals( 'deleted', $update_result['status'] );
502
+		$this->assertEquals($menu_id, $update_result['term_id']);
503
+		$this->assertNull($update_result['previous_term_id']);
504
+		$this->assertNull($update_result['error']);
505
+		$this->assertEquals('deleted', $update_result['status']);
506 506
 
507 507
 		$nav_menu_options = $this->get_nav_menu_items_option();
508
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
508
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
509 509
 	}
510 510
 
511 511
 }
Please login to merge, or discard this patch.
tests/core/widgets.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -14,54 +14,54 @@  discard block
 block discarded – undo
14 14
 
15 15
 	function setUp() {
16 16
 		parent::setUp();
17
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
17
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
18 18
 		//require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
19 19
 		$GLOBALS['wp_customize'] = new WP_Customize_Manager();
20 20
 		$this->manager = $GLOBALS['wp_customize'];
21 21
 
22
-		unset( $GLOBALS['_wp_sidebars_widgets'] ); // clear out cache set by wp_get_sidebars_widgets()
22
+		unset($GLOBALS['_wp_sidebars_widgets']); // clear out cache set by wp_get_sidebars_widgets()
23 23
 		$sidebars_widgets = wp_get_sidebars_widgets();
24
-		$this->assertEqualSets( array( 'wp_inactive_widgets', 'sidebar-1' ), array_keys( wp_get_sidebars_widgets() ) );
25
-		$this->assertContains( 'search-2', $sidebars_widgets['sidebar-1'] );
26
-		$this->assertContains( 'categories-2', $sidebars_widgets['sidebar-1'] );
27
-		$this->assertArrayHasKey( 2, get_option( 'widget_search' ) );
28
-		$widget_categories = get_option( 'widget_categories' );
29
-		$this->assertArrayHasKey( 2, $widget_categories );
30
-		$this->assertEquals( '', $widget_categories[2]['title'] );
31
-
32
-		remove_action( 'after_setup_theme', 'twentyfifteen_setup' ); // @todo We should not be including a theme anyway
33
-
34
-		$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
35
-		wp_set_current_user( $user_id );
24
+		$this->assertEqualSets(array('wp_inactive_widgets', 'sidebar-1'), array_keys(wp_get_sidebars_widgets()));
25
+		$this->assertContains('search-2', $sidebars_widgets['sidebar-1']);
26
+		$this->assertContains('categories-2', $sidebars_widgets['sidebar-1']);
27
+		$this->assertArrayHasKey(2, get_option('widget_search'));
28
+		$widget_categories = get_option('widget_categories');
29
+		$this->assertArrayHasKey(2, $widget_categories);
30
+		$this->assertEquals('', $widget_categories[2]['title']);
31
+
32
+		remove_action('after_setup_theme', 'twentyfifteen_setup'); // @todo We should not be including a theme anyway
33
+
34
+		$user_id = $this->factory->user->create(array('role' => 'administrator'));
35
+		wp_set_current_user($user_id);
36 36
 	}
37 37
 
38 38
 	function tearDown() {
39 39
 		$this->manager = null;
40
-		unset( $GLOBALS['wp_customize'] );
41
-		unset( $GLOBALS['wp_scripts'] );
40
+		unset($GLOBALS['wp_customize']);
41
+		unset($GLOBALS['wp_scripts']);
42 42
 		parent::tearDown();
43 43
 	}
44 44
 
45
-	function set_customized_post_data( $customized ) {
46
-		$_POST['customized'] = wp_slash( wp_json_encode( $customized ) );
45
+	function set_customized_post_data($customized) {
46
+		$_POST['customized'] = wp_slash(wp_json_encode($customized));
47 47
 	}
48 48
 
49 49
 	function do_customize_boot_actions() {
50 50
 		$_SERVER['REQUEST_METHOD'] = 'POST';
51
-		do_action( 'setup_theme' );
52
-		$_REQUEST['nonce'] = wp_create_nonce( 'preview-customize_' . $this->manager->theme()->get_stylesheet() );
53
-		do_action( 'after_setup_theme' );
54
-		do_action( 'init' );
55
-		do_action( 'wp_loaded' );
56
-		do_action( 'wp', $GLOBALS['wp'] );
51
+		do_action('setup_theme');
52
+		$_REQUEST['nonce'] = wp_create_nonce('preview-customize_'.$this->manager->theme()->get_stylesheet());
53
+		do_action('after_setup_theme');
54
+		do_action('init');
55
+		do_action('wp_loaded');
56
+		do_action('wp', $GLOBALS['wp']);
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * Test WP_Customize_Widgets::__construct()
61 61
 	 */
62 62
 	function test_construct() {
63
-		$this->assertInstanceOf( 'WP_Customize_Widgets', $this->manager->widgets );
64
-		$this->assertEquals( $this->manager, $this->manager->widgets->manager );
63
+		$this->assertInstanceOf('WP_Customize_Widgets', $this->manager->widgets);
64
+		$this->assertEquals($this->manager, $this->manager->widgets->manager);
65 65
 	}
66 66
 
67 67
 	/**
@@ -83,20 +83,20 @@  discard block
 block discarded – undo
83 83
 			),
84 84
 		);
85 85
 		$customized = array();
86
-		foreach ( $raw_widget_customized as $setting_id => $instance ) {
87
-			$customized[ $setting_id ] = $this->manager->widgets->sanitize_widget_js_instance( $instance );
86
+		foreach ($raw_widget_customized as $setting_id => $instance) {
87
+			$customized[$setting_id] = $this->manager->widgets->sanitize_widget_js_instance($instance);
88 88
 		}
89 89
 
90
-		$this->set_customized_post_data( $customized );
90
+		$this->set_customized_post_data($customized);
91 91
 		$this->do_customize_boot_actions();
92
-		$this->assertTrue( is_customize_preview() );
92
+		$this->assertTrue(is_customize_preview());
93 93
 
94
-		$this->assertNotEmpty( $this->manager->get_setting( 'widget_categories[2]' ), 'Expected setting for pre-existing widget category-2, being customized.' );
95
-		$this->assertNotEmpty( $this->manager->get_setting( 'widget_search[2]' ), 'Expected setting for pre-existing widget search-2, not being customized.' );
96
-		$this->assertNotEmpty( $this->manager->get_setting( 'widget_search[3]' ), 'Expected dynamic setting for non-existing widget search-3, being customized.' );
94
+		$this->assertNotEmpty($this->manager->get_setting('widget_categories[2]'), 'Expected setting for pre-existing widget category-2, being customized.');
95
+		$this->assertNotEmpty($this->manager->get_setting('widget_search[2]'), 'Expected setting for pre-existing widget search-2, not being customized.');
96
+		$this->assertNotEmpty($this->manager->get_setting('widget_search[3]'), 'Expected dynamic setting for non-existing widget search-3, being customized.');
97 97
 
98
-		$widget_categories = get_option( 'widget_categories' );
99
-		$this->assertEquals( $raw_widget_customized['widget_categories[2]'], $widget_categories[2], 'Expected $wp_customize->get_setting(widget_categories[2])->preview() to have been called.' );
98
+		$widget_categories = get_option('widget_categories');
99
+		$this->assertEquals($raw_widget_customized['widget_categories[2]'], $widget_categories[2], 'Expected $wp_customize->get_setting(widget_categories[2])->preview() to have been called.');
100 100
 	}
101 101
 
102 102
 	/**
@@ -104,68 +104,68 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	function test_get_setting_args() {
106 106
 
107
-		add_filter( 'widget_customizer_setting_args', array( $this, 'filter_widget_customizer_setting_args' ), 10, 2 );
107
+		add_filter('widget_customizer_setting_args', array($this, 'filter_widget_customizer_setting_args'), 10, 2);
108 108
 
109 109
 		$default_args = array(
110 110
 			'type' => 'option',
111 111
 			'capability' => 'edit_theme_options',
112 112
 			'transport' => 'refresh',
113 113
 			'default' => array(),
114
-			'sanitize_callback' => array( $this->manager->widgets, 'sanitize_widget_instance' ),
115
-			'sanitize_js_callback' => array( $this->manager->widgets, 'sanitize_widget_js_instance' ),
114
+			'sanitize_callback' => array($this->manager->widgets, 'sanitize_widget_instance'),
115
+			'sanitize_js_callback' => array($this->manager->widgets, 'sanitize_widget_js_instance'),
116 116
 		);
117 117
 
118
-		$args = $this->manager->widgets->get_setting_args( 'widget_foo[2]' );
119
-		foreach ( $default_args as $key => $default_value ) {
120
-			$this->assertEquals( $default_value, $args[ $key ] );
118
+		$args = $this->manager->widgets->get_setting_args('widget_foo[2]');
119
+		foreach ($default_args as $key => $default_value) {
120
+			$this->assertEquals($default_value, $args[$key]);
121 121
 		}
122
-		$this->assertEquals( 'WIDGET_FOO[2]', $args['uppercase_id_set_by_filter'] );
122
+		$this->assertEquals('WIDGET_FOO[2]', $args['uppercase_id_set_by_filter']);
123 123
 
124 124
 		$override_args = array(
125 125
 			'type' => 'theme_mod',
126 126
 			'capability' => 'edit_posts',
127 127
 			'transport' => 'postMessage',
128
-			'default' => array( 'title' => 'asd' ),
128
+			'default' => array('title' => 'asd'),
129 129
 			'sanitize_callback' => '__return_empty_array',
130 130
 			'sanitize_js_callback' => '__return_empty_array',
131 131
 		);
132
-		$args = $this->manager->widgets->get_setting_args( 'widget_bar[3]', $override_args );
133
-		foreach ( $override_args as $key => $override_value ) {
134
-			$this->assertEquals( $override_value, $args[ $key ] );
132
+		$args = $this->manager->widgets->get_setting_args('widget_bar[3]', $override_args);
133
+		foreach ($override_args as $key => $override_value) {
134
+			$this->assertEquals($override_value, $args[$key]);
135 135
 		}
136
-		$this->assertEquals( 'WIDGET_BAR[3]', $args['uppercase_id_set_by_filter'] );
136
+		$this->assertEquals('WIDGET_BAR[3]', $args['uppercase_id_set_by_filter']);
137 137
 
138 138
 		$default_args = array(
139 139
 			'type' => 'option',
140 140
 			'capability' => 'edit_theme_options',
141 141
 			'transport' => 'refresh',
142 142
 			'default' => array(),
143
-			'sanitize_callback' => array( $this->manager->widgets, 'sanitize_sidebar_widgets' ),
144
-			'sanitize_js_callback' => array( $this->manager->widgets, 'sanitize_sidebar_widgets_js_instance' ),
143
+			'sanitize_callback' => array($this->manager->widgets, 'sanitize_sidebar_widgets'),
144
+			'sanitize_js_callback' => array($this->manager->widgets, 'sanitize_sidebar_widgets_js_instance'),
145 145
 		);
146
-		$args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-1]' );
147
-		foreach ( $default_args as $key => $default_value ) {
148
-			$this->assertEquals( $default_value, $args[ $key ] );
146
+		$args = $this->manager->widgets->get_setting_args('sidebars_widgets[sidebar-1]');
147
+		foreach ($default_args as $key => $default_value) {
148
+			$this->assertEquals($default_value, $args[$key]);
149 149
 		}
150
-		$this->assertEquals( 'SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter'] );
150
+		$this->assertEquals('SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter']);
151 151
 
152 152
 		$override_args = array(
153 153
 			'type' => 'theme_mod',
154 154
 			'capability' => 'edit_posts',
155 155
 			'transport' => 'postMessage',
156
-			'default' => array( 'title' => 'asd' ),
156
+			'default' => array('title' => 'asd'),
157 157
 			'sanitize_callback' => '__return_empty_array',
158 158
 			'sanitize_js_callback' => '__return_empty_array',
159 159
 		);
160
-		$args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-2]', $override_args );
161
-		foreach ( $override_args as $key => $override_value ) {
162
-			$this->assertEquals( $override_value, $args[ $key ] );
160
+		$args = $this->manager->widgets->get_setting_args('sidebars_widgets[sidebar-2]', $override_args);
161
+		foreach ($override_args as $key => $override_value) {
162
+			$this->assertEquals($override_value, $args[$key]);
163 163
 		}
164
-		$this->assertEquals( 'SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter'] );
164
+		$this->assertEquals('SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter']);
165 165
 	}
166 166
 
167
-	function filter_widget_customizer_setting_args( $args, $id ) {
168
-		$args['uppercase_id_set_by_filter'] = strtoupper( $id );
167
+	function filter_widget_customizer_setting_args($args, $id) {
168
+		$args['uppercase_id_set_by_filter'] = strtoupper($id);
169 169
 		return $args;
170 170
 	}
171 171
 
@@ -182,18 +182,18 @@  discard block
 block discarded – undo
182 182
 			'dropdown' => '1',
183 183
 		);
184 184
 
185
-		$sanitized_for_js = $this->manager->widgets->sanitize_widget_js_instance( $new_categories_instance );
186
-		$this->assertArrayHasKey( 'encoded_serialized_instance', $sanitized_for_js );
187
-		$this->assertTrue( is_serialized( base64_decode( $sanitized_for_js['encoded_serialized_instance'] ), true ) );
188
-		$this->assertEquals( $new_categories_instance['title'], $sanitized_for_js['title'] );
189
-		$this->assertTrue( $sanitized_for_js['is_widget_customizer_js_value'] );
190
-		$this->assertArrayHasKey( 'instance_hash_key', $sanitized_for_js );
185
+		$sanitized_for_js = $this->manager->widgets->sanitize_widget_js_instance($new_categories_instance);
186
+		$this->assertArrayHasKey('encoded_serialized_instance', $sanitized_for_js);
187
+		$this->assertTrue(is_serialized(base64_decode($sanitized_for_js['encoded_serialized_instance']), true));
188
+		$this->assertEquals($new_categories_instance['title'], $sanitized_for_js['title']);
189
+		$this->assertTrue($sanitized_for_js['is_widget_customizer_js_value']);
190
+		$this->assertArrayHasKey('instance_hash_key', $sanitized_for_js);
191 191
 
192 192
 		$corrupted_sanitized_for_js = $sanitized_for_js;
193
-		$corrupted_sanitized_for_js['encoded_serialized_instance'] = base64_encode( serialize( array( 'title' => 'EVIL' ) ) );
194
-		$this->assertNull( $this->manager->widgets->sanitize_widget_instance( $corrupted_sanitized_for_js ), 'Expected sanitize_widget_instance to reject corrupted data.' );
193
+		$corrupted_sanitized_for_js['encoded_serialized_instance'] = base64_encode(serialize(array('title' => 'EVIL')));
194
+		$this->assertNull($this->manager->widgets->sanitize_widget_instance($corrupted_sanitized_for_js), 'Expected sanitize_widget_instance to reject corrupted data.');
195 195
 
196
-		$unsanitized_from_js = $this->manager->widgets->sanitize_widget_instance( $sanitized_for_js );
197
-		$this->assertEquals( $unsanitized_from_js, $new_categories_instance );
196
+		$unsanitized_from_js = $this->manager->widgets->sanitize_widget_instance($sanitized_for_js);
197
+		$this->assertEquals($unsanitized_from_js, $new_categories_instance);
198 198
 	}
199 199
 }
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,28 +5,28 @@
 block discarded – undo
5 5
  * @package WordPress
6 6
  * @subpackage Fields API
7 7
 */
8
-define( 'WP_TESTS_FORCE_KNOWN_BUGS', true );
8
+define('WP_TESTS_FORCE_KNOWN_BUGS', true);
9 9
 
10 10
 // Support for:
11 11
 // 1. `WP_DEVELOP_DIR` environment variable
12 12
 // 2. Plugin installed inside of WordPress.org developer checkout
13 13
 // 3. Tests checked out to /tmp
14 14
 // 4. VVV tests
15
-if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) {
16
-	$test_root = getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit';
17
-} else if ( file_exists( '../../../../tests/phpunit/includes/bootstrap.php' ) ) {
15
+if (false !== getenv('WP_DEVELOP_DIR')) {
16
+	$test_root = getenv('WP_DEVELOP_DIR').'/tests/phpunit';
17
+} else if (file_exists('../../../../tests/phpunit/includes/bootstrap.php')) {
18 18
 	$test_root = '../../../../tests/phpunit';
19
-} else if ( file_exists( '/tmp/wordpress-tests-lib/includes/bootstrap.php' ) ) {
19
+} else if (file_exists('/tmp/wordpress-tests-lib/includes/bootstrap.php')) {
20 20
 	$test_root = '/tmp/wordpress-tests-lib';
21
-} else if ( file_exists( '/srv/www/wordpress-develop/tests/phpunit/includes/bootstrap.php' ) ) {
21
+} else if (file_exists('/srv/www/wordpress-develop/tests/phpunit/includes/bootstrap.php')) {
22 22
 	$test_root = '/srv/www/wordpress-develop/tests/phpunit';
23 23
 }
24 24
 
25
-require $test_root . '/includes/functions.php';
25
+require $test_root.'/includes/functions.php';
26 26
 
27 27
 function _manually_load_plugin() {
28
-	require dirname( __FILE__ ) . '/../wordpress-fields-api.php';
28
+	require dirname(__FILE__).'/../wordpress-fields-api.php';
29 29
 }
30
-tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
30
+tests_add_filter('muplugins_loaded', '_manually_load_plugin');
31 31
 
32
-require $test_root . '/includes/bootstrap.php';
32
+require $test_root.'/includes/bootstrap.php';
Please login to merge, or discard this patch.
includes/class-wp-fields-api-section.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Fields API Section classes
4
- *
5
- * @package WordPress
6
- * @subpackage Customize
7
- * @since 3.4.0
8
- */
3
+	 * WordPress Fields API Section classes
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Customize
7
+	 * @since 3.4.0
8
+	 */
9 9
 
10 10
 /**
11 11
  * Fields API Section class.
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 		$args = func_get_args();
158 158
 
159
-		call_user_func_array( array( $this, 'init' ), $args );
159
+		call_user_func_array(array($this, 'init'), $args);
160 160
 
161 161
 	}
162 162
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param string $id            A specific ID of the section.
168 168
 	 * @param array  $args          Section arguments.
169 169
 	 */
170
-	public function init( $object_type, $id, $args = array() ) {
170
+	public function init($object_type, $id, $args = array()) {
171 171
 
172 172
 		/**
173 173
 		 * @var $wp_fields WP_Fields_API
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 		$this->object_type = $object_type;
178 178
 
179
-		if ( is_array( $id ) ) {
179
+		if (is_array($id)) {
180 180
 			$args = $id;
181 181
 
182 182
 			$id = '';
@@ -184,19 +184,19 @@  discard block
 block discarded – undo
184 184
 			$this->id = $id;
185 185
 		}
186 186
 
187
-		$keys = array_keys( get_object_vars( $this ) );
187
+		$keys = array_keys(get_object_vars($this));
188 188
 
189
-		foreach ( $keys as $key ) {
190
-			if ( isset( $args[ $key ] ) ) {
191
-				$this->$key = $args[ $key ];
189
+		foreach ($keys as $key) {
190
+			if (isset($args[$key])) {
191
+				$this->$key = $args[$key];
192 192
 			}
193 193
 		}
194 194
 
195 195
 		self::$instance_count += 1;
196 196
 		$this->instance_number = self::$instance_count;
197 197
 
198
-		if ( empty( $this->active_callback ) ) {
199
-			$this->active_callback = array( $this, 'active_callback' );
198
+		if (empty($this->active_callback)) {
199
+			$this->active_callback = array($this, 'active_callback');
200 200
 		}
201 201
 
202 202
 		/*if ( $this->screen ) {
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 		$section = $this;
225 225
 		$active = true;
226 226
 
227
-		if ( is_callable( $this->active_callback ) ) {
228
-			$active = call_user_func( $this->active_callback, $this );
227
+		if (is_callable($this->active_callback)) {
228
+			$active = call_user_func($this->active_callback, $this);
229 229
 		}
230 230
 
231 231
 		/**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		 * @param bool                 $active  Whether the Fields API section is active.
235 235
 		 * @param WP_Fields_API_Section $section {@see WP_Fields_API_Section} instance.
236 236
 		 */
237
-		$active = apply_filters( 'fields_api_section_active_' . $this->object_type, $active, $section );
237
+		$active = apply_filters('fields_api_section_active_'.$this->object_type, $active, $section);
238 238
 
239 239
 		return $active;
240 240
 
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 	 */
265 265
 	public function json() {
266 266
 
267
-		$array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'screen', 'type' ) );
268
-		$array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
267
+		$array = wp_array_slice_assoc((array) $this, array('id', 'description', 'priority', 'screen', 'type'));
268
+		$array['title'] = html_entity_decode($this->title, ENT_QUOTES, get_bloginfo('charset'));
269 269
 		$array['content'] = $this->get_content();
270 270
 		$array['active'] = $this->active();
271 271
 		$array['instanceNumber'] = $this->instance_number;
@@ -282,18 +282,18 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	public function check_capabilities() {
284 284
 
285
-		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
285
+		if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability)) {
286 286
 			return false;
287 287
 		}
288 288
 
289
-		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
289
+		if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports)) {
290 290
 			return false;
291 291
 		}
292 292
 
293 293
 		$access = true;
294 294
 
295
-		if ( is_callable( $this->capabilities_callback ) ) {
296
-			$access = call_user_func( $this->capabilities_callback, $this );
295
+		if (is_callable($this->capabilities_callback)) {
296
+			$access = call_user_func($this->capabilities_callback, $this);
297 297
 		}
298 298
 
299 299
 		return $access;
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 
312 312
 		$this->maybe_render();
313 313
 
314
-		$template = trim( ob_get_contents() );
314
+		$template = trim(ob_get_contents());
315 315
 
316 316
 		ob_end_clean();
317 317
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 */
325 325
 	final public function maybe_render() {
326 326
 
327
-		if ( ! $this->check_capabilities() ) {
327
+		if ( ! $this->check_capabilities()) {
328 328
 			return;
329 329
 		}
330 330
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		 *
337 337
 		 * @param WP_Fields_API_Section $this WP_Fields API_Section instance.
338 338
 		 */
339
-		do_action( "fields_api_render_section_{$this->object_type}", $this );
339
+		do_action("fields_api_render_section_{$this->object_type}", $this);
340 340
 
341 341
 		/**
342 342
 		 * Fires before rendering a specific Fields API section.
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		 * of the specific Fields API section to be rendered.
349 349
 		 *
350 350
 		 */
351
-		do_action( "fields_api_render_section_{$this->object_type}_{$this->object_name}_{$this->id}" );
351
+		do_action("fields_api_render_section_{$this->object_type}_{$this->object_name}_{$this->id}");
352 352
 
353 353
 		$this->render();
354 354
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * // @todo Merge render_template / print_template() from Customizer
361 361
 	 */
362 362
 	protected function render() {
363
-		echo esc_html( $this->title );
363
+		echo esc_html($this->title);
364 364
 	}
365 365
 
366 366
 	/**
Please login to merge, or discard this patch.
includes/class-wp-fields-api-screen.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 		$args = func_get_args();
151 151
 
152
-		call_user_func_array( array( $this, 'init' ), $args );
152
+		call_user_func_array(array($this, 'init'), $args);
153 153
 
154 154
 	}
155 155
 
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 * @param string $id            A specific ID of the screen.
161 161
 	 * @param array  $args          Screen arguments.
162 162
 	 */
163
-	public function init( $object_type, $id, $args = array() ) {
163
+	public function init($object_type, $id, $args = array()) {
164 164
 
165 165
 		$this->object_type = $object_type;
166 166
 
167
-		if ( is_array( $id ) ) {
167
+		if (is_array($id)) {
168 168
 			$args = $id;
169 169
 
170 170
 			$id = '';
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
 			$this->id = $id;
173 173
 		}
174 174
 
175
-		$keys = array_keys( get_object_vars( $this ) );
175
+		$keys = array_keys(get_object_vars($this));
176 176
 
177
-		foreach ( $keys as $key ) {
178
-			if ( isset( $args[ $key ] ) ) {
179
-				$this->$key = $args[ $key ];
177
+		foreach ($keys as $key) {
178
+			if (isset($args[$key])) {
179
+				$this->$key = $args[$key];
180 180
 			}
181 181
 		}
182 182
 
183 183
 		self::$instance_count += 1;
184 184
 		$this->instance_number = self::$instance_count;
185 185
 
186
-		if ( empty( $this->active_callback ) ) {
187
-			$this->active_callback = array( $this, 'active_callback' );
186
+		if (empty($this->active_callback)) {
187
+			$this->active_callback = array($this, 'active_callback');
188 188
 		}
189 189
 
190 190
 		$this->sections = array(); // Users cannot customize the $sections array.
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 		$screen = $this;
204 204
 		$active = true;
205 205
 
206
-		if ( is_callable( $this->active_callback ) ) {
207
-			$active = call_user_func( $this->active_callback, $this );
206
+		if (is_callable($this->active_callback)) {
207
+			$active = call_user_func($this->active_callback, $this);
208 208
 		}
209 209
 
210 210
 		/**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		 * @param bool                $active  Whether the Fields API screen is active.
215 215
 		 * @param WP_Fields_API_Screen $screen   {@see WP_Fields_API_Screen} instance.
216 216
 		 */
217
-		$active = apply_filters( 'fields_api_screen_active_' . $this->object_type, $active, $screen );
217
+		$active = apply_filters('fields_api_screen_active_'.$this->object_type, $active, $screen);
218 218
 
219 219
 		return $active;
220 220
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public function json() {
245 245
 
246
-		$array = wp_array_slice_assoc( (array) $this, array( 'id', 'title', 'description', 'priority', 'type' ) );
246
+		$array = wp_array_slice_assoc((array) $this, array('id', 'title', 'description', 'priority', 'type'));
247 247
 
248 248
 		$array['content'] = $this->get_content();
249 249
 		$array['active'] = $this->active();
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function check_capabilities() {
263 263
 
264
-		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
264
+		if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability)) {
265 265
 			return false;
266 266
 		}
267 267
 
268
-		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
268
+		if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports)) {
269 269
 			return false;
270 270
 		}
271 271
 
272 272
 		$access = true;
273 273
 
274
-		if ( is_callable( $this->capabilities_callback ) ) {
275
-			$access = call_user_func( $this->capabilities_callback, $this );
274
+		if (is_callable($this->capabilities_callback)) {
275
+			$access = call_user_func($this->capabilities_callback, $this);
276 276
 		}
277 277
 
278 278
 		return $access;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 
291 291
 		$this->maybe_render();
292 292
 
293
-		$template = trim( ob_get_contents() );
293
+		$template = trim(ob_get_contents());
294 294
 
295 295
 		ob_end_clean();
296 296
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 */
305 305
 	final public function maybe_render() {
306 306
 
307
-		if ( ! $this->check_capabilities() ) {
307
+		if ( ! $this->check_capabilities()) {
308 308
 			return;
309 309
 		}
310 310
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		 *
314 314
 		 * @param WP_Fields_API_Screen $this WP_Fields_API_Screen instance.
315 315
 		 */
316
-		do_action( "fields_api_render_screen_{$this->object_type}", $this );
316
+		do_action("fields_api_render_screen_{$this->object_type}", $this);
317 317
 
318 318
 		/**
319 319
 		 * Fires before rendering a specific Fields API screen.
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		 * The dynamic portion of the hook name, `$this->id`, refers to
322 322
 		 * the ID of the specific Fields API screen to be rendered.
323 323
 		 */
324
-		do_action( "fields_api_render_screen_{$this->object_type}_{$this->object_name}_{$this->id}" );
324
+		do_action("fields_api_render_screen_{$this->object_type}_{$this->object_name}_{$this->id}");
325 325
 
326 326
 		$this->render();
327 327
 
@@ -333,12 +333,12 @@  discard block
 block discarded – undo
333 333
 	 * @access protected
334 334
 	 */
335 335
 	protected function render() {
336
-		$classes = 'accordion-section control-section control-screen control-screen-' . $this->type;
336
+		$classes = 'accordion-section control-section control-screen control-screen-'.$this->type;
337 337
 		?>
338
-		<li id="accordion-screen-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
338
+		<li id="accordion-screen-<?php echo esc_attr($this->id); ?>" class="<?php echo esc_attr($classes); ?>">
339 339
 			<h3 class="accordion-section-title" tabindex="0">
340
-				<?php echo esc_html( $this->title ); ?>
341
-				<span class="screen-reader-text"><?php _e( 'Press return or enter to open this screen' ); ?></span>
340
+				<?php echo esc_html($this->title); ?>
341
+				<span class="screen-reader-text"><?php _e('Press return or enter to open this screen'); ?></span>
342 342
 			</h3>
343 343
 			<ul class="accordion-sub-container control-screen-content">
344 344
 				<?php $this->render_content(); ?>
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	protected function render_content() {
403 403
 		?>
404
-		<li class="screen-meta accordion-section control-section<?php if ( empty( $this->description ) ) { echo ' cannot-expand'; } ?>">
404
+		<li class="screen-meta accordion-section control-section<?php if (empty($this->description)) { echo ' cannot-expand'; } ?>">
405 405
 			<div class="accordion-section-title" tabindex="0">
406 406
 				<span class="preview-notice"><?php
407 407
 					/* translators: %s is the site/screen title in the Fields API */
408
-					printf( __( 'You are editing %s' ), '<strong class="screen-title">' . esc_html( $this->title ) . '</strong>' );
408
+					printf(__('You are editing %s'), '<strong class="screen-title">'.esc_html($this->title).'</strong>');
409 409
 				?></span>
410 410
 			</div>
411
-			<?php if ( ! empty( $this->description ) ) : ?>
411
+			<?php if ( ! empty($this->description)) : ?>
412 412
 				<div class="accordion-section-content description">
413 413
 					<?php echo $this->description; ?>
414 414
 				</div>
Please login to merge, or discard this patch.
wordpress-fields-api.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,32 +22,32 @@  discard block
 block discarded – undo
22 22
 /**
23 23
  * The absolute server path to the fields API directory.
24 24
  */
25
-define( 'WP_FIELDS_API_DIR', plugin_dir_path( __FILE__ ) );
25
+define('WP_FIELDS_API_DIR', plugin_dir_path(__FILE__));
26 26
 
27 27
 /**
28 28
  * On `plugins_loaded`, create an instance of the Fields API manager class.
29 29
  */
30 30
 function _wp_fields_api_include() {
31 31
 
32
-	require_once( WP_FIELDS_API_DIR . 'includes/class-wp-fields-api.php' );
32
+	require_once(WP_FIELDS_API_DIR.'includes/class-wp-fields-api.php');
33 33
 
34 34
 	// Init Customize class
35 35
 	$GLOBALS['wp_fields'] = new WP_Fields_API;
36 36
 
37 37
 }
38 38
 
39
-add_action( 'plugins_loaded', '_wp_fields_api_include', 8 );
39
+add_action('plugins_loaded', '_wp_fields_api_include', 8);
40 40
 
41 41
 /**
42 42
  * Implement Fields API Customizer instead of WP Core Customizer.
43 43
  */
44 44
 function _wp_fields_api_customize_include() {
45 45
 
46
-	if ( ! ( ( isset( $_REQUEST['wp_customize'] ) && 'on' == $_REQUEST['wp_customize'] ) || ( is_admin() && 'customize.php' == basename( $_SERVER['PHP_SELF'] ) ) ) ) {
46
+	if ( ! ((isset($_REQUEST['wp_customize']) && 'on' == $_REQUEST['wp_customize']) || (is_admin() && 'customize.php' == basename($_SERVER['PHP_SELF'])))) {
47 47
 		return;
48 48
 	}
49 49
 
50
-	require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
50
+	require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
51 51
 
52 52
 	// Init Customize class
53 53
 	$GLOBALS['wp_customize'] = new WP_Customize_Manager;
@@ -62,16 +62,16 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function _wp_fields_api_user_edit_include() {
64 64
 
65
-	require_once( WP_FIELDS_API_DIR . 'implementation/user-profile.php' );
65
+	require_once(WP_FIELDS_API_DIR.'implementation/user-profile.php');
66 66
 
67 67
 	return;
68 68
 
69 69
 	// Load our overrides
70
-	require_once( WP_FIELDS_API_DIR . 'implementation/wp-admin/includes/user.php' );
71
-	require_once( WP_FIELDS_API_DIR . 'implementation/wp-admin/user-edit.php' );
70
+	require_once(WP_FIELDS_API_DIR.'implementation/wp-admin/includes/user.php');
71
+	require_once(WP_FIELDS_API_DIR.'implementation/wp-admin/user-edit.php');
72 72
 
73 73
 	// Bail on original core file, don't run the rest
74 74
 	exit;
75 75
 
76 76
 }
77
-add_action( 'load-user-edit.php', '_wp_fields_api_user_edit_include' );
78 77
\ No newline at end of file
78
+add_action('load-user-edit.php', '_wp_fields_api_user_edit_include');
79 79
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wp-fields-api-field.php 2 patches
Doc Comments   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -182,8 +182,6 @@  discard block
 block discarded – undo
182 182
 	 * Check user capabilities and theme supports, and then save
183 183
 	 * the value of the field.
184 184
 	 *
185
-	 * @param mixed $value   The value to save.
186
-	 * @param int   $item_id The Item ID.
187 185
 	 *
188 186
 	 * @return false|mixed False if cap check fails or value isn't set.
189 187
 	 */
@@ -243,7 +241,6 @@  discard block
 block discarded – undo
243 241
 	 * Save the value of the field, using the related API.
244 242
 	 *
245 243
 	 * @param mixed $value The value to update.
246
-	 * @param int $item_id Item ID.
247 244
 	 *
248 245
 	 * @return mixed The result of saving the value.
249 246
 	 */
@@ -383,7 +380,6 @@  discard block
 block discarded – undo
383 380
 	/**
384 381
 	 * Fetch the value of the field.
385 382
 	 *
386
-	 * @param int $item_id (optional) The Item ID.
387 383
 	 *
388 384
 	 * @return mixed The value.
389 385
 	 */
@@ -655,7 +651,7 @@  discard block
 block discarded – undo
655 651
 	 *
656 652
 	 * @param       $root
657 653
 	 * @param       $keys
658
-	 * @param mixed $default A default value which is used as a fallback. Default is null.
654
+	 * @param string $default A default value which is used as a fallback. Default is null.
659 655
 	 *
660 656
 	 * @return mixed The requested value or the default value.
661 657
 	 */
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
 		$args = func_get_args();
113 113
 
114
-		call_user_func_array( array( $this, 'init' ), $args );
114
+		call_user_func_array(array($this, 'init'), $args);
115 115
 
116 116
 	}
117 117
 
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @return WP_Fields_API_Field $field
127 127
 	 */
128
-	public function init( $object_type, $id, $args = array() ) {
128
+	public function init($object_type, $id, $args = array()) {
129 129
 
130 130
 		$this->object_type = $object_type;
131 131
 
132
-		if ( is_array( $id ) ) {
132
+		if (is_array($id)) {
133 133
 			$args = $id;
134 134
 
135 135
 			$id = '';
@@ -137,31 +137,31 @@  discard block
 block discarded – undo
137 137
 			$this->id = $id;
138 138
 		}
139 139
 
140
-		$keys = array_keys( get_object_vars( $this ) );
140
+		$keys = array_keys(get_object_vars($this));
141 141
 
142
-		foreach ( $keys as $key ) {
143
-			if ( isset( $args[ $key ] ) ) {
144
-				$this->$key = $args[ $key ];
142
+		foreach ($keys as $key) {
143
+			if (isset($args[$key])) {
144
+				$this->$key = $args[$key];
145 145
 			}
146 146
 		}
147 147
 
148 148
 		// Parse the ID for array keys.
149
-		$this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) );
150
-		$this->id_data['base'] = array_shift( $this->id_data['keys'] );
149
+		$this->id_data['keys'] = preg_split('/\[/', str_replace(']', '', $this->id));
150
+		$this->id_data['base'] = array_shift($this->id_data['keys']);
151 151
 
152 152
 		// Rebuild the ID.
153 153
 		$this->id = $this->id_data['base'];
154 154
 
155
-		if ( ! empty( $this->id_data['keys'] ) ) {
156
-			$this->id .= '[' . implode( '][', $this->id_data['keys'] ) . ']';
155
+		if ( ! empty($this->id_data['keys'])) {
156
+			$this->id .= '['.implode('][', $this->id_data['keys']).']';
157 157
 		}
158 158
 
159
-		if ( $this->sanitize_callback ) {
160
-			add_filter( "fields_sanitize_{$this->object_type}_{$this->object_name}_{$this->id}", $this->sanitize_callback, 10, 2 );
159
+		if ($this->sanitize_callback) {
160
+			add_filter("fields_sanitize_{$this->object_type}_{$this->object_name}_{$this->id}", $this->sanitize_callback, 10, 2);
161 161
 		}
162 162
 
163
-		if ( $this->sanitize_js_callback ) {
164
-			add_filter( "fields_sanitize_js_{$this->object_type}_{$this->object_name}_{$this->id}", $this->sanitize_js_callback, 10, 2 );
163
+		if ($this->sanitize_js_callback) {
164
+			add_filter("fields_sanitize_js_{$this->object_type}_{$this->object_name}_{$this->id}", $this->sanitize_js_callback, 10, 2);
165 165
 		}
166 166
 
167 167
 	}
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 		$value   = func_get_arg(0);
181 181
 		$item_id = func_get_arg(1);
182 182
 
183
-		if ( ! $this->check_capabilities() || false === $value ) {
183
+		if ( ! $this->check_capabilities() || false === $value) {
184 184
 			return false;
185 185
 		}
186 186
 
187
-		$value = $this->sanitize( $value );
187
+		$value = $this->sanitize($value);
188 188
 
189 189
 		/**
190 190
 		 * Fires when the WP_Fields_API_Field::save() method is called.
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 		 *
199 199
 		 * @return string The value to save
200 200
 		 */
201
-		$value = apply_filters( 'field_save_' . $this->object_type . '_' . $this->id_data[ 'base' ], $value, $item_id, $this );
201
+		$value = apply_filters('field_save_'.$this->object_type.'_'.$this->id_data['base'], $value, $item_id, $this);
202 202
 
203
-		return $this->update( $value, $item_id );
203
+		return $this->update($value, $item_id);
204 204
 
205 205
 	}
206 206
 
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @return mixed Null if an input isn't valid, otherwise the sanitized value.
213 213
 	 */
214
-	public function sanitize( $value ) {
214
+	public function sanitize($value) {
215 215
 
216
-		$value = wp_unslash( $value );
216
+		$value = wp_unslash($value);
217 217
 
218 218
 		/**
219 219
 		 * Filter a Customize field value in un-slashed form.
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		 * @param mixed               $value Value of the field.
222 222
 		 * @param WP_Fields_API_Field $this  WP_Fields_API_Field instance.
223 223
 		 */
224
-		return apply_filters( "fields_sanitize_{$this->object_type}_{$this->object_name}_{$this->id}", $value, $this );
224
+		return apply_filters("fields_sanitize_{$this->object_type}_{$this->object_name}_{$this->id}", $value, $this);
225 225
 
226 226
 	}
227 227
 
@@ -233,27 +233,27 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @return mixed The result of saving the value.
235 235
 	 */
236
-	protected function update( $value ) {
236
+	protected function update($value) {
237 237
 
238 238
 		// @todo Support post / term / user / comment object field updates
239 239
 
240 240
 		$item_id = func_get_arg(1);
241 241
 
242
-		switch ( $this->object_type ) {
243
-			case is_callable( $this->update_value_callback ) :
244
-				return call_user_func( $this->update_value_callback, $value, $item_id, $this );
242
+		switch ($this->object_type) {
243
+			case is_callable($this->update_value_callback) :
244
+				return call_user_func($this->update_value_callback, $value, $item_id, $this);
245 245
 
246 246
 			case 'customizer' :
247
-				return $this->_update_theme_mod( $value );
247
+				return $this->_update_theme_mod($value);
248 248
 
249 249
 			case 'settings' :
250
-				return $this->_update_option( $value );
250
+				return $this->_update_option($value);
251 251
 
252 252
 			case 'post' :
253 253
 			case 'term' :
254 254
 			case 'user' :
255 255
 			case 'comment' :
256
-				return $this->_update_meta( $this->object_type, $value, $item_id );
256
+				return $this->_update_meta($this->object_type, $value, $item_id);
257 257
 
258 258
 			default :
259 259
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 				 * @param int                 $item_id Item ID.
268 268
 				 * @param WP_Fields_API_Field $this    WP_Fields_API_Field instance.
269 269
 				 */
270
-				do_action( "fields_update_{$this->object_type}", $value, $item_id, $this );
270
+				do_action("fields_update_{$this->object_type}", $value, $item_id, $this);
271 271
 		}
272 272
 
273 273
 		return null;
@@ -281,22 +281,22 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return null
283 283
 	 */
284
-	protected function _update_theme_mod( $value ) {
284
+	protected function _update_theme_mod($value) {
285 285
 
286
-		if ( is_null( $value ) ) {
287
-			remove_theme_mod( $this->id_data['base'] );
286
+		if (is_null($value)) {
287
+			remove_theme_mod($this->id_data['base']);
288 288
 		}
289 289
 
290 290
 		// Handle non-array theme mod.
291
-		if ( empty( $this->id_data['keys'] ) ) {
292
-			set_theme_mod( $this->id_data['base'], $value );
291
+		if (empty($this->id_data['keys'])) {
292
+			set_theme_mod($this->id_data['base'], $value);
293 293
 		} else {
294 294
 			// Handle array-based theme mod.
295
-			$mods = get_theme_mod( $this->id_data['base'] );
296
-			$mods = $this->multidimensional_replace( $mods, $this->id_data['keys'], $value );
295
+			$mods = get_theme_mod($this->id_data['base']);
296
+			$mods = $this->multidimensional_replace($mods, $this->id_data['keys'], $value);
297 297
 
298
-			if ( isset( $mods ) ) {
299
-				set_theme_mod( $this->id_data['base'], $mods );
298
+			if (isset($mods)) {
299
+				set_theme_mod($this->id_data['base'], $mods);
300 300
 			}
301 301
 		}
302 302
 
@@ -311,23 +311,23 @@  discard block
 block discarded – undo
311 311
 	 *
312 312
 	 * @return bool|null The result of saving the value.
313 313
 	 */
314
-	protected function _update_option( $value ) {
314
+	protected function _update_option($value) {
315 315
 
316
-		if ( is_null( $value ) ) {
317
-			delete_option( $this->id_data['base'] );
316
+		if (is_null($value)) {
317
+			delete_option($this->id_data['base']);
318 318
 		}
319 319
 
320 320
 		// Handle non-array option.
321
-		if ( empty( $this->id_data['keys'] ) ) {
322
-			return update_option( $this->id_data['base'], $value );
321
+		if (empty($this->id_data['keys'])) {
322
+			return update_option($this->id_data['base'], $value);
323 323
 		}
324 324
 
325 325
 		// Handle array-based options.
326
-		$options = get_option( $this->id_data['base'] );
327
-		$options = $this->multidimensional_replace( $options, $this->id_data['keys'], $value );
326
+		$options = get_option($this->id_data['base']);
327
+		$options = $this->multidimensional_replace($options, $this->id_data['keys'], $value);
328 328
 
329
-		if ( isset( $options ) ) {
330
-			return update_option( $this->id_data['base'], $options );
329
+		if (isset($options)) {
330
+			return update_option($this->id_data['base'], $options);
331 331
 		}
332 332
 
333 333
 		return null;
@@ -343,23 +343,23 @@  discard block
 block discarded – undo
343 343
 	 *
344 344
 	 * @return bool|null The result of saving the value.
345 345
 	 */
346
-	protected function _update_meta( $meta_type, $value, $item_id = 0 ) {
346
+	protected function _update_meta($meta_type, $value, $item_id = 0) {
347 347
 
348
-		if ( is_null( $value ) ) {
349
-			delete_metadata( $meta_type, $item_id, $this->id_data['base'] );
348
+		if (is_null($value)) {
349
+			delete_metadata($meta_type, $item_id, $this->id_data['base']);
350 350
 		}
351 351
 
352 352
 		// Handle non-array option.
353
-		if ( empty( $this->id_data['keys'] ) ) {
354
-			return update_metadata( $meta_type, $item_id, $this->id_data['base'], $value );
353
+		if (empty($this->id_data['keys'])) {
354
+			return update_metadata($meta_type, $item_id, $this->id_data['base'], $value);
355 355
 		}
356 356
 
357 357
 		// Handle array-based keys.
358
-		$keys = get_metadata( $meta_type, 0, $this->id_data['base'] );
359
-		$keys = $this->multidimensional_replace( $keys, $this->id_data['keys'], $value );
358
+		$keys = get_metadata($meta_type, 0, $this->id_data['base']);
359
+		$keys = $this->multidimensional_replace($keys, $this->id_data['keys'], $value);
360 360
 
361
-		if ( isset( $keys ) ) {
362
-			return update_metadata( $meta_type, $item_id, $this->id_data['base'], $keys );
361
+		if (isset($keys)) {
362
+			return update_metadata($meta_type, $item_id, $this->id_data['base'], $keys);
363 363
 		}
364 364
 
365 365
 		return null;
@@ -377,24 +377,24 @@  discard block
 block discarded – undo
377 377
 
378 378
 		$item_id = func_get_arg(0);
379 379
 
380
-		switch ( $this->object_type ) {
381
-			case is_callable( $this->value_callback ) :
382
-				$value = call_user_func( $this->value_callback, $item_id, $this );
383
-				$value = $this->multidimensional_get( $value, $this->id_data['keys'], $this->default );
380
+		switch ($this->object_type) {
381
+			case is_callable($this->value_callback) :
382
+				$value = call_user_func($this->value_callback, $item_id, $this);
383
+				$value = $this->multidimensional_get($value, $this->id_data['keys'], $this->default);
384 384
 
385 385
 				break;
386 386
 			case 'post' :
387 387
 			case 'term' :
388 388
 			case 'user' :
389 389
 			case 'comment' :
390
-				$value = $this->get_object_value( $item_id );
391
-				$value = $this->multidimensional_get( $value, $this->id_data['keys'], $this->default );
390
+				$value = $this->get_object_value($item_id);
391
+				$value = $this->multidimensional_get($value, $this->id_data['keys'], $this->default);
392 392
 				break;
393 393
 
394 394
 			case 'customizer' :
395 395
 			case 'settings' :
396 396
 				$value = $this->get_option_value();
397
-				$value = $this->multidimensional_get( $value, $this->id_data['keys'], $this->default );
397
+				$value = $this->multidimensional_get($value, $this->id_data['keys'], $this->default);
398 398
 				break;
399 399
 
400 400
 			default :
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 				 * @param mixed $default The field default value. Default empty.
411 411
 				 * @param int   $item_id (optional) The Item ID.
412 412
 				 */
413
-				$value = apply_filters( 'fields_value_' . $this->object_type . '_' . $this->object_name . '_' . $this->id_data['base'], $this->default, $item_id );
413
+				$value = apply_filters('fields_value_'.$this->object_type.'_'.$this->object_name.'_'.$this->id_data['base'], $this->default, $item_id);
414 414
 				break;
415 415
 		}
416 416
 
@@ -425,39 +425,39 @@  discard block
 block discarded – undo
425 425
 	 *
426 426
 	 * @return mixed|null
427 427
 	 */
428
-	public function get_object_value( $item_id ) {
428
+	public function get_object_value($item_id) {
429 429
 
430 430
 		$value = null;
431 431
 		$object = null;
432 432
 
433 433
 		$field_key = $this->id_data['base'];
434 434
 
435
-		switch ( $this->object_type ) {
435
+		switch ($this->object_type) {
436 436
 			case 'post' :
437
-				$object = get_post( $item_id );
437
+				$object = get_post($item_id);
438 438
 				break;
439 439
 
440 440
 			case 'term' :
441
-				$object = get_term( $item_id );
441
+				$object = get_term($item_id);
442 442
 				break;
443 443
 
444 444
 			case 'user' :
445
-				$object = get_userdata( $item_id );
445
+				$object = get_userdata($item_id);
446 446
 				break;
447 447
 
448 448
 			case 'comment' :
449
-				$object = get_comment( $item_id );
449
+				$object = get_comment($item_id);
450 450
 				break;
451 451
 		}
452 452
 
453
-		if ( $object && ! is_wp_error( $object ) && isset( $object->{$field_key} ) ) {
453
+		if ($object && ! is_wp_error($object) && isset($object->{$field_key} )) {
454 454
 			// Get value from object
455 455
 			$value = $object->{$field_key};
456 456
 		} else {
457 457
 			// Get value from meta
458
-			$value = get_metadata( $this->object_type, $item_id, $field_key );
458
+			$value = get_metadata($this->object_type, $item_id, $field_key);
459 459
 
460
-			if ( array() === $value ) {
460
+			if (array() === $value) {
461 461
 				$value = $this->default;
462 462
 			}
463 463
 		}
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		$function = '';
477 477
 		$value = null;
478 478
 
479
-		switch ( $this->object_type ) {
479
+		switch ($this->object_type) {
480 480
 			case 'customizer' :
481 481
 				$function = 'get_theme_mod';
482 482
 				break;
@@ -486,14 +486,14 @@  discard block
 block discarded – undo
486 486
 				break;
487 487
 		}
488 488
 
489
-		if ( is_callable( $function ) ) {
489
+		if (is_callable($function)) {
490 490
 			// Handle non-array value
491
-			if ( empty( $this->id_data['keys'] ) ) {
492
-				return $function( $this->id_data['base'], $this->default );
491
+			if (empty($this->id_data['keys'])) {
492
+				return $function($this->id_data['base'], $this->default);
493 493
 			}
494 494
 
495 495
 			// Handle array-based value
496
-			$value = $function( $this->id_data['base'] );
496
+			$value = $function($this->id_data['base']);
497 497
 		}
498 498
 
499 499
 		return $value;
@@ -517,10 +517,10 @@  discard block
 block discarded – undo
517 517
 		 * @param mixed                $value The field value.
518 518
 		 * @param WP_Fields_API_Field $this  {@see WP_Fields_API_Field} instance.
519 519
 		 */
520
-		$value = apply_filters( "fields_sanitize_js_{$this->object_type}_{$this->object_name}_{$this->id}", $value, $this );
520
+		$value = apply_filters("fields_sanitize_js_{$this->object_type}_{$this->object_name}_{$this->id}", $value, $this);
521 521
 
522
-		if ( is_string( $value ) ) {
523
-			return html_entity_decode( $value, ENT_QUOTES, 'UTF-8' );
522
+		if (is_string($value)) {
523
+			return html_entity_decode($value, ENT_QUOTES, 'UTF-8');
524 524
 		}
525 525
 
526 526
 		return $value;
@@ -534,18 +534,18 @@  discard block
 block discarded – undo
534 534
 	 */
535 535
 	public function check_capabilities() {
536 536
 
537
-		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
537
+		if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability)) {
538 538
 			return false;
539 539
 		}
540 540
 
541
-		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
541
+		if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports)) {
542 542
 			return false;
543 543
 		}
544 544
 
545 545
 		$access = true;
546 546
 
547
-		if ( is_callable( $this->capabilities_callback ) ) {
548
-			$access = call_user_func( $this->capabilities_callback, $this );
547
+		if (is_callable($this->capabilities_callback)) {
548
+			$access = call_user_func($this->capabilities_callback, $this);
549 549
 		}
550 550
 
551 551
 		return $access;
@@ -561,42 +561,42 @@  discard block
 block discarded – undo
561 561
 	 *
562 562
 	 * @return null|array Keys are 'root', 'node', and 'key'.
563 563
 	 */
564
-	final protected function multidimensional( &$root, $keys, $create = false ) {
564
+	final protected function multidimensional(&$root, $keys, $create = false) {
565 565
 
566
-		if ( $create && empty( $root ) ) {
566
+		if ($create && empty($root)) {
567 567
 			$root = array();
568 568
 		}
569 569
 
570
-		if ( ! isset( $root ) || empty( $keys ) ) {
570
+		if ( ! isset($root) || empty($keys)) {
571 571
 			return null;
572 572
 		}
573 573
 
574
-		$last = array_pop( $keys );
574
+		$last = array_pop($keys);
575 575
 		$node = &$root;
576 576
 
577
-		foreach ( $keys as $key ) {
578
-			if ( $create && ! isset( $node[ $key ] ) ) {
579
-				$node[ $key ] = array();
577
+		foreach ($keys as $key) {
578
+			if ($create && ! isset($node[$key])) {
579
+				$node[$key] = array();
580 580
 			}
581 581
 
582
-			if ( ! is_array( $node ) || ! isset( $node[ $key ] ) ) {
582
+			if ( ! is_array($node) || ! isset($node[$key])) {
583 583
 				return null;
584 584
 			}
585 585
 
586
-			$node = &$node[ $key ];
586
+			$node = &$node[$key];
587 587
 		}
588 588
 
589
-		if ( $create ) {
590
-			if ( ! is_array( $node ) ) {
589
+		if ($create) {
590
+			if ( ! is_array($node)) {
591 591
 				// account for an array overriding a string or object value
592 592
 				$node = array();
593 593
 			}
594
-			if ( ! isset( $node[ $last ] ) ) {
595
-				$node[ $last ] = array();
594
+			if ( ! isset($node[$last])) {
595
+				$node[$last] = array();
596 596
 			}
597 597
 		}
598 598
 
599
-		if ( ! isset( $node[ $last ] ) ) {
599
+		if ( ! isset($node[$last])) {
600 600
 			return null;
601 601
 		}
602 602
 
@@ -617,19 +617,19 @@  discard block
 block discarded – undo
617 617
 	 *
618 618
 	 * @return
619 619
 	 */
620
-	final protected function multidimensional_replace( $root, $keys, $value ) {
620
+	final protected function multidimensional_replace($root, $keys, $value) {
621 621
 
622
-		if ( ! isset( $value ) ) {
622
+		if ( ! isset($value)) {
623 623
 			return $root;
624
-		} elseif ( empty( $keys ) ) {
624
+		} elseif (empty($keys)) {
625 625
 			// If there are no keys, we're replacing the root.
626 626
 			return $value;
627 627
 		}
628 628
 
629
-		$result = $this->multidimensional( $root, $keys, true );
629
+		$result = $this->multidimensional($root, $keys, true);
630 630
 
631
-		if ( isset( $result ) ) {
632
-			$result['node'][ $result['key'] ] = $value;
631
+		if (isset($result)) {
632
+			$result['node'][$result['key']] = $value;
633 633
 		}
634 634
 
635 635
 		return $root;
@@ -645,18 +645,18 @@  discard block
 block discarded – undo
645 645
 	 *
646 646
 	 * @return mixed The requested value or the default value.
647 647
 	 */
648
-	final protected function multidimensional_get( $root, $keys, $default = null ) {
648
+	final protected function multidimensional_get($root, $keys, $default = null) {
649 649
 
650 650
 		// If there are no keys, test the root.
651
-		if ( empty( $keys ) ) {
652
-			if ( isset( $root ) ) {
651
+		if (empty($keys)) {
652
+			if (isset($root)) {
653 653
 				return $root;
654 654
 			}
655 655
 		} else {
656
-			$result = $this->multidimensional( $root, $keys );
656
+			$result = $this->multidimensional($root, $keys);
657 657
 
658
-			if ( isset( $result ) ) {
659
-				return $result['node'][ $result['key'] ];
658
+			if (isset($result)) {
659
+				return $result['node'][$result['key']];
660 660
 			}
661 661
 		}
662 662
 
@@ -672,11 +672,11 @@  discard block
 block discarded – undo
672 672
 	 *
673 673
 	 * @return bool True if value is set, false if not.
674 674
 	 */
675
-	final protected function multidimensional_isset( $root, $keys ) {
675
+	final protected function multidimensional_isset($root, $keys) {
676 676
 
677
-		$result = $this->multidimensional_get( $root, $keys );
677
+		$result = $this->multidimensional_get($root, $keys);
678 678
 
679
-		return isset( $result );
679
+		return isset($result);
680 680
 
681 681
 	}
682 682
 }
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	 *
699 699
 	 * @return mixed The result of saving the value.
700 700
 	 */
701
-	public function update( $value ) {
701
+	public function update($value) {
702 702
 
703 703
 		return null;
704 704
 
Please login to merge, or discard this patch.