Ticket #36905: 36905.4.patch
File 36905.4.patch, 8.1 KB (added by , 8 years ago) |
---|
-
src/wp-includes/general-template.php
1634 1634 * @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'. 1635 1635 * Default 'DESC'. 1636 1636 * @type string $post_type Post type. Default 'post'. 1637 * @type string $title List heading. Passing a null or empty value will result in no heading, and the list 1638 * will not be wrapped and $title_before and $title_after become useless. Default ''. 1639 * @type string $title_before Text or HTML to precede the title. Default ''. 1640 * @type string $title_after Text or HTML to follow the title. Default ''. 1641 * @type string $list_before Text or HTML to precede the list. Default ''. 1642 * @type string $list_after Text or HTML to follow the list. Default ''. 1637 1643 * } 1638 1644 * @return string|void String when retrieving. 1639 1645 */ … … 1645 1651 'format' => 'html', 'before' => '', 1646 1652 'after' => '', 'show_post_count' => false, 1647 1653 'echo' => 1, 'order' => 'DESC', 1648 'post_type' => 'post' 1654 'post_type' => 'post', 'title' => '', 1655 'title_before' => '', 'title_after' => '', 1656 'list_before' => '', 'list_after' => '' 1649 1657 ); 1650 1658 1651 1659 $r = wp_parse_args( $args, $defaults ); … … 1697 1705 1698 1706 $output = ''; 1699 1707 1708 if ( '' != $r['title'] ) { 1709 $output .= $r['title_before']. $r['title']. $r['title_after']; 1710 } 1711 1712 if ( $r['list_before'] ) { 1713 $output .= $r['list_before']; 1714 } 1715 1700 1716 $last_changed = wp_cache_get( 'last_changed', 'posts' ); 1701 1717 if ( ! $last_changed ) { 1702 1718 $last_changed = microtime(); … … 1828 1844 } 1829 1845 } 1830 1846 } 1847 1848 if ( $r['list_after'] ) { 1849 $output .= $r['list_after']; 1850 } 1851 1831 1852 if ( $r['echo'] ) { 1832 1853 echo $output; 1833 1854 } else { -
src/wp-includes/post-template.php
1131 1131 * @type string $title_li List heading. Passing a null or empty value will result in no heading, and the list 1132 1132 * will not be wrapped with unordered list `<ul>` tags. Default 'Pages'. 1133 1133 * @type Walker $walker Walker instance to use for listing pages. Default empty (Walker_Page). 1134 * @type string $before Text or HTML to precede the list of pages. Default <li class="pagenav"> 1135 * @type string $after Text or HTML to follow the list of pages. Default </li> 1134 1136 * } 1135 1137 * @return string|void HTML list of pages. 1136 1138 */ … … 1142 1144 'title_li' => __( 'Pages' ), 'echo' => 1, 1143 1145 'authors' => '', 'sort_column' => 'menu_order, post_title', 1144 1146 'link_before' => '', 'link_after' => '', 'walker' => '', 1147 'before' => '<li class="pagenav">', 'after' => '</li>' 1145 1148 ); 1146 1149 1147 1150 $r = wp_parse_args( $args, $defaults ); … … 1170 1173 1171 1174 if ( ! empty( $pages ) ) { 1172 1175 if ( $r['title_li'] ) { 1173 $output .= '<li class="pagenav">'. $r['title_li'] . '<ul>';1176 $output .= $r['before'] . $r['title_li'] . '<ul>'; 1174 1177 } 1175 1178 global $wp_query; 1176 1179 if ( is_page() || is_attachment() || $wp_query->is_posts_page ) { … … 1185 1188 $output .= walk_page_tree( $pages, $r['depth'], $current_page, $r ); 1186 1189 1187 1190 if ( $r['title_li'] ) { 1188 $output .= '</ul> </li>';1191 $output .= '</ul>' . $r['after']; 1189 1192 } 1190 1193 } 1191 1194 -
src/wp-includes/post.php
4326 4326 * @return WP_Post|array|void WP_Post on success or null on failure 4327 4327 */ 4328 4328 function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) { 4329 global $wpdb;4330 4329 4331 if ( is_array( $post_type ) ) { 4332 $post_type = esc_sql( $post_type ); 4333 $post_type_in_string = "'" . implode( "','", $post_type ) . "'"; 4334 $sql = $wpdb->prepare( " 4335 SELECT ID 4336 FROM $wpdb->posts 4337 WHERE post_title = %s 4338 AND post_type IN ($post_type_in_string) 4339 ", $page_title ); 4340 } else { 4341 $sql = $wpdb->prepare( " 4342 SELECT ID 4343 FROM $wpdb->posts 4344 WHERE post_title = %s 4345 AND post_type = %s 4346 ", $page_title, $post_type ); 4347 } 4330 // Make sure that we even query post statuses that are excluded from search 4331 $post_status = array_values( get_post_stati( array( 'exclude_from_search' => true ) ) ); 4348 4332 4349 $page = $wpdb->get_var( $sql ); 4333 $query = new WP_Query( 4334 array( 4335 'title' => $page_title, 4336 'post_type' => $post_type, 4337 'posts_per_page' => 1, 4338 'post_status' => array_merge( $post_status, array( 'any' ) ), 4339 'orderby' => 'none', 4340 'fields' => 'ids' 4341 ) 4342 ); 4343 $posts = $query->get_posts(); 4350 4344 4351 if ( $p age) {4352 return get_post( $p age, $output );4345 if ( $posts ) { 4346 return get_post( $posts[0], $output ); 4353 4347 } 4354 4348 } 4355 4349 -
tests/phpunit/tests/functions/getArchives.php
122 122 $archives = wp_get_archives( array( 'echo' => false, 'post_type' => 'taco' ) ); 123 123 $this->assertEquals( $expected, trim( $archives ) ); 124 124 } 125 126 /** 127 * @ticket 4969 128 */ 129 function test_wp_get_archives_title() { 130 $expected = "<h1>Archives Title</h1>\t<li><a href='$this->month_url'>" . date( 'F Y' ) . "</a></li>"; 131 $result = trim( wp_get_archives( 132 array( 133 'echo' => false, 134 'title' => 'Archives Title', 135 'title_before' => '<h1>', 136 'title_after' => '</h1>', 137 ) 138 ) ); 139 140 $this->assertEquals( $expected, $result ); 141 } 142 143 /** 144 * @ticket 4969 145 */ 146 function test_wp_get_archives_before_and_after_list() { 147 $date = date( 'F Y' ); 148 $expected = <<<EOF 149 <ul>\t<li><a href='$this->month_url'>$date</a></li> 150 </ul> 151 EOF; 152 $result = trim( wp_get_archives( 153 array( 154 'echo' => false, 155 'list_before' => '<ul>', 156 'list_after' => '</ul>', 157 ) 158 ) ); 159 160 $this->assertEquals( $expected, $result ); 161 } 125 162 } -
tests/phpunit/tests/post/listPages.php
342 342 $actual = wp_list_pages( $args ); 343 343 $this->AssertEquals( $expected['exclude'], $actual ); 344 344 } 345 346 /** 347 * @ticket 4969 348 */ 349 function test_wp_get_pages_before_and_after() { 350 $expected = '<div>The Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a> 351 <ul class=\'children\'> 352 <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li> 353 <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a></li> 354 <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a></li> 355 </ul> 356 </li> 357 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> 358 <ul class=\'children\'> 359 <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a></li> 360 <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a></li> 361 <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a></li> 362 </ul> 363 </li> 364 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> 365 <ul class=\'children\'> 366 <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a></li> 367 <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a></li> 368 <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a></li> 369 </ul> 370 </li> 371 </ul></div>'; 372 373 $result = trim( wp_list_pages( 374 array( 375 'echo' => false, 376 'before' => '<div>', 377 'after' => '</div>', 378 'title_li' => 'The Pages' 379 ) 380 ) ); 381 382 $this->assertEquals( $expected, $result ); 383 } 345 384 }