diff --git wp-includes/general-template.php wp-includes/general-template.php
index 6f0ff15..13b1f32 100644
|
|
|
function get_archives_link($url, $text, $format = 'html', $before = '', $after = |
| 1317 | 1317 | * @type bool|int $echo Whether to echo or return the links list. Default 1|true to echo. |
| 1318 | 1318 | * @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'. |
| 1319 | 1319 | * Default 'DESC'. |
| | 1320 | * @type string|int $offset Number of links to offset the query. Default empty. |
| 1320 | 1321 | * } |
| 1321 | 1322 | * @return string|null String when retrieving, null when displaying. |
| 1322 | 1323 | */ |
| … |
… |
function wp_get_archives( $args = '' ) { |
| 1328 | 1329 | 'format' => 'html', 'before' => '', |
| 1329 | 1330 | 'after' => '', 'show_post_count' => false, |
| 1330 | 1331 | 'echo' => 1, 'order' => 'DESC', |
| | 1332 | 'offset' => '', |
| 1331 | 1333 | ); |
| 1332 | 1334 | |
| 1333 | 1335 | $r = wp_parse_args( $args, $defaults ); |
| … |
… |
function wp_get_archives( $args = '' ) { |
| 1346 | 1348 | $order = 'DESC'; |
| 1347 | 1349 | } |
| 1348 | 1350 | |
| | 1351 | if ( ! empty( $r['offset'] ) ) { |
| | 1352 | $r['offset'] = absint( $r['offset'] ); |
| | 1353 | $r['offset'] = ' OFFSET ' . $r['offset']; |
| | 1354 | if ( empty( $r['limit'] ) ) { |
| | 1355 | $r['limit'] = ' LIMIT ' . PHP_INT_MAX; |
| | 1356 | } |
| | 1357 | } |
| | 1358 | |
| 1349 | 1359 | // this is what will separate dates on weekly archive links |
| 1350 | 1360 | $archive_week_separator = '–'; |
| 1351 | 1361 | |
| … |
… |
function wp_get_archives( $args = '' ) { |
| 1395 | 1405 | |
| 1396 | 1406 | $limit = $r['limit']; |
| 1397 | 1407 | |
| | 1408 | $offset = $r['offset']; |
| | 1409 | |
| 1398 | 1410 | if ( 'monthly' == $r['type'] ) { |
| 1399 | | $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit"; |
| | 1411 | $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit $offset"; |
| 1400 | 1412 | $key = md5( $query ); |
| 1401 | 1413 | $key = "wp_get_archives:$key:$last_changed"; |
| 1402 | 1414 | if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |
| … |
… |
function wp_get_archives( $args = '' ) { |
| 1416 | 1428 | } |
| 1417 | 1429 | } |
| 1418 | 1430 | } elseif ( 'yearly' == $r['type'] ) { |
| 1419 | | $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; |
| | 1431 | $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit $offset"; |
| 1420 | 1432 | $key = md5( $query ); |
| 1421 | 1433 | $key = "wp_get_archives:$key:$last_changed"; |
| 1422 | 1434 | if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |
| … |
… |
function wp_get_archives( $args = '' ) { |
| 1435 | 1447 | } |
| 1436 | 1448 | } |
| 1437 | 1449 | } elseif ( 'daily' == $r['type'] ) { |
| 1438 | | $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; |
| | 1450 | $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit $offset"; |
| 1439 | 1451 | $key = md5( $query ); |
| 1440 | 1452 | $key = "wp_get_archives:$key:$last_changed"; |
| 1441 | 1453 | if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |
| … |
… |
function wp_get_archives( $args = '' ) { |
| 1456 | 1468 | } |
| 1457 | 1469 | } elseif ( 'weekly' == $r['type'] ) { |
| 1458 | 1470 | $week = _wp_mysql_week( '`post_date`' ); |
| 1459 | | $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; |
| | 1471 | $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit $offset"; |
| 1460 | 1472 | $key = md5( $query ); |
| 1461 | 1473 | $key = "wp_get_archives:$key:$last_changed"; |
| 1462 | 1474 | if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |
| … |
… |
function wp_get_archives( $args = '' ) { |
| 1484 | 1496 | } |
| 1485 | 1497 | } elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) { |
| 1486 | 1498 | $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC '; |
| 1487 | | $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; |
| | 1499 | $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit $offset"; |
| 1488 | 1500 | $key = md5( $query ); |
| 1489 | 1501 | $key = "wp_get_archives:$key:$last_changed"; |
| 1490 | 1502 | if ( ! $results = wp_cache_get( $key, 'posts' ) ) { |