Changeset 46160
- Timestamp:
- 09/17/2019 07:57:18 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-post-type.php
r45735 r46160 514 514 public function add_supports() { 515 515 if ( ! empty( $this->supports ) ) { 516 add_post_type_support( $this->name, $this->supports ); 516 foreach ( $this->supports as $feature => $args ) { 517 if ( is_array( $args ) ) { 518 add_post_type_support( $this->name, $feature, $args ); 519 } else { 520 add_post_type_support( $this->name, $args ); 521 } 522 } 517 523 unset( $this->supports ); 518 524 } elseif ( false !== $this->supports ) { -
trunk/tests/phpunit/tests/post/wpPostType.php
r45607 r46160 63 63 } 64 64 65 /** 66 * Test that supports can optionally receive nested args. 67 * 68 * @ticket 40413 69 */ 70 public function test_add_supports_custom_with_args() { 71 $post_type = 'cpt'; 72 $post_type_object = new WP_Post_Type( 73 $post_type, 74 array( 75 'supports' => array( 76 'support_with_args' => array( 77 'arg1', 78 'arg2', 79 ), 80 'support_without_args', 81 ), 82 ) 83 ); 84 85 $post_type_object->add_supports(); 86 $post_type_supports = get_all_post_type_supports( $post_type ); 87 88 $post_type_object->remove_supports(); 89 $post_type_supports_after = get_all_post_type_supports( $post_type ); 90 91 $this->assertEqualSets( 92 array( 93 'support_with_args' => array( 94 array( 95 'arg1', 96 'arg2', 97 ), 98 ), 99 'support_without_args' => true, 100 ), 101 $post_type_supports 102 ); 103 $this->assertEqualSets( array(), $post_type_supports_after ); 104 } 105 65 106 public function test_does_not_add_query_var_if_not_public() { 66 107 $this->set_permalink_structure( '/%postname%' );
Note: See TracChangeset
for help on using the changeset viewer.