Changeset 49328
- Timestamp:
- 10/27/2020 04:40:35 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r49326 r49328 4092 4092 4093 4093 // Filter out empty terms. 4094 if ( isset( $postarr['tax_input'] ) && is_array( $postarr['tax_input'][ $taxonomy ] ) ) {4094 if ( isset( $postarr['tax_input'][ $taxonomy ] ) && is_array( $postarr['tax_input'][ $taxonomy ] ) ) { 4095 4095 $postarr['tax_input'][ $taxonomy ] = array_filter( $postarr['tax_input'][ $taxonomy ] ); 4096 4096 } -
trunk/tests/phpunit/tests/taxonomy.php
r49305 r49328 1008 1008 1009 1009 // Add post. 1010 $post_id = wp_insert_post(1010 $post_id = self::factory()->post->create( 1011 1011 array( 1012 1012 'post_title' => 'Foo', … … 1015 1015 ); 1016 1016 1017 // Test default category.1017 // Test default term. 1018 1018 $term = wp_get_post_terms( $post_id, $tax ); 1019 1019 $this->assertSame( get_option( 'default_term_' . $tax ), $term[0]->term_id ); … … 1029 1029 ) 1030 1030 ); 1031 $post_id = wp_insert_post(1031 $post_id = self::factory()->post->create( 1032 1032 array( 1033 1033 'post_title' => 'Foo', … … 1035 1035 ) 1036 1036 ); 1037 $term = wp_get_post_terms( $post_id, $tax ); 1037 1038 // Test default term. 1039 $term = wp_get_post_terms( $post_id, $tax ); 1038 1040 $this->assertSame( get_option( 'default_term_' . $tax ), $term[0]->term_id ); 1039 1041 1040 // wp_set_object_terms shouldn't assign default category.1042 // wp_set_object_terms() should not assign default term. 1041 1043 wp_set_object_terms( $post_id, array(), $tax ); 1042 1044 $term = wp_get_post_terms( $post_id, $tax ); … … 1045 1047 unregister_taxonomy( $tax ); 1046 1048 $this->assertSame( get_option( 'default_term_' . $tax ), false ); 1049 } 1050 1051 /** 1052 * @ticket 51320 1053 */ 1054 function test_default_term_for_post_in_multiple_taxonomies() { 1055 $post_type = 'test_post_type'; 1056 $tax1 = 'test_tax1'; 1057 $tax2 = 'test_tax2'; 1058 1059 register_post_type( $post_type, array( 'taxonomies' => array( $tax1, $tax2 ) ) ); 1060 register_taxonomy( $tax1, $post_type, array( 'default_term' => 'term_1' ) ); 1061 register_taxonomy( $tax2, $post_type, array( 'default_term' => 'term_2' ) ); 1062 1063 $post_id = self::factory()->post->create( array( 'post_type' => $post_type ) ); 1064 1065 $taxonomies = get_post_taxonomies( $post_id ); 1066 1067 $this->assertContains( $tax1, $taxonomies ); 1068 $this->assertContains( $tax2, $taxonomies ); 1047 1069 } 1048 1070
Note: See TracChangeset
for help on using the changeset viewer.