Ticket #21596: 21596.diff
File 21596.diff, 3.1 KB (added by , 8 years ago) |
---|
-
src/wp-includes/general-template.php
1394 1394 'format' => 'html', 'before' => '', 1395 1395 'after' => '', 'show_post_count' => false, 1396 1396 'echo' => 1, 'order' => 'DESC', 1397 'post_type' => 'post' 1397 1398 ); 1398 1399 1399 1400 $r = wp_parse_args( $args, $defaults ); 1400 1401 1402 $post_type_object = get_post_type_object( $r['post_type'] ); 1403 if ( ! is_post_type_viewable( $post_type_object ) ) { 1404 return; 1405 } 1406 1401 1407 if ( '' == $r['type'] ) { 1402 1408 $r['type'] = 'monthly'; 1403 1409 } … … 1439 1445 * @param string $sql_where Portion of SQL query containing the WHERE clause. 1440 1446 * @param array $r An array of default arguments. 1441 1447 */ 1442 $where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); 1448 $sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $r['post_type'] ); 1449 $where = apply_filters( 'getarchives_where', $sql_where, $r ); 1443 1450 1444 1451 /** 1445 1452 * Filter the SQL JOIN clause for retrieving archives. … … 1473 1480 $after = $r['after']; 1474 1481 foreach ( (array) $results as $result ) { 1475 1482 $url = get_month_link( $result->year, $result->month ); 1483 if ( 'post' !== $r['post_type'] ) { 1484 $url = add_query_arg( 'post_type', $r['post_type'], $url ); 1485 } 1476 1486 /* translators: 1: month name, 2: 4-digit year */ 1477 1487 $text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year ); 1478 1488 if ( $r['show_post_count'] ) { … … 1493 1503 $after = $r['after']; 1494 1504 foreach ( (array) $results as $result) { 1495 1505 $url = get_year_link( $result->year ); 1506 if ( 'post' !== $r['post_type'] ) { 1507 $url = add_query_arg( 'post_type', $r['post_type'], $url ); 1508 } 1496 1509 $text = sprintf( '%d', $result->year ); 1497 1510 if ( $r['show_post_count'] ) { 1498 1511 $r['after'] = ' (' . $result->posts . ')' . $after; … … 1512 1525 $after = $r['after']; 1513 1526 foreach ( (array) $results as $result ) { 1514 1527 $url = get_day_link( $result->year, $result->month, $result->dayofmonth ); 1528 if ( 'post' !== $r['post_type'] ) { 1529 $url = add_query_arg( 'post_type', $r['post_type'], $url ); 1530 } 1515 1531 $date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth ); 1516 1532 $text = mysql2date( $archive_day_date_format, $date ); 1517 1533 if ( $r['show_post_count'] ) { … … 1540 1556 $arc_week_start = date_i18n( $archive_week_start_date_format, $arc_week['start'] ); 1541 1557 $arc_week_end = date_i18n( $archive_week_end_date_format, $arc_week['end'] ); 1542 1558 $url = sprintf( '%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $result->week ); 1559 if ( 'post' !== $r['post_type'] ) { 1560 $url = add_query_arg( 'post_type', $r['post_type'], $url ); 1561 } 1543 1562 $text = $arc_week_start . $archive_week_separator . $arc_week_end; 1544 1563 if ( $r['show_post_count'] ) { 1545 1564 $r['after'] = ' (' . $result->posts . ')' . $after;