@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @access public |
133 | 133 | * |
134 | 134 | * @param string|null $object_type Object type. Null for all containers for all object types. |
135 | - * @param string|boolean|null $object_name Object name (for post types and taxonomies). |
|
135 | + * @param string|boolean $object_name Object name (for post types and taxonomies). |
|
136 | 136 | * True for all containers for all object names. |
137 | 137 | * |
138 | 138 | * @return WP_Fields_API_Screen[]|WP_Fields_API_Section[] |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @access public |
227 | 227 | * |
228 | 228 | * @param string $object_type Object type. |
229 | - * @param WP_Fields_API_Screen|string $id Field Screen object, or Screen ID. |
|
229 | + * @param string|null $id Field Screen object, or Screen ID. |
|
230 | 230 | * @param string $object_name Object name (for post types and taxonomies). |
231 | 231 | * @param array $args Optional. Screen arguments. Default empty array. |
232 | 232 | */ |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | * @access public |
499 | 499 | * |
500 | 500 | * @param string $object_type Object type. |
501 | - * @param WP_Fields_API_Section|string $id Field Section object, or Section ID. |
|
501 | + * @param string $id Field Section object, or Section ID. |
|
502 | 502 | * @param string $object_name Object name (for post types and taxonomies). |
503 | 503 | * @param array $args Section arguments. |
504 | 504 | */ |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @access public |
731 | 731 | * |
732 | 732 | * @param string $object_type Object type. |
733 | - * @param WP_Fields_API_Field|string $id Fields API Field object, or ID. |
|
733 | + * @param string $id Fields API Field object, or ID. |
|
734 | 734 | * @param string $object_name Object name (for post types and taxonomies). |
735 | 735 | * @param array $args Field arguments; passed to WP_Fields_API_Field |
736 | 736 | * constructor. |
@@ -908,7 +908,6 @@ discard block |
||
908 | 908 | * @see WP_Fields_API_Field |
909 | 909 | * |
910 | 910 | * @param string $type Field type ID. |
911 | - * @param string $screen_class Name of a custom field type which is a subclass of WP_Fields_API_Field. |
|
912 | 911 | */ |
913 | 912 | public function register_field_type( $type, $field_class = null ) { |
914 | 913 |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function __construct() { |
98 | 98 | |
99 | - require_once( WP_FIELDS_API_DIR . 'includes/class-wp-fields-api-field.php' ); |
|
100 | - require_once( WP_FIELDS_API_DIR . 'includes/class-wp-fields-api-control.php' ); |
|
101 | - require_once( WP_FIELDS_API_DIR . 'includes/class-wp-fields-api-section.php' ); |
|
102 | - require_once( WP_FIELDS_API_DIR . 'includes/class-wp-fields-api-screen.php' ); |
|
99 | + require_once(WP_FIELDS_API_DIR.'includes/class-wp-fields-api-field.php'); |
|
100 | + require_once(WP_FIELDS_API_DIR.'includes/class-wp-fields-api-control.php'); |
|
101 | + require_once(WP_FIELDS_API_DIR.'includes/class-wp-fields-api-section.php'); |
|
102 | + require_once(WP_FIELDS_API_DIR.'includes/class-wp-fields-api-screen.php'); |
|
103 | 103 | |
104 | 104 | // Register our wp_loaded() first before WP_Customize_Manage::wp_loaded() |
105 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 9 ); |
|
105 | + add_action('wp_loaded', array($this, 'wp_loaded'), 9); |
|
106 | 106 | |
107 | - add_action( 'fields_register', array( $this, 'register_controls' ) ); |
|
107 | + add_action('fields_register', array($this, 'register_controls')); |
|
108 | 108 | |
109 | 109 | } |
110 | 110 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param WP_Fields_API $this The Fields manager object. |
124 | 124 | */ |
125 | - do_action( 'fields_register', $this ); |
|
125 | + do_action('fields_register', $this); |
|
126 | 126 | |
127 | 127 | } |
128 | 128 | |
@@ -137,34 +137,34 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return WP_Fields_API_Screen[]|WP_Fields_API_Section[] |
139 | 139 | */ |
140 | - public function get_containers( $object_type = null, $object_name = null ) { |
|
140 | + public function get_containers($object_type = null, $object_name = null) { |
|
141 | 141 | |
142 | 142 | // $object_name defaults to '_{$object_type}' for internal handling. |
143 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
144 | - $object_name = '_' . $object_type; |
|
143 | + if (empty($object_name) && ! empty($object_type)) { |
|
144 | + $object_name = '_'.$object_type; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | // Setup containers. |
148 | - if ( empty( self::$containers ) ) { |
|
149 | - if ( true === $object_name ) { |
|
150 | - $this->prepare_controls( $object_type ); |
|
148 | + if (empty(self::$containers)) { |
|
149 | + if (true === $object_name) { |
|
150 | + $this->prepare_controls($object_type); |
|
151 | 151 | } else { |
152 | - $this->prepare_object_controls( $object_type, $object_name ); |
|
152 | + $this->prepare_object_controls($object_type, $object_name); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | $containers = array(); |
157 | 157 | |
158 | - if ( null === $object_type ) { |
|
158 | + if (null === $object_type) { |
|
159 | 159 | // Get all containers. |
160 | 160 | $containers = self::$containers; |
161 | - } elseif ( isset( self::$containers[ $object_type ][ $object_name ] ) ) { |
|
161 | + } elseif (isset(self::$containers[$object_type][$object_name])) { |
|
162 | 162 | // Get all containers by object name. |
163 | - $containers = self::$containers[ $object_type ][ $object_name ]; |
|
164 | - } elseif ( true === $object_name ) { |
|
163 | + $containers = self::$containers[$object_type][$object_name]; |
|
164 | + } elseif (true === $object_name) { |
|
165 | 165 | // Get all containers by object type. |
166 | - foreach ( self::$containers[ $object_type ] as $object_name => $object_containers ) { |
|
167 | - $containers = array_merge( $containers, array_values( $object_containers ) ); |
|
166 | + foreach (self::$containers[$object_type] as $object_name => $object_containers) { |
|
167 | + $containers = array_merge($containers, array_values($object_containers)); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
@@ -182,37 +182,37 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return WP_Fields_API_Screen[] |
184 | 184 | */ |
185 | - public function get_screens( $object_type = null, $object_name = null ) { |
|
185 | + public function get_screens($object_type = null, $object_name = null) { |
|
186 | 186 | |
187 | 187 | // $object_name defaults to '_{$object_type}' for internal handling. |
188 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
189 | - $object_name = '_' . $object_type; |
|
188 | + if (empty($object_name) && ! empty($object_type)) { |
|
189 | + $object_name = '_'.$object_type; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $screens = array(); |
193 | 193 | |
194 | - if ( null === $object_type ) { |
|
194 | + if (null === $object_type) { |
|
195 | 195 | // Late init. |
196 | - foreach ( self::$screens as $object_type => $object_names ) { |
|
197 | - foreach ( $object_names as $object_name => $screens ) { |
|
198 | - $this->get_screens( $object_type, $object_name ); |
|
196 | + foreach (self::$screens as $object_type => $object_names) { |
|
197 | + foreach ($object_names as $object_name => $screens) { |
|
198 | + $this->get_screens($object_type, $object_name); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | 202 | $screens = self::$screens; |
203 | - } elseif ( isset( self::$screens[ $object_type ][ $object_name ] ) ) { |
|
203 | + } elseif (isset(self::$screens[$object_type][$object_name])) { |
|
204 | 204 | // Late init. |
205 | - foreach ( self::$screens[ $object_type ][ $object_name ] as $id => $screen ) { |
|
205 | + foreach (self::$screens[$object_type][$object_name] as $id => $screen) { |
|
206 | 206 | // Late init |
207 | - self::$screens[ $object_type ][ $object_name ][ $id ] = $this->setup_screen( $object_type, $id, $object_name, $screen ); |
|
207 | + self::$screens[$object_type][$object_name][$id] = $this->setup_screen($object_type, $id, $object_name, $screen); |
|
208 | 208 | } |
209 | 209 | |
210 | - $screens = self::$screens[ $object_type ][ $object_name ]; |
|
211 | - } elseif ( true === $object_name ) { |
|
210 | + $screens = self::$screens[$object_type][$object_name]; |
|
211 | + } elseif (true === $object_name) { |
|
212 | 212 | // Get all screens. |
213 | 213 | // Late init. |
214 | - foreach ( self::$screens[ $object_type ] as $object_name => $object_screens ) { |
|
215 | - $screens = array_merge( $screens, array_values( $this->get_screens( $object_type, $object_name ) ) ); |
|
214 | + foreach (self::$screens[$object_type] as $object_name => $object_screens) { |
|
215 | + $screens = array_merge($screens, array_values($this->get_screens($object_type, $object_name))); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | * @param string $object_name Object name (for post types and taxonomies). |
231 | 231 | * @param array $args Optional. Screen arguments. Default empty array. |
232 | 232 | */ |
233 | - public function add_screen( $object_type, $id, $object_name = null, $args = array() ) { |
|
233 | + public function add_screen($object_type, $id, $object_name = null, $args = array()) { |
|
234 | 234 | |
235 | - if ( empty( $id ) && empty( $args ) ) { |
|
235 | + if (empty($id) && empty($args)) { |
|
236 | 236 | return; |
237 | 237 | } |
238 | 238 | |
239 | - if ( is_a( $id, 'WP_Fields_API_Screen' ) ) { |
|
239 | + if (is_a($id, 'WP_Fields_API_Screen')) { |
|
240 | 240 | $screen = $id; |
241 | 241 | |
242 | 242 | $id = $screen->id; |
@@ -246,19 +246,19 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | // $object_name defaults to '_{$object_type}' for internal handling. |
249 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
250 | - $object_name = '_' . $object_type; |
|
249 | + if (empty($object_name) && ! empty($object_type)) { |
|
250 | + $object_name = '_'.$object_type; |
|
251 | 251 | } |
252 | 252 | |
253 | - if ( ! isset( self::$screens[ $object_type ] ) ) { |
|
254 | - self::$screens[ $object_type ] = array(); |
|
253 | + if ( ! isset(self::$screens[$object_type])) { |
|
254 | + self::$screens[$object_type] = array(); |
|
255 | 255 | } |
256 | 256 | |
257 | - if ( ! isset( self::$screens[ $object_type ][ $object_name ] ) ) { |
|
258 | - self::$screens[ $object_type ][ $object_name ] = array(); |
|
257 | + if ( ! isset(self::$screens[$object_type][$object_name])) { |
|
258 | + self::$screens[$object_type][$object_name] = array(); |
|
259 | 259 | } |
260 | 260 | |
261 | - self::$screens[ $object_type ][ $object_name ][ $id ] = $screen; |
|
261 | + self::$screens[$object_type][$object_name][$id] = $screen; |
|
262 | 262 | |
263 | 263 | } |
264 | 264 | |
@@ -273,19 +273,19 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return WP_Fields_API_Screen|null Requested screen instance. |
275 | 275 | */ |
276 | - public function get_screen( $object_type, $id, $object_name = null ) { |
|
276 | + public function get_screen($object_type, $id, $object_name = null) { |
|
277 | 277 | |
278 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
279 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
278 | + if (empty($object_name) && ! empty($object_type)) { |
|
279 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | $screen = null; |
283 | 283 | |
284 | - if ( isset( self::$screens[ $object_type ][ $object_name ][ $id ] ) ) { |
|
284 | + if (isset(self::$screens[$object_type][$object_name][$id])) { |
|
285 | 285 | // Late init |
286 | - self::$screens[ $object_type ][ $object_name ][ $id ] = $this->setup_screen( $object_type, $id, $object_name, self::$screens[ $object_type ][ $object_name ][ $id ] ); |
|
286 | + self::$screens[$object_type][$object_name][$id] = $this->setup_screen($object_type, $id, $object_name, self::$screens[$object_type][$object_name][$id]); |
|
287 | 287 | |
288 | - $screen = self::$screens[ $object_type ][ $object_name ][ $id ]; |
|
288 | + $screen = self::$screens[$object_type][$object_name][$id]; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | return $screen; |
@@ -304,26 +304,26 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return WP_Fields_API_Screen|null $screen The screen object. |
306 | 306 | */ |
307 | - public function setup_screen( $object_type, $id, $object_name = null, $args = null ) { |
|
307 | + public function setup_screen($object_type, $id, $object_name = null, $args = null) { |
|
308 | 308 | |
309 | 309 | $screen = null; |
310 | 310 | |
311 | 311 | $screen_class = 'WP_Fields_API_Screen'; |
312 | 312 | |
313 | - if ( is_a( $args, $screen_class ) ) { |
|
313 | + if (is_a($args, $screen_class)) { |
|
314 | 314 | $screen = $args; |
315 | - } elseif ( is_array( $args ) ) { |
|
315 | + } elseif (is_array($args)) { |
|
316 | 316 | $args['object_name'] = $object_name; |
317 | 317 | |
318 | - if ( ! empty( $args['type'] ) ) { |
|
319 | - if ( ! empty( self::$registered_screen_types[ $args['type'] ] ) ) { |
|
320 | - $screen_class = self::$registered_screen_types[ $args['type'] ]; |
|
321 | - } elseif ( in_array( $args['type'], self::$registered_screen_types ) ) { |
|
318 | + if ( ! empty($args['type'])) { |
|
319 | + if ( ! empty(self::$registered_screen_types[$args['type']])) { |
|
320 | + $screen_class = self::$registered_screen_types[$args['type']]; |
|
321 | + } elseif (in_array($args['type'], self::$registered_screen_types)) { |
|
322 | 322 | $screen_class = $args['type']; |
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | - $screen = new $screen_class( $object_type, $id, $args ); |
|
326 | + $screen = new $screen_class($object_type, $id, $args); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | return $screen; |
@@ -339,29 +339,29 @@ discard block |
||
339 | 339 | * @param string $id Screen ID to remove, set true to remove all screens from an object. |
340 | 340 | * @param string $object_name Object name (for post types and taxonomies), set true to remove to all objects from an object type. |
341 | 341 | */ |
342 | - public function remove_screen( $object_type, $id, $object_name = null ) { |
|
342 | + public function remove_screen($object_type, $id, $object_name = null) { |
|
343 | 343 | |
344 | - if ( true === $object_type ) { |
|
344 | + if (true === $object_type) { |
|
345 | 345 | // Remove all screens |
346 | 346 | self::$screens = array(); |
347 | - } elseif ( true === $object_name ) { |
|
347 | + } elseif (true === $object_name) { |
|
348 | 348 | // Remove all screens for an object type |
349 | - if ( isset( self::$screens[ $object_type ] ) ) { |
|
350 | - unset( self::$screens[ $object_type ] ); |
|
349 | + if (isset(self::$screens[$object_type])) { |
|
350 | + unset(self::$screens[$object_type]); |
|
351 | 351 | } |
352 | 352 | } else { |
353 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
354 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
353 | + if (empty($object_name) && ! empty($object_type)) { |
|
354 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
355 | 355 | } |
356 | 356 | |
357 | - if ( true === $id && null !== $object_name ) { |
|
357 | + if (true === $id && null !== $object_name) { |
|
358 | 358 | // Remove all screens for an object type |
359 | - if ( isset( self::$screens[ $object_type ][ $object_name ] ) ) { |
|
360 | - unset( self::$screens[ $object_type ][ $object_name ] ); |
|
359 | + if (isset(self::$screens[$object_type][$object_name])) { |
|
360 | + unset(self::$screens[$object_type][$object_name]); |
|
361 | 361 | } |
362 | - } elseif ( isset( self::$screens[ $object_type ][ $object_name ][ $id ] ) ) { |
|
362 | + } elseif (isset(self::$screens[$object_type][$object_name][$id])) { |
|
363 | 363 | // Remove screen from object type and name |
364 | - unset( self::$screens[ $object_type ][ $object_name ][ $id ] ); |
|
364 | + unset(self::$screens[$object_type][$object_name][$id]); |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
@@ -377,13 +377,13 @@ discard block |
||
377 | 377 | * @param string $type Screen type ID. |
378 | 378 | * @param string $screen_class Name of a custom screen which is a subclass of WP_Fields_API_Screen. |
379 | 379 | */ |
380 | - public function register_screen_type( $type, $screen_class = null ) { |
|
380 | + public function register_screen_type($type, $screen_class = null) { |
|
381 | 381 | |
382 | - if ( null === $screen_class ) { |
|
382 | + if (null === $screen_class) { |
|
383 | 383 | $screen_class = $type; |
384 | 384 | } |
385 | 385 | |
386 | - self::$registered_screen_types[ $type ] = $screen_class; |
|
386 | + self::$registered_screen_types[$type] = $screen_class; |
|
387 | 387 | |
388 | 388 | } |
389 | 389 | |
@@ -397,8 +397,8 @@ discard block |
||
397 | 397 | /** |
398 | 398 | * @var WP_Fields_API_Screen $screen |
399 | 399 | */ |
400 | - foreach ( self::$registered_screen_types as $screen_type => $screen_class ) { |
|
401 | - $screen = $this->setup_screen( null, 'temp', null, array( 'type' => $screen_type ) ); |
|
400 | + foreach (self::$registered_screen_types as $screen_type => $screen_class) { |
|
401 | + $screen = $this->setup_screen(null, 'temp', null, array('type' => $screen_type)); |
|
402 | 402 | |
403 | 403 | $screen->print_template(); |
404 | 404 | } |
@@ -416,41 +416,41 @@ discard block |
||
416 | 416 | * |
417 | 417 | * @return WP_Fields_API_Section[] |
418 | 418 | */ |
419 | - public function get_sections( $object_type = null, $object_name = null, $screen = null ) { |
|
419 | + public function get_sections($object_type = null, $object_name = null, $screen = null) { |
|
420 | 420 | |
421 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
422 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
421 | + if (empty($object_name) && ! empty($object_type)) { |
|
422 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | $sections = array(); |
426 | 426 | |
427 | - if ( null === $object_type ) { |
|
427 | + if (null === $object_type) { |
|
428 | 428 | // Late init |
429 | - foreach ( self::$sections as $object_type => $object_names ) { |
|
430 | - foreach ( $object_names as $object_name => $sections ) { |
|
431 | - $this->get_sections( $object_type, $object_name ); |
|
429 | + foreach (self::$sections as $object_type => $object_names) { |
|
430 | + foreach ($object_names as $object_name => $sections) { |
|
431 | + $this->get_sections($object_type, $object_name); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | 435 | $sections = self::$sections; |
436 | 436 | |
437 | 437 | // Get only sections for a specific screen |
438 | - if ( null !== $screen ) { |
|
438 | + if (null !== $screen) { |
|
439 | 439 | $screen_sections = array(); |
440 | 440 | |
441 | - foreach ( $sections as $object_type => $object_names ) { |
|
442 | - foreach ( $object_names as $object_name => $object_sections ) { |
|
443 | - foreach ( $object_sections as $id => $section ) { |
|
444 | - if ( $screen == $section->screen->id ) { |
|
445 | - if ( ! isset( $screen_sections[ $object_type ] ) ) { |
|
446 | - $screen_sections[ $object_type ] = array(); |
|
441 | + foreach ($sections as $object_type => $object_names) { |
|
442 | + foreach ($object_names as $object_name => $object_sections) { |
|
443 | + foreach ($object_sections as $id => $section) { |
|
444 | + if ($screen == $section->screen->id) { |
|
445 | + if ( ! isset($screen_sections[$object_type])) { |
|
446 | + $screen_sections[$object_type] = array(); |
|
447 | 447 | } |
448 | 448 | |
449 | - if ( ! isset( $screen_sections[ $object_type ][ $object_name ] ) ) { |
|
450 | - $screen_sections[ $object_type ][ $object_name ] = array(); |
|
449 | + if ( ! isset($screen_sections[$object_type][$object_name])) { |
|
450 | + $screen_sections[$object_type][$object_name] = array(); |
|
451 | 451 | } |
452 | 452 | |
453 | - $screen_sections[ $object_type ][ $object_name ][ $id ] = $screen; |
|
453 | + $screen_sections[$object_type][$object_name][$id] = $screen; |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | } |
@@ -458,33 +458,33 @@ discard block |
||
458 | 458 | |
459 | 459 | $sections = $screen_sections; |
460 | 460 | } |
461 | - } elseif ( isset( self::$sections[ $object_type ][ $object_name ] ) ) { |
|
461 | + } elseif (isset(self::$sections[$object_type][$object_name])) { |
|
462 | 462 | // Late init |
463 | - foreach ( self::$sections[ $object_type ][ $object_name ] as $id => $section ) { |
|
463 | + foreach (self::$sections[$object_type][$object_name] as $id => $section) { |
|
464 | 464 | // Late init |
465 | - self::$sections[ $object_type ][ $object_name ][ $id ] = $this->setup_section( $object_type, $id, $object_name, $section ); |
|
465 | + self::$sections[$object_type][$object_name][$id] = $this->setup_section($object_type, $id, $object_name, $section); |
|
466 | 466 | } |
467 | 467 | |
468 | - $sections = self::$sections[ $object_type ][ $object_name ]; |
|
468 | + $sections = self::$sections[$object_type][$object_name]; |
|
469 | 469 | |
470 | 470 | // Get only sections for a specific screen |
471 | - if ( null !== $screen ) { |
|
471 | + if (null !== $screen) { |
|
472 | 472 | $screen_sections = array(); |
473 | 473 | |
474 | - foreach ( $sections as $id => $section ) { |
|
475 | - if ( $screen == $section->screen ) { |
|
476 | - $screen_sections[ $id ] = $section; |
|
474 | + foreach ($sections as $id => $section) { |
|
475 | + if ($screen == $section->screen) { |
|
476 | + $screen_sections[$id] = $section; |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | 480 | $sections = $screen_sections; |
481 | 481 | } |
482 | - } elseif ( true === $object_name ) { |
|
482 | + } elseif (true === $object_name) { |
|
483 | 483 | // Get all sections |
484 | 484 | |
485 | 485 | // Late init |
486 | - foreach ( self::$sections[ $object_type ] as $object_name => $object_sections ) { |
|
487 | - $sections = array_merge( $sections, array_values( $this->get_sections( $object_type, $object_name, $screen ) ) ); |
|
486 | + foreach (self::$sections[$object_type] as $object_name => $object_sections) { |
|
487 | + $sections = array_merge($sections, array_values($this->get_sections($object_type, $object_name, $screen))); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | * @param string $object_name Object name (for post types and taxonomies). |
503 | 503 | * @param array $args Section arguments. |
504 | 504 | */ |
505 | - public function add_section( $object_type, $id, $object_name = null, $args = array() ) { |
|
505 | + public function add_section($object_type, $id, $object_name = null, $args = array()) { |
|
506 | 506 | |
507 | - if ( empty( $id ) && empty( $args ) ) { |
|
507 | + if (empty($id) && empty($args)) { |
|
508 | 508 | return; |
509 | 509 | } |
510 | 510 | |
511 | - if ( is_a( $id, 'WP_Fields_API_Section' ) ) { |
|
511 | + if (is_a($id, 'WP_Fields_API_Section')) { |
|
512 | 512 | $section = $id; |
513 | 513 | |
514 | 514 | $id = $section->id; |
@@ -517,19 +517,19 @@ discard block |
||
517 | 517 | $section = $args; |
518 | 518 | } |
519 | 519 | |
520 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
521 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
520 | + if (empty($object_name) && ! empty($object_type)) { |
|
521 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
522 | 522 | } |
523 | 523 | |
524 | - if ( ! isset( self::$sections[ $object_type ] ) ) { |
|
525 | - self::$sections[ $object_type ] = array(); |
|
524 | + if ( ! isset(self::$sections[$object_type])) { |
|
525 | + self::$sections[$object_type] = array(); |
|
526 | 526 | } |
527 | 527 | |
528 | - if ( ! isset( self::$sections[ $object_type ][ $object_name ] ) ) { |
|
529 | - self::$sections[ $object_type ][ $object_name ] = array(); |
|
528 | + if ( ! isset(self::$sections[$object_type][$object_name])) { |
|
529 | + self::$sections[$object_type][$object_name] = array(); |
|
530 | 530 | } |
531 | 531 | |
532 | - self::$sections[ $object_type ][ $object_name ][ $id ] = $section; |
|
532 | + self::$sections[$object_type][$object_name][$id] = $section; |
|
533 | 533 | |
534 | 534 | } |
535 | 535 | |
@@ -544,19 +544,19 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @return WP_Fields_API_Section|null Requested section instance. |
546 | 546 | */ |
547 | - public function get_section( $object_type, $id, $object_name = null ) { |
|
547 | + public function get_section($object_type, $id, $object_name = null) { |
|
548 | 548 | |
549 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
550 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
549 | + if (empty($object_name) && ! empty($object_type)) { |
|
550 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | $section = null; |
554 | 554 | |
555 | - if ( isset( self::$sections[ $object_type ][ $object_name ][ $id ] ) ) { |
|
555 | + if (isset(self::$sections[$object_type][$object_name][$id])) { |
|
556 | 556 | // Late init |
557 | - self::$sections[ $object_type ][ $object_name ][ $id ] = $this->setup_section( $object_type, $id, $object_name, self::$sections[ $object_type ][ $object_name ][ $id ] ); |
|
557 | + self::$sections[$object_type][$object_name][$id] = $this->setup_section($object_type, $id, $object_name, self::$sections[$object_type][$object_name][$id]); |
|
558 | 558 | |
559 | - $section = self::$sections[ $object_type ][ $object_name ][ $id ]; |
|
559 | + $section = self::$sections[$object_type][$object_name][$id]; |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | return $section; |
@@ -575,26 +575,26 @@ discard block |
||
575 | 575 | * |
576 | 576 | * @return WP_Fields_API_Screen|null $section The section object. |
577 | 577 | */ |
578 | - public function setup_section( $object_type, $id, $object_name = null, $args = null ) { |
|
578 | + public function setup_section($object_type, $id, $object_name = null, $args = null) { |
|
579 | 579 | |
580 | 580 | $section = null; |
581 | 581 | |
582 | 582 | $section_class = 'WP_Fields_API_Section'; |
583 | 583 | |
584 | - if ( is_a( $args, $section_class ) ) { |
|
584 | + if (is_a($args, $section_class)) { |
|
585 | 585 | $section = $args; |
586 | - } elseif ( is_array( $args ) ) { |
|
586 | + } elseif (is_array($args)) { |
|
587 | 587 | $args['object_name'] = $object_name; |
588 | 588 | |
589 | - if ( ! empty( $args['type'] ) ) { |
|
590 | - if ( ! empty( self::$registered_section_types[ $args['type'] ] ) ) { |
|
591 | - $section_class = self::$registered_section_types[ $args['type'] ]; |
|
592 | - } elseif ( in_array( $args['type'], self::$registered_section_types ) ) { |
|
589 | + if ( ! empty($args['type'])) { |
|
590 | + if ( ! empty(self::$registered_section_types[$args['type']])) { |
|
591 | + $section_class = self::$registered_section_types[$args['type']]; |
|
592 | + } elseif (in_array($args['type'], self::$registered_section_types)) { |
|
593 | 593 | $section_class = $args['type']; |
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | - $section = new $section_class( $object_type, $id, $args ); |
|
597 | + $section = new $section_class($object_type, $id, $args); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | return $section; |
@@ -610,29 +610,29 @@ discard block |
||
610 | 610 | * @param string $id Section ID to remove, set true to remove all sections from an object. |
611 | 611 | * @param string $object_name Object name (for post types and taxonomies), set true to remove to all objects from an object type. |
612 | 612 | */ |
613 | - public function remove_section( $object_type, $id, $object_name = null ) { |
|
613 | + public function remove_section($object_type, $id, $object_name = null) { |
|
614 | 614 | |
615 | - if ( true === $object_type ) { |
|
615 | + if (true === $object_type) { |
|
616 | 616 | // Remove all sections |
617 | 617 | self::$sections = array(); |
618 | - } elseif ( true === $object_name ) { |
|
618 | + } elseif (true === $object_name) { |
|
619 | 619 | // Remove all sections for an object type |
620 | - if ( isset( self::$sections[ $object_type ] ) ) { |
|
621 | - unset( self::$sections[ $object_type ] ); |
|
620 | + if (isset(self::$sections[$object_type])) { |
|
621 | + unset(self::$sections[$object_type]); |
|
622 | 622 | } |
623 | 623 | } else { |
624 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
625 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
624 | + if (empty($object_name) && ! empty($object_type)) { |
|
625 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
626 | 626 | } |
627 | 627 | |
628 | - if ( true === $id && null !== $object_name ) { |
|
628 | + if (true === $id && null !== $object_name) { |
|
629 | 629 | // Remove all sections for an object type |
630 | - if ( isset( self::$sections[ $object_type ][ $object_name ] ) ) { |
|
631 | - unset( self::$sections[ $object_type ][ $object_name ] ); |
|
630 | + if (isset(self::$sections[$object_type][$object_name])) { |
|
631 | + unset(self::$sections[$object_type][$object_name]); |
|
632 | 632 | } |
633 | - } elseif ( isset( self::$sections[ $object_type ][ $object_name ][ $id ] ) ) { |
|
633 | + } elseif (isset(self::$sections[$object_type][$object_name][$id])) { |
|
634 | 634 | // Remove section from object type and name |
635 | - unset( self::$sections[ $object_type ][ $object_name ][ $id ] ); |
|
635 | + unset(self::$sections[$object_type][$object_name][$id]); |
|
636 | 636 | } |
637 | 637 | } |
638 | 638 | |
@@ -648,13 +648,13 @@ discard block |
||
648 | 648 | * @param string $type Section type ID. |
649 | 649 | * @param string $section_class Name of a custom section which is a subclass of WP_Fields_API_Section. |
650 | 650 | */ |
651 | - public function register_section_type( $type, $section_class = null ) { |
|
651 | + public function register_section_type($type, $section_class = null) { |
|
652 | 652 | |
653 | - if ( null === $section_class ) { |
|
653 | + if (null === $section_class) { |
|
654 | 654 | $section_class = $type; |
655 | 655 | } |
656 | 656 | |
657 | - self::$registered_section_types[ $type ] = $section_class; |
|
657 | + self::$registered_section_types[$type] = $section_class; |
|
658 | 658 | |
659 | 659 | } |
660 | 660 | |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | /** |
669 | 669 | * @var $section WP_Fields_API_Section |
670 | 670 | */ |
671 | - foreach ( self::$registered_control_types as $section_type => $section_class ) { |
|
672 | - $section = $this->setup_section( null, 'temp', null, array( 'type' => $section_type ) ); |
|
671 | + foreach (self::$registered_control_types as $section_type => $section_class) { |
|
672 | + $section = $this->setup_section(null, 'temp', null, array('type' => $section_type)); |
|
673 | 673 | |
674 | 674 | $section->print_template(); |
675 | 675 | } |
@@ -686,37 +686,37 @@ discard block |
||
686 | 686 | * |
687 | 687 | * @return WP_Fields_API_Field[] |
688 | 688 | */ |
689 | - public function get_fields( $object_type = null, $object_name = null ) { |
|
689 | + public function get_fields($object_type = null, $object_name = null) { |
|
690 | 690 | |
691 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
692 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
691 | + if (empty($object_name) && ! empty($object_type)) { |
|
692 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | $fields = array(); |
696 | 696 | |
697 | - if ( null === $object_type ) { |
|
697 | + if (null === $object_type) { |
|
698 | 698 | // Late init |
699 | - foreach ( self::$fields as $object_type => $object_names ) { |
|
700 | - foreach ( $object_names as $object_name => $fields ) { |
|
701 | - $this->get_fields( $object_type, $object_name ); |
|
699 | + foreach (self::$fields as $object_type => $object_names) { |
|
700 | + foreach ($object_names as $object_name => $fields) { |
|
701 | + $this->get_fields($object_type, $object_name); |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | |
705 | 705 | $fields = self::$fields; |
706 | - } elseif ( isset( self::$fields[ $object_type ][ $object_name ] ) ) { |
|
706 | + } elseif (isset(self::$fields[$object_type][$object_name])) { |
|
707 | 707 | // Late init |
708 | - foreach ( self::$fields[ $object_type ][ $object_name ] as $id => $field ) { |
|
708 | + foreach (self::$fields[$object_type][$object_name] as $id => $field) { |
|
709 | 709 | // Late init |
710 | - self::$fields[ $object_type ][ $object_name ][ $id ] = $this->setup_field( $object_type, $id, $object_name, $field ); |
|
710 | + self::$fields[$object_type][$object_name][$id] = $this->setup_field($object_type, $id, $object_name, $field); |
|
711 | 711 | } |
712 | 712 | |
713 | - $fields = self::$fields[ $object_type ][ $object_name ]; |
|
714 | - } elseif ( true === $object_name ) { |
|
713 | + $fields = self::$fields[$object_type][$object_name]; |
|
714 | + } elseif (true === $object_name) { |
|
715 | 715 | // Get all fields |
716 | 716 | |
717 | 717 | // Late init |
718 | - foreach ( self::$fields[ $object_type ] as $object_name => $object_fields ) { |
|
719 | - $fields = array_merge( $fields, array_values( $this->get_fields( $object_type, $object_name ) ) ); |
|
718 | + foreach (self::$fields[$object_type] as $object_name => $object_fields) { |
|
719 | + $fields = array_merge($fields, array_values($this->get_fields($object_type, $object_name))); |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
@@ -735,15 +735,15 @@ discard block |
||
735 | 735 | * @param array $args Field arguments; passed to WP_Fields_API_Field |
736 | 736 | * constructor. |
737 | 737 | */ |
738 | - public function add_field( $object_type, $id, $object_name = null, $args = array() ) { |
|
738 | + public function add_field($object_type, $id, $object_name = null, $args = array()) { |
|
739 | 739 | |
740 | - if ( empty( $id ) && empty( $args ) ) { |
|
740 | + if (empty($id) && empty($args)) { |
|
741 | 741 | return; |
742 | 742 | } |
743 | 743 | |
744 | 744 | $control = array(); |
745 | 745 | |
746 | - if ( is_a( $id, 'WP_Fields_API_Field' ) ) { |
|
746 | + if (is_a($id, 'WP_Fields_API_Field')) { |
|
747 | 747 | $field = $id; |
748 | 748 | |
749 | 749 | $id = $field->id; |
@@ -751,46 +751,46 @@ discard block |
||
751 | 751 | // Save for late init |
752 | 752 | $field = $args; |
753 | 753 | |
754 | - if ( isset( $field['control'] ) ) { |
|
754 | + if (isset($field['control'])) { |
|
755 | 755 | $control = $field['control']; |
756 | 756 | |
757 | 757 | // Remove from field args |
758 | - unset( $field['control'] ); |
|
758 | + unset($field['control']); |
|
759 | 759 | } |
760 | 760 | } |
761 | 761 | |
762 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
763 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
762 | + if (empty($object_name) && ! empty($object_type)) { |
|
763 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
764 | 764 | } |
765 | 765 | |
766 | - if ( ! isset( self::$fields[ $object_type ] ) ) { |
|
767 | - self::$fields[ $object_type ] = array(); |
|
766 | + if ( ! isset(self::$fields[$object_type])) { |
|
767 | + self::$fields[$object_type] = array(); |
|
768 | 768 | } |
769 | 769 | |
770 | - if ( ! isset( self::$fields[ $object_type ][ $object_name ] ) ) { |
|
771 | - self::$fields[ $object_type ][ $object_name ] = array(); |
|
770 | + if ( ! isset(self::$fields[$object_type][$object_name])) { |
|
771 | + self::$fields[$object_type][$object_name] = array(); |
|
772 | 772 | } |
773 | 773 | |
774 | - self::$fields[ $object_type ][ $object_name ][ $id ] = $field; |
|
774 | + self::$fields[$object_type][$object_name][$id] = $field; |
|
775 | 775 | |
776 | 776 | // Control handling |
777 | - if ( ! empty( $control ) ) { |
|
777 | + if ( ! empty($control)) { |
|
778 | 778 | // Generate Control ID if not set |
779 | - if ( empty( $control['id'] ) ) { |
|
780 | - $control['id'] = 'control_' . sanitize_key( $object_type ) . '_' . sanitize_key( $object_name ) . '_' . sanitize_key( $id ); |
|
779 | + if (empty($control['id'])) { |
|
780 | + $control['id'] = 'control_'.sanitize_key($object_type).'_'.sanitize_key($object_name).'_'.sanitize_key($id); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | // Get Control ID |
784 | 784 | $control_id = $control['id']; |
785 | 785 | |
786 | 786 | // Remove ID from control args |
787 | - unset( $control['id'] ); |
|
787 | + unset($control['id']); |
|
788 | 788 | |
789 | 789 | // Add field |
790 | 790 | $control['fields'] = $id; |
791 | 791 | |
792 | 792 | // Add control for field |
793 | - $this->add_control( $object_type, $control_id, $object_name, $control ); |
|
793 | + $this->add_control($object_type, $control_id, $object_name, $control); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | } |
@@ -806,19 +806,19 @@ discard block |
||
806 | 806 | * |
807 | 807 | * @return WP_Fields_API_Field|null |
808 | 808 | */ |
809 | - public function get_field( $object_type, $id, $object_name = null ) { |
|
809 | + public function get_field($object_type, $id, $object_name = null) { |
|
810 | 810 | |
811 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
812 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
811 | + if (empty($object_name) && ! empty($object_type)) { |
|
812 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | $field = null; |
816 | 816 | |
817 | - if ( isset( self::$fields[ $object_type ][ $object_name ][ $id ] ) ) { |
|
817 | + if (isset(self::$fields[$object_type][$object_name][$id])) { |
|
818 | 818 | // Late init |
819 | - self::$fields[ $object_type ][ $object_name ][ $id ] = $this->setup_field( $object_type, $id, $object_name, self::$fields[ $object_type ][ $object_name ][ $id ] ); |
|
819 | + self::$fields[$object_type][$object_name][$id] = $this->setup_field($object_type, $id, $object_name, self::$fields[$object_type][$object_name][$id]); |
|
820 | 820 | |
821 | - $field = self::$fields[ $object_type ][ $object_name ][ $id ]; |
|
821 | + $field = self::$fields[$object_type][$object_name][$id]; |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | return $field; |
@@ -837,26 +837,26 @@ discard block |
||
837 | 837 | * |
838 | 838 | * @return WP_Fields_API_Screen|null $field The field object. |
839 | 839 | */ |
840 | - public function setup_field( $object_type, $id, $object_name = null, $args = null ) { |
|
840 | + public function setup_field($object_type, $id, $object_name = null, $args = null) { |
|
841 | 841 | |
842 | 842 | $field = null; |
843 | 843 | |
844 | 844 | $field_class = 'WP_Fields_API_Field'; |
845 | 845 | |
846 | - if ( is_a( $args, $field_class ) ) { |
|
846 | + if (is_a($args, $field_class)) { |
|
847 | 847 | $field = $args; |
848 | - } elseif ( is_array( $args ) ) { |
|
848 | + } elseif (is_array($args)) { |
|
849 | 849 | $args['object_name'] = $object_name; |
850 | 850 | |
851 | - if ( ! empty( $args['type'] ) ) { |
|
852 | - if ( ! empty( self::$registered_field_types[ $args['type'] ] ) ) { |
|
853 | - $field_class = self::$registered_field_types[ $args['type'] ]; |
|
854 | - } elseif ( in_array( $args['type'], self::$registered_field_types ) ) { |
|
851 | + if ( ! empty($args['type'])) { |
|
852 | + if ( ! empty(self::$registered_field_types[$args['type']])) { |
|
853 | + $field_class = self::$registered_field_types[$args['type']]; |
|
854 | + } elseif (in_array($args['type'], self::$registered_field_types)) { |
|
855 | 855 | $field_class = $args['type']; |
856 | 856 | } |
857 | 857 | } |
858 | 858 | |
859 | - $field = new $field_class( $object_type, $id, $args ); |
|
859 | + $field = new $field_class($object_type, $id, $args); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | return $field; |
@@ -872,29 +872,29 @@ discard block |
||
872 | 872 | * @param string $id Field ID to remove, set true to remove all fields from an object. |
873 | 873 | * @param string $object_name Object name (for post types and taxonomies), set true to remove to all objects from an object type. |
874 | 874 | */ |
875 | - public function remove_field( $object_type, $id, $object_name = null ) { |
|
875 | + public function remove_field($object_type, $id, $object_name = null) { |
|
876 | 876 | |
877 | - if ( true === $object_type ) { |
|
877 | + if (true === $object_type) { |
|
878 | 878 | // Remove all fields |
879 | 879 | self::$fields = array(); |
880 | - } elseif ( true === $object_name ) { |
|
880 | + } elseif (true === $object_name) { |
|
881 | 881 | // Remove all fields for an object type |
882 | - if ( isset( self::$fields[ $object_type ] ) ) { |
|
883 | - unset( self::$fields[ $object_type ] ); |
|
882 | + if (isset(self::$fields[$object_type])) { |
|
883 | + unset(self::$fields[$object_type]); |
|
884 | 884 | } |
885 | 885 | } else { |
886 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
887 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
886 | + if (empty($object_name) && ! empty($object_type)) { |
|
887 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
888 | 888 | } |
889 | 889 | |
890 | - if ( true === $id && null !== $object_name ) { |
|
890 | + if (true === $id && null !== $object_name) { |
|
891 | 891 | // Remove all fields for an object type |
892 | - if ( isset( self::$fields[ $object_type ][ $object_name ] ) ) { |
|
893 | - unset( self::$fields[ $object_type ][ $object_name ] ); |
|
892 | + if (isset(self::$fields[$object_type][$object_name])) { |
|
893 | + unset(self::$fields[$object_type][$object_name]); |
|
894 | 894 | } |
895 | - } elseif ( isset( self::$fields[ $object_type ][ $object_name ][ $id ] ) ) { |
|
895 | + } elseif (isset(self::$fields[$object_type][$object_name][$id])) { |
|
896 | 896 | // Remove field from object type and name |
897 | - unset( self::$fields[ $object_type ][ $object_name ][ $id ] ); |
|
897 | + unset(self::$fields[$object_type][$object_name][$id]); |
|
898 | 898 | } |
899 | 899 | } |
900 | 900 | |
@@ -910,13 +910,13 @@ discard block |
||
910 | 910 | * @param string $type Field type ID. |
911 | 911 | * @param string $screen_class Name of a custom field type which is a subclass of WP_Fields_API_Field. |
912 | 912 | */ |
913 | - public function register_field_type( $type, $field_class = null ) { |
|
913 | + public function register_field_type($type, $field_class = null) { |
|
914 | 914 | |
915 | - if ( null === $field_class ) { |
|
915 | + if (null === $field_class) { |
|
916 | 916 | $field_class = $type; |
917 | 917 | } |
918 | 918 | |
919 | - self::$registered_field_types[ $type ] = $field_class; |
|
919 | + self::$registered_field_types[$type] = $field_class; |
|
920 | 920 | |
921 | 921 | } |
922 | 922 | |
@@ -931,41 +931,41 @@ discard block |
||
931 | 931 | * |
932 | 932 | * @return WP_Fields_API_Control[] |
933 | 933 | */ |
934 | - public function get_controls( $object_type = null, $object_name = null, $section = null ) { |
|
934 | + public function get_controls($object_type = null, $object_name = null, $section = null) { |
|
935 | 935 | |
936 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
937 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
936 | + if (empty($object_name) && ! empty($object_type)) { |
|
937 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | $controls = array(); |
941 | 941 | |
942 | - if ( null === $object_type ) { |
|
942 | + if (null === $object_type) { |
|
943 | 943 | // Late init |
944 | - foreach ( self::$controls as $object_type => $object_names ) { |
|
945 | - foreach ( $object_names as $object_name => $controls ) { |
|
946 | - $this->get_controls( $object_type, $object_name ); |
|
944 | + foreach (self::$controls as $object_type => $object_names) { |
|
945 | + foreach ($object_names as $object_name => $controls) { |
|
946 | + $this->get_controls($object_type, $object_name); |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | |
950 | 950 | $controls = self::$controls; |
951 | 951 | |
952 | 952 | // Get only controls for a specific section |
953 | - if ( null !== $section ) { |
|
953 | + if (null !== $section) { |
|
954 | 954 | $section_controls = array(); |
955 | 955 | |
956 | - foreach ( $controls as $object_type => $object_names ) { |
|
957 | - foreach ( $object_names as $object_name => $object_controls ) { |
|
958 | - foreach ( $object_controls as $id => $control ) { |
|
959 | - if ( $section == $control->section->id ) { |
|
960 | - if ( ! isset( $section_controls[ $object_type ] ) ) { |
|
961 | - $section_controls[ $object_type ] = array(); |
|
956 | + foreach ($controls as $object_type => $object_names) { |
|
957 | + foreach ($object_names as $object_name => $object_controls) { |
|
958 | + foreach ($object_controls as $id => $control) { |
|
959 | + if ($section == $control->section->id) { |
|
960 | + if ( ! isset($section_controls[$object_type])) { |
|
961 | + $section_controls[$object_type] = array(); |
|
962 | 962 | } |
963 | 963 | |
964 | - if ( ! isset( $section_controls[ $object_type ][ $object_name ] ) ) { |
|
965 | - $section_controls[ $object_type ][ $object_name ] = array(); |
|
964 | + if ( ! isset($section_controls[$object_type][$object_name])) { |
|
965 | + $section_controls[$object_type][$object_name] = array(); |
|
966 | 966 | } |
967 | 967 | |
968 | - $section_controls[ $object_type ][ $object_name ][ $id ] = $control; |
|
968 | + $section_controls[$object_type][$object_name][$id] = $control; |
|
969 | 969 | } |
970 | 970 | } |
971 | 971 | } |
@@ -973,34 +973,34 @@ discard block |
||
973 | 973 | |
974 | 974 | $controls = $section_controls; |
975 | 975 | } |
976 | - } elseif ( isset( self::$controls[ $object_type ][ $object_name ] ) ) { |
|
976 | + } elseif (isset(self::$controls[$object_type][$object_name])) { |
|
977 | 977 | // Late init |
978 | - foreach ( self::$controls[ $object_type ][ $object_name ] as $id => $control ) { |
|
978 | + foreach (self::$controls[$object_type][$object_name] as $id => $control) { |
|
979 | 979 | // Late init |
980 | - self::$controls[ $object_type ][ $object_name ][ $id ] = $this->setup_control( $object_type, $id, $object_name, $control ); |
|
980 | + self::$controls[$object_type][$object_name][$id] = $this->setup_control($object_type, $id, $object_name, $control); |
|
981 | 981 | } |
982 | 982 | |
983 | - $controls = self::$controls[ $object_type ][ $object_name ]; |
|
983 | + $controls = self::$controls[$object_type][$object_name]; |
|
984 | 984 | |
985 | 985 | // Get only controls for a specific section |
986 | - if ( null !== $section ) { |
|
986 | + if (null !== $section) { |
|
987 | 987 | $section_controls = array(); |
988 | 988 | |
989 | - foreach ( $controls as $id => $control ) { |
|
989 | + foreach ($controls as $id => $control) { |
|
990 | 990 | // $control->section is not an object, like $control->field is |
991 | - if ( $section == $control->section ) { |
|
992 | - $section_controls[ $id ] = $control; |
|
991 | + if ($section == $control->section) { |
|
992 | + $section_controls[$id] = $control; |
|
993 | 993 | } |
994 | 994 | } |
995 | 995 | |
996 | 996 | $controls = $section_controls; |
997 | 997 | } |
998 | - } elseif ( true === $object_name ) { |
|
998 | + } elseif (true === $object_name) { |
|
999 | 999 | // Get all fields |
1000 | 1000 | |
1001 | 1001 | // Late init |
1002 | - foreach ( self::$controls[ $object_type ] as $object_name => $object_controls ) { |
|
1003 | - $controls = array_merge( $controls, array_values( $this->get_controls( $object_type, $object_name, $section ) ) ); |
|
1002 | + foreach (self::$controls[$object_type] as $object_name => $object_controls) { |
|
1003 | + $controls = array_merge($controls, array_values($this->get_controls($object_type, $object_name, $section))); |
|
1004 | 1004 | } |
1005 | 1005 | } |
1006 | 1006 | |
@@ -1019,13 +1019,13 @@ discard block |
||
1019 | 1019 | * @param array $args Control arguments; passed to WP_Fields_API_Control |
1020 | 1020 | * constructor. |
1021 | 1021 | */ |
1022 | - public function add_control( $object_type, $id, $object_name = null, $args = array() ) { |
|
1022 | + public function add_control($object_type, $id, $object_name = null, $args = array()) { |
|
1023 | 1023 | |
1024 | - if ( empty( $id ) && empty( $args ) ) { |
|
1024 | + if (empty($id) && empty($args)) { |
|
1025 | 1025 | return; |
1026 | 1026 | } |
1027 | 1027 | |
1028 | - if ( is_a( $id, 'WP_Fields_API_Control' ) ) { |
|
1028 | + if (is_a($id, 'WP_Fields_API_Control')) { |
|
1029 | 1029 | $control = $id; |
1030 | 1030 | |
1031 | 1031 | $id = $control->id; |
@@ -1034,19 +1034,19 @@ discard block |
||
1034 | 1034 | $control = $args; |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
1038 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
1037 | + if (empty($object_name) && ! empty($object_type)) { |
|
1038 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | - if ( ! isset( self::$controls[ $object_type ] ) ) { |
|
1042 | - self::$controls[ $object_type ] = array(); |
|
1041 | + if ( ! isset(self::$controls[$object_type])) { |
|
1042 | + self::$controls[$object_type] = array(); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | - if ( ! isset( self::$controls[ $object_type ][ $object_name ] ) ) { |
|
1046 | - self::$controls[ $object_type ][ $object_name ] = array(); |
|
1045 | + if ( ! isset(self::$controls[$object_type][$object_name])) { |
|
1046 | + self::$controls[$object_type][$object_name] = array(); |
|
1047 | 1047 | } |
1048 | 1048 | |
1049 | - self::$controls[ $object_type ][ $object_name ][ $id ] = $control; |
|
1049 | + self::$controls[$object_type][$object_name][$id] = $control; |
|
1050 | 1050 | |
1051 | 1051 | } |
1052 | 1052 | |
@@ -1061,19 +1061,19 @@ discard block |
||
1061 | 1061 | * |
1062 | 1062 | * @return WP_Fields_API_Control|null $control The control object. |
1063 | 1063 | */ |
1064 | - public function get_control( $object_type, $id, $object_name = null ) { |
|
1064 | + public function get_control($object_type, $id, $object_name = null) { |
|
1065 | 1065 | |
1066 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
1067 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
1066 | + if (empty($object_name) && ! empty($object_type)) { |
|
1067 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | $control = null; |
1071 | 1071 | |
1072 | - if ( isset( self::$controls[ $object_type ][ $object_name ][ $id ] ) ) { |
|
1072 | + if (isset(self::$controls[$object_type][$object_name][$id])) { |
|
1073 | 1073 | // Late init |
1074 | - self::$controls[ $object_type ][ $object_name ][ $id ] = $this->setup_control( $object_type, $id, $object_name, self::$controls[ $object_type ][ $object_name ][ $id ] ); |
|
1074 | + self::$controls[$object_type][$object_name][$id] = $this->setup_control($object_type, $id, $object_name, self::$controls[$object_type][$object_name][$id]); |
|
1075 | 1075 | |
1076 | - $control = self::$controls[ $object_type ][ $object_name ][ $id ]; |
|
1076 | + $control = self::$controls[$object_type][$object_name][$id]; |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | return $control; |
@@ -1092,26 +1092,26 @@ discard block |
||
1092 | 1092 | * |
1093 | 1093 | * @return WP_Fields_API_Control|null $control The control object. |
1094 | 1094 | */ |
1095 | - public function setup_control( $object_type, $id, $object_name = null, $args = null ) { |
|
1095 | + public function setup_control($object_type, $id, $object_name = null, $args = null) { |
|
1096 | 1096 | |
1097 | 1097 | $control = null; |
1098 | 1098 | |
1099 | 1099 | $control_class = 'WP_Fields_API_Control'; |
1100 | 1100 | |
1101 | - if ( is_a( $args, $control_class ) ) { |
|
1101 | + if (is_a($args, $control_class)) { |
|
1102 | 1102 | $control = $args; |
1103 | - } elseif ( is_array( $args ) ) { |
|
1103 | + } elseif (is_array($args)) { |
|
1104 | 1104 | $args['object_name'] = $object_name; |
1105 | 1105 | |
1106 | - if ( ! empty( $args['type'] ) ) { |
|
1107 | - if ( ! empty( self::$registered_control_types[ $args['type'] ] ) ) { |
|
1108 | - $control_class = self::$registered_control_types[ $args['type'] ]; |
|
1109 | - } elseif ( in_array( $args['type'], self::$registered_control_types ) ) { |
|
1106 | + if ( ! empty($args['type'])) { |
|
1107 | + if ( ! empty(self::$registered_control_types[$args['type']])) { |
|
1108 | + $control_class = self::$registered_control_types[$args['type']]; |
|
1109 | + } elseif (in_array($args['type'], self::$registered_control_types)) { |
|
1110 | 1110 | $control_class = $args['type']; |
1111 | 1111 | } |
1112 | 1112 | } |
1113 | 1113 | |
1114 | - $control = new $control_class( $object_type, $id, $args ); |
|
1114 | + $control = new $control_class($object_type, $id, $args); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | return $control; |
@@ -1127,29 +1127,29 @@ discard block |
||
1127 | 1127 | * @param string $id Control ID to remove, set true to remove all controls from an object. |
1128 | 1128 | * @param string $object_name Object name (for post types and taxonomies), set true to remove to all objects from an object type. |
1129 | 1129 | */ |
1130 | - public function remove_control( $object_type, $id, $object_name = null ) { |
|
1130 | + public function remove_control($object_type, $id, $object_name = null) { |
|
1131 | 1131 | |
1132 | - if ( true === $object_type ) { |
|
1132 | + if (true === $object_type) { |
|
1133 | 1133 | // Remove all controls |
1134 | 1134 | self::$controls = array(); |
1135 | - } elseif ( true === $object_name ) { |
|
1135 | + } elseif (true === $object_name) { |
|
1136 | 1136 | // Remove all controls for an object type |
1137 | - if ( isset( self::$controls[ $object_type ] ) ) { |
|
1138 | - unset( self::$controls[ $object_type ] ); |
|
1137 | + if (isset(self::$controls[$object_type])) { |
|
1138 | + unset(self::$controls[$object_type]); |
|
1139 | 1139 | } |
1140 | 1140 | } else { |
1141 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
1142 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
1141 | + if (empty($object_name) && ! empty($object_type)) { |
|
1142 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
1143 | 1143 | } |
1144 | 1144 | |
1145 | - if ( true === $id && null !== $object_name ) { |
|
1145 | + if (true === $id && null !== $object_name) { |
|
1146 | 1146 | // Remove all controls for an object type |
1147 | - if ( isset( self::$controls[ $object_type ][ $object_name ] ) ) { |
|
1148 | - unset( self::$controls[ $object_type ][ $object_name ] ); |
|
1147 | + if (isset(self::$controls[$object_type][$object_name])) { |
|
1148 | + unset(self::$controls[$object_type][$object_name]); |
|
1149 | 1149 | } |
1150 | - } elseif ( isset( self::$controls[ $object_type ][ $object_name ][ $id ] ) ) { |
|
1150 | + } elseif (isset(self::$controls[$object_type][$object_name][$id])) { |
|
1151 | 1151 | // Remove control from object type and name |
1152 | - unset( self::$controls[ $object_type ][ $object_name ][ $id ] ); |
|
1152 | + unset(self::$controls[$object_type][$object_name][$id]); |
|
1153 | 1153 | } |
1154 | 1154 | } |
1155 | 1155 | |
@@ -1165,13 +1165,13 @@ discard block |
||
1165 | 1165 | * @param string $type Control type ID. |
1166 | 1166 | * @param string $control_class Name of a custom control which is a subclass of WP_Fields_API_Control. |
1167 | 1167 | */ |
1168 | - public function register_control_type( $type, $control_class = null ) { |
|
1168 | + public function register_control_type($type, $control_class = null) { |
|
1169 | 1169 | |
1170 | - if ( null === $control_class ) { |
|
1170 | + if (null === $control_class) { |
|
1171 | 1171 | $control_class = $type; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | - self::$registered_control_types[ $type ] = $control_class; |
|
1174 | + self::$registered_control_types[$type] = $control_class; |
|
1175 | 1175 | |
1176 | 1176 | } |
1177 | 1177 | |
@@ -1185,8 +1185,8 @@ discard block |
||
1185 | 1185 | /** |
1186 | 1186 | * @var $control WP_Fields_API_Control |
1187 | 1187 | */ |
1188 | - foreach ( self::$registered_control_types as $control_type => $control_class ) { |
|
1189 | - $control = $this->setup_control( null, 'temp', null, array( 'type' => $control_type ) ); |
|
1188 | + foreach (self::$registered_control_types as $control_type => $control_class) { |
|
1189 | + $control = $this->setup_control(null, 'temp', null, array('type' => $control_type)); |
|
1190 | 1190 | |
1191 | 1191 | $control->print_template(); |
1192 | 1192 | } |
@@ -1203,13 +1203,13 @@ discard block |
||
1203 | 1203 | * |
1204 | 1204 | * @return int |
1205 | 1205 | */ |
1206 | - protected final function _cmp_priority( $a, $b ) { |
|
1206 | + protected final function _cmp_priority($a, $b) { |
|
1207 | 1207 | |
1208 | - if ( is_int( $a->priority ) && is_int( $b->priority ) ) { |
|
1208 | + if (is_int($a->priority) && is_int($b->priority)) { |
|
1209 | 1209 | // Priority integers |
1210 | 1210 | $compare = $a->priority - $b->priority; |
1211 | 1211 | |
1212 | - if ( $a->priority === $b->priority ) { |
|
1212 | + if ($a->priority === $b->priority) { |
|
1213 | 1213 | $compare = $a->instance_number - $a->instance_number; |
1214 | 1214 | } |
1215 | 1215 | } else { |
@@ -1232,13 +1232,13 @@ discard block |
||
1232 | 1232 | * |
1233 | 1233 | * @param string $object_type Object type. |
1234 | 1234 | */ |
1235 | - public function prepare_controls( $object_type = null ) { |
|
1235 | + public function prepare_controls($object_type = null) { |
|
1236 | 1236 | |
1237 | 1237 | // Prepare controls for all object types |
1238 | - foreach ( self::$fields as $object => $object_names ) { |
|
1239 | - if ( null === $object_type || $object === $object_type ) { |
|
1240 | - foreach ( $object_names as $object_name => $fields ) { |
|
1241 | - $this->prepare_object_controls( $object, $object_name ); |
|
1238 | + foreach (self::$fields as $object => $object_names) { |
|
1239 | + if (null === $object_type || $object === $object_type) { |
|
1240 | + foreach ($object_names as $object_name => $fields) { |
|
1241 | + $this->prepare_object_controls($object, $object_name); |
|
1242 | 1242 | } |
1243 | 1243 | } |
1244 | 1244 | } |
@@ -1257,10 +1257,10 @@ discard block |
||
1257 | 1257 | * @param string $object_type Object type. |
1258 | 1258 | * @param string $object_name Object name (for post types and taxonomies). |
1259 | 1259 | */ |
1260 | - public function prepare_object_controls( $object_type, $object_name = null ) { |
|
1260 | + public function prepare_object_controls($object_type, $object_name = null) { |
|
1261 | 1261 | |
1262 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
1263 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
1262 | + if (empty($object_name) && ! empty($object_type)) { |
|
1263 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | // Reset prepared IDs |
@@ -1274,69 +1274,69 @@ discard block |
||
1274 | 1274 | // Setup |
1275 | 1275 | |
1276 | 1276 | // Get controls |
1277 | - $controls = $this->get_controls( $object_type, $object_name ); |
|
1277 | + $controls = $this->get_controls($object_type, $object_name); |
|
1278 | 1278 | |
1279 | 1279 | // Get sections |
1280 | - $sections = $this->get_sections( $object_type, $object_name ); |
|
1280 | + $sections = $this->get_sections($object_type, $object_name); |
|
1281 | 1281 | |
1282 | 1282 | // Get screens |
1283 | - $screens = $this->get_screens( $object_type, $object_name ); |
|
1283 | + $screens = $this->get_screens($object_type, $object_name); |
|
1284 | 1284 | |
1285 | 1285 | // Controls |
1286 | 1286 | |
1287 | 1287 | // Sort controls by priority |
1288 | - uasort( $controls, array( $this, '_cmp_priority' ) ); |
|
1288 | + uasort($controls, array($this, '_cmp_priority')); |
|
1289 | 1289 | |
1290 | - foreach ( $controls as $id => $control ) { |
|
1290 | + foreach ($controls as $id => $control) { |
|
1291 | 1291 | // Check if section or screen exists |
1292 | - if ( $control->section && ! isset( $sections[ $control->section ] ) ) { |
|
1292 | + if ($control->section && ! isset($sections[$control->section])) { |
|
1293 | 1293 | continue; |
1294 | - } elseif ( $control->screen && ! isset( $screens[ $control->screen ] ) ) { |
|
1294 | + } elseif ($control->screen && ! isset($screens[$control->screen])) { |
|
1295 | 1295 | continue; |
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | // Check if control can be used by user |
1299 | - if ( ! $control->check_capabilities() ) { |
|
1299 | + if ( ! $control->check_capabilities()) { |
|
1300 | 1300 | continue; |
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | // Add to prepared IDs |
1304 | 1304 | $prepared_ids['control'][] = $id; |
1305 | 1305 | |
1306 | - if ( $control->section ) { |
|
1306 | + if ($control->section) { |
|
1307 | 1307 | // Add control to section controls |
1308 | - $sections[ $control->section ]->controls[] = $control; |
|
1309 | - } elseif ( $control->screen ) { |
|
1308 | + $sections[$control->section]->controls[] = $control; |
|
1309 | + } elseif ($control->screen) { |
|
1310 | 1310 | // Add control to screen controls |
1311 | - $screens[ $control->screen ]->controls[] = $control; |
|
1311 | + $screens[$control->screen]->controls[] = $control; |
|
1312 | 1312 | } |
1313 | 1313 | } |
1314 | 1314 | |
1315 | 1315 | // Sections |
1316 | 1316 | |
1317 | 1317 | // Sort sections by priority |
1318 | - uasort( $sections, array( $this, '_cmp_priority' ) ); |
|
1318 | + uasort($sections, array($this, '_cmp_priority')); |
|
1319 | 1319 | |
1320 | - foreach ( $sections as $id => $section ) { |
|
1320 | + foreach ($sections as $id => $section) { |
|
1321 | 1321 | // Check if section can be seen by user |
1322 | - if ( ! $section->check_capabilities() ) { |
|
1322 | + if ( ! $section->check_capabilities()) { |
|
1323 | 1323 | continue; |
1324 | 1324 | } |
1325 | 1325 | |
1326 | - if ( $section->controls ) { |
|
1326 | + if ($section->controls) { |
|
1327 | 1327 | // Sort section controls by priority |
1328 | - usort( $section->controls, array( $this, '_cmp_priority' ) ); |
|
1328 | + usort($section->controls, array($this, '_cmp_priority')); |
|
1329 | 1329 | } |
1330 | 1330 | |
1331 | - if ( ! $section->screen ) { |
|
1331 | + if ( ! $section->screen) { |
|
1332 | 1332 | // Top-level section. |
1333 | 1333 | |
1334 | 1334 | // Add to prepared IDs |
1335 | 1335 | $prepared_ids['section'][] = $id; |
1336 | 1336 | $prepared_ids['container'][] = $id; |
1337 | - } elseif ( $section->screen && isset( $screens[ $section->screen ] ) ) { |
|
1337 | + } elseif ($section->screen && isset($screens[$section->screen])) { |
|
1338 | 1338 | // This section belongs to a screen. |
1339 | - $screens[ $section->screen ]->sections[ $id ] = $section; |
|
1339 | + $screens[$section->screen]->sections[$id] = $section; |
|
1340 | 1340 | |
1341 | 1341 | // Add to prepared IDs |
1342 | 1342 | $prepared_ids['section'][] = $id; |
@@ -1347,17 +1347,17 @@ discard block |
||
1347 | 1347 | // Screens |
1348 | 1348 | |
1349 | 1349 | // Sort screens by priority |
1350 | - uasort( $screens, array( $this, '_cmp_priority' ) ); |
|
1350 | + uasort($screens, array($this, '_cmp_priority')); |
|
1351 | 1351 | |
1352 | - foreach ( $screens as $id => $screen ) { |
|
1352 | + foreach ($screens as $id => $screen) { |
|
1353 | 1353 | // Check if screen has sections or can be seen by user |
1354 | - if ( ! $screen->check_capabilities() ) { |
|
1354 | + if ( ! $screen->check_capabilities()) { |
|
1355 | 1355 | continue; |
1356 | 1356 | } |
1357 | 1357 | |
1358 | - if ( $screen->sections ) { |
|
1358 | + if ($screen->sections) { |
|
1359 | 1359 | // Sort screen sections by priority |
1360 | - uasort( $screen->sections, array( $this, '_cmp_priority' ) ); |
|
1360 | + uasort($screen->sections, array($this, '_cmp_priority')); |
|
1361 | 1361 | } |
1362 | 1362 | |
1363 | 1363 | // Add to prepared IDs |
@@ -1366,67 +1366,67 @@ discard block |
||
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | // Merge screens and top-level sections together. |
1369 | - $containers = array_merge( $screens, $sections ); |
|
1369 | + $containers = array_merge($screens, $sections); |
|
1370 | 1370 | |
1371 | 1371 | // Sort containers by priority |
1372 | - uasort( $containers, array( $this, '_cmp_priority' ) ); |
|
1372 | + uasort($containers, array($this, '_cmp_priority')); |
|
1373 | 1373 | |
1374 | 1374 | // Saving |
1375 | 1375 | |
1376 | 1376 | // Save controls |
1377 | - if ( ! isset( self::$controls[ $object_type ] ) ) { |
|
1378 | - self::$controls[ $object_type ] = array(); |
|
1377 | + if ( ! isset(self::$controls[$object_type])) { |
|
1378 | + self::$controls[$object_type] = array(); |
|
1379 | 1379 | } |
1380 | 1380 | |
1381 | - if ( ! isset( self::$controls[ $object_type ][ $object_name ] ) ) { |
|
1382 | - self::$controls[ $object_type ][ $object_name ] = array(); |
|
1381 | + if ( ! isset(self::$controls[$object_type][$object_name])) { |
|
1382 | + self::$controls[$object_type][$object_name] = array(); |
|
1383 | 1383 | } |
1384 | 1384 | |
1385 | - self::$controls[ $object_type ][ $object_name ] = $controls; |
|
1385 | + self::$controls[$object_type][$object_name] = $controls; |
|
1386 | 1386 | |
1387 | 1387 | // Save sections |
1388 | - if ( ! isset( self::$sections[ $object_type ] ) ) { |
|
1389 | - self::$sections[ $object_type ] = array(); |
|
1388 | + if ( ! isset(self::$sections[$object_type])) { |
|
1389 | + self::$sections[$object_type] = array(); |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | - if ( ! isset( self::$sections[ $object_type ][ $object_name ] ) ) { |
|
1393 | - self::$sections[ $object_type ][ $object_name ] = array(); |
|
1392 | + if ( ! isset(self::$sections[$object_type][$object_name])) { |
|
1393 | + self::$sections[$object_type][$object_name] = array(); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | - self::$sections[ $object_type ][ $object_name ] = $sections; |
|
1396 | + self::$sections[$object_type][$object_name] = $sections; |
|
1397 | 1397 | |
1398 | 1398 | // Save screens |
1399 | - if ( ! isset( self::$screens[ $object_type ] ) ) { |
|
1400 | - self::$screens[ $object_type ] = array(); |
|
1399 | + if ( ! isset(self::$screens[$object_type])) { |
|
1400 | + self::$screens[$object_type] = array(); |
|
1401 | 1401 | } |
1402 | 1402 | |
1403 | - if ( ! isset( self::$screens[ $object_type ][ $object_name ] ) ) { |
|
1404 | - self::$screens[ $object_type ][ $object_name ] = array(); |
|
1403 | + if ( ! isset(self::$screens[$object_type][$object_name])) { |
|
1404 | + self::$screens[$object_type][$object_name] = array(); |
|
1405 | 1405 | } |
1406 | 1406 | |
1407 | - self::$screens[ $object_type ][ $object_name ] = $screens; |
|
1407 | + self::$screens[$object_type][$object_name] = $screens; |
|
1408 | 1408 | |
1409 | 1409 | // Save containers |
1410 | - if ( ! isset( self::$containers[ $object_type ] ) ) { |
|
1411 | - self::$containers[ $object_type ] = array(); |
|
1410 | + if ( ! isset(self::$containers[$object_type])) { |
|
1411 | + self::$containers[$object_type] = array(); |
|
1412 | 1412 | } |
1413 | 1413 | |
1414 | - if ( ! isset( self::$containers[ $object_type ][ $object_name ] ) ) { |
|
1415 | - self::$containers[ $object_type ][ $object_name ] = array(); |
|
1414 | + if ( ! isset(self::$containers[$object_type][$object_name])) { |
|
1415 | + self::$containers[$object_type][$object_name] = array(); |
|
1416 | 1416 | } |
1417 | 1417 | |
1418 | - self::$containers[ $object_type ][ $object_name ] = $containers; |
|
1418 | + self::$containers[$object_type][$object_name] = $containers; |
|
1419 | 1419 | |
1420 | 1420 | // Saved prepared IDs |
1421 | - if ( ! isset( self::$prepared_ids[ $object_type ] ) ) { |
|
1422 | - self::$prepared_ids[ $object_type ] = array(); |
|
1421 | + if ( ! isset(self::$prepared_ids[$object_type])) { |
|
1422 | + self::$prepared_ids[$object_type] = array(); |
|
1423 | 1423 | } |
1424 | 1424 | |
1425 | - if ( ! isset( self::$prepared_ids[ $object_type ][ $object_name ] ) ) { |
|
1426 | - self::$prepared_ids[ $object_type ][ $object_name ] = array(); |
|
1425 | + if ( ! isset(self::$prepared_ids[$object_type][$object_name])) { |
|
1426 | + self::$prepared_ids[$object_type][$object_name] = array(); |
|
1427 | 1427 | } |
1428 | 1428 | |
1429 | - self::$prepared_ids[ $object_type ][ $object_name ] = $prepared_ids; |
|
1429 | + self::$prepared_ids[$object_type][$object_name] = $prepared_ids; |
|
1430 | 1430 | |
1431 | 1431 | } |
1432 | 1432 | |
@@ -1438,23 +1438,23 @@ discard block |
||
1438 | 1438 | public function register_controls() { |
1439 | 1439 | |
1440 | 1440 | /* Control Types */ |
1441 | - $this->register_control_type( 'text', 'WP_Fields_API_Control' ); |
|
1442 | - $this->register_control_type( 'checkbox', 'WP_Fields_API_Checkbox_Control' ); |
|
1443 | - $this->register_control_type( 'multi-checkbox', 'WP_Fields_API_Multi_Checkbox_Control' ); |
|
1444 | - $this->register_control_type( 'radio', 'WP_Fields_API_Radio_Control' ); |
|
1445 | - $this->register_control_type( 'select', 'WP_Fields_API_Select_Control' ); |
|
1446 | - $this->register_control_type( 'dropdown-pages', 'WP_Fields_API_Dropdown_Pages_Control' ); |
|
1447 | - $this->register_control_type( 'color', 'WP_Fields_API_Color_Control' ); |
|
1448 | - $this->register_control_type( 'media', 'WP_Fields_API_Media_Control' ); |
|
1449 | - $this->register_control_type( 'upload', 'WP_Fields_API_Upload_Control' ); |
|
1450 | - $this->register_control_type( 'image', 'WP_Fields_API_Image_Control' ); |
|
1441 | + $this->register_control_type('text', 'WP_Fields_API_Control'); |
|
1442 | + $this->register_control_type('checkbox', 'WP_Fields_API_Checkbox_Control'); |
|
1443 | + $this->register_control_type('multi-checkbox', 'WP_Fields_API_Multi_Checkbox_Control'); |
|
1444 | + $this->register_control_type('radio', 'WP_Fields_API_Radio_Control'); |
|
1445 | + $this->register_control_type('select', 'WP_Fields_API_Select_Control'); |
|
1446 | + $this->register_control_type('dropdown-pages', 'WP_Fields_API_Dropdown_Pages_Control'); |
|
1447 | + $this->register_control_type('color', 'WP_Fields_API_Color_Control'); |
|
1448 | + $this->register_control_type('media', 'WP_Fields_API_Media_Control'); |
|
1449 | + $this->register_control_type('upload', 'WP_Fields_API_Upload_Control'); |
|
1450 | + $this->register_control_type('image', 'WP_Fields_API_Image_Control'); |
|
1451 | 1451 | |
1452 | 1452 | /** |
1453 | 1453 | * Fires once WordPress has loaded, allowing control types to be registered. |
1454 | 1454 | * |
1455 | 1455 | * @param WP_Fields_API $this WP_Fields_API instance. |
1456 | 1456 | */ |
1457 | - do_action( 'fields_register_controls', $this ); |
|
1457 | + do_action('fields_register_controls', $this); |
|
1458 | 1458 | |
1459 | 1459 | } |
1460 | 1460 | |
@@ -1470,15 +1470,15 @@ discard block |
||
1470 | 1470 | * |
1471 | 1471 | * @return boolean |
1472 | 1472 | */ |
1473 | - public function is_prepared( $object_type, $type, $id, $object_name = null ) { |
|
1473 | + public function is_prepared($object_type, $type, $id, $object_name = null) { |
|
1474 | 1474 | |
1475 | - if ( empty( $object_name ) && ! empty( $object_type ) ) { |
|
1476 | - $object_name = '_' . $object_type; // Default to _object_type for internal handling |
|
1475 | + if (empty($object_name) && ! empty($object_type)) { |
|
1476 | + $object_name = '_'.$object_type; // Default to _object_type for internal handling |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | $found = false; |
1480 | 1480 | |
1481 | - if ( ! empty( self::$prepared_ids[ $object_type ][ $object_name ][ $type ] ) && in_array( $id, self::$prepared_ids[ $object_type ][ $object_name ][ $type ] ) ) { |
|
1481 | + if ( ! empty(self::$prepared_ids[$object_type][$object_name][$type]) && in_array($id, self::$prepared_ids[$object_type][$object_name][$type])) { |
|
1482 | 1482 | $found = true; |
1483 | 1483 | } |
1484 | 1484 |
@@ -124,7 +124,6 @@ |
||
124 | 124 | * Test WP_Fields_API::add_screen() |
125 | 125 | * |
126 | 126 | * @param string $object_type |
127 | - * @param string $object_name |
|
128 | 127 | */ |
129 | 128 | public function test_add_screen_invalid( $object_type = 'post' ) { |
130 | 129 |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | global $wp_fields; |
18 | 18 | |
19 | 19 | // Reset WP Fields instance for testing purposes |
20 | - $wp_fields->remove_screen( true, true ); |
|
21 | - $wp_fields->remove_section( true, true ); |
|
22 | - $wp_fields->remove_field( true, true ); |
|
23 | - $wp_fields->remove_control( true, true ); |
|
20 | + $wp_fields->remove_screen(true, true); |
|
21 | + $wp_fields->remove_section(true, true); |
|
22 | + $wp_fields->remove_field(true, true); |
|
23 | + $wp_fields->remove_control(true, true); |
|
24 | 24 | |
25 | 25 | } |
26 | 26 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | global $wp_fields; |
38 | 38 | |
39 | - $this->assertTrue( is_a( $wp_fields, 'WP_Fields_API' ) ); |
|
39 | + $this->assertTrue(is_a($wp_fields, 'WP_Fields_API')); |
|
40 | 40 | |
41 | 41 | } |
42 | 42 | |
@@ -51,29 +51,29 @@ discard block |
||
51 | 51 | global $wp_fields; |
52 | 52 | |
53 | 53 | // Add a section / screen |
54 | - $this->test_add_section( 'post', 'my_custom_post_type' ); |
|
54 | + $this->test_add_section('post', 'my_custom_post_type'); |
|
55 | 55 | |
56 | 56 | // Get containers for object type / name |
57 | - $containers = $wp_fields->get_containers( 'post', 'my_custom_post_type' ); |
|
57 | + $containers = $wp_fields->get_containers('post', 'my_custom_post_type'); |
|
58 | 58 | |
59 | 59 | // There are two containers, the screen and the section |
60 | - $this->assertEquals( 2, count( $containers ) ); |
|
60 | + $this->assertEquals(2, count($containers)); |
|
61 | 61 | |
62 | - $this->assertArrayHasKey( 'my_test_screen', $containers ); |
|
63 | - $this->assertArrayHasKey( 'my_test_section', $containers ); |
|
62 | + $this->assertArrayHasKey('my_test_screen', $containers); |
|
63 | + $this->assertArrayHasKey('my_test_section', $containers); |
|
64 | 64 | |
65 | 65 | // Get a containers that doesn't exist |
66 | - $containers = $wp_fields->get_containers( 'post' ); |
|
66 | + $containers = $wp_fields->get_containers('post'); |
|
67 | 67 | |
68 | - $this->assertEquals( 0, count( $containers ) ); |
|
68 | + $this->assertEquals(0, count($containers)); |
|
69 | 69 | |
70 | 70 | // Get all containers for all object types |
71 | 71 | $containers = $wp_fields->get_containers(); |
72 | 72 | |
73 | 73 | // Each array item is an object type with an array of object names |
74 | - $this->assertEquals( 1, count( $containers ) ); |
|
74 | + $this->assertEquals(1, count($containers)); |
|
75 | 75 | |
76 | - $this->assertArrayHasKey( 'post', $containers ); |
|
76 | + $this->assertArrayHasKey('post', $containers); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | global $wp_fields; |
89 | 89 | |
90 | 90 | // Add a section / screen |
91 | - $this->test_add_section( 'post', 'my_custom_post_type' ); |
|
91 | + $this->test_add_section('post', 'my_custom_post_type'); |
|
92 | 92 | |
93 | 93 | // Get containers for object type / name |
94 | - $containers = $wp_fields->get_containers( 'post', true ); |
|
94 | + $containers = $wp_fields->get_containers('post', true); |
|
95 | 95 | |
96 | 96 | // There are two containers, the screen and the section |
97 | - $this->assertEquals( 2, count( $containers ) ); |
|
97 | + $this->assertEquals(2, count($containers)); |
|
98 | 98 | |
99 | - $container_ids = wp_list_pluck( $containers, 'id' ); |
|
99 | + $container_ids = wp_list_pluck($containers, 'id'); |
|
100 | 100 | |
101 | - $this->assertContains( 'my_test_screen', $container_ids ); |
|
102 | - $this->assertContains( 'my_test_section', $container_ids ); |
|
101 | + $this->assertContains('my_test_screen', $container_ids); |
|
102 | + $this->assertContains('my_test_section', $container_ids); |
|
103 | 103 | |
104 | 104 | } |
105 | 105 | |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | * @param string $object_type |
110 | 110 | * @param string $object_name |
111 | 111 | */ |
112 | - public function test_add_screen( $object_type = 'post', $object_name = null ) { |
|
112 | + public function test_add_screen($object_type = 'post', $object_name = null) { |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @var $wp_fields WP_Fields_API |
116 | 116 | */ |
117 | 117 | global $wp_fields; |
118 | 118 | |
119 | - $wp_fields->add_screen( $object_type, 'my_test_screen', $object_name ); |
|
119 | + $wp_fields->add_screen($object_type, 'my_test_screen', $object_name); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 | |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | * @param string $object_type |
127 | 127 | * @param string $object_name |
128 | 128 | */ |
129 | - public function test_add_screen_invalid( $object_type = 'post' ) { |
|
129 | + public function test_add_screen_invalid($object_type = 'post') { |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * @var $wp_fields WP_Fields_API |
133 | 133 | */ |
134 | 134 | global $wp_fields; |
135 | 135 | |
136 | - $wp_fields->add_screen( $object_type, null, null, array() ); |
|
136 | + $wp_fields->add_screen($object_type, null, null, array()); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | |
@@ -148,37 +148,37 @@ discard block |
||
148 | 148 | global $wp_fields; |
149 | 149 | |
150 | 150 | // Add a screen |
151 | - $this->test_add_screen( 'post', 'my_custom_post_type' ); |
|
151 | + $this->test_add_screen('post', 'my_custom_post_type'); |
|
152 | 152 | |
153 | 153 | // Get screens for object type / name |
154 | - $screens = $wp_fields->get_screens( 'post', 'my_custom_post_type' ); |
|
154 | + $screens = $wp_fields->get_screens('post', 'my_custom_post_type'); |
|
155 | 155 | |
156 | - $this->assertEquals( 1, count( $screens ) ); |
|
156 | + $this->assertEquals(1, count($screens)); |
|
157 | 157 | |
158 | - $this->assertArrayHasKey( 'my_test_screen', $screens ); |
|
158 | + $this->assertArrayHasKey('my_test_screen', $screens); |
|
159 | 159 | |
160 | 160 | // Get a screen that doesn't exist |
161 | - $screens = $wp_fields->get_screens( 'post', 'some_other_post_type' ); |
|
161 | + $screens = $wp_fields->get_screens('post', 'some_other_post_type'); |
|
162 | 162 | |
163 | - $this->assertEquals( 0, count( $screens ) ); |
|
163 | + $this->assertEquals(0, count($screens)); |
|
164 | 164 | |
165 | 165 | // Get all screens for object type |
166 | - $screens = $wp_fields->get_screens( 'post', true ); |
|
166 | + $screens = $wp_fields->get_screens('post', true); |
|
167 | 167 | |
168 | - $this->assertEquals( 1, count( $screens ) ); |
|
168 | + $this->assertEquals(1, count($screens)); |
|
169 | 169 | |
170 | - $screen_ids = wp_list_pluck( $screens, 'id' ); |
|
170 | + $screen_ids = wp_list_pluck($screens, 'id'); |
|
171 | 171 | |
172 | - $this->assertContains( 'my_test_screen', $screen_ids ); |
|
172 | + $this->assertContains('my_test_screen', $screen_ids); |
|
173 | 173 | |
174 | 174 | // Get all screens for all object types |
175 | 175 | $screens = $wp_fields->get_screens(); |
176 | 176 | |
177 | 177 | // Each array item is an object type with an array of object names |
178 | - $this->assertEquals( 1, count( $screens ) ); |
|
178 | + $this->assertEquals(1, count($screens)); |
|
179 | 179 | |
180 | 180 | // Array keys are object types |
181 | - $this->assertArrayHasKey( 'post', $screens ); |
|
181 | + $this->assertArrayHasKey('post', $screens); |
|
182 | 182 | |
183 | 183 | } |
184 | 184 | |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | global $wp_fields; |
194 | 194 | |
195 | 195 | // Add a screen |
196 | - $this->test_add_screen( 'post' ); |
|
196 | + $this->test_add_screen('post'); |
|
197 | 197 | |
198 | 198 | // Get screens for object type / name |
199 | - $screens = $wp_fields->get_screens( 'post' ); |
|
199 | + $screens = $wp_fields->get_screens('post'); |
|
200 | 200 | |
201 | - $this->assertEquals( 1, count( $screens ) ); |
|
201 | + $this->assertEquals(1, count($screens)); |
|
202 | 202 | |
203 | - $this->assertArrayHasKey( 'my_test_screen', $screens ); |
|
203 | + $this->assertArrayHasKey('my_test_screen', $screens); |
|
204 | 204 | |
205 | 205 | } |
206 | 206 | |
@@ -215,24 +215,24 @@ discard block |
||
215 | 215 | global $wp_fields; |
216 | 216 | |
217 | 217 | // Add a screen |
218 | - $this->test_add_screen( 'post', 'my_custom_post_type' ); |
|
218 | + $this->test_add_screen('post', 'my_custom_post_type'); |
|
219 | 219 | |
220 | 220 | // Screen exists for this object type / name |
221 | - $screen = $wp_fields->get_screen( 'post', 'my_test_screen', 'my_custom_post_type' ); |
|
221 | + $screen = $wp_fields->get_screen('post', 'my_test_screen', 'my_custom_post_type'); |
|
222 | 222 | |
223 | - $this->assertNotEmpty( $screen ); |
|
223 | + $this->assertNotEmpty($screen); |
|
224 | 224 | |
225 | - $this->assertEquals( 'my_test_screen', $screen->id ); |
|
225 | + $this->assertEquals('my_test_screen', $screen->id); |
|
226 | 226 | |
227 | 227 | // Screen doesn't exist for this object type / name |
228 | - $screen = $wp_fields->get_screen( 'post', 'my_test_screen1' ); |
|
228 | + $screen = $wp_fields->get_screen('post', 'my_test_screen1'); |
|
229 | 229 | |
230 | - $this->assertEmpty( $screen ); |
|
230 | + $this->assertEmpty($screen); |
|
231 | 231 | |
232 | 232 | // Screen doesn't exist for this object type / name |
233 | - $screen = $wp_fields->get_screen( 'post', 'my_test_screen2', 'my_custom_post_type' ); |
|
233 | + $screen = $wp_fields->get_screen('post', 'my_test_screen2', 'my_custom_post_type'); |
|
234 | 234 | |
235 | - $this->assertEmpty( $screen ); |
|
235 | + $this->assertEmpty($screen); |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | global $wp_fields; |
248 | 248 | |
249 | 249 | // Add a screen |
250 | - $this->test_add_screen( 'post', 'my_custom_post_type' ); |
|
250 | + $this->test_add_screen('post', 'my_custom_post_type'); |
|
251 | 251 | |
252 | 252 | // Screen exists for this object type / name |
253 | - $screen = $wp_fields->get_screen( 'post', 'my_test_screen', 'my_custom_post_type' ); |
|
253 | + $screen = $wp_fields->get_screen('post', 'my_test_screen', 'my_custom_post_type'); |
|
254 | 254 | |
255 | - $this->assertNotEmpty( $screen ); |
|
255 | + $this->assertNotEmpty($screen); |
|
256 | 256 | |
257 | - $this->assertEquals( 'my_test_screen', $screen->id ); |
|
257 | + $this->assertEquals('my_test_screen', $screen->id); |
|
258 | 258 | |
259 | 259 | // Remove screen |
260 | - $wp_fields->remove_screen( 'post', 'my_test_screen', 'my_custom_post_type' ); |
|
260 | + $wp_fields->remove_screen('post', 'my_test_screen', 'my_custom_post_type'); |
|
261 | 261 | |
262 | 262 | // Screen no longer exists for this object type / name |
263 | - $screen = $wp_fields->get_screen( 'post', 'my_test_screen', 'my_custom_post_type' ); |
|
263 | + $screen = $wp_fields->get_screen('post', 'my_test_screen', 'my_custom_post_type'); |
|
264 | 264 | |
265 | - $this->assertEmpty( $screen ); |
|
265 | + $this->assertEmpty($screen); |
|
266 | 266 | |
267 | 267 | } |
268 | 268 | |
@@ -277,15 +277,15 @@ discard block |
||
277 | 277 | global $wp_fields; |
278 | 278 | |
279 | 279 | // Add a screen |
280 | - $this->test_add_screen( 'post', 'my_custom_post_type' ); |
|
280 | + $this->test_add_screen('post', 'my_custom_post_type'); |
|
281 | 281 | |
282 | 282 | // Remove screen |
283 | - $wp_fields->remove_screen( 'post', null, true ); |
|
283 | + $wp_fields->remove_screen('post', null, true); |
|
284 | 284 | |
285 | 285 | // Screen no longer exists for this object type / name |
286 | - $screen = $wp_fields->get_screen( 'post', 'my_test_screen', 'my_custom_post_type' ); |
|
286 | + $screen = $wp_fields->get_screen('post', 'my_test_screen', 'my_custom_post_type'); |
|
287 | 287 | |
288 | - $this->assertEmpty( $screen ); |
|
288 | + $this->assertEmpty($screen); |
|
289 | 289 | |
290 | 290 | } |
291 | 291 | |
@@ -300,15 +300,15 @@ discard block |
||
300 | 300 | global $wp_fields; |
301 | 301 | |
302 | 302 | // Add a screen |
303 | - $this->test_add_screen( 'post' ); |
|
303 | + $this->test_add_screen('post'); |
|
304 | 304 | |
305 | 305 | // Remove screen |
306 | - $wp_fields->remove_screen( 'post', 'my_test_screen' ); |
|
306 | + $wp_fields->remove_screen('post', 'my_test_screen'); |
|
307 | 307 | |
308 | 308 | // Screen no longer exists for this object type / name |
309 | - $screen = $wp_fields->get_screen( 'post', 'my_test_screen' ); |
|
309 | + $screen = $wp_fields->get_screen('post', 'my_test_screen'); |
|
310 | 310 | |
311 | - $this->assertEmpty( $screen ); |
|
311 | + $this->assertEmpty($screen); |
|
312 | 312 | |
313 | 313 | } |
314 | 314 | |
@@ -323,15 +323,15 @@ discard block |
||
323 | 323 | global $wp_fields; |
324 | 324 | |
325 | 325 | // Add a screen |
326 | - $this->test_add_screen( 'post', 'my_custom_post_type' ); |
|
326 | + $this->test_add_screen('post', 'my_custom_post_type'); |
|
327 | 327 | |
328 | 328 | // Remove screen |
329 | - $wp_fields->remove_screen( 'post', true, 'my_custom_post_type' ); |
|
329 | + $wp_fields->remove_screen('post', true, 'my_custom_post_type'); |
|
330 | 330 | |
331 | 331 | // Screen no longer exists for this object type / name |
332 | - $screen = $wp_fields->get_screen( 'post', 'my_test_screen', 'my_custom_post_type' ); |
|
332 | + $screen = $wp_fields->get_screen('post', 'my_test_screen', 'my_custom_post_type'); |
|
333 | 333 | |
334 | - $this->assertEmpty( $screen ); |
|
334 | + $this->assertEmpty($screen); |
|
335 | 335 | |
336 | 336 | } |
337 | 337 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @param string $object_type |
342 | 342 | * @param string $object_name |
343 | 343 | */ |
344 | - public function test_add_section( $object_type = 'post', $object_name = null ) { |
|
344 | + public function test_add_section($object_type = 'post', $object_name = null) { |
|
345 | 345 | |
346 | 346 | /** |
347 | 347 | * @var $wp_fields WP_Fields_API |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | global $wp_fields; |
350 | 350 | |
351 | 351 | // Add a screen |
352 | - $this->test_add_screen( $object_type, $object_name ); |
|
352 | + $this->test_add_screen($object_type, $object_name); |
|
353 | 353 | |
354 | - $wp_fields->add_section( $object_type, 'my_test_section', $object_name, array( |
|
354 | + $wp_fields->add_section($object_type, 'my_test_section', $object_name, array( |
|
355 | 355 | 'screen' => 'my_test_screen', |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | |
358 | 358 | } |
359 | 359 | |
@@ -368,43 +368,43 @@ discard block |
||
368 | 368 | global $wp_fields; |
369 | 369 | |
370 | 370 | // Add a screen |
371 | - $this->test_add_section( 'post', 'my_custom_post_type' ); |
|
371 | + $this->test_add_section('post', 'my_custom_post_type'); |
|
372 | 372 | |
373 | 373 | // Get sections for object type / name |
374 | - $sections = $wp_fields->get_sections( 'post', 'my_custom_post_type' ); |
|
374 | + $sections = $wp_fields->get_sections('post', 'my_custom_post_type'); |
|
375 | 375 | |
376 | - $this->assertEquals( 1, count( $sections ) ); |
|
376 | + $this->assertEquals(1, count($sections)); |
|
377 | 377 | |
378 | - $this->assertArrayHasKey( 'my_test_section', $sections ); |
|
378 | + $this->assertArrayHasKey('my_test_section', $sections); |
|
379 | 379 | |
380 | 380 | // Get a section that doesn't exist |
381 | - $sections = $wp_fields->get_sections( 'post', 'some_other_post_type' ); |
|
381 | + $sections = $wp_fields->get_sections('post', 'some_other_post_type'); |
|
382 | 382 | |
383 | - $this->assertEquals( 0, count( $sections ) ); |
|
383 | + $this->assertEquals(0, count($sections)); |
|
384 | 384 | |
385 | 385 | // Get sections by screen |
386 | - $sections = $wp_fields->get_sections( 'post', 'my_custom_post_type', 'my_test_screen' ); |
|
386 | + $sections = $wp_fields->get_sections('post', 'my_custom_post_type', 'my_test_screen'); |
|
387 | 387 | |
388 | - $this->assertEquals( 1, count( $sections ) ); |
|
388 | + $this->assertEquals(1, count($sections)); |
|
389 | 389 | |
390 | - $this->assertArrayHasKey( 'my_test_section', $sections ); |
|
390 | + $this->assertArrayHasKey('my_test_section', $sections); |
|
391 | 391 | |
392 | 392 | // Get all sections for object type |
393 | - $sections = $wp_fields->get_sections( 'post', true ); |
|
393 | + $sections = $wp_fields->get_sections('post', true); |
|
394 | 394 | |
395 | - $this->assertEquals( 1, count( $sections ) ); |
|
395 | + $this->assertEquals(1, count($sections)); |
|
396 | 396 | |
397 | - $section_ids = wp_list_pluck( $sections, 'id' ); |
|
397 | + $section_ids = wp_list_pluck($sections, 'id'); |
|
398 | 398 | |
399 | - $this->assertContains( 'my_test_section', $section_ids ); |
|
399 | + $this->assertContains('my_test_section', $section_ids); |
|
400 | 400 | |
401 | 401 | // Get all sections for all object types |
402 | 402 | $sections = $wp_fields->get_sections(); |
403 | 403 | |
404 | 404 | // Each array item is an object type with an array of object names |
405 | - $this->assertEquals( 1, count( $sections ) ); |
|
405 | + $this->assertEquals(1, count($sections)); |
|
406 | 406 | |
407 | - $this->assertArrayHasKey( 'post', $sections ); |
|
407 | + $this->assertArrayHasKey('post', $sections); |
|
408 | 408 | |
409 | 409 | } |
410 | 410 | |
@@ -419,24 +419,24 @@ discard block |
||
419 | 419 | global $wp_fields; |
420 | 420 | |
421 | 421 | // Add a screen |
422 | - $this->test_add_section( 'post', 'my_custom_post_type' ); |
|
422 | + $this->test_add_section('post', 'my_custom_post_type'); |
|
423 | 423 | |
424 | 424 | // Section exists for this object type / name |
425 | - $section = $wp_fields->get_section( 'post', 'my_test_section', 'my_custom_post_type' ); |
|
425 | + $section = $wp_fields->get_section('post', 'my_test_section', 'my_custom_post_type'); |
|
426 | 426 | |
427 | - $this->assertNotEmpty( $section ); |
|
427 | + $this->assertNotEmpty($section); |
|
428 | 428 | |
429 | - $this->assertEquals( 'my_test_section', $section->id ); |
|
429 | + $this->assertEquals('my_test_section', $section->id); |
|
430 | 430 | |
431 | 431 | // Section doesn't exist for this object type / name |
432 | - $section = $wp_fields->get_section( 'post', 'my_test_section', 'some_other_post_type' ); |
|
432 | + $section = $wp_fields->get_section('post', 'my_test_section', 'some_other_post_type'); |
|
433 | 433 | |
434 | - $this->assertEmpty( $section ); |
|
434 | + $this->assertEmpty($section); |
|
435 | 435 | |
436 | 436 | // Section doesn't exist for this object type / name |
437 | - $section = $wp_fields->get_section( 'post', 'my_test_section2', 'my_custom_post_type' ); |
|
437 | + $section = $wp_fields->get_section('post', 'my_test_section2', 'my_custom_post_type'); |
|
438 | 438 | |
439 | - $this->assertEmpty( $section ); |
|
439 | + $this->assertEmpty($section); |
|
440 | 440 | |
441 | 441 | } |
442 | 442 | |
@@ -451,22 +451,22 @@ discard block |
||
451 | 451 | global $wp_fields; |
452 | 452 | |
453 | 453 | // Add a screen |
454 | - $this->test_add_section( 'post', 'my_custom_post_type' ); |
|
454 | + $this->test_add_section('post', 'my_custom_post_type'); |
|
455 | 455 | |
456 | 456 | // Section exists for this object type / name |
457 | - $section = $wp_fields->get_section( 'post', 'my_test_section', 'my_custom_post_type' ); |
|
457 | + $section = $wp_fields->get_section('post', 'my_test_section', 'my_custom_post_type'); |
|
458 | 458 | |
459 | - $this->assertNotEmpty( $section ); |
|
459 | + $this->assertNotEmpty($section); |
|
460 | 460 | |
461 | - $this->assertEquals( 'my_test_section', $section->id ); |
|
461 | + $this->assertEquals('my_test_section', $section->id); |
|
462 | 462 | |
463 | 463 | // Remove section |
464 | - $wp_fields->remove_section( 'post', 'my_test_section', 'my_custom_post_type' ); |
|
464 | + $wp_fields->remove_section('post', 'my_test_section', 'my_custom_post_type'); |
|
465 | 465 | |
466 | 466 | // Section no longer exists for this object type / name |
467 | - $section = $wp_fields->get_section( 'post', 'my_test_section', 'my_custom_post_type' ); |
|
467 | + $section = $wp_fields->get_section('post', 'my_test_section', 'my_custom_post_type'); |
|
468 | 468 | |
469 | - $this->assertEmpty( $section ); |
|
469 | + $this->assertEmpty($section); |
|
470 | 470 | |
471 | 471 | } |
472 | 472 | |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @param string $object_type |
477 | 477 | * @param string $object_name |
478 | 478 | */ |
479 | - public function test_add_field( $object_type = 'post', $object_name = null ) { |
|
479 | + public function test_add_field($object_type = 'post', $object_name = null) { |
|
480 | 480 | |
481 | 481 | /** |
482 | 482 | * @var $wp_fields WP_Fields_API |
@@ -484,16 +484,16 @@ discard block |
||
484 | 484 | global $wp_fields; |
485 | 485 | |
486 | 486 | // Add a section for the control |
487 | - $this->test_add_section( $object_type, $object_name ); |
|
487 | + $this->test_add_section($object_type, $object_name); |
|
488 | 488 | |
489 | - $wp_fields->add_field( $object_type, 'my_test_field', $object_name, array( |
|
489 | + $wp_fields->add_field($object_type, 'my_test_field', $object_name, array( |
|
490 | 490 | 'control' => array( |
491 | 491 | 'id' => 'my_test_field_control', |
492 | 492 | 'label' => 'My Test Field', |
493 | 493 | 'type' => 'text', |
494 | 494 | 'section' => 'my_test_section', |
495 | 495 | ), |
496 | - ) ); |
|
496 | + )); |
|
497 | 497 | |
498 | 498 | } |
499 | 499 | |
@@ -508,26 +508,26 @@ discard block |
||
508 | 508 | global $wp_fields; |
509 | 509 | |
510 | 510 | // Add a field |
511 | - $this->test_add_field( 'post', 'my_custom_post_type' ); |
|
511 | + $this->test_add_field('post', 'my_custom_post_type'); |
|
512 | 512 | |
513 | 513 | // Get fields for object type / name |
514 | - $fields = $wp_fields->get_fields( 'post', 'my_custom_post_type' ); |
|
514 | + $fields = $wp_fields->get_fields('post', 'my_custom_post_type'); |
|
515 | 515 | |
516 | - $this->assertEquals( 1, count( $fields ) ); |
|
516 | + $this->assertEquals(1, count($fields)); |
|
517 | 517 | |
518 | - $this->assertArrayHasKey( 'my_test_field', $fields ); |
|
518 | + $this->assertArrayHasKey('my_test_field', $fields); |
|
519 | 519 | |
520 | 520 | // Get a field that doesn't exist |
521 | - $fields = $wp_fields->get_fields( 'post', 'some_other_post_type' ); |
|
521 | + $fields = $wp_fields->get_fields('post', 'some_other_post_type'); |
|
522 | 522 | |
523 | - $this->assertEquals( 0, count( $fields ) ); |
|
523 | + $this->assertEquals(0, count($fields)); |
|
524 | 524 | |
525 | 525 | // Get fields by section |
526 | - $fields = $wp_fields->get_fields( 'post', 'my_custom_post_type', 'my_test_section' ); |
|
526 | + $fields = $wp_fields->get_fields('post', 'my_custom_post_type', 'my_test_section'); |
|
527 | 527 | |
528 | - $this->assertEquals( 1, count( $fields ) ); |
|
528 | + $this->assertEquals(1, count($fields)); |
|
529 | 529 | |
530 | - $this->assertArrayHasKey( 'my_test_field', $fields ); |
|
530 | + $this->assertArrayHasKey('my_test_field', $fields); |
|
531 | 531 | |
532 | 532 | } |
533 | 533 | |
@@ -542,24 +542,24 @@ discard block |
||
542 | 542 | global $wp_fields; |
543 | 543 | |
544 | 544 | // Add a field |
545 | - $this->test_add_field( 'post', 'my_custom_post_type' ); |
|
545 | + $this->test_add_field('post', 'my_custom_post_type'); |
|
546 | 546 | |
547 | 547 | // Field exists for this object type / name |
548 | - $field = $wp_fields->get_field( 'post', 'my_test_field', 'my_custom_post_type' ); |
|
548 | + $field = $wp_fields->get_field('post', 'my_test_field', 'my_custom_post_type'); |
|
549 | 549 | |
550 | - $this->assertNotEmpty( $field ); |
|
550 | + $this->assertNotEmpty($field); |
|
551 | 551 | |
552 | - $this->assertEquals( 'my_test_field', $field->id ); |
|
552 | + $this->assertEquals('my_test_field', $field->id); |
|
553 | 553 | |
554 | 554 | // Field doesn't exist for this object type / name |
555 | - $field = $wp_fields->get_field( 'post', 'my_test_field', 'some_other_post_type' ); |
|
555 | + $field = $wp_fields->get_field('post', 'my_test_field', 'some_other_post_type'); |
|
556 | 556 | |
557 | - $this->assertEmpty( $field ); |
|
557 | + $this->assertEmpty($field); |
|
558 | 558 | |
559 | 559 | // Field doesn't exist for this object type / name |
560 | - $field = $wp_fields->get_field( 'post', 'my_test_field2', 'my_custom_post_type' ); |
|
560 | + $field = $wp_fields->get_field('post', 'my_test_field2', 'my_custom_post_type'); |
|
561 | 561 | |
562 | - $this->assertEmpty( $field ); |
|
562 | + $this->assertEmpty($field); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
@@ -574,22 +574,22 @@ discard block |
||
574 | 574 | global $wp_fields; |
575 | 575 | |
576 | 576 | // Add a field |
577 | - $this->test_add_field( 'post', 'my_custom_post_type' ); |
|
577 | + $this->test_add_field('post', 'my_custom_post_type'); |
|
578 | 578 | |
579 | 579 | // Field exists for this object type / name |
580 | - $field = $wp_fields->get_field( 'post', 'my_test_field', 'my_custom_post_type' ); |
|
580 | + $field = $wp_fields->get_field('post', 'my_test_field', 'my_custom_post_type'); |
|
581 | 581 | |
582 | - $this->assertNotEmpty( $field ); |
|
582 | + $this->assertNotEmpty($field); |
|
583 | 583 | |
584 | - $this->assertEquals( 'my_test_field', $field->id ); |
|
584 | + $this->assertEquals('my_test_field', $field->id); |
|
585 | 585 | |
586 | 586 | // Remove field |
587 | - $wp_fields->remove_field( 'post', 'my_test_field', 'my_custom_post_type' ); |
|
587 | + $wp_fields->remove_field('post', 'my_test_field', 'my_custom_post_type'); |
|
588 | 588 | |
589 | 589 | // Field no longer exists for this object type / name |
590 | - $field = $wp_fields->get_field( 'post', 'my_test_field', 'my_custom_post_type' ); |
|
590 | + $field = $wp_fields->get_field('post', 'my_test_field', 'my_custom_post_type'); |
|
591 | 591 | |
592 | - $this->assertEmpty( $field ); |
|
592 | + $this->assertEmpty($field); |
|
593 | 593 | |
594 | 594 | } |
595 | 595 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | * @param string $object_type |
600 | 600 | * @param string $object_name |
601 | 601 | */ |
602 | - public function test_add_control( $object_type = 'post', $object_name = null ) { |
|
602 | + public function test_add_control($object_type = 'post', $object_name = null) { |
|
603 | 603 | |
604 | 604 | /** |
605 | 605 | * @var $wp_fields WP_Fields_API |
@@ -607,14 +607,14 @@ discard block |
||
607 | 607 | global $wp_fields; |
608 | 608 | |
609 | 609 | // Add a field for the control |
610 | - $this->test_add_field( $object_type, $object_name ); |
|
610 | + $this->test_add_field($object_type, $object_name); |
|
611 | 611 | |
612 | - $wp_fields->add_control( $object_type, 'my_test_control', $object_name, array( |
|
612 | + $wp_fields->add_control($object_type, 'my_test_control', $object_name, array( |
|
613 | 613 | 'section' => 'my_test_section', |
614 | 614 | 'fields' => 'my_test_field', |
615 | 615 | 'label' => 'My Test Control Field', |
616 | 616 | 'type' => 'text', |
617 | - ) ); |
|
617 | + )); |
|
618 | 618 | |
619 | 619 | } |
620 | 620 | |
@@ -629,33 +629,33 @@ discard block |
||
629 | 629 | global $wp_fields; |
630 | 630 | |
631 | 631 | // Add a control / field / section |
632 | - $this->test_add_control( 'post', 'my_custom_post_type' ); |
|
632 | + $this->test_add_control('post', 'my_custom_post_type'); |
|
633 | 633 | |
634 | 634 | // Get controls for object type / name |
635 | - $controls = $wp_fields->get_controls( 'post', 'my_custom_post_type' ); |
|
635 | + $controls = $wp_fields->get_controls('post', 'my_custom_post_type'); |
|
636 | 636 | |
637 | 637 | // There are two controls, the default one with the main field and this control |
638 | - $this->assertEquals( 2, count( $controls ) ); |
|
638 | + $this->assertEquals(2, count($controls)); |
|
639 | 639 | |
640 | - $this->assertArrayHasKey( 'my_test_control', $controls ); |
|
641 | - $this->assertArrayHasKey( 'my_test_field_control', $controls ); |
|
640 | + $this->assertArrayHasKey('my_test_control', $controls); |
|
641 | + $this->assertArrayHasKey('my_test_field_control', $controls); |
|
642 | 642 | |
643 | - $this->assertEquals( 'my_test_section', $controls['my_test_control']->section ); |
|
643 | + $this->assertEquals('my_test_section', $controls['my_test_control']->section); |
|
644 | 644 | |
645 | 645 | // Get a control that doesn't exist |
646 | - $controls = $wp_fields->get_controls( 'post', 'some_other_post_type' ); |
|
646 | + $controls = $wp_fields->get_controls('post', 'some_other_post_type'); |
|
647 | 647 | |
648 | - $this->assertEquals( 0, count( $controls ) ); |
|
648 | + $this->assertEquals(0, count($controls)); |
|
649 | 649 | |
650 | 650 | // Get controls by section |
651 | - $controls = $wp_fields->get_controls( 'post', 'my_custom_post_type', 'my_test_section' ); |
|
651 | + $controls = $wp_fields->get_controls('post', 'my_custom_post_type', 'my_test_section'); |
|
652 | 652 | |
653 | - $this->assertEquals( 2, count( $controls ) ); |
|
653 | + $this->assertEquals(2, count($controls)); |
|
654 | 654 | |
655 | - $this->assertArrayHasKey( 'my_test_control', $controls ); |
|
656 | - $this->assertArrayHasKey( 'my_test_field_control', $controls ); |
|
655 | + $this->assertArrayHasKey('my_test_control', $controls); |
|
656 | + $this->assertArrayHasKey('my_test_field_control', $controls); |
|
657 | 657 | |
658 | - $this->assertEquals( 'my_test_section', $controls['my_test_control']->section ); |
|
658 | + $this->assertEquals('my_test_section', $controls['my_test_control']->section); |
|
659 | 659 | |
660 | 660 | } |
661 | 661 | |
@@ -670,37 +670,37 @@ discard block |
||
670 | 670 | global $wp_fields; |
671 | 671 | |
672 | 672 | // Add a control / field / section |
673 | - $this->test_add_control( 'post', 'my_custom_post_type' ); |
|
673 | + $this->test_add_control('post', 'my_custom_post_type'); |
|
674 | 674 | |
675 | 675 | // Control exists for this object type / name |
676 | - $control = $wp_fields->get_control( 'post', 'my_test_field_control', 'my_custom_post_type' ); |
|
676 | + $control = $wp_fields->get_control('post', 'my_test_field_control', 'my_custom_post_type'); |
|
677 | 677 | |
678 | - $this->assertNotEmpty( $control ); |
|
678 | + $this->assertNotEmpty($control); |
|
679 | 679 | |
680 | - $this->assertEquals( 'my_test_field_control', $control->id ); |
|
681 | - $this->assertNotEmpty( $control->field ); |
|
682 | - $this->assertEquals( 'my_test_field', $control->field->id ); |
|
683 | - $this->assertEquals( 'my_test_section', $control->section ); |
|
680 | + $this->assertEquals('my_test_field_control', $control->id); |
|
681 | + $this->assertNotEmpty($control->field); |
|
682 | + $this->assertEquals('my_test_field', $control->field->id); |
|
683 | + $this->assertEquals('my_test_section', $control->section); |
|
684 | 684 | |
685 | 685 | // Control exists for this object type / name |
686 | - $control = $wp_fields->get_control( 'post', 'my_test_control', 'my_custom_post_type' ); |
|
686 | + $control = $wp_fields->get_control('post', 'my_test_control', 'my_custom_post_type'); |
|
687 | 687 | |
688 | - $this->assertNotEmpty( $control ); |
|
688 | + $this->assertNotEmpty($control); |
|
689 | 689 | |
690 | - $this->assertEquals( 'my_test_control', $control->id ); |
|
691 | - $this->assertNotEmpty( $control->field ); |
|
692 | - $this->assertEquals( 'my_test_field', $control->field->id ); |
|
693 | - $this->assertEquals( 'my_test_section', $control->section ); |
|
690 | + $this->assertEquals('my_test_control', $control->id); |
|
691 | + $this->assertNotEmpty($control->field); |
|
692 | + $this->assertEquals('my_test_field', $control->field->id); |
|
693 | + $this->assertEquals('my_test_section', $control->section); |
|
694 | 694 | |
695 | 695 | // Control doesn't exist for this object type / name |
696 | - $control = $wp_fields->get_control( 'post', 'my_test_control', 'some_other_post_type' ); |
|
696 | + $control = $wp_fields->get_control('post', 'my_test_control', 'some_other_post_type'); |
|
697 | 697 | |
698 | - $this->assertEmpty( $control ); |
|
698 | + $this->assertEmpty($control); |
|
699 | 699 | |
700 | 700 | // Control doesn't exist for this object type / name |
701 | - $control = $wp_fields->get_control( 'post', 'my_test_control2', 'my_custom_post_type' ); |
|
701 | + $control = $wp_fields->get_control('post', 'my_test_control2', 'my_custom_post_type'); |
|
702 | 702 | |
703 | - $this->assertEmpty( $control ); |
|
703 | + $this->assertEmpty($control); |
|
704 | 704 | |
705 | 705 | } |
706 | 706 | |
@@ -715,32 +715,32 @@ discard block |
||
715 | 715 | global $wp_fields; |
716 | 716 | |
717 | 717 | // Add a control / field / section |
718 | - $this->test_add_control( 'post', 'my_custom_post_type' ); |
|
718 | + $this->test_add_control('post', 'my_custom_post_type'); |
|
719 | 719 | |
720 | 720 | // Control exists for this object type / name |
721 | - $control = $wp_fields->get_control( 'post', 'my_test_control', 'my_custom_post_type' ); |
|
721 | + $control = $wp_fields->get_control('post', 'my_test_control', 'my_custom_post_type'); |
|
722 | 722 | |
723 | - $this->assertNotEmpty( $control ); |
|
723 | + $this->assertNotEmpty($control); |
|
724 | 724 | |
725 | - $this->assertEquals( 'my_test_control', $control->id ); |
|
726 | - $this->assertEquals( 'my_test_field', $control->field->id ); |
|
727 | - $this->assertEquals( 'my_test_section', $control->section ); |
|
725 | + $this->assertEquals('my_test_control', $control->id); |
|
726 | + $this->assertEquals('my_test_field', $control->field->id); |
|
727 | + $this->assertEquals('my_test_section', $control->section); |
|
728 | 728 | |
729 | 729 | // Remove control |
730 | - $wp_fields->remove_control( 'post', 'my_test_control', 'my_custom_post_type' ); |
|
730 | + $wp_fields->remove_control('post', 'my_test_control', 'my_custom_post_type'); |
|
731 | 731 | |
732 | 732 | // Control no longer exists for this object type / name |
733 | - $control = $wp_fields->get_control( 'post', 'my_test_control', 'my_custom_post_type' ); |
|
733 | + $control = $wp_fields->get_control('post', 'my_test_control', 'my_custom_post_type'); |
|
734 | 734 | |
735 | - $this->assertEmpty( $control ); |
|
735 | + $this->assertEmpty($control); |
|
736 | 736 | |
737 | 737 | // Remove field's control |
738 | - $wp_fields->remove_control( 'post', 'my_test_field_control', 'my_custom_post_type' ); |
|
738 | + $wp_fields->remove_control('post', 'my_test_field_control', 'my_custom_post_type'); |
|
739 | 739 | |
740 | 740 | // Control no longer exists for this object type / name |
741 | - $control = $wp_fields->get_control( 'post', 'my_test_field_control', 'my_custom_post_type' ); |
|
741 | + $control = $wp_fields->get_control('post', 'my_test_field_control', 'my_custom_post_type'); |
|
742 | 742 | |
743 | - $this->assertEmpty( $control ); |
|
743 | + $this->assertEmpty($control); |
|
744 | 744 | |
745 | 745 | } |
746 | 746 |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Fields API Text Control class. |
|
4 | - * |
|
5 | - * @see WP_Fields_API_Control |
|
6 | - */ |
|
3 | + * Fields API Text Control class. |
|
4 | + * |
|
5 | + * @see WP_Fields_API_Control |
|
6 | + */ |
|
7 | 7 | class WP_Fields_API_Text_Control extends WP_Fields_API_Control { |
8 | 8 | |
9 | 9 | /** |
@@ -155,8 +155,9 @@ |
||
155 | 155 | |
156 | 156 | <select <?php $this->link(); ?>> |
157 | 157 | <?php |
158 | - foreach ( $this->choices as $value => $label ) |
|
159 | - echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>'; |
|
158 | + foreach ( $this->choices as $value => $label ) { |
|
159 | + echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>'; |
|
160 | + } |
|
160 | 161 | ?> |
161 | 162 | </select> |
162 | 163 | </label> |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | |
14 | 14 | ?> |
15 | 15 | <label> |
16 | - <?php if ( ! empty( $this->label ) ) : ?> |
|
17 | - <span class="fields-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
16 | + <?php if ( ! empty($this->label)) : ?> |
|
17 | + <span class="fields-control-title"><?php echo esc_html($this->label); ?></span> |
|
18 | 18 | <?php endif; |
19 | - if ( ! empty( $this->description ) ) : ?> |
|
19 | + if ( ! empty($this->description)) : ?> |
|
20 | 20 | <span class="description fields-control-description"><?php echo $this->description; ?></span> |
21 | 21 | <?php endif; ?> |
22 | - <input type="<?php echo esc_attr( $this->type ); ?>" <?php $this->input_attrs(); ?> value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); ?> /> |
|
22 | + <input type="<?php echo esc_attr($this->type); ?>" <?php $this->input_attrs(); ?> value="<?php echo esc_attr($this->value()); ?>" <?php $this->link(); ?> /> |
|
23 | 23 | </label> |
24 | 24 | <?php |
25 | 25 | |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | $checkbox_value = $this->checkbox_value(); |
54 | 54 | ?> |
55 | 55 | <label> |
56 | - <input type="checkbox" value="<?php echo esc_attr( $checkbox_value ); ?>" <?php $this->link(); checked( $checkbox_value, $this->value() ); ?> /> |
|
57 | - <?php echo esc_html( $this->label ); ?> |
|
58 | - <?php if ( ! empty( $this->description ) ) : ?> |
|
56 | + <input type="checkbox" value="<?php echo esc_attr($checkbox_value); ?>" <?php $this->link(); checked($checkbox_value, $this->value()); ?> /> |
|
57 | + <?php echo esc_html($this->label); ?> |
|
58 | + <?php if ( ! empty($this->description)) : ?> |
|
59 | 59 | <span class="description fields-control-description"><?php echo $this->description; ?></span> |
60 | 60 | <?php endif; ?> |
61 | 61 | </label> |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $value = $this->value(); |
74 | 74 | |
75 | - if ( isset( $this->checkbox_value ) ) { |
|
75 | + if (isset($this->checkbox_value)) { |
|
76 | 76 | $value = $this->checkbox_value; |
77 | 77 | } |
78 | 78 | |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function render_content() { |
96 | 96 | |
97 | - if ( empty( $this->choices ) ) { |
|
97 | + if (empty($this->choices)) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | 100 | |
101 | - $name = '_fields-checkbox-' . $this->id; |
|
101 | + $name = '_fields-checkbox-'.$this->id; |
|
102 | 102 | |
103 | - if ( ! empty( $this->label ) ) : ?> |
|
104 | - <span class="fields-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
103 | + if ( ! empty($this->label)) : ?> |
|
104 | + <span class="fields-control-title"><?php echo esc_html($this->label); ?></span> |
|
105 | 105 | <?php endif; |
106 | - if ( ! empty( $this->description ) ) : ?> |
|
107 | - <span class="description fields-control-description"><?php echo $this->description ; ?></span> |
|
106 | + if ( ! empty($this->description)) : ?> |
|
107 | + <span class="description fields-control-description"><?php echo $this->description; ?></span> |
|
108 | 108 | <?php endif; |
109 | 109 | |
110 | - foreach ( $this->choices as $value => $label ) : |
|
110 | + foreach ($this->choices as $value => $label) : |
|
111 | 111 | ?> |
112 | 112 | <label> |
113 | - <input type="checkbox" value="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $name ); ?>" <?php $this->link(); checked( $this->value(), $value ); ?> /> |
|
114 | - <?php echo esc_html( $label ); ?><br/> |
|
113 | + <input type="checkbox" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($name); ?>" <?php $this->link(); checked($this->value(), $value); ?> /> |
|
114 | + <?php echo esc_html($label); ?><br/> |
|
115 | 115 | </label> |
116 | 116 | <?php |
117 | 117 | endforeach; |
@@ -132,24 +132,24 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function render_content() { |
134 | 134 | |
135 | - if ( empty( $this->choices ) ) { |
|
135 | + if (empty($this->choices)) { |
|
136 | 136 | return; |
137 | 137 | } |
138 | 138 | |
139 | - $name = '_fields-radio-' . $this->id; |
|
139 | + $name = '_fields-radio-'.$this->id; |
|
140 | 140 | |
141 | - if ( ! empty( $this->label ) ) : ?> |
|
142 | - <span class="fields-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
141 | + if ( ! empty($this->label)) : ?> |
|
142 | + <span class="fields-control-title"><?php echo esc_html($this->label); ?></span> |
|
143 | 143 | <?php endif; |
144 | - if ( ! empty( $this->description ) ) : ?> |
|
145 | - <span class="description fields-control-description"><?php echo $this->description ; ?></span> |
|
144 | + if ( ! empty($this->description)) : ?> |
|
145 | + <span class="description fields-control-description"><?php echo $this->description; ?></span> |
|
146 | 146 | <?php endif; |
147 | 147 | |
148 | - foreach ( $this->choices as $value => $label ) : |
|
148 | + foreach ($this->choices as $value => $label) : |
|
149 | 149 | ?> |
150 | 150 | <label> |
151 | - <input type="radio" value="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $name ); ?>" <?php $this->link(); checked( $this->value(), $value ); ?> /> |
|
152 | - <?php echo esc_html( $label ); ?><br/> |
|
151 | + <input type="radio" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($name); ?>" <?php $this->link(); checked($this->value(), $value); ?> /> |
|
152 | + <?php echo esc_html($label); ?><br/> |
|
153 | 153 | </label> |
154 | 154 | <?php |
155 | 155 | endforeach; |
@@ -170,22 +170,22 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function render_content() { |
172 | 172 | |
173 | - if ( empty( $this->choices ) ) { |
|
173 | + if (empty($this->choices)) { |
|
174 | 174 | return; |
175 | 175 | } |
176 | 176 | ?> |
177 | 177 | <label> |
178 | - <?php if ( ! empty( $this->label ) ) : ?> |
|
179 | - <span class="fields-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
178 | + <?php if ( ! empty($this->label)) : ?> |
|
179 | + <span class="fields-control-title"><?php echo esc_html($this->label); ?></span> |
|
180 | 180 | <?php endif; |
181 | - if ( ! empty( $this->description ) ) : ?> |
|
181 | + if ( ! empty($this->description)) : ?> |
|
182 | 182 | <span class="description fields-control-description"><?php echo $this->description; ?></span> |
183 | 183 | <?php endif; ?> |
184 | 184 | |
185 | 185 | <select <?php $this->link(); ?>> |
186 | 186 | <?php |
187 | - foreach ( $this->choices as $value => $label ) |
|
188 | - echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>'; |
|
187 | + foreach ($this->choices as $value => $label) |
|
188 | + echo '<option value="'.esc_attr($value).'"'.selected($this->value(), $value, false).'>'.$label.'</option>'; |
|
189 | 189 | ?> |
190 | 190 | </select> |
191 | 191 | </label> |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | public function choices() { |
211 | 211 | |
212 | 212 | $choices = array( |
213 | - '0' => __( '— Select —' ), |
|
213 | + '0' => __('— Select —'), |
|
214 | 214 | ); |
215 | 215 | |
216 | 216 | $pages = get_pages(); |
217 | 217 | |
218 | - $choices = $this->get_page_choices_recurse( $choices, $pages ); |
|
218 | + $choices = $this->get_page_choices_recurse($choices, $pages); |
|
219 | 219 | |
220 | 220 | return $choices; |
221 | 221 | |
@@ -231,17 +231,17 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return array |
233 | 233 | */ |
234 | - public function get_page_choices_recurse( $choices, $pages, $depth = 0, $parent = 0 ) { |
|
234 | + public function get_page_choices_recurse($choices, $pages, $depth = 0, $parent = 0) { |
|
235 | 235 | |
236 | - $pad = str_repeat( ' ', $depth * 3 ); |
|
236 | + $pad = str_repeat(' ', $depth * 3); |
|
237 | 237 | |
238 | - foreach ( $pages as $page ) { |
|
239 | - if ( $parent == $page->post_parent ) { |
|
238 | + foreach ($pages as $page) { |
|
239 | + if ($parent == $page->post_parent) { |
|
240 | 240 | $title = $page->post_title; |
241 | 241 | |
242 | - if ( '' === $title ) { |
|
242 | + if ('' === $title) { |
|
243 | 243 | /* translators: %d: ID of a post */ |
244 | - $title = sprintf( __( '#%d (no title)' ), $page->ID ); |
|
244 | + $title = sprintf(__('#%d (no title)'), $page->ID); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | * @param string $title Page title. |
253 | 253 | * @param object $page Page data object. |
254 | 254 | */ |
255 | - $title = apply_filters( 'list_pages', $title, $page ); |
|
255 | + $title = apply_filters('list_pages', $title, $page); |
|
256 | 256 | |
257 | - $choices[ $page->ID ] = $pad . $title; |
|
257 | + $choices[$page->ID] = $pad.$title; |
|
258 | 258 | |
259 | - $choices = $this->get_page_choices_recurse( $choices, $pages, $depth + 1, $page->ID ); |
|
259 | + $choices = $this->get_page_choices_recurse($choices, $pages, $depth + 1, $page->ID); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | * @param string $id Control ID. |
296 | 296 | * @param array $args Optional. Arguments to override class property defaults. |
297 | 297 | */ |
298 | - public function __construct( $manager, $id, $args = array() ) { |
|
298 | + public function __construct($manager, $id, $args = array()) { |
|
299 | 299 | |
300 | 300 | $this->statuses = array( |
301 | - '' => __( 'Default' ), |
|
301 | + '' => __('Default'), |
|
302 | 302 | ); |
303 | 303 | |
304 | - parent::__construct( $manager, $id, $args ); |
|
304 | + parent::__construct($manager, $id, $args); |
|
305 | 305 | |
306 | 306 | } |
307 | 307 | |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | * @since 3.4.0 |
312 | 312 | */ |
313 | 313 | public function enqueue() { |
314 | - wp_enqueue_script( 'wp-color-picker' ); |
|
315 | - wp_enqueue_style( 'wp-color-picker' ); |
|
314 | + wp_enqueue_script('wp-color-picker'); |
|
315 | + wp_enqueue_style('wp-color-picker'); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | <span class="description customize-control-description">{{{ data.description }}}</span> |
365 | 365 | <# } #> |
366 | 366 | <div class="customize-control-content"> |
367 | - <input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ); ?>" {{ defaultValue }} /> |
|
367 | + <input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e('Hex Value'); ?>" {{ defaultValue }} /> |
|
368 | 368 | </div> |
369 | 369 | </label> |
370 | 370 | <?php |
@@ -416,17 +416,17 @@ discard block |
||
416 | 416 | * @param string $id Control ID. |
417 | 417 | * @param array $args Optional. Arguments to override class property defaults. |
418 | 418 | */ |
419 | - public function __construct( $manager, $id, $args = array() ) { |
|
420 | - parent::__construct( $manager, $id, $args ); |
|
419 | + public function __construct($manager, $id, $args = array()) { |
|
420 | + parent::__construct($manager, $id, $args); |
|
421 | 421 | |
422 | 422 | $this->button_labels = array( |
423 | - 'select' => __( 'Select File' ), |
|
424 | - 'change' => __( 'Change File' ), |
|
425 | - 'default' => __( 'Default' ), |
|
426 | - 'remove' => __( 'Remove' ), |
|
427 | - 'placeholder' => __( 'No file selected' ), |
|
428 | - 'frame_title' => __( 'Select File' ), |
|
429 | - 'frame_button' => __( 'Choose File' ), |
|
423 | + 'select' => __('Select File'), |
|
424 | + 'change' => __('Change File'), |
|
425 | + 'default' => __('Default'), |
|
426 | + 'remove' => __('Remove'), |
|
427 | + 'placeholder' => __('No file selected'), |
|
428 | + 'frame_title' => __('Select File'), |
|
429 | + 'frame_button' => __('Choose File'), |
|
430 | 430 | ); |
431 | 431 | } |
432 | 432 | |
@@ -450,40 +450,40 @@ discard block |
||
450 | 450 | */ |
451 | 451 | public function to_json() { |
452 | 452 | parent::to_json(); |
453 | - $this->json['label'] = html_entity_decode( $this->label, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
453 | + $this->json['label'] = html_entity_decode($this->label, ENT_QUOTES, get_bloginfo('charset')); |
|
454 | 454 | $this->json['mime_type'] = $this->mime_type; |
455 | 455 | $this->json['button_labels'] = $this->button_labels; |
456 | - $this->json['canUpload'] = current_user_can( 'upload_files' ); |
|
456 | + $this->json['canUpload'] = current_user_can('upload_files'); |
|
457 | 457 | |
458 | 458 | $value = $this->value(); |
459 | 459 | |
460 | - if ( is_object( $this->setting ) ) { |
|
461 | - if ( $this->setting->default ) { |
|
460 | + if (is_object($this->setting)) { |
|
461 | + if ($this->setting->default) { |
|
462 | 462 | // Fake an attachment model - needs all fields used by template. |
463 | 463 | // Note that the default value must be a URL, NOT an attachment ID. |
464 | - $type = in_array( substr( $this->setting->default, -3 ), array( 'jpg', 'png', 'gif', 'bmp' ) ) ? 'image' : 'document'; |
|
464 | + $type = in_array(substr($this->setting->default, -3), array('jpg', 'png', 'gif', 'bmp')) ? 'image' : 'document'; |
|
465 | 465 | $default_attachment = array( |
466 | 466 | 'id' => 1, |
467 | 467 | 'url' => $this->setting->default, |
468 | 468 | 'type' => $type, |
469 | - 'icon' => wp_mime_type_icon( $type ), |
|
470 | - 'title' => basename( $this->setting->default ), |
|
469 | + 'icon' => wp_mime_type_icon($type), |
|
470 | + 'title' => basename($this->setting->default), |
|
471 | 471 | ); |
472 | 472 | |
473 | - if ( 'image' === $type ) { |
|
473 | + if ('image' === $type) { |
|
474 | 474 | $default_attachment['sizes'] = array( |
475 | - 'full' => array( 'url' => $this->setting->default ), |
|
475 | + 'full' => array('url' => $this->setting->default), |
|
476 | 476 | ); |
477 | 477 | } |
478 | 478 | |
479 | 479 | $this->json['defaultAttachment'] = $default_attachment; |
480 | 480 | } |
481 | 481 | |
482 | - if ( $value && $this->setting->default && $value === $this->setting->default ) { |
|
482 | + if ($value && $this->setting->default && $value === $this->setting->default) { |
|
483 | 483 | // Set the default as the attachment. |
484 | 484 | $this->json['attachment'] = $this->json['defaultAttachment']; |
485 | - } elseif ( $value ) { |
|
486 | - $this->json['attachment'] = wp_prepare_attachment_for_js( $value ); |
|
485 | + } elseif ($value) { |
|
486 | + $this->json['attachment'] = wp_prepare_attachment_for_js($value); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
@@ -614,11 +614,11 @@ discard block |
||
614 | 614 | parent::to_json(); |
615 | 615 | |
616 | 616 | $value = $this->value(); |
617 | - if ( $value ) { |
|
617 | + if ($value) { |
|
618 | 618 | // Get the attachment model for the existing file. |
619 | - $attachment_id = attachment_url_to_postid( $value ); |
|
620 | - if ( $attachment_id ) { |
|
621 | - $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id ); |
|
619 | + $attachment_id = attachment_url_to_postid($value); |
|
620 | + if ($attachment_id) { |
|
621 | + $this->json['attachment'] = wp_prepare_attachment_for_js($attachment_id); |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | } |
@@ -645,17 +645,17 @@ discard block |
||
645 | 645 | * @param string $id Control ID. |
646 | 646 | * @param array $args Optional. Arguments to override class property defaults. |
647 | 647 | */ |
648 | - public function __construct( $manager, $id, $args = array() ) { |
|
649 | - parent::__construct( $manager, $id, $args ); |
|
648 | + public function __construct($manager, $id, $args = array()) { |
|
649 | + parent::__construct($manager, $id, $args); |
|
650 | 650 | |
651 | 651 | $this->button_labels = array( |
652 | - 'select' => __( 'Select Image' ), |
|
653 | - 'change' => __( 'Change Image' ), |
|
654 | - 'remove' => __( 'Remove' ), |
|
655 | - 'default' => __( 'Default' ), |
|
656 | - 'placeholder' => __( 'No image selected' ), |
|
657 | - 'frame_title' => __( 'Select Image' ), |
|
658 | - 'frame_button' => __( 'Choose Image' ), |
|
652 | + 'select' => __('Select Image'), |
|
653 | + 'change' => __('Change Image'), |
|
654 | + 'remove' => __('Remove'), |
|
655 | + 'default' => __('Default'), |
|
656 | + 'placeholder' => __('No image selected'), |
|
657 | + 'frame_title' => __('Select Image'), |
|
658 | + 'frame_button' => __('Choose Image'), |
|
659 | 659 | ); |
660 | 660 | } |
661 | 661 | |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | * @param string $label |
674 | 674 | * @param mixed $callback |
675 | 675 | */ |
676 | - public function add_tab( $id, $label, $callback ) {} |
|
676 | + public function add_tab($id, $label, $callback) {} |
|
677 | 677 | |
678 | 678 | /** |
679 | 679 | * @since 3.4.0 |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * |
682 | 682 | * @param string $id |
683 | 683 | */ |
684 | - public function remove_tab( $id ) {} |
|
684 | + public function remove_tab($id) {} |
|
685 | 685 | |
686 | 686 | /** |
687 | 687 | * @since 3.4.0 |
@@ -690,5 +690,5 @@ discard block |
||
690 | 690 | * @param string $url |
691 | 691 | * @param string $thumbnail_url |
692 | 692 | */ |
693 | - public function print_tab_image( $url, $thumbnail_url = null ) {} |
|
693 | + public function print_tab_image($url, $thumbnail_url = null) {} |
|
694 | 694 | } |
695 | 695 | \ No newline at end of file |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Fields API Field Class |
|
4 | - * |
|
5 | - * Handles saving and sanitizing of fields. |
|
6 | - * |
|
7 | - * @package WordPress |
|
8 | - * @subpackage Fields_API |
|
9 | - */ |
|
3 | + * Fields API Field Class |
|
4 | + * |
|
5 | + * Handles saving and sanitizing of fields. |
|
6 | + * |
|
7 | + * @package WordPress |
|
8 | + * @subpackage Fields_API |
|
9 | + */ |
|
10 | 10 | class WP_Fields_API_Field { |
11 | 11 | |
12 | 12 | /** |
@@ -182,8 +182,6 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | */ |
@@ -111,7 +111,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function setUp() { |
22 | 22 | parent::setUp(); |
23 | - require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' ); |
|
23 | + require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php'); |
|
24 | 24 | //require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; |
25 | - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); |
|
25 | + wp_set_current_user($this->factory->user->create(array('role' => 'administrator'))); |
|
26 | 26 | |
27 | 27 | global $wp_customize; |
28 | 28 | $this->wp_customize = new WP_Customize_Manager(); |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param object $menu_item Menu item. |
45 | 45 | * @return object |
46 | 46 | */ |
47 | - function filter_type_label( $menu_item ) { |
|
48 | - if ( 'custom_type' === $menu_item->type ) { |
|
47 | + function filter_type_label($menu_item) { |
|
48 | + if ('custom_type' === $menu_item->type) { |
|
49 | 49 | $menu_item->type_label = 'Custom Label'; |
50 | 50 | } |
51 | 51 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * Test constants and statics. |
57 | 57 | */ |
58 | 58 | function test_constants() { |
59 | - do_action( 'customize_register', $this->wp_customize ); |
|
60 | - $this->assertTrue( post_type_exists( WP_Customize_Nav_Menu_Item_Setting::POST_TYPE ) ); |
|
59 | + do_action('customize_register', $this->wp_customize); |
|
60 | + $this->assertTrue(post_type_exists(WP_Customize_Nav_Menu_Item_Setting::POST_TYPE)); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | * @see WP_Customize_Nav_Menu_Item_Setting::__construct() |
67 | 67 | */ |
68 | 68 | function test_construct() { |
69 | - do_action( 'customize_register', $this->wp_customize ); |
|
69 | + do_action('customize_register', $this->wp_customize); |
|
70 | 70 | |
71 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[123]' ); |
|
72 | - $this->assertEquals( 'nav_menu_item', $setting->type ); |
|
73 | - $this->assertEquals( 'postMessage', $setting->transport ); |
|
74 | - $this->assertEquals( 123, $setting->post_id ); |
|
75 | - $this->assertNull( $setting->previous_post_id ); |
|
76 | - $this->assertNull( $setting->update_status ); |
|
77 | - $this->assertNull( $setting->update_error ); |
|
78 | - $this->assertInternalType( 'array', $setting->default ); |
|
71 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, 'nav_menu_item[123]'); |
|
72 | + $this->assertEquals('nav_menu_item', $setting->type); |
|
73 | + $this->assertEquals('postMessage', $setting->transport); |
|
74 | + $this->assertEquals(123, $setting->post_id); |
|
75 | + $this->assertNull($setting->previous_post_id); |
|
76 | + $this->assertNull($setting->update_status); |
|
77 | + $this->assertNull($setting->update_error); |
|
78 | + $this->assertInternalType('array', $setting->default); |
|
79 | 79 | |
80 | 80 | $default = array( |
81 | 81 | 'object_id' => 0, |
@@ -94,34 +94,34 @@ discard block |
||
94 | 94 | 'original_title' => '', |
95 | 95 | 'nav_menu_term_id' => 0, |
96 | 96 | ); |
97 | - $this->assertEquals( $default, $setting->default ); |
|
97 | + $this->assertEquals($default, $setting->default); |
|
98 | 98 | |
99 | 99 | $exception = null; |
100 | 100 | try { |
101 | - $bad_setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'foo_bar_baz' ); |
|
102 | - unset( $bad_setting ); |
|
103 | - } catch ( Exception $e ) { |
|
101 | + $bad_setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, 'foo_bar_baz'); |
|
102 | + unset($bad_setting); |
|
103 | + } catch (Exception $e) { |
|
104 | 104 | $exception = $e; |
105 | 105 | } |
106 | - $this->assertInstanceOf( 'Exception', $exception ); |
|
106 | + $this->assertInstanceOf('Exception', $exception); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * Test empty constructor. |
111 | 111 | */ |
112 | 112 | function test_construct_empty_menus() { |
113 | - do_action( 'customize_register', $this->wp_customize ); |
|
113 | + do_action('customize_register', $this->wp_customize); |
|
114 | 114 | $_wp_customize = $this->wp_customize; |
115 | 115 | unset($_wp_customize->nav_menus); |
116 | 116 | |
117 | 117 | $exception = null; |
118 | 118 | try { |
119 | - $bad_setting = new WP_Customize_Nav_Menu_Item_Setting( $_wp_customize, 'nav_menu_item[123]' ); |
|
120 | - unset( $bad_setting ); |
|
121 | - } catch ( Exception $e ) { |
|
119 | + $bad_setting = new WP_Customize_Nav_Menu_Item_Setting($_wp_customize, 'nav_menu_item[123]'); |
|
120 | + unset($bad_setting); |
|
121 | + } catch (Exception $e) { |
|
122 | 122 | $exception = $e; |
123 | 123 | } |
124 | - $this->assertInstanceOf( 'Exception', $exception ); |
|
124 | + $this->assertInstanceOf('Exception', $exception); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | * @see WP_Customize_Nav_Menu_Item_Setting::__construct() |
131 | 131 | */ |
132 | 132 | function test_construct_placeholder() { |
133 | - do_action( 'customize_register', $this->wp_customize ); |
|
133 | + do_action('customize_register', $this->wp_customize); |
|
134 | 134 | $default = array( |
135 | 135 | 'title' => 'Lorem', |
136 | 136 | 'description' => 'ipsum', |
137 | 137 | 'menu_item_parent' => 123, |
138 | 138 | ); |
139 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[-5]', compact( 'default' ) ); |
|
139 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, 'nav_menu_item[-5]', compact('default')); |
|
140 | 140 | $this->assertEquals( -5, $setting->post_id ); |
141 | - $this->assertNull( $setting->previous_post_id ); |
|
142 | - $this->assertEquals( $default, $setting->default ); |
|
141 | + $this->assertNull($setting->previous_post_id); |
|
142 | + $this->assertEquals($default, $setting->default); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,41 +148,41 @@ discard block |
||
148 | 148 | * @see WP_Customize_Nav_Menu_Item_Setting::value() |
149 | 149 | */ |
150 | 150 | function test_value_type_post_type() { |
151 | - do_action( 'customize_register', $this->wp_customize ); |
|
151 | + do_action('customize_register', $this->wp_customize); |
|
152 | 152 | |
153 | - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); |
|
153 | + $post_id = $this->factory->post->create(array('post_title' => 'Hello World')); |
|
154 | 154 | |
155 | - $menu_id = wp_create_nav_menu( 'Menu' ); |
|
155 | + $menu_id = wp_create_nav_menu('Menu'); |
|
156 | 156 | $item_title = 'Greetings'; |
157 | - $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
|
157 | + $item_id = wp_update_nav_menu_item($menu_id, 0, array( |
|
158 | 158 | 'menu-item-type' => 'post_type', |
159 | 159 | 'menu-item-object' => 'post', |
160 | 160 | 'menu-item-object-id' => $post_id, |
161 | 161 | 'menu-item-title' => $item_title, |
162 | 162 | 'menu-item-status' => 'publish', |
163 | - ) ); |
|
163 | + )); |
|
164 | 164 | |
165 | - $post = get_post( $item_id ); |
|
166 | - $menu_item = wp_setup_nav_menu_item( $post ); |
|
167 | - $this->assertEquals( $item_title, $menu_item->title ); |
|
165 | + $post = get_post($item_id); |
|
166 | + $menu_item = wp_setup_nav_menu_item($post); |
|
167 | + $this->assertEquals($item_title, $menu_item->title); |
|
168 | 168 | |
169 | 169 | $setting_id = "nav_menu_item[$item_id]"; |
170 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
170 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
171 | 171 | |
172 | 172 | $value = $setting->value(); |
173 | - $this->assertEquals( $menu_item->title, $value['title'] ); |
|
174 | - $this->assertEquals( $menu_item->type, $value['type'] ); |
|
175 | - $this->assertEquals( $menu_item->object_id, $value['object_id'] ); |
|
176 | - $this->assertEquals( $menu_id, $value['nav_menu_term_id'] ); |
|
177 | - $this->assertEquals( 'Hello World', $value['original_title'] ); |
|
178 | - |
|
179 | - $other_menu_id = wp_create_nav_menu( 'Menu2' ); |
|
180 | - wp_update_nav_menu_item( $other_menu_id, $item_id, array( |
|
173 | + $this->assertEquals($menu_item->title, $value['title']); |
|
174 | + $this->assertEquals($menu_item->type, $value['type']); |
|
175 | + $this->assertEquals($menu_item->object_id, $value['object_id']); |
|
176 | + $this->assertEquals($menu_id, $value['nav_menu_term_id']); |
|
177 | + $this->assertEquals('Hello World', $value['original_title']); |
|
178 | + |
|
179 | + $other_menu_id = wp_create_nav_menu('Menu2'); |
|
180 | + wp_update_nav_menu_item($other_menu_id, $item_id, array( |
|
181 | 181 | 'menu-item-title' => 'Hola', |
182 | - ) ); |
|
182 | + )); |
|
183 | 183 | $value = $setting->value(); |
184 | - $this->assertEquals( 'Hola', $value['title'] ); |
|
185 | - $this->assertEquals( $other_menu_id, $value['nav_menu_term_id'] ); |
|
184 | + $this->assertEquals('Hola', $value['title']); |
|
185 | + $this->assertEquals($other_menu_id, $value['nav_menu_term_id']); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -191,33 +191,33 @@ discard block |
||
191 | 191 | * @see WP_Customize_Nav_Menu_Item_Setting::value() |
192 | 192 | */ |
193 | 193 | function test_value_type_taxonomy() { |
194 | - do_action( 'customize_register', $this->wp_customize ); |
|
194 | + do_action('customize_register', $this->wp_customize); |
|
195 | 195 | |
196 | - $tax_id = $this->factory->category->create( array( 'name' => 'Salutations' ) ); |
|
196 | + $tax_id = $this->factory->category->create(array('name' => 'Salutations')); |
|
197 | 197 | |
198 | - $menu_id = wp_create_nav_menu( 'Menu' ); |
|
198 | + $menu_id = wp_create_nav_menu('Menu'); |
|
199 | 199 | $item_title = 'Greetings'; |
200 | - $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
|
200 | + $item_id = wp_update_nav_menu_item($menu_id, 0, array( |
|
201 | 201 | 'menu-item-type' => 'taxonomy', |
202 | 202 | 'menu-item-object' => 'category', |
203 | 203 | 'menu-item-object-id' => $tax_id, |
204 | 204 | 'menu-item-title' => $item_title, |
205 | 205 | 'menu-item-status' => 'publish', |
206 | - ) ); |
|
206 | + )); |
|
207 | 207 | |
208 | - $post = get_post( $item_id ); |
|
209 | - $menu_item = wp_setup_nav_menu_item( $post ); |
|
210 | - $this->assertEquals( $item_title, $menu_item->title ); |
|
208 | + $post = get_post($item_id); |
|
209 | + $menu_item = wp_setup_nav_menu_item($post); |
|
210 | + $this->assertEquals($item_title, $menu_item->title); |
|
211 | 211 | |
212 | 212 | $setting_id = "nav_menu_item[$item_id]"; |
213 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
213 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
214 | 214 | |
215 | 215 | $value = $setting->value(); |
216 | - $this->assertEquals( $menu_item->title, $value['title'] ); |
|
217 | - $this->assertEquals( $menu_item->type, $value['type'] ); |
|
218 | - $this->assertEquals( $menu_item->object_id, $value['object_id'] ); |
|
219 | - $this->assertEquals( $menu_id, $value['nav_menu_term_id'] ); |
|
220 | - $this->assertEquals( 'Salutations', $value['original_title'] ); |
|
216 | + $this->assertEquals($menu_item->title, $value['title']); |
|
217 | + $this->assertEquals($menu_item->type, $value['type']); |
|
218 | + $this->assertEquals($menu_item->object_id, $value['object_id']); |
|
219 | + $this->assertEquals($menu_id, $value['nav_menu_term_id']); |
|
220 | + $this->assertEquals('Salutations', $value['original_title']); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -226,26 +226,26 @@ discard block |
||
226 | 226 | * @see WP_Customize_Nav_Menu_Item_Setting::value() |
227 | 227 | */ |
228 | 228 | function test_custom_type_label() { |
229 | - do_action( 'customize_register', $this->wp_customize ); |
|
230 | - add_filter( 'wp_setup_nav_menu_item', array( $this, 'filter_type_label' ) ); |
|
229 | + do_action('customize_register', $this->wp_customize); |
|
230 | + add_filter('wp_setup_nav_menu_item', array($this, 'filter_type_label')); |
|
231 | 231 | |
232 | - $menu_id = wp_create_nav_menu( 'Menu' ); |
|
233 | - $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
|
232 | + $menu_id = wp_create_nav_menu('Menu'); |
|
233 | + $item_id = wp_update_nav_menu_item($menu_id, 0, array( |
|
234 | 234 | 'menu-item-type' => 'custom_type', |
235 | 235 | 'menu-item-object' => 'custom_object', |
236 | 236 | 'menu-item-title' => 'Cool beans', |
237 | 237 | 'menu-item-status' => 'publish', |
238 | - ) ); |
|
238 | + )); |
|
239 | 239 | |
240 | - $post = get_post( $item_id ); |
|
241 | - $menu_item = wp_setup_nav_menu_item( $post ); |
|
240 | + $post = get_post($item_id); |
|
241 | + $menu_item = wp_setup_nav_menu_item($post); |
|
242 | 242 | |
243 | 243 | $setting_id = "nav_menu_item[$item_id]"; |
244 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
244 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
245 | 245 | |
246 | 246 | $value = $setting->value(); |
247 | - $this->assertEquals( $menu_item->type_label, 'Custom Label' ); |
|
248 | - $this->assertEquals( $menu_item->type_label, $value['type_label'] ); |
|
247 | + $this->assertEquals($menu_item->type_label, 'Custom Label'); |
|
248 | + $this->assertEquals($menu_item->type_label, $value['type_label']); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @see WP_Customize_Nav_Menu_Item_Setting::value() |
255 | 255 | */ |
256 | 256 | function test_value_nav_menu_term_id_returns_zero() { |
257 | - do_action( 'customize_register', $this->wp_customize ); |
|
257 | + do_action('customize_register', $this->wp_customize); |
|
258 | 258 | |
259 | 259 | $menu_id = -123; |
260 | 260 | $post_value = array( |
@@ -264,29 +264,29 @@ discard block |
||
264 | 264 | 'auto_add' => false, |
265 | 265 | ); |
266 | 266 | $setting_id = "nav_menu[$menu_id]"; |
267 | - $menu = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id ); |
|
267 | + $menu = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id); |
|
268 | 268 | |
269 | - $this->wp_customize->set_post_value( $menu->id, $post_value ); |
|
269 | + $this->wp_customize->set_post_value($menu->id, $post_value); |
|
270 | 270 | $menu->preview(); |
271 | 271 | $value = $menu->value(); |
272 | - $this->assertEquals( $post_value, $value ); |
|
272 | + $this->assertEquals($post_value, $value); |
|
273 | 273 | |
274 | - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); |
|
275 | - $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
|
274 | + $post_id = $this->factory->post->create(array('post_title' => 'Hello World')); |
|
275 | + $item_id = wp_update_nav_menu_item($menu_id, 0, array( |
|
276 | 276 | 'menu-item-type' => 'post_type', |
277 | 277 | 'menu-item-object' => 'post', |
278 | 278 | 'menu-item-object-id' => $post_id, |
279 | 279 | 'menu-item-title' => 'Hello World', |
280 | 280 | 'menu-item-status' => 'publish', |
281 | - ) ); |
|
281 | + )); |
|
282 | 282 | |
283 | - $post = get_post( $item_id ); |
|
284 | - $menu_item = wp_setup_nav_menu_item( $post ); |
|
283 | + $post = get_post($item_id); |
|
284 | + $menu_item = wp_setup_nav_menu_item($post); |
|
285 | 285 | |
286 | 286 | $setting_id = "nav_menu_item[$item_id]"; |
287 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
287 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
288 | 288 | $value = $setting->value(); |
289 | - $this->assertEquals( 0, $value['nav_menu_term_id'] ); |
|
289 | + $this->assertEquals(0, $value['nav_menu_term_id']); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -295,22 +295,22 @@ discard block |
||
295 | 295 | * @see WP_Customize_Nav_Menu_Item_Setting::preview() |
296 | 296 | */ |
297 | 297 | function test_preview_updated() { |
298 | - do_action( 'customize_register', $this->wp_customize ); |
|
298 | + do_action('customize_register', $this->wp_customize); |
|
299 | 299 | |
300 | - $first_post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); |
|
301 | - $second_post_id = $this->factory->post->create( array( 'post_title' => 'Hola Muno' ) ); |
|
300 | + $first_post_id = $this->factory->post->create(array('post_title' => 'Hello World')); |
|
301 | + $second_post_id = $this->factory->post->create(array('post_title' => 'Hola Muno')); |
|
302 | 302 | |
303 | - $primary_menu_id = wp_create_nav_menu( 'Primary' ); |
|
304 | - $secondary_menu_id = wp_create_nav_menu( 'Secondary' ); |
|
303 | + $primary_menu_id = wp_create_nav_menu('Primary'); |
|
304 | + $secondary_menu_id = wp_create_nav_menu('Secondary'); |
|
305 | 305 | $item_title = 'Greetings'; |
306 | - $item_id = wp_update_nav_menu_item( $primary_menu_id, 0, array( |
|
306 | + $item_id = wp_update_nav_menu_item($primary_menu_id, 0, array( |
|
307 | 307 | 'menu-item-type' => 'post_type', |
308 | 308 | 'menu-item-object' => 'post', |
309 | 309 | 'menu-item-object-id' => $first_post_id, |
310 | 310 | 'menu-item-title' => $item_title, |
311 | 311 | 'menu-item-status' => 'publish', |
312 | - ) ); |
|
313 | - $this->assertNotEmpty( wp_get_nav_menu_items( $primary_menu_id, array( 'post_status' => 'publish,draft' ) ) ); |
|
312 | + )); |
|
313 | + $this->assertNotEmpty(wp_get_nav_menu_items($primary_menu_id, array('post_status' => 'publish,draft'))); |
|
314 | 314 | |
315 | 315 | $post_value = array( |
316 | 316 | 'type' => 'post_type', |
@@ -321,22 +321,22 @@ discard block |
||
321 | 321 | 'nav_menu_term_id' => $secondary_menu_id, |
322 | 322 | ); |
323 | 323 | $setting_id = "nav_menu_item[$item_id]"; |
324 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
325 | - $this->wp_customize->set_post_value( $setting_id, $post_value ); |
|
326 | - unset( $post_value['nav_menu_term_id'] ); |
|
324 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
325 | + $this->wp_customize->set_post_value($setting_id, $post_value); |
|
326 | + unset($post_value['nav_menu_term_id']); |
|
327 | 327 | $setting->preview(); |
328 | 328 | |
329 | 329 | // Make sure the menu item appears in the new menu. |
330 | - $this->assertNotContains( $item_id, wp_list_pluck( wp_get_nav_menu_items( $primary_menu_id ), 'db_id' ) ); |
|
331 | - $menu_items = wp_get_nav_menu_items( $secondary_menu_id ); |
|
332 | - $db_ids = wp_list_pluck( $menu_items, 'db_id' ); |
|
333 | - $this->assertContains( $item_id, $db_ids ); |
|
334 | - $i = array_search( $item_id, $db_ids ); |
|
335 | - $updated_item = $menu_items[ $i ]; |
|
330 | + $this->assertNotContains($item_id, wp_list_pluck(wp_get_nav_menu_items($primary_menu_id), 'db_id')); |
|
331 | + $menu_items = wp_get_nav_menu_items($secondary_menu_id); |
|
332 | + $db_ids = wp_list_pluck($menu_items, 'db_id'); |
|
333 | + $this->assertContains($item_id, $db_ids); |
|
334 | + $i = array_search($item_id, $db_ids); |
|
335 | + $updated_item = $menu_items[$i]; |
|
336 | 336 | $post_value['post_status'] = $post_value['status']; |
337 | - unset( $post_value['status'] ); |
|
338 | - foreach ( $post_value as $key => $value ) { |
|
339 | - $this->assertEquals( $value, $updated_item->$key, "Key $key mismatch" ); |
|
337 | + unset($post_value['status']); |
|
338 | + foreach ($post_value as $key => $value) { |
|
339 | + $this->assertEquals($value, $updated_item->$key, "Key $key mismatch"); |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
@@ -346,20 +346,20 @@ discard block |
||
346 | 346 | * @see WP_Customize_Nav_Menu_Item_Setting::preview() |
347 | 347 | */ |
348 | 348 | function test_preview_inserted() { |
349 | - do_action( 'customize_register', $this->wp_customize ); |
|
349 | + do_action('customize_register', $this->wp_customize); |
|
350 | 350 | |
351 | - $menu_id = wp_create_nav_menu( 'Primary' ); |
|
352 | - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); |
|
351 | + $menu_id = wp_create_nav_menu('Primary'); |
|
352 | + $post_id = $this->factory->post->create(array('post_title' => 'Hello World')); |
|
353 | 353 | $item_ids = array(); |
354 | - for ( $i = 0; $i < 5; $i += 1 ) { |
|
355 | - $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
|
354 | + for ($i = 0; $i < 5; $i += 1) { |
|
355 | + $item_id = wp_update_nav_menu_item($menu_id, 0, array( |
|
356 | 356 | 'menu-item-type' => 'post_type', |
357 | 357 | 'menu-item-object' => 'post', |
358 | 358 | 'menu-item-object-id' => $post_id, |
359 | 359 | 'menu-item-title' => "Item $i", |
360 | 360 | 'menu-item-status' => 'publish', |
361 | 361 | 'menu-item-position' => $i + 1, |
362 | - ) ); |
|
362 | + )); |
|
363 | 363 | $item_ids[] = $item_id; |
364 | 364 | } |
365 | 365 | |
@@ -370,28 +370,28 @@ discard block |
||
370 | 370 | 'title' => 'Inserted item', |
371 | 371 | 'status' => 'publish', |
372 | 372 | 'nav_menu_term_id' => $menu_id, |
373 | - 'position' => count( $item_ids ) + 1, |
|
373 | + 'position' => count($item_ids) + 1, |
|
374 | 374 | ); |
375 | 375 | |
376 | 376 | $new_item_id = -10; |
377 | 377 | $setting_id = "nav_menu_item[$new_item_id]"; |
378 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
379 | - $this->wp_customize->set_post_value( $setting_id, $post_value ); |
|
380 | - unset( $post_value['nav_menu_term_id'] ); |
|
378 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
379 | + $this->wp_customize->set_post_value($setting_id, $post_value); |
|
380 | + unset($post_value['nav_menu_term_id']); |
|
381 | 381 | |
382 | - $current_items = wp_get_nav_menu_items( $menu_id ); |
|
382 | + $current_items = wp_get_nav_menu_items($menu_id); |
|
383 | 383 | $setting->preview(); |
384 | - $preview_items = wp_get_nav_menu_items( $menu_id ); |
|
385 | - $this->assertNotEquals( count( $current_items ), count( $preview_items ) ); |
|
384 | + $preview_items = wp_get_nav_menu_items($menu_id); |
|
385 | + $this->assertNotEquals(count($current_items), count($preview_items)); |
|
386 | 386 | |
387 | - $last_item = array_pop( $preview_items ); |
|
388 | - $this->assertEquals( $new_item_id, $last_item->db_id ); |
|
387 | + $last_item = array_pop($preview_items); |
|
388 | + $this->assertEquals($new_item_id, $last_item->db_id); |
|
389 | 389 | $post_value['post_status'] = $post_value['status']; |
390 | - unset( $post_value['status'] ); |
|
390 | + unset($post_value['status']); |
|
391 | 391 | $post_value['menu_order'] = $post_value['position']; |
392 | - unset( $post_value['position'] ); |
|
393 | - foreach ( $post_value as $key => $value ) { |
|
394 | - $this->assertEquals( $value, $last_item->$key, "Mismatch for $key property." ); |
|
392 | + unset($post_value['position']); |
|
393 | + foreach ($post_value as $key => $value) { |
|
394 | + $this->assertEquals($value, $last_item->$key, "Mismatch for $key property."); |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
@@ -401,34 +401,34 @@ discard block |
||
401 | 401 | * @see WP_Customize_Nav_Menu_Item_Setting::preview() |
402 | 402 | */ |
403 | 403 | function test_preview_deleted() { |
404 | - do_action( 'customize_register', $this->wp_customize ); |
|
404 | + do_action('customize_register', $this->wp_customize); |
|
405 | 405 | |
406 | - $menu_id = wp_create_nav_menu( 'Primary' ); |
|
407 | - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); |
|
406 | + $menu_id = wp_create_nav_menu('Primary'); |
|
407 | + $post_id = $this->factory->post->create(array('post_title' => 'Hello World')); |
|
408 | 408 | $item_ids = array(); |
409 | - for ( $i = 0; $i < 5; $i += 1 ) { |
|
410 | - $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
|
409 | + for ($i = 0; $i < 5; $i += 1) { |
|
410 | + $item_id = wp_update_nav_menu_item($menu_id, 0, array( |
|
411 | 411 | 'menu-item-type' => 'post_type', |
412 | 412 | 'menu-item-object' => 'post', |
413 | 413 | 'menu-item-object-id' => $post_id, |
414 | 414 | 'menu-item-title' => "Item $i", |
415 | 415 | 'menu-item-status' => 'publish', |
416 | 416 | 'menu-item-position' => $i + 1, |
417 | - ) ); |
|
417 | + )); |
|
418 | 418 | $item_ids[] = $item_id; |
419 | 419 | } |
420 | 420 | |
421 | 421 | $delete_item_id = $item_ids[2]; |
422 | 422 | $setting_id = "nav_menu_item[$delete_item_id]"; |
423 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
424 | - $this->wp_customize->set_post_value( $setting_id, false ); |
|
423 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
424 | + $this->wp_customize->set_post_value($setting_id, false); |
|
425 | 425 | |
426 | - $current_items = wp_get_nav_menu_items( $menu_id ); |
|
427 | - $this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) ); |
|
426 | + $current_items = wp_get_nav_menu_items($menu_id); |
|
427 | + $this->assertContains($delete_item_id, wp_list_pluck($current_items, 'db_id')); |
|
428 | 428 | $setting->preview(); |
429 | - $preview_items = wp_get_nav_menu_items( $menu_id ); |
|
430 | - $this->assertNotEquals( count( $current_items ), count( $preview_items ) ); |
|
431 | - $this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) ); |
|
429 | + $preview_items = wp_get_nav_menu_items($menu_id); |
|
430 | + $this->assertNotEquals(count($current_items), count($preview_items)); |
|
431 | + $this->assertContains($delete_item_id, wp_list_pluck($current_items, 'db_id')); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -437,11 +437,11 @@ discard block |
||
437 | 437 | * @see WP_Customize_Nav_Menu_Item_Setting::sanitize() |
438 | 438 | */ |
439 | 439 | function test_sanitize() { |
440 | - do_action( 'customize_register', $this->wp_customize ); |
|
441 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[123]' ); |
|
440 | + do_action('customize_register', $this->wp_customize); |
|
441 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, 'nav_menu_item[123]'); |
|
442 | 442 | |
443 | - $this->assertNull( $setting->sanitize( 'not an array' ) ); |
|
444 | - $this->assertNull( $setting->sanitize( 123 ) ); |
|
443 | + $this->assertNull($setting->sanitize('not an array')); |
|
444 | + $this->assertNull($setting->sanitize(123)); |
|
445 | 445 | |
446 | 446 | $unsanitized = array( |
447 | 447 | 'object_id' => 'bad', |
@@ -461,24 +461,24 @@ discard block |
||
461 | 461 | 'nav_menu_term_id' => 'heilo', |
462 | 462 | ); |
463 | 463 | |
464 | - $sanitized = $setting->sanitize( $unsanitized ); |
|
465 | - $this->assertEqualSets( array_keys( $unsanitized ), array_keys( $sanitized ) ); |
|
466 | - |
|
467 | - $this->assertEquals( 0, $sanitized['object_id'] ); |
|
468 | - $this->assertEquals( 'bhellob', $sanitized['object'] ); |
|
469 | - $this->assertEquals( 0, $sanitized['menu_item_parent'] ); |
|
470 | - $this->assertEquals( 0, $sanitized['position'] ); |
|
471 | - $this->assertEquals( 'customb', $sanitized['type'] ); |
|
472 | - $this->assertEquals( 'Hi', $sanitized['title'] ); |
|
473 | - $this->assertEquals( '', $sanitized['url'] ); |
|
474 | - $this->assertEquals( 'onclick', $sanitized['target'] ); |
|
475 | - $this->assertEquals( 'evil', $sanitized['attr_title'] ); |
|
476 | - $this->assertEquals( 'Hello world', $sanitized['description'] ); |
|
477 | - $this->assertEquals( 'hello inject', $sanitized['classes'] ); |
|
478 | - $this->assertEquals( 'hello inject', $sanitized['xfn'] ); |
|
479 | - $this->assertEquals( 'publish', $sanitized['status'] ); |
|
480 | - $this->assertEquals( 'Hi', $sanitized['original_title'] ); |
|
481 | - $this->assertEquals( 0, $sanitized['nav_menu_term_id'] ); |
|
464 | + $sanitized = $setting->sanitize($unsanitized); |
|
465 | + $this->assertEqualSets(array_keys($unsanitized), array_keys($sanitized)); |
|
466 | + |
|
467 | + $this->assertEquals(0, $sanitized['object_id']); |
|
468 | + $this->assertEquals('bhellob', $sanitized['object']); |
|
469 | + $this->assertEquals(0, $sanitized['menu_item_parent']); |
|
470 | + $this->assertEquals(0, $sanitized['position']); |
|
471 | + $this->assertEquals('customb', $sanitized['type']); |
|
472 | + $this->assertEquals('Hi', $sanitized['title']); |
|
473 | + $this->assertEquals('', $sanitized['url']); |
|
474 | + $this->assertEquals('onclick', $sanitized['target']); |
|
475 | + $this->assertEquals('evil', $sanitized['attr_title']); |
|
476 | + $this->assertEquals('Hello world', $sanitized['description']); |
|
477 | + $this->assertEquals('hello inject', $sanitized['classes']); |
|
478 | + $this->assertEquals('hello inject', $sanitized['xfn']); |
|
479 | + $this->assertEquals('publish', $sanitized['status']); |
|
480 | + $this->assertEquals('Hi', $sanitized['original_title']); |
|
481 | + $this->assertEquals(0, $sanitized['nav_menu_term_id']); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -487,22 +487,22 @@ discard block |
||
487 | 487 | * @see WP_Customize_Nav_Menu_Item_Setting::update() |
488 | 488 | */ |
489 | 489 | function test_save_updated() { |
490 | - do_action( 'customize_register', $this->wp_customize ); |
|
490 | + do_action('customize_register', $this->wp_customize); |
|
491 | 491 | |
492 | - $first_post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); |
|
493 | - $second_post_id = $this->factory->post->create( array( 'post_title' => 'Hola Muno' ) ); |
|
492 | + $first_post_id = $this->factory->post->create(array('post_title' => 'Hello World')); |
|
493 | + $second_post_id = $this->factory->post->create(array('post_title' => 'Hola Muno')); |
|
494 | 494 | |
495 | - $primary_menu_id = wp_create_nav_menu( 'Primary' ); |
|
496 | - $secondary_menu_id = wp_create_nav_menu( 'Secondary' ); |
|
495 | + $primary_menu_id = wp_create_nav_menu('Primary'); |
|
496 | + $secondary_menu_id = wp_create_nav_menu('Secondary'); |
|
497 | 497 | $item_title = 'Greetings'; |
498 | - $item_id = wp_update_nav_menu_item( $primary_menu_id, 0, array( |
|
498 | + $item_id = wp_update_nav_menu_item($primary_menu_id, 0, array( |
|
499 | 499 | 'menu-item-type' => 'post_type', |
500 | 500 | 'menu-item-object' => 'post', |
501 | 501 | 'menu-item-object-id' => $first_post_id, |
502 | 502 | 'menu-item-title' => $item_title, |
503 | 503 | 'menu-item-status' => 'publish', |
504 | - ) ); |
|
505 | - $this->assertNotEmpty( wp_get_nav_menu_items( $primary_menu_id, array( 'post_status' => 'publish,draft' ) ) ); |
|
504 | + )); |
|
505 | + $this->assertNotEmpty(wp_get_nav_menu_items($primary_menu_id, array('post_status' => 'publish,draft'))); |
|
506 | 506 | |
507 | 507 | $post_value = array( |
508 | 508 | 'type' => 'post_type', |
@@ -513,37 +513,37 @@ discard block |
||
513 | 513 | 'nav_menu_term_id' => $secondary_menu_id, |
514 | 514 | ); |
515 | 515 | $setting_id = "nav_menu_item[$item_id]"; |
516 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
517 | - $this->wp_customize->set_post_value( $setting_id, $post_value ); |
|
518 | - unset( $post_value['nav_menu_term_id'] ); |
|
516 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
517 | + $this->wp_customize->set_post_value($setting_id, $post_value); |
|
518 | + unset($post_value['nav_menu_term_id']); |
|
519 | 519 | $setting->save(); |
520 | 520 | |
521 | 521 | // Make sure the menu item appears in the new menu. |
522 | - $this->assertNotContains( $item_id, wp_list_pluck( wp_get_nav_menu_items( $primary_menu_id ), 'db_id' ) ); |
|
523 | - $menu_items = wp_get_nav_menu_items( $secondary_menu_id ); |
|
524 | - $db_ids = wp_list_pluck( $menu_items, 'db_id' ); |
|
525 | - $this->assertContains( $item_id, $db_ids ); |
|
526 | - $i = array_search( $item_id, $db_ids ); |
|
527 | - $updated_item = $menu_items[ $i ]; |
|
522 | + $this->assertNotContains($item_id, wp_list_pluck(wp_get_nav_menu_items($primary_menu_id), 'db_id')); |
|
523 | + $menu_items = wp_get_nav_menu_items($secondary_menu_id); |
|
524 | + $db_ids = wp_list_pluck($menu_items, 'db_id'); |
|
525 | + $this->assertContains($item_id, $db_ids); |
|
526 | + $i = array_search($item_id, $db_ids); |
|
527 | + $updated_item = $menu_items[$i]; |
|
528 | 528 | $post_value['post_status'] = $post_value['status']; |
529 | - unset( $post_value['status'] ); |
|
530 | - foreach ( $post_value as $key => $value ) { |
|
531 | - $this->assertEquals( $value, $updated_item->$key, "Key $key mismatch" ); |
|
529 | + unset($post_value['status']); |
|
530 | + foreach ($post_value as $key => $value) { |
|
531 | + $this->assertEquals($value, $updated_item->$key, "Key $key mismatch"); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | // Verify the Ajax responses is being amended. |
535 | - $save_response = apply_filters( 'customize_save_response', array() ); |
|
536 | - $this->assertArrayHasKey( 'nav_menu_item_updates', $save_response ); |
|
537 | - $update_result = array_shift( $save_response['nav_menu_item_updates'] ); |
|
538 | - $this->assertArrayHasKey( 'post_id', $update_result ); |
|
539 | - $this->assertArrayHasKey( 'previous_post_id', $update_result ); |
|
540 | - $this->assertArrayHasKey( 'error', $update_result ); |
|
541 | - $this->assertArrayHasKey( 'status', $update_result ); |
|
542 | - |
|
543 | - $this->assertEquals( $item_id, $update_result['post_id'] ); |
|
544 | - $this->assertNull( $update_result['previous_post_id'] ); |
|
545 | - $this->assertNull( $update_result['error'] ); |
|
546 | - $this->assertEquals( 'updated', $update_result['status'] ); |
|
535 | + $save_response = apply_filters('customize_save_response', array()); |
|
536 | + $this->assertArrayHasKey('nav_menu_item_updates', $save_response); |
|
537 | + $update_result = array_shift($save_response['nav_menu_item_updates']); |
|
538 | + $this->assertArrayHasKey('post_id', $update_result); |
|
539 | + $this->assertArrayHasKey('previous_post_id', $update_result); |
|
540 | + $this->assertArrayHasKey('error', $update_result); |
|
541 | + $this->assertArrayHasKey('status', $update_result); |
|
542 | + |
|
543 | + $this->assertEquals($item_id, $update_result['post_id']); |
|
544 | + $this->assertNull($update_result['previous_post_id']); |
|
545 | + $this->assertNull($update_result['error']); |
|
546 | + $this->assertEquals('updated', $update_result['status']); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
@@ -552,20 +552,20 @@ discard block |
||
552 | 552 | * @see WP_Customize_Nav_Menu_Item_Setting::update() |
553 | 553 | */ |
554 | 554 | function test_save_inserted() { |
555 | - do_action( 'customize_register', $this->wp_customize ); |
|
555 | + do_action('customize_register', $this->wp_customize); |
|
556 | 556 | |
557 | - $menu_id = wp_create_nav_menu( 'Primary' ); |
|
558 | - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); |
|
557 | + $menu_id = wp_create_nav_menu('Primary'); |
|
558 | + $post_id = $this->factory->post->create(array('post_title' => 'Hello World')); |
|
559 | 559 | $item_ids = array(); |
560 | - for ( $i = 0; $i < 5; $i += 1 ) { |
|
561 | - $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
|
560 | + for ($i = 0; $i < 5; $i += 1) { |
|
561 | + $item_id = wp_update_nav_menu_item($menu_id, 0, array( |
|
562 | 562 | 'menu-item-type' => 'post_type', |
563 | 563 | 'menu-item-object' => 'post', |
564 | 564 | 'menu-item-object-id' => $post_id, |
565 | 565 | 'menu-item-title' => "Item $i", |
566 | 566 | 'menu-item-status' => 'publish', |
567 | 567 | 'menu-item-position' => $i + 1, |
568 | - ) ); |
|
568 | + )); |
|
569 | 569 | $item_ids[] = $item_id; |
570 | 570 | } |
571 | 571 | |
@@ -576,43 +576,43 @@ discard block |
||
576 | 576 | 'title' => 'Inserted item', |
577 | 577 | 'status' => 'publish', |
578 | 578 | 'nav_menu_term_id' => $menu_id, |
579 | - 'position' => count( $item_ids ) + 1, |
|
579 | + 'position' => count($item_ids) + 1, |
|
580 | 580 | ); |
581 | 581 | |
582 | 582 | $new_item_id = -10; |
583 | 583 | $setting_id = "nav_menu_item[$new_item_id]"; |
584 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
585 | - $this->wp_customize->set_post_value( $setting_id, $post_value ); |
|
586 | - unset( $post_value['nav_menu_term_id'] ); |
|
584 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
585 | + $this->wp_customize->set_post_value($setting_id, $post_value); |
|
586 | + unset($post_value['nav_menu_term_id']); |
|
587 | 587 | |
588 | - $current_items = wp_get_nav_menu_items( $menu_id ); |
|
588 | + $current_items = wp_get_nav_menu_items($menu_id); |
|
589 | 589 | $setting->save(); |
590 | - $preview_items = wp_get_nav_menu_items( $menu_id ); |
|
591 | - $this->assertNotEquals( count( $current_items ), count( $preview_items ) ); |
|
590 | + $preview_items = wp_get_nav_menu_items($menu_id); |
|
591 | + $this->assertNotEquals(count($current_items), count($preview_items)); |
|
592 | 592 | |
593 | - $last_item = array_pop( $preview_items ); |
|
594 | - $this->assertEquals( $setting->post_id, $last_item->db_id ); |
|
593 | + $last_item = array_pop($preview_items); |
|
594 | + $this->assertEquals($setting->post_id, $last_item->db_id); |
|
595 | 595 | $post_value['post_status'] = $post_value['status']; |
596 | - unset( $post_value['status'] ); |
|
596 | + unset($post_value['status']); |
|
597 | 597 | $post_value['menu_order'] = $post_value['position']; |
598 | - unset( $post_value['position'] ); |
|
599 | - foreach ( $post_value as $key => $value ) { |
|
600 | - $this->assertEquals( $value, $last_item->$key, "Mismatch for $key property." ); |
|
598 | + unset($post_value['position']); |
|
599 | + foreach ($post_value as $key => $value) { |
|
600 | + $this->assertEquals($value, $last_item->$key, "Mismatch for $key property."); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | // Verify the Ajax responses is being amended. |
604 | - $save_response = apply_filters( 'customize_save_response', array() ); |
|
605 | - $this->assertArrayHasKey( 'nav_menu_item_updates', $save_response ); |
|
606 | - $update_result = array_shift( $save_response['nav_menu_item_updates'] ); |
|
607 | - $this->assertArrayHasKey( 'post_id', $update_result ); |
|
608 | - $this->assertArrayHasKey( 'previous_post_id', $update_result ); |
|
609 | - $this->assertArrayHasKey( 'error', $update_result ); |
|
610 | - $this->assertArrayHasKey( 'status', $update_result ); |
|
611 | - |
|
612 | - $this->assertEquals( $setting->post_id, $update_result['post_id'] ); |
|
613 | - $this->assertEquals( $new_item_id, $update_result['previous_post_id'] ); |
|
614 | - $this->assertNull( $update_result['error'] ); |
|
615 | - $this->assertEquals( 'inserted', $update_result['status'] ); |
|
604 | + $save_response = apply_filters('customize_save_response', array()); |
|
605 | + $this->assertArrayHasKey('nav_menu_item_updates', $save_response); |
|
606 | + $update_result = array_shift($save_response['nav_menu_item_updates']); |
|
607 | + $this->assertArrayHasKey('post_id', $update_result); |
|
608 | + $this->assertArrayHasKey('previous_post_id', $update_result); |
|
609 | + $this->assertArrayHasKey('error', $update_result); |
|
610 | + $this->assertArrayHasKey('status', $update_result); |
|
611 | + |
|
612 | + $this->assertEquals($setting->post_id, $update_result['post_id']); |
|
613 | + $this->assertEquals($new_item_id, $update_result['previous_post_id']); |
|
614 | + $this->assertNull($update_result['error']); |
|
615 | + $this->assertEquals('inserted', $update_result['status']); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -621,48 +621,48 @@ discard block |
||
621 | 621 | * @see WP_Customize_Nav_Menu_Item_Setting::update() |
622 | 622 | */ |
623 | 623 | function test_save_deleted() { |
624 | - do_action( 'customize_register', $this->wp_customize ); |
|
624 | + do_action('customize_register', $this->wp_customize); |
|
625 | 625 | |
626 | - $menu_id = wp_create_nav_menu( 'Primary' ); |
|
627 | - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); |
|
626 | + $menu_id = wp_create_nav_menu('Primary'); |
|
627 | + $post_id = $this->factory->post->create(array('post_title' => 'Hello World')); |
|
628 | 628 | $item_ids = array(); |
629 | - for ( $i = 0; $i < 5; $i += 1 ) { |
|
630 | - $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
|
629 | + for ($i = 0; $i < 5; $i += 1) { |
|
630 | + $item_id = wp_update_nav_menu_item($menu_id, 0, array( |
|
631 | 631 | 'menu-item-type' => 'post_type', |
632 | 632 | 'menu-item-object' => 'post', |
633 | 633 | 'menu-item-object-id' => $post_id, |
634 | 634 | 'menu-item-title' => "Item $i", |
635 | 635 | 'menu-item-status' => 'publish', |
636 | 636 | 'menu-item-position' => $i + 1, |
637 | - ) ); |
|
637 | + )); |
|
638 | 638 | $item_ids[] = $item_id; |
639 | 639 | } |
640 | 640 | |
641 | 641 | $delete_item_id = $item_ids[2]; |
642 | 642 | $setting_id = "nav_menu_item[$delete_item_id]"; |
643 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); |
|
644 | - $this->wp_customize->set_post_value( $setting_id, false ); |
|
643 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id); |
|
644 | + $this->wp_customize->set_post_value($setting_id, false); |
|
645 | 645 | |
646 | - $current_items = wp_get_nav_menu_items( $menu_id ); |
|
647 | - $this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) ); |
|
646 | + $current_items = wp_get_nav_menu_items($menu_id); |
|
647 | + $this->assertContains($delete_item_id, wp_list_pluck($current_items, 'db_id')); |
|
648 | 648 | $setting->save(); |
649 | - $preview_items = wp_get_nav_menu_items( $menu_id ); |
|
650 | - $this->assertNotEquals( count( $current_items ), count( $preview_items ) ); |
|
651 | - $this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) ); |
|
649 | + $preview_items = wp_get_nav_menu_items($menu_id); |
|
650 | + $this->assertNotEquals(count($current_items), count($preview_items)); |
|
651 | + $this->assertContains($delete_item_id, wp_list_pluck($current_items, 'db_id')); |
|
652 | 652 | |
653 | 653 | // Verify the Ajax responses is being amended. |
654 | - $save_response = apply_filters( 'customize_save_response', array() ); |
|
655 | - $this->assertArrayHasKey( 'nav_menu_item_updates', $save_response ); |
|
656 | - $update_result = array_shift( $save_response['nav_menu_item_updates'] ); |
|
657 | - $this->assertArrayHasKey( 'post_id', $update_result ); |
|
658 | - $this->assertArrayHasKey( 'previous_post_id', $update_result ); |
|
659 | - $this->assertArrayHasKey( 'error', $update_result ); |
|
660 | - $this->assertArrayHasKey( 'status', $update_result ); |
|
661 | - |
|
662 | - $this->assertEquals( $delete_item_id, $update_result['post_id'] ); |
|
663 | - $this->assertNull( $update_result['previous_post_id'] ); |
|
664 | - $this->assertNull( $update_result['error'] ); |
|
665 | - $this->assertEquals( 'deleted', $update_result['status'] ); |
|
654 | + $save_response = apply_filters('customize_save_response', array()); |
|
655 | + $this->assertArrayHasKey('nav_menu_item_updates', $save_response); |
|
656 | + $update_result = array_shift($save_response['nav_menu_item_updates']); |
|
657 | + $this->assertArrayHasKey('post_id', $update_result); |
|
658 | + $this->assertArrayHasKey('previous_post_id', $update_result); |
|
659 | + $this->assertArrayHasKey('error', $update_result); |
|
660 | + $this->assertArrayHasKey('status', $update_result); |
|
661 | + |
|
662 | + $this->assertEquals($delete_item_id, $update_result['post_id']); |
|
663 | + $this->assertNull($update_result['previous_post_id']); |
|
664 | + $this->assertNull($update_result['error']); |
|
665 | + $this->assertEquals('deleted', $update_result['status']); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | } |
@@ -14,7 +14,7 @@ discard block |
||
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']; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | function tearDown() { |
25 | 25 | $this->manager = null; |
26 | - unset( $GLOBALS['wp_customize'] ); |
|
26 | + unset($GLOBALS['wp_customize']); |
|
27 | 27 | parent::tearDown(); |
28 | 28 | } |
29 | 29 | |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | * @see WP_Customize_Panel::__construct() |
32 | 32 | */ |
33 | 33 | function test_construct_default_args() { |
34 | - $panel = new WP_Customize_Panel( $this->manager, 'foo' ); |
|
35 | - $this->assertInternalType( 'int', $panel->instance_number ); |
|
36 | - $this->assertEquals( $this->manager, $panel->manager ); |
|
37 | - $this->assertEquals( 'foo', $panel->id ); |
|
38 | - $this->assertEquals( 160, $panel->priority ); |
|
39 | - $this->assertEquals( 'edit_theme_options', $panel->capability ); |
|
40 | - $this->assertEquals( '', $panel->theme_supports ); |
|
41 | - $this->assertEquals( '', $panel->title ); |
|
42 | - $this->assertEquals( '', $panel->description ); |
|
43 | - $this->assertEmpty( $panel->sections ); |
|
44 | - $this->assertEquals( 'default', $panel->type ); |
|
45 | - $this->assertEquals( array( $panel, 'active_callback' ), $panel->active_callback ); |
|
34 | + $panel = new WP_Customize_Panel($this->manager, 'foo'); |
|
35 | + $this->assertInternalType('int', $panel->instance_number); |
|
36 | + $this->assertEquals($this->manager, $panel->manager); |
|
37 | + $this->assertEquals('foo', $panel->id); |
|
38 | + $this->assertEquals(160, $panel->priority); |
|
39 | + $this->assertEquals('edit_theme_options', $panel->capability); |
|
40 | + $this->assertEquals('', $panel->theme_supports); |
|
41 | + $this->assertEquals('', $panel->title); |
|
42 | + $this->assertEquals('', $panel->description); |
|
43 | + $this->assertEmpty($panel->sections); |
|
44 | + $this->assertEquals('default', $panel->type); |
|
45 | + $this->assertEquals(array($panel, 'active_callback'), $panel->active_callback); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | 'active_callback' => '__return_true', |
60 | 60 | ); |
61 | 61 | |
62 | - $panel = new WP_Customize_Panel( $this->manager, 'foo', $args ); |
|
63 | - foreach ( $args as $key => $value ) { |
|
64 | - $this->assertEquals( $value, $panel->$key ); |
|
62 | + $panel = new WP_Customize_Panel($this->manager, 'foo', $args); |
|
63 | + foreach ($args as $key => $value) { |
|
64 | + $this->assertEquals($value, $panel->$key); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @see WP_Customize_Panel::__construct() |
70 | 70 | */ |
71 | 71 | function test_construct_custom_type() { |
72 | - $panel = new Custom_Panel_Test( $this->manager, 'foo' ); |
|
73 | - $this->assertEquals( 'titleless', $panel->type ); |
|
72 | + $panel = new Custom_Panel_Test($this->manager, 'foo'); |
|
73 | + $this->assertEquals('titleless', $panel->type); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | * @see WP_Customize_Panel::active_callback() |
79 | 79 | */ |
80 | 80 | function test_active() { |
81 | - $panel = new WP_Customize_Panel( $this->manager, 'foo' ); |
|
82 | - $this->assertTrue( $panel->active() ); |
|
81 | + $panel = new WP_Customize_Panel($this->manager, 'foo'); |
|
82 | + $this->assertTrue($panel->active()); |
|
83 | 83 | |
84 | - $panel = new WP_Customize_Panel( $this->manager, 'foo', array( |
|
84 | + $panel = new WP_Customize_Panel($this->manager, 'foo', array( |
|
85 | 85 | 'active_callback' => '__return_false', |
86 | - ) ); |
|
87 | - $this->assertFalse( $panel->active() ); |
|
88 | - add_filter( 'customize_panel_active', array( $this, 'filter_active_test' ), 10, 2 ); |
|
89 | - $this->assertTrue( $panel->active() ); |
|
86 | + )); |
|
87 | + $this->assertFalse($panel->active()); |
|
88 | + add_filter('customize_panel_active', array($this, 'filter_active_test'), 10, 2); |
|
89 | + $this->assertTrue($panel->active()); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param WP_Customize_Panel $panel |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | - function filter_active_test( $active, $panel ) { |
|
98 | - $this->assertFalse( $active ); |
|
99 | - $this->assertInstanceOf( 'WP_Customize_Panel', $panel ); |
|
97 | + function filter_active_test($active, $panel) { |
|
98 | + $this->assertFalse($active); |
|
99 | + $this->assertInstanceOf('WP_Customize_Panel', $panel); |
|
100 | 100 | $active = true; |
101 | 101 | return $active; |
102 | 102 | } |
@@ -114,105 +114,105 @@ discard block |
||
114 | 114 | 'type' => 'horizontal', |
115 | 115 | 'active_callback' => '__return_true', |
116 | 116 | ); |
117 | - $panel = new WP_Customize_Panel( $this->manager, 'foo', $args ); |
|
117 | + $panel = new WP_Customize_Panel($this->manager, 'foo', $args); |
|
118 | 118 | $data = $panel->json(); |
119 | - $this->assertEquals( 'foo', $data['id'] ); |
|
120 | - foreach ( array( 'title', 'description', 'priority', 'type' ) as $key ) { |
|
121 | - $this->assertEquals( $args[ $key ], $data[ $key ] ); |
|
119 | + $this->assertEquals('foo', $data['id']); |
|
120 | + foreach (array('title', 'description', 'priority', 'type') as $key) { |
|
121 | + $this->assertEquals($args[$key], $data[$key]); |
|
122 | 122 | } |
123 | - $this->assertEmpty( $data['content'] ); |
|
124 | - $this->assertTrue( $data['active'] ); |
|
125 | - $this->assertInternalType( 'int', $data['instanceNumber'] ); |
|
123 | + $this->assertEmpty($data['content']); |
|
124 | + $this->assertTrue($data['active']); |
|
125 | + $this->assertInternalType('int', $data['instanceNumber']); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
129 | 129 | * @see WP_Customize_Panel::check_capabilities() |
130 | 130 | */ |
131 | 131 | function test_check_capabilities() { |
132 | - $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); |
|
133 | - wp_set_current_user( $user_id ); |
|
132 | + $user_id = $this->factory->user->create(array('role' => 'administrator')); |
|
133 | + wp_set_current_user($user_id); |
|
134 | 134 | |
135 | - $panel = new WP_Customize_Panel( $this->manager, 'foo' ); |
|
136 | - $this->assertTrue( $panel->check_capabilities() ); |
|
135 | + $panel = new WP_Customize_Panel($this->manager, 'foo'); |
|
136 | + $this->assertTrue($panel->check_capabilities()); |
|
137 | 137 | $old_cap = $panel->capability; |
138 | 138 | $panel->capability = 'do_not_allow'; |
139 | - $this->assertFalse( $panel->check_capabilities() ); |
|
139 | + $this->assertFalse($panel->check_capabilities()); |
|
140 | 140 | $panel->capability = $old_cap; |
141 | - $this->assertTrue( $panel->check_capabilities() ); |
|
141 | + $this->assertTrue($panel->check_capabilities()); |
|
142 | 142 | $panel->theme_supports = 'impossible_feature'; |
143 | - $this->assertFalse( $panel->check_capabilities() ); |
|
143 | + $this->assertFalse($panel->check_capabilities()); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @see WP_Customize_Panel::get_content() |
148 | 148 | */ |
149 | 149 | function test_get_content() { |
150 | - $panel = new WP_Customize_Panel( $this->manager, 'foo' ); |
|
151 | - $this->assertEmpty( $panel->get_content() ); |
|
150 | + $panel = new WP_Customize_Panel($this->manager, 'foo'); |
|
151 | + $this->assertEmpty($panel->get_content()); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | 155 | * @see WP_Customize_Panel::maybe_render() |
156 | 156 | */ |
157 | 157 | function test_maybe_render() { |
158 | - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); |
|
159 | - $panel = new WP_Customize_Panel( $this->manager, 'bar' ); |
|
160 | - $customize_render_panel_count = did_action( 'customize_render_panel' ); |
|
161 | - add_action( 'customize_render_panel', array( $this, 'action_customize_render_panel_test' ) ); |
|
158 | + wp_set_current_user($this->factory->user->create(array('role' => 'administrator'))); |
|
159 | + $panel = new WP_Customize_Panel($this->manager, 'bar'); |
|
160 | + $customize_render_panel_count = did_action('customize_render_panel'); |
|
161 | + add_action('customize_render_panel', array($this, 'action_customize_render_panel_test')); |
|
162 | 162 | ob_start(); |
163 | 163 | $panel->maybe_render(); |
164 | 164 | $content = ob_get_clean(); |
165 | - $this->assertTrue( $panel->check_capabilities() ); |
|
166 | - $this->assertEmpty( $content ); |
|
167 | - $this->assertEquals( $customize_render_panel_count + 1, did_action( 'customize_render_panel' ), 'Unexpected did_action count for customize_render_panel' ); |
|
168 | - $this->assertEquals( 1, did_action( "customize_render_panel_{$panel->id}" ), "Unexpected did_action count for customize_render_panel_{$panel->id}" ); |
|
165 | + $this->assertTrue($panel->check_capabilities()); |
|
166 | + $this->assertEmpty($content); |
|
167 | + $this->assertEquals($customize_render_panel_count + 1, did_action('customize_render_panel'), 'Unexpected did_action count for customize_render_panel'); |
|
168 | + $this->assertEquals(1, did_action("customize_render_panel_{$panel->id}"), "Unexpected did_action count for customize_render_panel_{$panel->id}"); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | 172 | * @see WP_Customize_Panel::maybe_render() |
173 | 173 | * @param WP_Customize_Panel $panel |
174 | 174 | */ |
175 | - function action_customize_render_panel_test( $panel ) { |
|
176 | - $this->assertInstanceOf( 'WP_Customize_Panel', $panel ); |
|
175 | + function action_customize_render_panel_test($panel) { |
|
176 | + $this->assertInstanceOf('WP_Customize_Panel', $panel); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | 180 | * @see WP_Customize_Panel::print_template() |
181 | 181 | */ |
182 | 182 | function test_print_templates_standard() { |
183 | - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); |
|
183 | + wp_set_current_user($this->factory->user->create(array('role' => 'administrator'))); |
|
184 | 184 | |
185 | - $panel = new WP_Customize_Panel( $this->manager, 'baz' ); |
|
185 | + $panel = new WP_Customize_Panel($this->manager, 'baz'); |
|
186 | 186 | ob_start(); |
187 | 187 | $panel->print_template(); |
188 | 188 | $content = ob_get_clean(); |
189 | - $this->assertContains( '<script type="text/html" id="tmpl-customize-panel-default-content">', $content ); |
|
190 | - $this->assertContains( 'accordion-section-title', $content ); |
|
191 | - $this->assertContains( 'control-panel-content', $content ); |
|
192 | - $this->assertContains( '<script type="text/html" id="tmpl-customize-panel-default">', $content ); |
|
193 | - $this->assertContains( 'customize-panel-description', $content ); |
|
194 | - $this->assertContains( 'preview-notice', $content ); |
|
189 | + $this->assertContains('<script type="text/html" id="tmpl-customize-panel-default-content">', $content); |
|
190 | + $this->assertContains('accordion-section-title', $content); |
|
191 | + $this->assertContains('control-panel-content', $content); |
|
192 | + $this->assertContains('<script type="text/html" id="tmpl-customize-panel-default">', $content); |
|
193 | + $this->assertContains('customize-panel-description', $content); |
|
194 | + $this->assertContains('preview-notice', $content); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | 198 | * @see WP_Customize_Panel::print_template() |
199 | 199 | */ |
200 | 200 | function test_print_templates_custom() { |
201 | - wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); |
|
201 | + wp_set_current_user($this->factory->user->create(array('role' => 'administrator'))); |
|
202 | 202 | |
203 | - $panel = new Custom_Panel_Test( $this->manager, 'baz' ); |
|
203 | + $panel = new Custom_Panel_Test($this->manager, 'baz'); |
|
204 | 204 | ob_start(); |
205 | 205 | $panel->print_template(); |
206 | 206 | $content = ob_get_clean(); |
207 | - $this->assertContains( '<script type="text/html" id="tmpl-customize-panel-titleless-content">', $content ); |
|
208 | - $this->assertNotContains( 'accordion-section-title', $content ); |
|
207 | + $this->assertContains('<script type="text/html" id="tmpl-customize-panel-titleless-content">', $content); |
|
208 | + $this->assertNotContains('accordion-section-title', $content); |
|
209 | 209 | |
210 | - $this->assertContains( '<script type="text/html" id="tmpl-customize-panel-titleless">', $content ); |
|
211 | - $this->assertNotContains( 'preview-notice', $content ); |
|
210 | + $this->assertContains('<script type="text/html" id="tmpl-customize-panel-titleless">', $content); |
|
211 | + $this->assertNotContains('preview-notice', $content); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | -require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-panel.php' ); |
|
215 | +require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-panel.php'); |
|
216 | 216 | //require_once ABSPATH . WPINC . '/class-wp-customize-panel.php'; |
217 | 217 | class Custom_Panel_Test extends WP_Customize_Panel { |
218 | 218 | public $type = 'titleless'; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | function setUp() { |
21 | 21 | parent::setUp(); |
22 | - require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' ); |
|
22 | + require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php'); |
|
23 | 23 | //require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' ); |
24 | 24 | $GLOBALS['wp_customize'] = new WP_Customize_Manager(); |
25 | 25 | $this->manager = $GLOBALS['wp_customize']; |
@@ -28,24 +28,24 @@ discard block |
||
28 | 28 | |
29 | 29 | function tearDown() { |
30 | 30 | $this->manager = null; |
31 | - unset( $GLOBALS['wp_customize'] ); |
|
31 | + unset($GLOBALS['wp_customize']); |
|
32 | 32 | parent::tearDown(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | function test_constructor_without_args() { |
36 | - $setting = new WP_Customize_Setting( $this->manager, 'foo' ); |
|
37 | - $this->assertEquals( $this->manager, $setting->manager ); |
|
38 | - $this->assertEquals( 'foo', $setting->id ); |
|
39 | - $this->assertEquals( 'theme_mod', $setting->type ); |
|
40 | - $this->assertEquals( 'edit_theme_options', $setting->capability ); |
|
41 | - $this->assertEquals( '', $setting->theme_supports ); |
|
42 | - $this->assertEquals( '', $setting->default ); |
|
43 | - $this->assertEquals( 'refresh', $setting->transport ); |
|
44 | - $this->assertEquals( '', $setting->sanitize_callback ); |
|
45 | - $this->assertEquals( '', $setting->sanitize_js_callback ); |
|
46 | - $this->assertFalse( has_filter( "customize_sanitize_{$setting->id}" ) ); |
|
47 | - $this->assertFalse( has_filter( "customize_sanitize_js_{$setting->id}" ) ); |
|
48 | - $this->assertEquals( false, $setting->dirty ); |
|
36 | + $setting = new WP_Customize_Setting($this->manager, 'foo'); |
|
37 | + $this->assertEquals($this->manager, $setting->manager); |
|
38 | + $this->assertEquals('foo', $setting->id); |
|
39 | + $this->assertEquals('theme_mod', $setting->type); |
|
40 | + $this->assertEquals('edit_theme_options', $setting->capability); |
|
41 | + $this->assertEquals('', $setting->theme_supports); |
|
42 | + $this->assertEquals('', $setting->default); |
|
43 | + $this->assertEquals('refresh', $setting->transport); |
|
44 | + $this->assertEquals('', $setting->sanitize_callback); |
|
45 | + $this->assertEquals('', $setting->sanitize_js_callback); |
|
46 | + $this->assertFalse(has_filter("customize_sanitize_{$setting->id}")); |
|
47 | + $this->assertFalse(has_filter("customize_sanitize_js_{$setting->id}")); |
|
48 | + $this->assertEquals(false, $setting->dirty); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | function test_constructor_with_args() { |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | 'theme_supports' => 'widgets', |
56 | 56 | 'default' => 'barbar', |
57 | 57 | 'transport' => 'postMessage', |
58 | - 'sanitize_callback' => create_function( '$value', 'return $value . ":sanitize_callback";' ), |
|
59 | - 'sanitize_js_callback' => create_function( '$value', 'return $value . ":sanitize_js_callback";' ), |
|
58 | + 'sanitize_callback' => create_function('$value', 'return $value . ":sanitize_callback";'), |
|
59 | + 'sanitize_js_callback' => create_function('$value', 'return $value . ":sanitize_js_callback";'), |
|
60 | 60 | ); |
61 | - $setting = new WP_Customize_Setting( $this->manager, 'bar', $args ); |
|
62 | - $this->assertEquals( 'bar', $setting->id ); |
|
63 | - foreach ( $args as $key => $value ) { |
|
64 | - $this->assertEquals( $value, $setting->$key ); |
|
61 | + $setting = new WP_Customize_Setting($this->manager, 'bar', $args); |
|
62 | + $this->assertEquals('bar', $setting->id); |
|
63 | + foreach ($args as $key => $value) { |
|
64 | + $this->assertEquals($value, $setting->$key); |
|
65 | 65 | } |
66 | - $this->assertEquals( 10, has_filter( "customize_sanitize_{$setting->id}", $args['sanitize_callback'] ) ); |
|
67 | - $this->assertEquals( 10, has_filter( "customize_sanitize_js_{$setting->id}" ), $args['sanitize_js_callback'] ); |
|
66 | + $this->assertEquals(10, has_filter("customize_sanitize_{$setting->id}", $args['sanitize_callback'])); |
|
67 | + $this->assertEquals(10, has_filter("customize_sanitize_js_{$setting->id}"), $args['sanitize_js_callback']); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | public $post_data_overrides = array( |
@@ -93,64 +93,64 @@ discard block |
||
93 | 93 | * Run assertions on non-multidimensional standard settings. |
94 | 94 | */ |
95 | 95 | function test_preview_standard_types_non_multidimensional() { |
96 | - $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) ); |
|
96 | + $_POST['customized'] = wp_slash(wp_json_encode($this->post_data_overrides)); |
|
97 | 97 | |
98 | 98 | // Try non-multidimensional settings |
99 | - foreach ( $this->standard_type_configs as $type => $type_options ) { |
|
99 | + foreach ($this->standard_type_configs as $type => $type_options) { |
|
100 | 100 | // Non-multidimensional: See what effect the preview filter has on a non-existent setting (default value should be seen) |
101 | 101 | $name = "unset_{$type}_without_post_value"; |
102 | 102 | $default = "default_value_{$name}"; |
103 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
104 | - $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) ); |
|
105 | - $this->assertEquals( $default, $setting->value() ); |
|
103 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
104 | + $this->assertEquals($this->undefined, call_user_func($type_options['getter'], $name, $this->undefined)); |
|
105 | + $this->assertEquals($default, $setting->value()); |
|
106 | 106 | $setting->preview(); |
107 | - $this->assertEquals( $default, call_user_func( $type_options['getter'], $name, $this->undefined ), sprintf( 'Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default ) ); |
|
108 | - $this->assertEquals( $default, $setting->value() ); |
|
107 | + $this->assertEquals($default, call_user_func($type_options['getter'], $name, $this->undefined), sprintf('Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default)); |
|
108 | + $this->assertEquals($default, $setting->value()); |
|
109 | 109 | |
110 | 110 | // Non-multidimensional: See what effect the preview has on an extant setting (default value should not be seen) |
111 | 111 | $name = "set_{$type}_without_post_value"; |
112 | 112 | $default = "default_value_{$name}"; |
113 | 113 | $initial_value = "initial_value_{$name}"; |
114 | - call_user_func( $type_options['setter'], $name, $initial_value ); |
|
115 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
116 | - $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) ); |
|
117 | - $this->assertEquals( $initial_value, $setting->value() ); |
|
114 | + call_user_func($type_options['setter'], $name, $initial_value); |
|
115 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
116 | + $this->assertEquals($initial_value, call_user_func($type_options['getter'], $name)); |
|
117 | + $this->assertEquals($initial_value, $setting->value()); |
|
118 | 118 | $setting->preview(); |
119 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods) |
|
120 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods) |
|
121 | - $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) ); |
|
122 | - $this->assertEquals( $initial_value, $setting->value() ); |
|
119 | + $this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods) |
|
120 | + $this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods) |
|
121 | + $this->assertEquals($initial_value, call_user_func($type_options['getter'], $name)); |
|
122 | + $this->assertEquals($initial_value, $setting->value()); |
|
123 | 123 | |
124 | 124 | // @todo What if we call the setter after preview() is called? If no post_value, should the new set value be stored? If that happens, then the following 3 assertions should be inverted |
125 | 125 | $overridden_value = "overridden_value_$name"; |
126 | - call_user_func( $type_options['setter'], $name, $overridden_value ); |
|
127 | - $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) ); |
|
128 | - $this->assertEquals( $initial_value, $setting->value() ); |
|
129 | - $this->assertNotEquals( $overridden_value, $setting->value() ); |
|
126 | + call_user_func($type_options['setter'], $name, $overridden_value); |
|
127 | + $this->assertEquals($initial_value, call_user_func($type_options['getter'], $name)); |
|
128 | + $this->assertEquals($initial_value, $setting->value()); |
|
129 | + $this->assertNotEquals($overridden_value, $setting->value()); |
|
130 | 130 | |
131 | 131 | // Non-multidimensional: Test unset setting being overridden by a post value |
132 | 132 | $name = "unset_{$type}_overridden"; |
133 | 133 | $default = "default_value_{$name}"; |
134 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
135 | - $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) ); |
|
136 | - $this->assertEquals( $default, $setting->value() ); |
|
134 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
135 | + $this->assertEquals($this->undefined, call_user_func($type_options['getter'], $name, $this->undefined)); |
|
136 | + $this->assertEquals($default, $setting->value()); |
|
137 | 137 | $setting->preview(); // activate post_data |
138 | - $this->assertEquals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) ); |
|
139 | - $this->assertEquals( $this->post_data_overrides[ $name ], $setting->value() ); |
|
138 | + $this->assertEquals($this->post_data_overrides[$name], call_user_func($type_options['getter'], $name, $this->undefined)); |
|
139 | + $this->assertEquals($this->post_data_overrides[$name], $setting->value()); |
|
140 | 140 | |
141 | 141 | // Non-multidimensional: Test set setting being overridden by a post value |
142 | 142 | $name = "set_{$type}_overridden"; |
143 | 143 | $default = "default_value_{$name}"; |
144 | 144 | $initial_value = "initial_value_{$name}"; |
145 | - call_user_func( $type_options['setter'], $name, $initial_value ); |
|
146 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
147 | - $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name, $this->undefined ) ); |
|
148 | - $this->assertEquals( $initial_value, $setting->value() ); |
|
145 | + call_user_func($type_options['setter'], $name, $initial_value); |
|
146 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
147 | + $this->assertEquals($initial_value, call_user_func($type_options['getter'], $name, $this->undefined)); |
|
148 | + $this->assertEquals($initial_value, $setting->value()); |
|
149 | 149 | $setting->preview(); // activate post_data |
150 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods) |
|
151 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods) |
|
152 | - $this->assertEquals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) ); |
|
153 | - $this->assertEquals( $this->post_data_overrides[ $name ], $setting->value() ); |
|
150 | + $this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods) |
|
151 | + $this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods) |
|
152 | + $this->assertEquals($this->post_data_overrides[$name], call_user_func($type_options['getter'], $name, $this->undefined)); |
|
153 | + $this->assertEquals($this->post_data_overrides[$name], $setting->value()); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -158,79 +158,79 @@ discard block |
||
158 | 158 | * Run assertions on multidimensional standard settings. |
159 | 159 | */ |
160 | 160 | function test_preview_standard_types_multidimensional() { |
161 | - $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) ); |
|
161 | + $_POST['customized'] = wp_slash(wp_json_encode($this->post_data_overrides)); |
|
162 | 162 | |
163 | - foreach ( $this->standard_type_configs as $type => $type_options ) { |
|
163 | + foreach ($this->standard_type_configs as $type => $type_options) { |
|
164 | 164 | // Multidimensional: See what effect the preview filter has on a non-existent setting (default value should be seen) |
165 | 165 | $base_name = "unset_{$type}_multi"; |
166 | - $name = $base_name . '[foo]'; |
|
166 | + $name = $base_name.'[foo]'; |
|
167 | 167 | $default = "default_value_{$name}"; |
168 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
169 | - $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) ); |
|
170 | - $this->assertEquals( $default, $setting->value() ); |
|
168 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
169 | + $this->assertEquals($this->undefined, call_user_func($type_options['getter'], $base_name, $this->undefined)); |
|
170 | + $this->assertEquals($default, $setting->value()); |
|
171 | 171 | $setting->preview(); |
172 | - $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined ); |
|
173 | - $this->assertArrayHasKey( 'foo', $base_value ); |
|
174 | - $this->assertEquals( $default, $base_value['foo'] ); |
|
172 | + $base_value = call_user_func($type_options['getter'], $base_name, $this->undefined); |
|
173 | + $this->assertArrayHasKey('foo', $base_value); |
|
174 | + $this->assertEquals($default, $base_value['foo']); |
|
175 | 175 | |
176 | 176 | // Multidimensional: See what effect the preview has on an extant setting (default value should not be seen) |
177 | 177 | $base_name = "set_{$type}_multi"; |
178 | - $name = $base_name . '[foo]'; |
|
178 | + $name = $base_name.'[foo]'; |
|
179 | 179 | $default = "default_value_{$name}"; |
180 | 180 | $initial_value = "initial_value_{$name}"; |
181 | - $base_initial_value = array( 'foo' => $initial_value, 'bar' => 'persisted' ); |
|
182 | - call_user_func( $type_options['setter'], $base_name, $base_initial_value ); |
|
183 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
184 | - $base_value = call_user_func( $type_options['getter'], $base_name, array() ); |
|
185 | - $this->assertEquals( $initial_value, $base_value['foo'] ); |
|
186 | - $this->assertEquals( $initial_value, $setting->value() ); |
|
181 | + $base_initial_value = array('foo' => $initial_value, 'bar' => 'persisted'); |
|
182 | + call_user_func($type_options['setter'], $base_name, $base_initial_value); |
|
183 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
184 | + $base_value = call_user_func($type_options['getter'], $base_name, array()); |
|
185 | + $this->assertEquals($initial_value, $base_value['foo']); |
|
186 | + $this->assertEquals($initial_value, $setting->value()); |
|
187 | 187 | $setting->preview(); |
188 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods) |
|
189 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods) |
|
190 | - $base_value = call_user_func( $type_options['getter'], $base_name, array() ); |
|
191 | - $this->assertEquals( $initial_value, $base_value['foo'] ); |
|
192 | - $this->assertEquals( $initial_value, $setting->value() ); |
|
188 | + $this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods) |
|
189 | + $this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods) |
|
190 | + $base_value = call_user_func($type_options['getter'], $base_name, array()); |
|
191 | + $this->assertEquals($initial_value, $base_value['foo']); |
|
192 | + $this->assertEquals($initial_value, $setting->value()); |
|
193 | 193 | |
194 | 194 | // Multidimensional: Test unset setting being overridden by a post value |
195 | 195 | $base_name = "unset_{$type}_multi_overridden"; |
196 | - $name = $base_name . '[foo]'; |
|
196 | + $name = $base_name.'[foo]'; |
|
197 | 197 | $default = "default_value_{$name}"; |
198 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
199 | - $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) ); |
|
200 | - $this->assertEquals( $default, $setting->value() ); |
|
198 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
199 | + $this->assertEquals($this->undefined, call_user_func($type_options['getter'], $base_name, $this->undefined)); |
|
200 | + $this->assertEquals($default, $setting->value()); |
|
201 | 201 | $setting->preview(); |
202 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods) |
|
203 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods) |
|
204 | - $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined ); |
|
205 | - $this->assertArrayHasKey( 'foo', $base_value ); |
|
206 | - $this->assertEquals( $this->post_data_overrides[ $name ], $base_value['foo'] ); |
|
202 | + $this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods) |
|
203 | + $this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods) |
|
204 | + $base_value = call_user_func($type_options['getter'], $base_name, $this->undefined); |
|
205 | + $this->assertArrayHasKey('foo', $base_value); |
|
206 | + $this->assertEquals($this->post_data_overrides[$name], $base_value['foo']); |
|
207 | 207 | |
208 | 208 | // Multidimemsional: Test set setting being overridden by a post value |
209 | 209 | $base_name = "set_{$type}_multi_overridden"; |
210 | - $name = $base_name . '[foo]'; |
|
210 | + $name = $base_name.'[foo]'; |
|
211 | 211 | $default = "default_value_{$name}"; |
212 | 212 | $initial_value = "initial_value_{$name}"; |
213 | - $base_initial_value = array( 'foo' => $initial_value, 'bar' => 'persisted' ); |
|
214 | - call_user_func( $type_options['setter'], $base_name, $base_initial_value ); |
|
215 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
216 | - $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined ); |
|
217 | - $this->arrayHasKey( 'foo', $base_value ); |
|
218 | - $this->arrayHasKey( 'bar', $base_value ); |
|
219 | - $this->assertEquals( $base_initial_value['foo'], $base_value['foo'] ); |
|
220 | - |
|
221 | - $getter = call_user_func( $type_options['getter'], $base_name, $this->undefined ); |
|
222 | - $this->assertEquals( $base_initial_value['bar'], $getter['bar'] ); |
|
223 | - $this->assertEquals( $initial_value, $setting->value() ); |
|
213 | + $base_initial_value = array('foo' => $initial_value, 'bar' => 'persisted'); |
|
214 | + call_user_func($type_options['setter'], $base_name, $base_initial_value); |
|
215 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
216 | + $base_value = call_user_func($type_options['getter'], $base_name, $this->undefined); |
|
217 | + $this->arrayHasKey('foo', $base_value); |
|
218 | + $this->arrayHasKey('bar', $base_value); |
|
219 | + $this->assertEquals($base_initial_value['foo'], $base_value['foo']); |
|
220 | + |
|
221 | + $getter = call_user_func($type_options['getter'], $base_name, $this->undefined); |
|
222 | + $this->assertEquals($base_initial_value['bar'], $getter['bar']); |
|
223 | + $this->assertEquals($initial_value, $setting->value()); |
|
224 | 224 | $setting->preview(); |
225 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods) |
|
226 | - $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods) |
|
227 | - $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined ); |
|
228 | - $this->assertArrayHasKey( 'foo', $base_value ); |
|
229 | - $this->assertEquals( $this->post_data_overrides[ $name ], $base_value['foo'] ); |
|
230 | - $this->arrayHasKey( 'bar', call_user_func( $type_options['getter'], $base_name, $this->undefined ) ); |
|
231 | - |
|
232 | - $getter = call_user_func( $type_options['getter'], $base_name, $this->undefined ); |
|
233 | - $this->assertEquals( $base_initial_value['bar'], $getter['bar'] ); |
|
225 | + $this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods) |
|
226 | + $this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods) |
|
227 | + $base_value = call_user_func($type_options['getter'], $base_name, $this->undefined); |
|
228 | + $this->assertArrayHasKey('foo', $base_value); |
|
229 | + $this->assertEquals($this->post_data_overrides[$name], $base_value['foo']); |
|
230 | + $this->arrayHasKey('bar', call_user_func($type_options['getter'], $base_name, $this->undefined)); |
|
231 | + |
|
232 | + $getter = call_user_func($type_options['getter'], $base_name, $this->undefined); |
|
233 | + $this->assertEquals($base_initial_value['bar'], $getter['bar']); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
@@ -244,33 +244,33 @@ discard block |
||
244 | 244 | */ |
245 | 245 | protected $custom_type_data_previewed; |
246 | 246 | |
247 | - function custom_type_getter( $name, $default = null ) { |
|
248 | - if ( did_action( "customize_preview_{$name}" ) && array_key_exists( $name, $this->custom_type_data_previewed ) ) { |
|
249 | - $value = $this->custom_type_data_previewed[ $name ]; |
|
250 | - } else if ( array_key_exists( $name, $this->custom_type_data_saved ) ) { |
|
251 | - $value = $this->custom_type_data_saved[ $name ]; |
|
247 | + function custom_type_getter($name, $default = null) { |
|
248 | + if (did_action("customize_preview_{$name}") && array_key_exists($name, $this->custom_type_data_previewed)) { |
|
249 | + $value = $this->custom_type_data_previewed[$name]; |
|
250 | + } else if (array_key_exists($name, $this->custom_type_data_saved)) { |
|
251 | + $value = $this->custom_type_data_saved[$name]; |
|
252 | 252 | } else { |
253 | 253 | $value = $default; |
254 | 254 | } |
255 | 255 | return $value; |
256 | 256 | } |
257 | 257 | |
258 | - function custom_type_setter( $name, $value ) { |
|
259 | - $this->custom_type_data_saved[ $name ] = $value; |
|
258 | + function custom_type_setter($name, $value) { |
|
259 | + $this->custom_type_data_saved[$name] = $value; |
|
260 | 260 | } |
261 | 261 | |
262 | - function custom_type_value_filter( $default ) { |
|
263 | - $name = preg_replace( '/^customize_value_/', '', current_filter() ); |
|
264 | - return $this->custom_type_getter( $name, $default ); |
|
262 | + function custom_type_value_filter($default) { |
|
263 | + $name = preg_replace('/^customize_value_/', '', current_filter()); |
|
264 | + return $this->custom_type_getter($name, $default); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
268 | 268 | * @param WP_Customize_Setting $setting |
269 | 269 | */ |
270 | - function custom_type_preview( $setting ) { |
|
271 | - $previewed_value = $setting->post_value( $this->undefined ); |
|
272 | - if ( $this->undefined !== $previewed_value ) { |
|
273 | - $this->custom_type_data_previewed[ $setting->id ] = $previewed_value; |
|
270 | + function custom_type_preview($setting) { |
|
271 | + $previewed_value = $setting->post_value($this->undefined); |
|
272 | + if ($this->undefined !== $previewed_value) { |
|
273 | + $this->custom_type_data_previewed[$setting->id] = $previewed_value; |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | |
@@ -280,74 +280,74 @@ discard block |
||
280 | 280 | "unset_{$type}_with_post_value" => "unset_{$type}_without_post_value", |
281 | 281 | "set_{$type}_with_post_value" => "set_{$type}_without_post_value", |
282 | 282 | ); |
283 | - $_POST['customized'] = wp_slash( wp_json_encode( $post_data_overrides ) ); |
|
283 | + $_POST['customized'] = wp_slash(wp_json_encode($post_data_overrides)); |
|
284 | 284 | |
285 | 285 | $this->custom_type_data_saved = array(); |
286 | 286 | $this->custom_type_data_previewed = array(); |
287 | 287 | |
288 | - add_action( "customize_preview_{$type}", array( $this, 'custom_type_preview' ) ); |
|
288 | + add_action("customize_preview_{$type}", array($this, 'custom_type_preview')); |
|
289 | 289 | |
290 | 290 | // Custom type not existing and no post value override |
291 | 291 | $name = "unset_{$type}_without_post_value"; |
292 | 292 | $default = "default_value_{$name}"; |
293 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
293 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
294 | 294 | // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need |
295 | - add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) ); |
|
296 | - $this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); |
|
297 | - $this->assertEquals( $default, $setting->value() ); |
|
295 | + add_filter("customize_value_{$name}", array($this, 'custom_type_value_filter')); |
|
296 | + $this->assertEquals($this->undefined, $this->custom_type_getter($name, $this->undefined)); |
|
297 | + $this->assertEquals($default, $setting->value()); |
|
298 | 298 | $setting->preview(); |
299 | - $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) ); |
|
300 | - $this->assertEquals( 1, did_action( "customize_preview_{$setting->type}" ) ); |
|
301 | - $this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); // Note: for a non-custom type this is $default |
|
302 | - $this->assertEquals( $default, $setting->value() ); // should be same as above |
|
299 | + $this->assertEquals(1, did_action("customize_preview_{$setting->id}")); |
|
300 | + $this->assertEquals(1, did_action("customize_preview_{$setting->type}")); |
|
301 | + $this->assertEquals($this->undefined, $this->custom_type_getter($name, $this->undefined)); // Note: for a non-custom type this is $default |
|
302 | + $this->assertEquals($default, $setting->value()); // should be same as above |
|
303 | 303 | |
304 | 304 | // Custom type existing and no post value override |
305 | 305 | $name = "set_{$type}_without_post_value"; |
306 | 306 | $default = "default_value_{$name}"; |
307 | 307 | $initial_value = "initial_value_{$name}"; |
308 | - $this->custom_type_setter( $name, $initial_value ); |
|
309 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
308 | + $this->custom_type_setter($name, $initial_value); |
|
309 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
310 | 310 | // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need |
311 | - add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) ); |
|
312 | - $this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); |
|
313 | - $this->assertEquals( $initial_value, $setting->value() ); |
|
311 | + add_filter("customize_value_{$name}", array($this, 'custom_type_value_filter')); |
|
312 | + $this->assertEquals($initial_value, $this->custom_type_getter($name, $this->undefined)); |
|
313 | + $this->assertEquals($initial_value, $setting->value()); |
|
314 | 314 | $setting->preview(); |
315 | - $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) ); |
|
316 | - $this->assertEquals( 2, did_action( "customize_preview_{$setting->type}" ) ); |
|
317 | - $this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); // should be same as above |
|
318 | - $this->assertEquals( $initial_value, $setting->value() ); // should be same as above |
|
315 | + $this->assertEquals(1, did_action("customize_preview_{$setting->id}")); |
|
316 | + $this->assertEquals(2, did_action("customize_preview_{$setting->type}")); |
|
317 | + $this->assertEquals($initial_value, $this->custom_type_getter($name, $this->undefined)); // should be same as above |
|
318 | + $this->assertEquals($initial_value, $setting->value()); // should be same as above |
|
319 | 319 | |
320 | 320 | // Custom type not existing and with a post value override |
321 | 321 | $name = "unset_{$type}_with_post_value"; |
322 | 322 | $default = "default_value_{$name}"; |
323 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
323 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
324 | 324 | // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need |
325 | - add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) ); |
|
326 | - $this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); |
|
327 | - $this->assertEquals( $default, $setting->value() ); |
|
325 | + add_filter("customize_value_{$name}", array($this, 'custom_type_value_filter')); |
|
326 | + $this->assertEquals($this->undefined, $this->custom_type_getter($name, $this->undefined)); |
|
327 | + $this->assertEquals($default, $setting->value()); |
|
328 | 328 | $setting->preview(); |
329 | - $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) ); |
|
330 | - $this->assertEquals( 3, did_action( "customize_preview_{$setting->type}" ) ); |
|
331 | - $this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) ); |
|
332 | - $this->assertEquals( $post_data_overrides[ $name ], $setting->value() ); |
|
329 | + $this->assertEquals(1, did_action("customize_preview_{$setting->id}")); |
|
330 | + $this->assertEquals(3, did_action("customize_preview_{$setting->type}")); |
|
331 | + $this->assertEquals($post_data_overrides[$name], $this->custom_type_getter($name, $this->undefined)); |
|
332 | + $this->assertEquals($post_data_overrides[$name], $setting->value()); |
|
333 | 333 | |
334 | 334 | // Custom type not existing and with a post value override |
335 | 335 | $name = "set_{$type}_with_post_value"; |
336 | 336 | $default = "default_value_{$name}"; |
337 | 337 | $initial_value = "initial_value_{$name}"; |
338 | - $this->custom_type_setter( $name, $initial_value ); |
|
339 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
338 | + $this->custom_type_setter($name, $initial_value); |
|
339 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
340 | 340 | // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need |
341 | - add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) ); |
|
342 | - $this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); |
|
343 | - $this->assertEquals( $initial_value, $setting->value() ); |
|
341 | + add_filter("customize_value_{$name}", array($this, 'custom_type_value_filter')); |
|
342 | + $this->assertEquals($initial_value, $this->custom_type_getter($name, $this->undefined)); |
|
343 | + $this->assertEquals($initial_value, $setting->value()); |
|
344 | 344 | $setting->preview(); |
345 | - $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) ); |
|
346 | - $this->assertEquals( 4, did_action( "customize_preview_{$setting->type}" ) ); |
|
347 | - $this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) ); |
|
348 | - $this->assertEquals( $post_data_overrides[ $name ], $setting->value() ); |
|
345 | + $this->assertEquals(1, did_action("customize_preview_{$setting->id}")); |
|
346 | + $this->assertEquals(4, did_action("customize_preview_{$setting->type}")); |
|
347 | + $this->assertEquals($post_data_overrides[$name], $this->custom_type_getter($name, $this->undefined)); |
|
348 | + $this->assertEquals($post_data_overrides[$name], $setting->value()); |
|
349 | 349 | |
350 | - unset( $this->custom_type_data_previewed, $this->custom_type_data_saved ); |
|
350 | + unset($this->custom_type_data_previewed, $this->custom_type_data_saved); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -359,12 +359,12 @@ discard block |
||
359 | 359 | $type = 'option'; |
360 | 360 | $name = 'unset_option_without_post_value'; |
361 | 361 | $default = "default_value_{$name}"; |
362 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); |
|
363 | - $this->assertEquals( $this->undefined, get_option( $name, $this->undefined ) ); |
|
364 | - $this->assertEquals( $default, $setting->value() ); |
|
362 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default')); |
|
363 | + $this->assertEquals($this->undefined, get_option($name, $this->undefined)); |
|
364 | + $this->assertEquals($default, $setting->value()); |
|
365 | 365 | $setting->preview(); |
366 | - $this->assertEquals( $default, get_option( $name, $this->undefined ), sprintf( 'Expected get_option(%s) to return setting default: %s.', $name, $default ) ); |
|
367 | - $this->assertEquals( $default, $setting->value() ); |
|
366 | + $this->assertEquals($default, get_option($name, $this->undefined), sprintf('Expected get_option(%s) to return setting default: %s.', $name, $default)); |
|
367 | + $this->assertEquals($default, $setting->value()); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -378,14 +378,14 @@ discard block |
||
378 | 378 | $type = 'option'; |
379 | 379 | $name = 'blogname'; |
380 | 380 | $post_value = rand_str(); |
381 | - $this->manager->set_post_value( $name, $post_value ); |
|
382 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) ); |
|
383 | - $this->assertFalse( $setting->is_current_blog_previewed() ); |
|
381 | + $this->manager->set_post_value($name, $post_value); |
|
382 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type')); |
|
383 | + $this->assertFalse($setting->is_current_blog_previewed()); |
|
384 | 384 | $setting->preview(); |
385 | - $this->assertTrue( $setting->is_current_blog_previewed() ); |
|
385 | + $this->assertTrue($setting->is_current_blog_previewed()); |
|
386 | 386 | |
387 | - $this->assertEquals( $post_value, $setting->value() ); |
|
388 | - $this->assertEquals( $post_value, get_option( $name ) ); |
|
387 | + $this->assertEquals($post_value, $setting->value()); |
|
388 | + $this->assertEquals($post_value, get_option($name)); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -395,24 +395,24 @@ discard block |
||
395 | 395 | * @group multisite |
396 | 396 | */ |
397 | 397 | function test_previewing_with_switch_to_blog() { |
398 | - if ( ! is_multisite() ) { |
|
399 | - $this->markTestSkipped( 'Cannot test WP_Customize_Setting::is_current_blog_previewed() with switch_to_blog() if not on multisite.' ); |
|
398 | + if ( ! is_multisite()) { |
|
399 | + $this->markTestSkipped('Cannot test WP_Customize_Setting::is_current_blog_previewed() with switch_to_blog() if not on multisite.'); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | $type = 'option'; |
403 | 403 | $name = 'blogdescription'; |
404 | 404 | $post_value = rand_str(); |
405 | - $this->manager->set_post_value( $name, $post_value ); |
|
406 | - $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) ); |
|
407 | - $this->assertFalse( $setting->is_current_blog_previewed() ); |
|
405 | + $this->manager->set_post_value($name, $post_value); |
|
406 | + $setting = new WP_Customize_Setting($this->manager, $name, compact('type')); |
|
407 | + $this->assertFalse($setting->is_current_blog_previewed()); |
|
408 | 408 | $setting->preview(); |
409 | - $this->assertTrue( $setting->is_current_blog_previewed() ); |
|
409 | + $this->assertTrue($setting->is_current_blog_previewed()); |
|
410 | 410 | |
411 | 411 | $blog_id = $this->factory->blog->create(); |
412 | - switch_to_blog( $blog_id ); |
|
413 | - $this->assertFalse( $setting->is_current_blog_previewed() ); |
|
414 | - $this->assertNotEquals( $post_value, $setting->value() ); |
|
415 | - $this->assertNotEquals( $post_value, get_option( $name ) ); |
|
412 | + switch_to_blog($blog_id); |
|
413 | + $this->assertFalse($setting->is_current_blog_previewed()); |
|
414 | + $this->assertNotEquals($post_value, $setting->value()); |
|
415 | + $this->assertNotEquals($post_value, get_option($name)); |
|
416 | 416 | restore_current_blog(); |
417 | 417 | } |
418 | 418 | } |
@@ -21,9 +21,9 @@ discard block |
||
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 | global $wp_customize; |
28 | 28 | $this->wp_customize = new WP_Customize_Manager(); |
29 | 29 | $wp_customize = $this->wp_customize; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array $items Menu item types. |
45 | 45 | * @return array Menu item types. |
46 | 46 | */ |
47 | - function filter_item_types( $items ) { |
|
47 | + function filter_item_types($items) { |
|
48 | 48 | $items[] = array( |
49 | 49 | 'title' => 'Custom', |
50 | 50 | 'type' => 'custom_type', |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | * @param string $object The object name (e.g. category). |
63 | 63 | * @return array Menu items. |
64 | 64 | */ |
65 | - function filter_items( $items, $type, $object ) { |
|
65 | + function filter_items($items, $type, $object) { |
|
66 | 66 | $items[] = array( |
67 | 67 | 'id' => 'custom-1', |
68 | 68 | 'title' => 'Cool beans', |
69 | 69 | 'type' => $type, |
70 | 70 | 'type_label' => 'Custom Label', |
71 | 71 | 'object' => $object, |
72 | - 'url' => home_url( '/cool-beans/' ), |
|
72 | + 'url' => home_url('/cool-beans/'), |
|
73 | 73 | 'classes' => 'custom-menu-item cool-beans', |
74 | 74 | ); |
75 | 75 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @see WP_Customize_Nav_Menus::__construct() |
83 | 83 | */ |
84 | 84 | function test_construct() { |
85 | - do_action( 'customize_register', $this->wp_customize ); |
|
86 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
87 | - $this->assertInstanceOf( 'WP_Customize_Manager', $menus->manager ); |
|
85 | + do_action('customize_register', $this->wp_customize); |
|
86 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
87 | + $this->assertInstanceOf('WP_Customize_Manager', $menus->manager); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
94 | 94 | */ |
95 | 95 | function test_load_available_items_query_returns_wp_error() { |
96 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
96 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
97 | 97 | |
98 | 98 | // Invalid post type $obj_name. |
99 | - $items = $menus->load_available_items_query( 'post_type', 'invalid' ); |
|
100 | - $this->assertInstanceOf( 'WP_Error', $items ); |
|
101 | - $this->assertEquals( 'nav_menus_invalid_post_type', $items->get_error_code() ); |
|
99 | + $items = $menus->load_available_items_query('post_type', 'invalid'); |
|
100 | + $this->assertInstanceOf('WP_Error', $items); |
|
101 | + $this->assertEquals('nav_menus_invalid_post_type', $items->get_error_code()); |
|
102 | 102 | |
103 | 103 | // Invalid taxonomy $obj_name. |
104 | - $items = $menus->load_available_items_query( 'taxonomy', 'invalid' ); |
|
105 | - $this->assertInstanceOf( 'WP_Error', $items ); |
|
106 | - $this->assertEquals( 'invalid_taxonomy', $items->get_error_code() ); |
|
104 | + $items = $menus->load_available_items_query('taxonomy', 'invalid'); |
|
105 | + $this->assertInstanceOf('WP_Error', $items); |
|
106 | + $this->assertEquals('invalid_taxonomy', $items->get_error_code()); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -112,29 +112,29 @@ discard block |
||
112 | 112 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
113 | 113 | */ |
114 | 114 | function test_load_available_items_query_maybe_returns_home() { |
115 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
115 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
116 | 116 | |
117 | 117 | // Expected menu item array. |
118 | 118 | $expected = array( |
119 | 119 | 'id' => 'home', |
120 | - 'title' => _x( 'Home', 'nav menu home label' ), |
|
120 | + 'title' => _x('Home', 'nav menu home label'), |
|
121 | 121 | 'type' => 'custom', |
122 | - 'type_label' => __( 'Custom Link' ), |
|
122 | + 'type_label' => __('Custom Link'), |
|
123 | 123 | 'object' => '', |
124 | 124 | 'url' => home_url(), |
125 | 125 | ); |
126 | 126 | |
127 | 127 | // Create pages. |
128 | - $this->factory->post->create_many( 15, array( 'post_type' => 'page' ) ); |
|
128 | + $this->factory->post->create_many(15, array('post_type' => 'page')); |
|
129 | 129 | |
130 | 130 | // Home is included in menu items when page is zero. |
131 | - $items = $menus->load_available_items_query( 'post_type', 'page', 0 ); |
|
132 | - $this->assertContains( $expected, $items ); |
|
131 | + $items = $menus->load_available_items_query('post_type', 'page', 0); |
|
132 | + $this->assertContains($expected, $items); |
|
133 | 133 | |
134 | 134 | // Home is not included in menu items when page is larger than zero. |
135 | - $items = $menus->load_available_items_query( 'post_type', 'page', 1 ); |
|
136 | - $this->assertNotEmpty( $items ); |
|
137 | - $this->assertNotContains( $expected, $items ); |
|
135 | + $items = $menus->load_available_items_query('post_type', 'page', 1); |
|
136 | + $this->assertNotEmpty($items); |
|
137 | + $this->assertNotContains($expected, $items); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
144 | 144 | */ |
145 | 145 | function test_load_available_items_query_returns_post_item_with_page_number() { |
146 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
146 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
147 | 147 | |
148 | 148 | // Create page. |
149 | - $post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) ); |
|
149 | + $post_id = $this->factory->post->create(array('post_title' => 'Post Title')); |
|
150 | 150 | |
151 | 151 | // Create pages. |
152 | - $this->factory->post->create_many( 10 ); |
|
152 | + $this->factory->post->create_many(10); |
|
153 | 153 | |
154 | 154 | // Expected menu item array. |
155 | 155 | $expected = array( |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | 'type' => 'post_type', |
159 | 159 | 'type_label' => 'Post', |
160 | 160 | 'object' => 'post', |
161 | - 'object_id' => intval( $post_id ), |
|
162 | - 'url' => get_permalink( intval( $post_id ) ), |
|
161 | + 'object_id' => intval($post_id), |
|
162 | + 'url' => get_permalink(intval($post_id)), |
|
163 | 163 | ); |
164 | 164 | |
165 | 165 | // Offset the query and get the second page of menu items. |
166 | - $items = $menus->load_available_items_query( 'post_type', 'post', 1 ); |
|
167 | - $this->assertContains( $expected, $items ); |
|
166 | + $items = $menus->load_available_items_query('post_type', 'post', 1); |
|
167 | + $this->assertContains($expected, $items); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
174 | 174 | */ |
175 | 175 | function test_load_available_items_query_returns_page_item() { |
176 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
176 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
177 | 177 | |
178 | 178 | // Create page. |
179 | - $page_id = $this->factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) ); |
|
179 | + $page_id = $this->factory->post->create(array('post_title' => 'Page Title', 'post_type' => 'page')); |
|
180 | 180 | |
181 | 181 | // Expected menu item array. |
182 | 182 | $expected = array( |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | 'type' => 'post_type', |
186 | 186 | 'type_label' => 'Page', |
187 | 187 | 'object' => 'page', |
188 | - 'object_id' => intval( $page_id ), |
|
189 | - 'url' => get_permalink( intval( $page_id ) ), |
|
188 | + 'object_id' => intval($page_id), |
|
189 | + 'url' => get_permalink(intval($page_id)), |
|
190 | 190 | ); |
191 | 191 | |
192 | - $items = $menus->load_available_items_query( 'post_type', 'page', 0 ); |
|
193 | - $this->assertContains( $expected, $items ); |
|
192 | + $items = $menus->load_available_items_query('post_type', 'page', 0); |
|
193 | + $this->assertContains($expected, $items); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
200 | 200 | */ |
201 | 201 | function test_load_available_items_query_returns_post_item() { |
202 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
202 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
203 | 203 | |
204 | 204 | // Create post. |
205 | - $post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) ); |
|
205 | + $post_id = $this->factory->post->create(array('post_title' => 'Post Title')); |
|
206 | 206 | |
207 | 207 | // Expected menu item array. |
208 | 208 | $expected = array( |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | 'type' => 'post_type', |
212 | 212 | 'type_label' => 'Post', |
213 | 213 | 'object' => 'post', |
214 | - 'object_id' => intval( $post_id ), |
|
215 | - 'url' => get_permalink( intval( $post_id ) ), |
|
214 | + 'object_id' => intval($post_id), |
|
215 | + 'url' => get_permalink(intval($post_id)), |
|
216 | 216 | ); |
217 | 217 | |
218 | - $items = $menus->load_available_items_query( 'post_type', 'post', 0 ); |
|
219 | - $this->assertContains( $expected, $items ); |
|
218 | + $items = $menus->load_available_items_query('post_type', 'post', 0); |
|
219 | + $this->assertContains($expected, $items); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
226 | 226 | */ |
227 | 227 | function test_load_available_items_query_returns_term_item() { |
228 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
228 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
229 | 229 | |
230 | 230 | // Create term. |
231 | - $term_id = $this->factory->category->create( array( 'name' => 'Term Title' ) ); |
|
231 | + $term_id = $this->factory->category->create(array('name' => 'Term Title')); |
|
232 | 232 | |
233 | 233 | // Expected menu item array. |
234 | 234 | $expected = array( |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | 'type' => 'taxonomy', |
238 | 238 | 'type_label' => 'Category', |
239 | 239 | 'object' => 'category', |
240 | - 'object_id' => intval( $term_id ), |
|
241 | - 'url' => get_term_link( intval( $term_id ), 'category' ), |
|
240 | + 'object_id' => intval($term_id), |
|
241 | + 'url' => get_term_link(intval($term_id), 'category'), |
|
242 | 242 | ); |
243 | 243 | |
244 | - $items = $menus->load_available_items_query( 'taxonomy', 'category', 0 ); |
|
245 | - $this->assertContains( $expected, $items ); |
|
244 | + $items = $menus->load_available_items_query('taxonomy', 'category', 0); |
|
245 | + $this->assertContains($expected, $items); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -251,9 +251,9 @@ discard block |
||
251 | 251 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
252 | 252 | */ |
253 | 253 | function test_load_available_items_query_returns_custom_item() { |
254 | - add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); |
|
255 | - add_filter( 'customize_nav_menu_available_items', array( $this, 'filter_items' ), 10, 4 ); |
|
256 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
254 | + add_filter('customize_nav_menu_available_item_types', array($this, 'filter_item_types')); |
|
255 | + add_filter('customize_nav_menu_available_items', array($this, 'filter_items'), 10, 4); |
|
256 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
257 | 257 | |
258 | 258 | // Expected menu item array. |
259 | 259 | $expected = array( |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | 'type' => 'custom_type', |
263 | 263 | 'type_label' => 'Custom Label', |
264 | 264 | 'object' => 'custom_object', |
265 | - 'url' => home_url( '/cool-beans/' ), |
|
265 | + 'url' => home_url('/cool-beans/'), |
|
266 | 266 | 'classes' => 'custom-menu-item cool-beans', |
267 | 267 | ); |
268 | 268 | |
269 | - $items = $menus->load_available_items_query( 'custom_type', 'custom_object', 0 ); |
|
270 | - $this->assertContains( $expected, $items ); |
|
269 | + $items = $menus->load_available_items_query('custom_type', 'custom_object', 0); |
|
270 | + $this->assertContains($expected, $items); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -276,56 +276,56 @@ discard block |
||
276 | 276 | * @see WP_Customize_Nav_Menus::search_available_items_query() |
277 | 277 | */ |
278 | 278 | function test_search_available_items_query() { |
279 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
279 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
280 | 280 | |
281 | 281 | // Create posts |
282 | 282 | $post_ids = array(); |
283 | - $post_ids[] = $this->factory->post->create( array( 'post_title' => 'Search & Test' ) ); |
|
284 | - $post_ids[] = $this->factory->post->create( array( 'post_title' => 'Some Other Title' ) ); |
|
283 | + $post_ids[] = $this->factory->post->create(array('post_title' => 'Search & Test')); |
|
284 | + $post_ids[] = $this->factory->post->create(array('post_title' => 'Some Other Title')); |
|
285 | 285 | |
286 | 286 | // Create terms |
287 | 287 | $term_ids = array(); |
288 | - $term_ids[] = $this->factory->category->create( array( 'name' => 'Dogs Are Cool' ) ); |
|
289 | - $term_ids[] = $this->factory->category->create( array( 'name' => 'Cats Drool' ) ); |
|
288 | + $term_ids[] = $this->factory->category->create(array('name' => 'Dogs Are Cool')); |
|
289 | + $term_ids[] = $this->factory->category->create(array('name' => 'Cats Drool')); |
|
290 | 290 | |
291 | 291 | // Test empty results |
292 | 292 | $expected = array(); |
293 | - $results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => 'This Does NOT Exist' ) ); |
|
294 | - $this->assertEquals( $expected, $results ); |
|
293 | + $results = $menus->search_available_items_query(array('pagenum' => 1, 's' => 'This Does NOT Exist')); |
|
294 | + $this->assertEquals($expected, $results); |
|
295 | 295 | |
296 | 296 | // Test posts |
297 | - foreach ( $post_ids as $post_id ) { |
|
297 | + foreach ($post_ids as $post_id) { |
|
298 | 298 | $expected = array( |
299 | - 'id' => 'post-' . $post_id, |
|
300 | - 'title' => html_entity_decode( get_the_title( $post_id ) ), |
|
299 | + 'id' => 'post-'.$post_id, |
|
300 | + 'title' => html_entity_decode(get_the_title($post_id)), |
|
301 | 301 | 'type' => 'post_type', |
302 | - 'type_label' => get_post_type_object( 'post' )->labels->singular_name, |
|
302 | + 'type_label' => get_post_type_object('post')->labels->singular_name, |
|
303 | 303 | 'object' => 'post', |
304 | - 'object_id' => intval( $post_id ), |
|
305 | - 'url' => get_permalink( intval( $post_id ) ), |
|
304 | + 'object_id' => intval($post_id), |
|
305 | + 'url' => get_permalink(intval($post_id)), |
|
306 | 306 | ); |
307 | - wp_set_object_terms( $post_id, $term_ids, 'category' ); |
|
307 | + wp_set_object_terms($post_id, $term_ids, 'category'); |
|
308 | 308 | $search = $post_id === $post_ids[0] ? 'test & search' : 'other title'; |
309 | - $s = sanitize_text_field( wp_unslash( $search ) ); |
|
310 | - $results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => $s ) ); |
|
311 | - $this->assertEquals( $expected, $results[0] ); |
|
309 | + $s = sanitize_text_field(wp_unslash($search)); |
|
310 | + $results = $menus->search_available_items_query(array('pagenum' => 1, 's' => $s)); |
|
311 | + $this->assertEquals($expected, $results[0]); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | // Test terms |
315 | - foreach ( $term_ids as $term_id ) { |
|
316 | - $term = get_term_by( 'id', $term_id, 'category' ); |
|
315 | + foreach ($term_ids as $term_id) { |
|
316 | + $term = get_term_by('id', $term_id, 'category'); |
|
317 | 317 | $expected = array( |
318 | - 'id' => 'term-' . $term_id, |
|
318 | + 'id' => 'term-'.$term_id, |
|
319 | 319 | 'title' => $term->name, |
320 | 320 | 'type' => 'taxonomy', |
321 | - 'type_label' => get_taxonomy( 'category' )->labels->singular_name, |
|
321 | + 'type_label' => get_taxonomy('category')->labels->singular_name, |
|
322 | 322 | 'object' => 'category', |
323 | - 'object_id' => intval( $term_id ), |
|
324 | - 'url' => get_term_link( intval( $term_id ), 'category' ), |
|
323 | + 'object_id' => intval($term_id), |
|
324 | + 'url' => get_term_link(intval($term_id), 'category'), |
|
325 | 325 | ); |
326 | - $s = sanitize_text_field( wp_unslash( $term->name ) ); |
|
327 | - $results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => $s ) ); |
|
328 | - $this->assertEquals( $expected, $results[0] ); |
|
326 | + $s = sanitize_text_field(wp_unslash($term->name)); |
|
327 | + $results = $menus->search_available_items_query(array('pagenum' => 1, 's' => $s)); |
|
328 | + $this->assertEquals($expected, $results[0]); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | * @see WP_Customize_Nav_Menus::enqueue_scripts() |
336 | 336 | */ |
337 | 337 | function test_enqueue_scripts() { |
338 | - do_action( 'customize_register', $this->wp_customize ); |
|
339 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
338 | + do_action('customize_register', $this->wp_customize); |
|
339 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
340 | 340 | $menus->enqueue_scripts(); |
341 | - $this->assertTrue( wp_script_is( 'customize-nav-menus' ) ); |
|
341 | + $this->assertTrue(wp_script_is('customize-nav-menus')); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -347,15 +347,15 @@ discard block |
||
347 | 347 | * @see WP_Customize_Nav_Menus::filter_dynamic_setting_args() |
348 | 348 | */ |
349 | 349 | function test_filter_dynamic_setting_args() { |
350 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
350 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
351 | 351 | |
352 | - $expected = array( 'type' => 'nav_menu_item' ); |
|
353 | - $results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu_item[123]' ); |
|
354 | - $this->assertEquals( $expected, $results ); |
|
352 | + $expected = array('type' => 'nav_menu_item'); |
|
353 | + $results = $menus->filter_dynamic_setting_args($this->wp_customize, 'nav_menu_item[123]'); |
|
354 | + $this->assertEquals($expected, $results); |
|
355 | 355 | |
356 | - $expected = array( 'type' => 'nav_menu' ); |
|
357 | - $results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu[123]' ); |
|
358 | - $this->assertEquals( $expected, $results ); |
|
356 | + $expected = array('type' => 'nav_menu'); |
|
357 | + $results = $menus->filter_dynamic_setting_args($this->wp_customize, 'nav_menu[123]'); |
|
358 | + $this->assertEquals($expected, $results); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -364,16 +364,16 @@ discard block |
||
364 | 364 | * @see WP_Customize_Nav_Menus::filter_dynamic_setting_class() |
365 | 365 | */ |
366 | 366 | function test_filter_dynamic_setting_class() { |
367 | - do_action( 'customize_register', $this->wp_customize ); |
|
368 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
367 | + do_action('customize_register', $this->wp_customize); |
|
368 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
369 | 369 | |
370 | 370 | $expected = 'WP_Customize_Nav_Menu_Item_Setting'; |
371 | - $results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu_item[123]', array( 'type' => 'nav_menu_item' ) ); |
|
372 | - $this->assertEquals( $expected, $results ); |
|
371 | + $results = $menus->filter_dynamic_setting_class('WP_Customize_Setting', 'nav_menu_item[123]', array('type' => 'nav_menu_item')); |
|
372 | + $this->assertEquals($expected, $results); |
|
373 | 373 | |
374 | 374 | $expected = 'WP_Customize_Nav_Menu_Setting'; |
375 | - $results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu[123]', array( 'type' => 'nav_menu' ) ); |
|
376 | - $this->assertEquals( $expected, $results ); |
|
375 | + $results = $menus->filter_dynamic_setting_class('WP_Customize_Setting', 'nav_menu[123]', array('type' => 'nav_menu')); |
|
376 | + $this->assertEquals($expected, $results); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -382,20 +382,20 @@ discard block |
||
382 | 382 | * @see WP_Customize_Nav_Menus::customize_register() |
383 | 383 | */ |
384 | 384 | function test_customize_register() { |
385 | - do_action( 'customize_register', $this->wp_customize ); |
|
386 | - $menu_id = wp_create_nav_menu( 'Primary' ); |
|
387 | - $post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) ); |
|
388 | - $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
|
385 | + do_action('customize_register', $this->wp_customize); |
|
386 | + $menu_id = wp_create_nav_menu('Primary'); |
|
387 | + $post_id = $this->factory->post->create(array('post_title' => 'Hello World')); |
|
388 | + $item_id = wp_update_nav_menu_item($menu_id, 0, array( |
|
389 | 389 | 'menu-item-type' => 'post_type', |
390 | 390 | 'menu-item-object' => 'post', |
391 | 391 | 'menu-item-object-id' => $post_id, |
392 | 392 | 'menu-item-title' => 'Hello World', |
393 | 393 | 'menu-item-status' => 'publish', |
394 | - ) ); |
|
395 | - $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, "nav_menu_item[$item_id]" ); |
|
396 | - do_action( 'customize_register', $this->wp_customize ); |
|
397 | - $this->assertEquals( 'Primary', $this->wp_customize->get_section( "nav_menu[$menu_id]" )->title ); |
|
398 | - $this->assertEquals( 'Hello World', $this->wp_customize->get_control( "nav_menu_item[$item_id]" )->label ); |
|
394 | + )); |
|
395 | + $setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, "nav_menu_item[$item_id]"); |
|
396 | + do_action('customize_register', $this->wp_customize); |
|
397 | + $this->assertEquals('Primary', $this->wp_customize->get_section("nav_menu[$menu_id]")->title); |
|
398 | + $this->assertEquals('Hello World', $this->wp_customize->get_control("nav_menu_item[$item_id]")->label); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -405,16 +405,16 @@ discard block |
||
405 | 405 | */ |
406 | 406 | function test_intval_base10() { |
407 | 407 | |
408 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
408 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
409 | 409 | |
410 | - $this->assertEquals( 2, $menus->intval_base10( 2 ) ); |
|
411 | - $this->assertEquals( 4, $menus->intval_base10( 4.1 ) ); |
|
412 | - $this->assertEquals( 4, $menus->intval_base10( '4' ) ); |
|
413 | - $this->assertEquals( 4, $menus->intval_base10( '04' ) ); |
|
414 | - $this->assertEquals( 42, $menus->intval_base10( +42 ) ); |
|
410 | + $this->assertEquals(2, $menus->intval_base10(2)); |
|
411 | + $this->assertEquals(4, $menus->intval_base10(4.1)); |
|
412 | + $this->assertEquals(4, $menus->intval_base10('4')); |
|
413 | + $this->assertEquals(4, $menus->intval_base10('04')); |
|
414 | + $this->assertEquals(42, $menus->intval_base10( +42 )); |
|
415 | 415 | $this->assertEquals( -42, $menus->intval_base10( -42 ) ); |
416 | - $this->assertEquals( 26, $menus->intval_base10( 0x1A ) ); |
|
417 | - $this->assertEquals( 0, $menus->intval_base10( array() ) ); |
|
416 | + $this->assertEquals(26, $menus->intval_base10(0x1A)); |
|
417 | + $this->assertEquals(0, $menus->intval_base10(array())); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -424,31 +424,31 @@ discard block |
||
424 | 424 | */ |
425 | 425 | function test_available_item_types() { |
426 | 426 | |
427 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
427 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
428 | 428 | |
429 | 429 | $expected = array( |
430 | - array( 'title' => 'Post', 'type' => 'post_type', 'object' => 'post' ), |
|
431 | - array( 'title' => 'Page', 'type' => 'post_type', 'object' => 'page' ), |
|
432 | - array( 'title' => 'Category', 'type' => 'taxonomy', 'object' => 'category' ), |
|
433 | - array( 'title' => 'Tag', 'type' => 'taxonomy', 'object' => 'post_tag' ), |
|
430 | + array('title' => 'Post', 'type' => 'post_type', 'object' => 'post'), |
|
431 | + array('title' => 'Page', 'type' => 'post_type', 'object' => 'page'), |
|
432 | + array('title' => 'Category', 'type' => 'taxonomy', 'object' => 'category'), |
|
433 | + array('title' => 'Tag', 'type' => 'taxonomy', 'object' => 'post_tag'), |
|
434 | 434 | ); |
435 | 435 | |
436 | - if ( current_theme_supports( 'post-formats' ) ) { |
|
437 | - $expected[] = array( 'title' => 'Format', 'type' => 'taxonomy', 'object' => 'post_format' ); |
|
436 | + if (current_theme_supports('post-formats')) { |
|
437 | + $expected[] = array('title' => 'Format', 'type' => 'taxonomy', 'object' => 'post_format'); |
|
438 | 438 | } |
439 | 439 | |
440 | - $this->assertEquals( $expected, $menus->available_item_types() ); |
|
440 | + $this->assertEquals($expected, $menus->available_item_types()); |
|
441 | 441 | |
442 | - register_taxonomy( 'wptests_tax', array( 'post' ), array( 'labels' => array( 'name' => 'Foo' ) ) ); |
|
443 | - $expected[] = array( 'title' => 'Foo', 'type' => 'taxonomy', 'object' => 'wptests_tax' ); |
|
442 | + register_taxonomy('wptests_tax', array('post'), array('labels' => array('name' => 'Foo'))); |
|
443 | + $expected[] = array('title' => 'Foo', 'type' => 'taxonomy', 'object' => 'wptests_tax'); |
|
444 | 444 | |
445 | - $this->assertEquals( $expected, $menus->available_item_types() ); |
|
445 | + $this->assertEquals($expected, $menus->available_item_types()); |
|
446 | 446 | |
447 | - $expected[] = array( 'title' => 'Custom', 'type' => 'custom_type', 'object' => 'custom_object' ); |
|
447 | + $expected[] = array('title' => 'Custom', 'type' => 'custom_type', 'object' => 'custom_object'); |
|
448 | 448 | |
449 | - add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); |
|
450 | - $this->assertEquals( $expected, $menus->available_item_types() ); |
|
451 | - remove_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); |
|
449 | + add_filter('customize_nav_menu_available_item_types', array($this, 'filter_item_types')); |
|
450 | + $this->assertEquals($expected, $menus->available_item_types()); |
|
451 | + remove_filter('customize_nav_menu_available_item_types', array($this, 'filter_item_types')); |
|
452 | 452 | |
453 | 453 | } |
454 | 454 | |
@@ -458,8 +458,8 @@ discard block |
||
458 | 458 | * @see WP_Customize_Nav_Menus::print_templates() |
459 | 459 | */ |
460 | 460 | function test_print_templates() { |
461 | - do_action( 'customize_register', $this->wp_customize ); |
|
462 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
461 | + do_action('customize_register', $this->wp_customize); |
|
462 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
463 | 463 | |
464 | 464 | ob_start(); |
465 | 465 | $menus->print_templates(); |
@@ -467,13 +467,13 @@ discard block |
||
467 | 467 | |
468 | 468 | $expected = sprintf( |
469 | 469 | '<button type="button" class="menus-move-up">%1$s</button><button type="button" class="menus-move-down">%2$s</button><button type="button" class="menus-move-left">%3$s</button><button type="button" class="menus-move-right">%4$s</button>', |
470 | - esc_html( 'Move up' ), |
|
471 | - esc_html( 'Move down' ), |
|
472 | - esc_html( 'Move one level up' ), |
|
473 | - esc_html( 'Move one level down' ) |
|
470 | + esc_html('Move up'), |
|
471 | + esc_html('Move down'), |
|
472 | + esc_html('Move one level up'), |
|
473 | + esc_html('Move one level down') |
|
474 | 474 | ); |
475 | 475 | |
476 | - $this->assertContains( $expected, $template ); |
|
476 | + $this->assertContains($expected, $template); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -482,42 +482,42 @@ discard block |
||
482 | 482 | * @see WP_Customize_Nav_Menus::available_items_template() |
483 | 483 | */ |
484 | 484 | function test_available_items_template() { |
485 | - add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); |
|
486 | - do_action( 'customize_register', $this->wp_customize ); |
|
487 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
485 | + add_filter('customize_nav_menu_available_item_types', array($this, 'filter_item_types')); |
|
486 | + do_action('customize_register', $this->wp_customize); |
|
487 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
488 | 488 | |
489 | 489 | ob_start(); |
490 | 490 | $menus->available_items_template(); |
491 | 491 | $template = ob_get_clean(); |
492 | 492 | |
493 | - $expected = sprintf( 'Customizing ▸ %s', esc_html( $this->wp_customize->get_panel( 'nav_menus' )->title ) ); |
|
493 | + $expected = sprintf('Customizing ▸ %s', esc_html($this->wp_customize->get_panel('nav_menus')->title)); |
|
494 | 494 | |
495 | - $this->assertContains( $expected, $template ); |
|
495 | + $this->assertContains($expected, $template); |
|
496 | 496 | |
497 | - $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
|
498 | - if ( $post_types ) { |
|
499 | - foreach ( $post_types as $type ) { |
|
500 | - $this->assertContains( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template ); |
|
501 | - $this->assertRegExp( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $type->labels->singular_name ) . '#', $template ); |
|
502 | - $this->assertContains( 'data-type="post_type"', $template ); |
|
503 | - $this->assertContains( 'data-object="' . esc_attr( $type->name ) . '"', $template ); |
|
497 | + $post_types = get_post_types(array('show_in_nav_menus' => true), 'object'); |
|
498 | + if ($post_types) { |
|
499 | + foreach ($post_types as $type) { |
|
500 | + $this->assertContains('available-menu-items-post_type-'.esc_attr($type->name), $template); |
|
501 | + $this->assertRegExp('#<h4 class="accordion-section-title".*>\s*'.esc_html($type->labels->singular_name).'#', $template); |
|
502 | + $this->assertContains('data-type="post_type"', $template); |
|
503 | + $this->assertContains('data-object="'.esc_attr($type->name).'"', $template); |
|
504 | 504 | } |
505 | 505 | } |
506 | 506 | |
507 | - $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); |
|
508 | - if ( $taxonomies ) { |
|
509 | - foreach ( $taxonomies as $tax ) { |
|
510 | - $this->assertContains( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template ); |
|
511 | - $this->assertRegExp( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $tax->labels->singular_name ) . '#', $template ); |
|
512 | - $this->assertContains( 'data-type="taxonomy"', $template ); |
|
513 | - $this->assertContains( 'data-object="' . esc_attr( $tax->name ) . '"', $template ); |
|
507 | + $taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object'); |
|
508 | + if ($taxonomies) { |
|
509 | + foreach ($taxonomies as $tax) { |
|
510 | + $this->assertContains('available-menu-items-taxonomy-'.esc_attr($tax->name), $template); |
|
511 | + $this->assertRegExp('#<h4 class="accordion-section-title".*>\s*'.esc_html($tax->labels->singular_name).'#', $template); |
|
512 | + $this->assertContains('data-type="taxonomy"', $template); |
|
513 | + $this->assertContains('data-object="'.esc_attr($tax->name).'"', $template); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
517 | - $this->assertContains( 'available-menu-items-custom_type', $template ); |
|
518 | - $this->assertRegExp( '#<h4 class="accordion-section-title".*>\s*Custom#', $template ); |
|
519 | - $this->assertContains( 'data-type="custom_type"', $template ); |
|
520 | - $this->assertContains( 'data-object="custom_object"', $template ); |
|
517 | + $this->assertContains('available-menu-items-custom_type', $template); |
|
518 | + $this->assertRegExp('#<h4 class="accordion-section-title".*>\s*Custom#', $template); |
|
519 | + $this->assertContains('data-type="custom_type"', $template); |
|
520 | + $this->assertContains('data-object="custom_object"', $template); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -526,16 +526,16 @@ discard block |
||
526 | 526 | * @see WP_Customize_Nav_Menus::customize_preview_init() |
527 | 527 | */ |
528 | 528 | function test_customize_preview_init() { |
529 | - do_action( 'customize_register', $this->wp_customize ); |
|
530 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
529 | + do_action('customize_register', $this->wp_customize); |
|
530 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
531 | 531 | |
532 | 532 | $menus->customize_preview_init(); |
533 | - $this->assertEquals( 10, has_action( 'template_redirect', array( $menus, 'render_menu' ) ) ); |
|
534 | - $this->assertEquals( 10, has_action( 'wp_enqueue_scripts', array( $menus, 'customize_preview_enqueue_deps' ) ) ); |
|
533 | + $this->assertEquals(10, has_action('template_redirect', array($menus, 'render_menu'))); |
|
534 | + $this->assertEquals(10, has_action('wp_enqueue_scripts', array($menus, 'customize_preview_enqueue_deps'))); |
|
535 | 535 | |
536 | - if ( ! isset( $_REQUEST[ WP_Customize_Nav_Menus::RENDER_QUERY_VAR ] ) ) { |
|
537 | - $this->assertEquals( 1000, has_filter( 'wp_nav_menu_args', array( $menus, 'filter_wp_nav_menu_args' ) ) ); |
|
538 | - $this->assertEquals( 10, has_filter( 'wp_nav_menu', array( $menus, 'filter_wp_nav_menu' ) ) ); |
|
536 | + if ( ! isset($_REQUEST[WP_Customize_Nav_Menus::RENDER_QUERY_VAR])) { |
|
537 | + $this->assertEquals(1000, has_filter('wp_nav_menu_args', array($menus, 'filter_wp_nav_menu_args'))); |
|
538 | + $this->assertEquals(10, has_filter('wp_nav_menu', array($menus, 'filter_wp_nav_menu'))); |
|
539 | 539 | } |
540 | 540 | } |
541 | 541 | |
@@ -545,16 +545,16 @@ discard block |
||
545 | 545 | * @see WP_Customize_Nav_Menus::filter_wp_nav_menu_args() |
546 | 546 | */ |
547 | 547 | function test_filter_wp_nav_menu_args() { |
548 | - do_action( 'customize_register', $this->wp_customize ); |
|
549 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
548 | + do_action('customize_register', $this->wp_customize); |
|
549 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
550 | 550 | |
551 | - $results = $menus->filter_wp_nav_menu_args( array( |
|
551 | + $results = $menus->filter_wp_nav_menu_args(array( |
|
552 | 552 | 'echo' => true, |
553 | 553 | 'fallback_cb' => 'wp_page_menu', |
554 | 554 | 'walker' => '', |
555 | - 'menu' => wp_create_nav_menu( 'Foo' ), |
|
556 | - ) ); |
|
557 | - $this->assertEquals( 1, $results['can_partial_refresh'] ); |
|
555 | + 'menu' => wp_create_nav_menu('Foo'), |
|
556 | + )); |
|
557 | + $this->assertEquals(1, $results['can_partial_refresh']); |
|
558 | 558 | |
559 | 559 | $expected = array( |
560 | 560 | 'echo', |
@@ -563,20 +563,20 @@ discard block |
||
563 | 563 | 'instance_number', |
564 | 564 | 'walker', |
565 | 565 | ); |
566 | - $results = $menus->filter_wp_nav_menu_args( array( |
|
566 | + $results = $menus->filter_wp_nav_menu_args(array( |
|
567 | 567 | 'echo' => false, |
568 | 568 | 'fallback_cb' => 'wp_page_menu', |
569 | 569 | 'walker' => new Walker_Nav_Menu(), |
570 | - ) ); |
|
571 | - $this->assertEqualSets( $expected, array_keys( $results ) ); |
|
572 | - $this->assertEquals( 'wp_page_menu', $results['fallback_cb'] ); |
|
573 | - $this->assertEquals( 0, $results['can_partial_refresh'] ); |
|
574 | - |
|
575 | - $this->assertNotEmpty( $menus->preview_nav_menu_instance_args[ $results['instance_number'] ] ); |
|
576 | - $preview_nav_menu_instance_args = $menus->preview_nav_menu_instance_args[ $results['instance_number'] ]; |
|
577 | - $this->assertEquals( '', $preview_nav_menu_instance_args['fallback_cb'] ); |
|
578 | - $this->assertEquals( '', $preview_nav_menu_instance_args['walker'] ); |
|
579 | - $this->assertNotEmpty( $preview_nav_menu_instance_args['args_hash'] ); |
|
570 | + )); |
|
571 | + $this->assertEqualSets($expected, array_keys($results)); |
|
572 | + $this->assertEquals('wp_page_menu', $results['fallback_cb']); |
|
573 | + $this->assertEquals(0, $results['can_partial_refresh']); |
|
574 | + |
|
575 | + $this->assertNotEmpty($menus->preview_nav_menu_instance_args[$results['instance_number']]); |
|
576 | + $preview_nav_menu_instance_args = $menus->preview_nav_menu_instance_args[$results['instance_number']]; |
|
577 | + $this->assertEquals('', $preview_nav_menu_instance_args['fallback_cb']); |
|
578 | + $this->assertEquals('', $preview_nav_menu_instance_args['walker']); |
|
579 | + $this->assertNotEmpty($preview_nav_menu_instance_args['args_hash']); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -585,27 +585,27 @@ discard block |
||
585 | 585 | * @see WP_Customize_Nav_Menus::filter_wp_nav_menu() |
586 | 586 | */ |
587 | 587 | function test_filter_wp_nav_menu() { |
588 | - do_action( 'customize_register', $this->wp_customize ); |
|
589 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
588 | + do_action('customize_register', $this->wp_customize); |
|
589 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
590 | 590 | |
591 | - $args = $menus->filter_wp_nav_menu_args( array( |
|
591 | + $args = $menus->filter_wp_nav_menu_args(array( |
|
592 | 592 | 'echo' => true, |
593 | - 'menu' => wp_create_nav_menu( 'Foo' ), |
|
593 | + 'menu' => wp_create_nav_menu('Foo'), |
|
594 | 594 | 'fallback_cb' => 'wp_page_menu', |
595 | 595 | 'walker' => '', |
596 | - ) ); |
|
596 | + )); |
|
597 | 597 | |
598 | 598 | ob_start(); |
599 | - wp_nav_menu( $args ); |
|
599 | + wp_nav_menu($args); |
|
600 | 600 | $nav_menu_content = ob_get_clean(); |
601 | 601 | |
602 | - $object_args = json_decode( json_encode( $args ), false ); |
|
603 | - $result = $menus->filter_wp_nav_menu( $nav_menu_content, $object_args ); |
|
602 | + $object_args = json_decode(json_encode($args), false); |
|
603 | + $result = $menus->filter_wp_nav_menu($nav_menu_content, $object_args); |
|
604 | 604 | $expected = sprintf( |
605 | 605 | '<div class="partial-refreshable-nav-menu partial-refreshable-nav-menu-%1$d menu">', |
606 | 606 | $args['instance_number'] |
607 | 607 | ); |
608 | - $this->assertStringStartsWith( $expected, $result ); |
|
608 | + $this->assertStringStartsWith($expected, $result); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -614,13 +614,13 @@ discard block |
||
614 | 614 | * @see WP_Customize_Nav_Menus::customize_preview_enqueue_deps() |
615 | 615 | */ |
616 | 616 | function test_customize_preview_enqueue_deps() { |
617 | - do_action( 'customize_register', $this->wp_customize ); |
|
618 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
617 | + do_action('customize_register', $this->wp_customize); |
|
618 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
619 | 619 | |
620 | 620 | $menus->customize_preview_enqueue_deps(); |
621 | 621 | |
622 | - $this->assertTrue( wp_script_is( 'customize-preview-nav-menus' ) ); |
|
623 | - $this->assertEquals( 10, has_action( 'wp_print_footer_scripts', array( $menus, 'export_preview_data' ) ) ); |
|
622 | + $this->assertTrue(wp_script_is('customize-preview-nav-menus')); |
|
623 | + $this->assertEquals(10, has_action('wp_print_footer_scripts', array($menus, 'export_preview_data'))); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -629,8 +629,8 @@ discard block |
||
629 | 629 | * @see WP_Customize_Nav_Menus::export_preview_data() |
630 | 630 | */ |
631 | 631 | function test_export_preview_data() { |
632 | - do_action( 'customize_register', $this->wp_customize ); |
|
633 | - $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
632 | + do_action('customize_register', $this->wp_customize); |
|
633 | + $menus = new WP_Customize_Nav_Menus($this->wp_customize); |
|
634 | 634 | |
635 | 635 | $request_uri = $_SERVER['REQUEST_URI']; |
636 | 636 | |
@@ -641,15 +641,15 @@ discard block |
||
641 | 641 | |
642 | 642 | $_SERVER['REQUEST_URI'] = $request_uri; |
643 | 643 | |
644 | - $this->assertContains( '_wpCustomizePreviewNavMenusExports', $data ); |
|
645 | - $this->assertContains( 'renderQueryVar', $data ); |
|
646 | - $this->assertContains( 'renderNonceValue', $data ); |
|
647 | - $this->assertContains( 'renderNoncePostKey', $data ); |
|
648 | - $this->assertContains( 'requestUri', $data ); |
|
649 | - $this->assertContains( 'theme', $data ); |
|
650 | - $this->assertContains( 'previewCustomizeNonce', $data ); |
|
651 | - $this->assertContains( 'navMenuInstanceArgs', $data ); |
|
652 | - $this->assertContains( 'requestUri', $data ); |
|
644 | + $this->assertContains('_wpCustomizePreviewNavMenusExports', $data); |
|
645 | + $this->assertContains('renderQueryVar', $data); |
|
646 | + $this->assertContains('renderNonceValue', $data); |
|
647 | + $this->assertContains('renderNoncePostKey', $data); |
|
648 | + $this->assertContains('requestUri', $data); |
|
649 | + $this->assertContains('theme', $data); |
|
650 | + $this->assertContains('previewCustomizeNonce', $data); |
|
651 | + $this->assertContains('navMenuInstanceArgs', $data); |
|
652 | + $this->assertContains('requestUri', $data); |
|
653 | 653 | |
654 | 654 | } |
655 | 655 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | function setUp() { |
11 | 11 | parent::setUp(); |
12 | - require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' ); |
|
12 | + require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php'); |
|
13 | 13 | //require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' ); |
14 | 14 | $GLOBALS['wp_customize'] = new WP_Customize_Manager(); |
15 | 15 | $this->manager = $GLOBALS['wp_customize']; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | function tearDown() { |
20 | 20 | $this->manager = null; |
21 | - unset( $GLOBALS['wp_customize'] ); |
|
21 | + unset($GLOBALS['wp_customize']); |
|
22 | 22 | parent::tearDown(); |
23 | 23 | } |
24 | 24 | |
@@ -38,28 +38,28 @@ discard block |
||
38 | 38 | * @group ajax |
39 | 39 | */ |
40 | 40 | function test_doing_ajax() { |
41 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
42 | - define( 'DOING_AJAX', true ); |
|
41 | + if ( ! defined('DOING_AJAX')) { |
|
42 | + define('DOING_AJAX', true); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $manager = $this->instantiate(); |
46 | - $this->assertTrue( $manager->doing_ajax() ); |
|
46 | + $this->assertTrue($manager->doing_ajax()); |
|
47 | 47 | |
48 | 48 | $_REQUEST['action'] = 'customize_save'; |
49 | - $this->assertTrue( $manager->doing_ajax( 'customize_save' ) ); |
|
50 | - $this->assertFalse( $manager->doing_ajax( 'update-widget' ) ); |
|
49 | + $this->assertTrue($manager->doing_ajax('customize_save')); |
|
50 | + $this->assertFalse($manager->doing_ajax('update-widget')); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Test ! WP_Customize_Manager::doing_ajax(). |
55 | 55 | */ |
56 | 56 | function test_not_doing_ajax() { |
57 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
58 | - $this->markTestSkipped( 'Cannot test when DOING_AJAX' ); |
|
57 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
58 | + $this->markTestSkipped('Cannot test when DOING_AJAX'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | $manager = $this->instantiate(); |
62 | - $this->assertFalse( $manager->doing_ajax() ); |
|
62 | + $this->assertFalse($manager->doing_ajax()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | 'foo' => 'bar', |
75 | 75 | 'baz[quux]' => 123, |
76 | 76 | ); |
77 | - $_POST['customized'] = wp_slash( wp_json_encode( $customized ) ); |
|
77 | + $_POST['customized'] = wp_slash(wp_json_encode($customized)); |
|
78 | 78 | $post_values = $manager->unsanitized_post_values(); |
79 | - $this->assertEquals( $customized, $post_values ); |
|
79 | + $this->assertEquals($customized, $post_values); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | $posted_settings = array( |
89 | 89 | 'foo' => 'OOF', |
90 | 90 | ); |
91 | - $_POST['customized'] = wp_slash( wp_json_encode( $posted_settings ) ); |
|
91 | + $_POST['customized'] = wp_slash(wp_json_encode($posted_settings)); |
|
92 | 92 | |
93 | 93 | $manager = $this->instantiate(); |
94 | 94 | |
95 | - $manager->add_setting( 'foo', array( 'default' => 'foo_default' ) ); |
|
96 | - $foo_setting = $manager->get_setting( 'foo' ); |
|
97 | - $this->assertEquals( 'foo_default', $manager->get_setting( 'foo' )->value(), 'Expected non-previewed setting to return default when value() method called.' ); |
|
98 | - $this->assertEquals( $posted_settings['foo'], $manager->post_value( $foo_setting, 'post_value_foo_default' ), 'Expected post_value($foo_setting) to return value supplied in $_POST[customized][foo]' ); |
|
95 | + $manager->add_setting('foo', array('default' => 'foo_default')); |
|
96 | + $foo_setting = $manager->get_setting('foo'); |
|
97 | + $this->assertEquals('foo_default', $manager->get_setting('foo')->value(), 'Expected non-previewed setting to return default when value() method called.'); |
|
98 | + $this->assertEquals($posted_settings['foo'], $manager->post_value($foo_setting, 'post_value_foo_default'), 'Expected post_value($foo_setting) to return value supplied in $_POST[customized][foo]'); |
|
99 | 99 | |
100 | - $manager->add_setting( 'bar', array( 'default' => 'bar_default' ) ); |
|
101 | - $bar_setting = $manager->get_setting( 'bar' ); |
|
102 | - $this->assertEquals( 'post_value_bar_default', $manager->post_value( $bar_setting, 'post_value_bar_default' ), 'Expected post_value($bar_setting, $default) to return $default since no value supplied in $_POST[customized][bar]' ); |
|
100 | + $manager->add_setting('bar', array('default' => 'bar_default')); |
|
101 | + $bar_setting = $manager->get_setting('bar'); |
|
102 | + $this->assertEquals('post_value_bar_default', $manager->post_value($bar_setting, 'post_value_bar_default'), 'Expected post_value($bar_setting, $default) to return $default since no value supplied in $_POST[customized][bar]'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -109,17 +109,17 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function test_add_dynamic_settings() { |
111 | 111 | $manager = $this->instantiate(); |
112 | - $setting_ids = array( 'foo', 'bar' ); |
|
113 | - $manager->add_setting( 'foo', array( 'default' => 'foo_default' ) ); |
|
114 | - $this->assertEmpty( $manager->get_setting( 'bar' ), 'Expected there to not be a bar setting up front.' ); |
|
115 | - $manager->add_dynamic_settings( $setting_ids ); |
|
116 | - $this->assertEmpty( $manager->get_setting( 'bar' ), 'Expected the bar setting to remain absent since filters not added.' ); |
|
112 | + $setting_ids = array('foo', 'bar'); |
|
113 | + $manager->add_setting('foo', array('default' => 'foo_default')); |
|
114 | + $this->assertEmpty($manager->get_setting('bar'), 'Expected there to not be a bar setting up front.'); |
|
115 | + $manager->add_dynamic_settings($setting_ids); |
|
116 | + $this->assertEmpty($manager->get_setting('bar'), 'Expected the bar setting to remain absent since filters not added.'); |
|
117 | 117 | |
118 | 118 | $this->action_customize_register_for_dynamic_settings(); |
119 | - $manager->add_dynamic_settings( $setting_ids ); |
|
120 | - $this->assertNotEmpty( $manager->get_setting( 'bar' ), 'Expected bar setting to be created since filters were added.' ); |
|
121 | - $this->assertEquals( 'foo_default', $manager->get_setting( 'foo' )->default, 'Expected static foo setting to not get overridden by dynamic setting.' ); |
|
122 | - $this->assertEquals( 'dynamic_bar_default', $manager->get_setting( 'bar' )->default, 'Expected dynamic setting bar to have default providd by filter.' ); |
|
119 | + $manager->add_dynamic_settings($setting_ids); |
|
120 | + $this->assertNotEmpty($manager->get_setting('bar'), 'Expected bar setting to be created since filters were added.'); |
|
121 | + $this->assertEquals('foo_default', $manager->get_setting('foo')->default, 'Expected static foo setting to not get overridden by dynamic setting.'); |
|
122 | + $this->assertEquals('dynamic_bar_default', $manager->get_setting('bar')->default, 'Expected dynamic setting bar to have default providd by filter.'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -134,35 +134,35 @@ discard block |
||
134 | 134 | 'foo' => 'OOF', |
135 | 135 | 'bar' => 'RAB', |
136 | 136 | ); |
137 | - $_POST['customized'] = wp_slash( wp_json_encode( $posted_settings ) ); |
|
137 | + $_POST['customized'] = wp_slash(wp_json_encode($posted_settings)); |
|
138 | 138 | |
139 | - add_action( 'customize_register', array( $this, 'action_customize_register_for_dynamic_settings' ) ); |
|
139 | + add_action('customize_register', array($this, 'action_customize_register_for_dynamic_settings')); |
|
140 | 140 | |
141 | 141 | $manager = $this->instantiate(); |
142 | - $manager->add_setting( 'foo', array( 'default' => 'foo_default' ) ); |
|
142 | + $manager->add_setting('foo', array('default' => 'foo_default')); |
|
143 | 143 | |
144 | - $this->assertEmpty( $manager->get_setting( 'bar' ), 'Expected dynamic setting "bar" to not be registered.' ); |
|
145 | - do_action( 'customize_register', $manager ); |
|
146 | - $this->assertNotEmpty( $manager->get_setting( 'bar' ), 'Expected dynamic setting "bar" to be automatically registered after customize_register action.' ); |
|
147 | - $this->assertEmpty( $manager->get_setting( 'baz' ), 'Expected unrecognized dynamic setting "baz" to remain unregistered.' ); |
|
144 | + $this->assertEmpty($manager->get_setting('bar'), 'Expected dynamic setting "bar" to not be registered.'); |
|
145 | + do_action('customize_register', $manager); |
|
146 | + $this->assertNotEmpty($manager->get_setting('bar'), 'Expected dynamic setting "bar" to be automatically registered after customize_register action.'); |
|
147 | + $this->assertEmpty($manager->get_setting('baz'), 'Expected unrecognized dynamic setting "baz" to remain unregistered.'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | 151 | * In lieu of closures, callback for customize_register action added in test_register_dynamic_settings(). |
152 | 152 | */ |
153 | 153 | function action_customize_register_for_dynamic_settings() { |
154 | - add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args_for_test_dynamic_settings' ), 10, 2 ); |
|
155 | - add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_customize_dynamic_setting_class_for_test_dynamic_settings' ), 10, 3 ); |
|
154 | + add_filter('customize_dynamic_setting_args', array($this, 'filter_customize_dynamic_setting_args_for_test_dynamic_settings'), 10, 2); |
|
155 | + add_filter('customize_dynamic_setting_class', array($this, 'filter_customize_dynamic_setting_class_for_test_dynamic_settings'), 10, 3); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | 159 | * In lieu of closures, callback for customize_dynamic_setting_args filter added for test_register_dynamic_settings(). |
160 | 160 | */ |
161 | - function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) { |
|
162 | - $this->assertEquals( false, $setting_args, 'Expected $setting_args to be false by default.' ); |
|
163 | - $this->assertInternalType( 'string', $setting_id ); |
|
164 | - if ( in_array( $setting_id, array( 'foo', 'bar' ) ) ) { |
|
165 | - $setting_args = array( 'default' => "dynamic_{$setting_id}_default" ); |
|
161 | + function filter_customize_dynamic_setting_args_for_test_dynamic_settings($setting_args, $setting_id) { |
|
162 | + $this->assertEquals(false, $setting_args, 'Expected $setting_args to be false by default.'); |
|
163 | + $this->assertInternalType('string', $setting_id); |
|
164 | + if (in_array($setting_id, array('foo', 'bar'))) { |
|
165 | + $setting_args = array('default' => "dynamic_{$setting_id}_default"); |
|
166 | 166 | } |
167 | 167 | return $setting_args; |
168 | 168 | } |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | /** |
171 | 171 | * In lieu of closures, callback for customize_dynamic_setting_class filter added for test_register_dynamic_settings(). |
172 | 172 | */ |
173 | - function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $setting_class, $setting_id, $setting_args ) { |
|
174 | - $this->assertEquals( 'WP_Customize_Setting', $setting_class ); |
|
175 | - $this->assertInternalType( 'string', $setting_id ); |
|
176 | - $this->assertInternalType( 'array', $setting_args ); |
|
173 | + function filter_customize_dynamic_setting_class_for_test_dynamic_settings($setting_class, $setting_id, $setting_args) { |
|
174 | + $this->assertEquals('WP_Customize_Setting', $setting_class); |
|
175 | + $this->assertInternalType('string', $setting_id); |
|
176 | + $this->assertInternalType('array', $setting_args); |
|
177 | 177 | return $setting_class; |
178 | 178 | } |
179 | 179 | } |