Make WordPress Core

Ticket #8703: 8703.2.diff

File 8703.2.diff, 4.2 KB (added by sivel, 15 years ago)
  • wp-includes/link-template.php

     
    973973}
    974974
    975975/**
     976 * Display adjacent post relational link.
     977 *
     978 * Can either be next or previous post relational link.
     979 *
     980 * @since 2.8.0
     981 *
     982 * @param string $title Optional. Link title format.
     983 * @param bool $in_same_cat Optional. Whether link should be in same category.
     984 * @param string $excluded_categories Optional. Excluded categories IDs.
     985 * @param bool $previous Optional, default is true. Whether display link to previous post.
     986 */
     987function adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) {
     988        if ( $previous && is_attachment() )
     989                $post = & get_post($GLOBALS['post']->post_parent);
     990        else
     991                $post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);
     992
     993        if ( !$post )
     994                return;
     995
     996        if ( empty($post->post_title) )
     997                $post->post_title = $previous ? __('Previous Post') : __('Next Post');
     998
     999        $date = mysql2date(get_option('date_format'), $post->post_date);
     1000
     1001        $title = str_replace('%title', $post->post_title, $title);
     1002        $title = str_replace('%date', $date, $title);
     1003
     1004        $title = apply_filters('the_title', $title, $post);
     1005       
     1006        $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
     1007        $link .= $title;
     1008        $link .= "' href='" . get_permalink($post) . "' />\n";
     1009
     1010        $adjacent = $previous ? 'previous' : 'next';
     1011        echo apply_filters( "{$adjacent}_post_rel_link", $link );
     1012}
     1013
     1014/**
     1015 * Display relational links for the posts adjacent to the current post.
     1016 *
     1017 * @since 2.8.0
     1018 *
     1019 * @param string $title Optional. Link title format.
     1020 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1021 * @param string $excluded_categories Optional. Excluded categories IDs.
     1022 */
     1023function adjacent_posts_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
     1024        adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true);
     1025        adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false);
     1026}
     1027
     1028/**
     1029 * Display relational link for the next post adjacent to the current post.
     1030 *
     1031 * @since 2.8.0
     1032 *
     1033 * @param string $title Optional. Link title format.
     1034 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1035 * @param string $excluded_categories Optional. Excluded categories IDs.
     1036 */
     1037function next_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
     1038        adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false);
     1039}
     1040
     1041/**
     1042 * Display relational link for the previous post adjacent to the current post.
     1043 *
     1044 * @since 2.8.0
     1045 *
     1046 * @param string $title Optional. Link title format.
     1047 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1048 * @param string $excluded_categories Optional. Excluded categories IDs.
     1049 */
     1050function prev_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
     1051        adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true);
     1052}
     1053
     1054/**
    9761055 * Retrieve get links for page numbers.
    9771056 *
    9781057 * @since 1.5.0
  • wp-content/themes/classic/header.php

     
    1717        </style>
    1818
    1919        <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
     20        <?php if ( is_single() ) adjacent_posts_rel_link(); ?>
    2021        <?php wp_get_archives('type=monthly&format=link'); ?>
    2122        <?php //comments_popup_script(); // off by default ?>
    2223        <?php wp_head(); ?>
  • wp-content/themes/default/header.php

     
    1414
    1515<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    1616<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
     17<?php if ( is_single() ) adjacent_posts_rel_link(); ?>
    1718
    1819<style type="text/css" media="screen">
    1920