- Timestamp:
- 08/27/2020 02:46:22 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-walker-category-checklist.php
r47557 r48880 82 82 } 83 83 84 $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];84 $args['popular_cats'] = ! empty( $args['popular_cats'] ) ? array_map( 'intval', $args['popular_cats'] ) : array(); 85 85 86 86 $class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : ''; 87 87 88 $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];88 $args['selected_cats'] = ! empty( $args['selected_cats'] ) ? array_map( 'intval', $args['selected_cats'] ) : array(); 89 89 90 90 if ( ! empty( $args['list_only'] ) ) { -
trunk/src/wp-admin/includes/template.php
r48760 r48880 121 121 122 122 if ( is_array( $parsed_args['selected_cats'] ) ) { 123 $args['selected_cats'] = $parsed_args['selected_cats'];123 $args['selected_cats'] = array_map( 'intval', $parsed_args['selected_cats'] ); 124 124 } elseif ( $post_id ) { 125 125 $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) ); … … 129 129 130 130 if ( is_array( $parsed_args['popular_cats'] ) ) { 131 $args['popular_cats'] = $parsed_args['popular_cats'];131 $args['popular_cats'] = array_map( 'intval', $parsed_args['popular_cats'] ); 132 132 } else { 133 133 $args['popular_cats'] = get_terms( -
trunk/tests/phpunit/tests/admin/includesTemplate.php
r48858 r48880 4 4 */ 5 5 class Tests_Admin_includesTemplate extends WP_UnitTestCase { 6 6 7 function test_equal() { 7 8 $this->assertEquals( ' selected=\'selected\'', selected( 'foo', 'foo', false ) ); … … 45 46 $this->assertEquals( '', selected( 0, false, false ) ); 46 47 $this->assertEquals( '', checked( 0, false, false ) ); 48 } 49 50 /** 51 * @ticket 51147 52 * @dataProvider data_wp_terms_checklist_with_selected_cats 53 */ 54 public function test_wp_terms_checklist_with_selected_cats( $term_id ) { 55 $output = wp_terms_checklist( 56 0, 57 array( 58 'selected_cats' => array( $term_id ), 59 'echo' => false, 60 ) 61 ); 62 63 $this->assertContains( "checked='checked'", $output ); 64 } 65 66 /** 67 * @ticket 51147 68 * @dataProvider data_wp_terms_checklist_with_selected_cats 69 */ 70 public function test_wp_terms_checklist_with_popular_cats( $term_id ) { 71 $output = wp_terms_checklist( 72 0, 73 array( 74 'popular_cats' => array( $term_id ), 75 'echo' => false, 76 ) 77 ); 78 79 $this->assertContains( 'class="popular-category"', $output ); 80 } 81 82 public function data_wp_terms_checklist_with_selected_cats() { 83 return array( 84 array( '1' ), 85 array( 1 ), 86 ); 47 87 } 48 88
Note: See TracChangeset
for help on using the changeset viewer.