Twenty Fifteen: Use new core navigation tags.

Props obenland, iamtakashi, fixes #30189



Built from https://develop.svn.wordpress.org/trunk@30216


git-svn-id: http://core.svn.wordpress.org/trunk@30216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ian Stewart 2014-11-03 21:40:23 +00:00
parent fe241e3fdc
commit 6be421fb37
9 changed files with 45 additions and 110 deletions

View File

@ -100,7 +100,11 @@ get_header(); ?>
<?php endwhile; ?>
<?php twentyfifteen_paging_nav(); ?>
<?php
the_pagination( array(
'before_page_number' => '<span class="meta-nav">' . __( 'Page', 'twentyfifteen' ) . '</span>',
) );
?>
<?php else : ?>

View File

@ -260,12 +260,20 @@ function twentyfifteen_post_nav_background() {
if ( $previous && has_post_thumbnail( $previous->ID ) ) {
$prevthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), 'post-thumbnail' );
$css .= '.post-navigation .nav-previous { background-image: url(' . esc_url( $prevthumb[0] ) . '); }';
$css .= '
.post-navigation .nav-previous { background-image: url(' . esc_url( $prevthumb[0] ) . '); }
.post-navigation .nav-previous .post-title, .post-navigation .nav-previous .meta-nav { color: #fff; }
.post-navigation .nav-previous a:before { background-color: rgba(0, 0, 0, 0.4); }
';
}
if ( $next && has_post_thumbnail( $next->ID ) ) {
$nextthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), 'post-thumbnail' );
$css .= '.post-navigation .nav-next { background-image: url(' . esc_url( $nextthumb[0] ) . '); }';
$css .= '
.post-navigation .nav-next { background-image: url(' . esc_url( $nextthumb[0] ) . '); }
.post-navigation .nav-next .post-title, .post-navigation .nav-next .meta-nav { color: #fff; }
.post-navigation .nav-next a:before { background-color: rgba(0, 0, 0, 0.4); }
';
}
wp_add_inline_style( 'twentyfifteen-style', $css );

View File

@ -70,7 +70,11 @@ get_header(); ?>
endif;
?>
<?php twentyfifteen_post_nav(); ?>
<?php
the_post_navigation( array(
'prev_text' => _x( '<span class="meta-nav">Published in</span><span class="post-title">%title</span>', 'Parent post link', 'twentyfifteen' ),
) );
?>
<?php endwhile; // end of the loop. ?>

View File

@ -9,84 +9,6 @@
* @since Twenty Fifteen 1.0
*/
if ( ! function_exists( 'twentyfifteen_paging_nav' ) ) :
/**
* Display navigation to next/previous set of posts when applicable.
*
* @since Twenty Fifteen 1.0
* @uses paginate_links()
*
* @global WP_Query $wp_query WordPress Query object.
*/
function twentyfifteen_paging_nav() {
// Don't print empty markup if there's only one page.
if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
return;
}
// Set up paginated links.
$links = paginate_links( array(
'prev_text' => esc_html__( 'Previous', 'twentyfifteen' ),
'next_text' => esc_html__( 'Next', 'twentyfifteen' ),
'before_page_number' => '<span class="meta-nav">' . esc_html__( 'Page', 'twentyfifteen' ) . '</span>',
) );
if ( $links ) :
?>
<nav class="navigation pagination" role="navigation">
<h2 class="screen-reader-text"><?php esc_html_e( 'Posts navigation', 'twentyfifteen' ); ?></h2>
<div class="nav-links">
<?php echo $links; ?>
</div><!-- .nav-links -->
</nav><!-- .pagination -->
<?php
endif;
}
endif;
if ( ! function_exists( 'twentyfifteen_post_nav' ) ) :
/**
* Display navigation to next/previous post when applicable.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_post_nav() {
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ( ! $next && ! $previous ) || ( is_attachment() && 'attachment' == $previous->post_type ) ) {
return;
}
$prev_class = $next_class = '';
if ( $previous && has_post_thumbnail( $previous->ID ) ) {
$prev_class = ' has-post-thumbnail';
}
if ( $next && has_post_thumbnail( $next->ID ) ) {
$next_class = ' has-post-thumbnail';
}
?>
<nav class="navigation post-navigation" role="navigation">
<h2 class="screen-reader-text"><?php esc_html_e( 'Post navigation', 'twentyfifteen' ); ?></h2>
<div class="nav-links">
<?php
if ( is_attachment() ) :
previous_post_link( '<div class="nav-previous' . $prev_class . '">%link</div>', _x( '<span class="meta-nav">Published In</span><span class="post-title">%title</span>', 'Parent post link', 'twentyfifteen' ) );
else :
previous_post_link( '<div class="nav-previous' . $prev_class . '">%link</div>', _x( '<span class="meta-nav">Previous</span><span class="post-title">%title</span>', 'Previous post link', 'twentyfifteen' ) );
next_post_link( '<div class="nav-next' . $next_class . '">%link</div>', _x( '<span class="meta-nav">Next</span><span class="post-title">%title</span>', 'Next post link', 'twentyfifteen' ) );
endif;
?>
</div><!-- .nav-links -->
</nav><!-- .post-navigation -->
<?php
}
endif;
if ( ! function_exists( 'twentyfifteen_comment_nav' ) ) :
/**
* Display navigation to next/previous comments when applicable.

View File

@ -40,7 +40,11 @@ get_header(); ?>
<?php endwhile; ?>
<?php twentyfifteen_paging_nav(); ?>
<?php
the_pagination( array(
'before_page_number' => '<span class="meta-nav">' . __( 'Page', 'twentyfifteen' ) . '</span>',
) );
?>
<?php else : ?>

View File

@ -32,7 +32,11 @@ get_header(); ?>
<?php endwhile; ?>
<?php twentyfifteen_paging_nav(); ?>
<?php
the_pagination( array(
'before_page_number' => '<span class="meta-nav">' . __( 'Page', 'twentyfifteen' ) . '</span>',
) );
?>
<?php else : ?>

View File

@ -23,7 +23,12 @@ get_header(); ?>
endif;
?>
<?php twentyfifteen_post_nav(); ?>
<?php
the_post_navigation( array(
'next_text' => _x( '<span class="meta-nav">Previous</span><span class="post-title">%title</span>', 'Previous post link', 'twentyfifteen' ),
'prev_text' => _x( '<span class="meta-nav">Next</span><span class="post-title">%title</span>', 'Next post link', 'twentyfifteen' ),
) );
?>
<?php endwhile; // end of the loop. ?>

View File

@ -981,20 +981,14 @@ a:focus {
z-index: 2;
}
.post-navigation a:hover .post-title,
.post-navigation a:focus .post-title {
color: #707070;
color: rgba(51, 51, 51, 0.7);
}
.post-navigation .has-post-thumbnail {
.post-navigation .nav-next,
.post-navigation .nav-previous {
background-position: center;
background-size: cover;
position: relative;
}
.post-navigation .has-post-thumbnail a:before {
background-color: rgba(0, 0, 0, 0.4);
.post-navigation a:before {
content: "";
display: block;
height: 100%;
@ -1005,26 +999,16 @@ a:focus {
z-index: 1;
}
.post-navigation .has-post-thumbnail a:hover:before,
.post-navigation .has-post-thumbnail a:focus:before {
background-color: rgba(0, 0, 0, 0.2);
.post-navigation a:hover:before,
.post-navigation a:focus:before {
opacity: 0.5;
}
.post-navigation .has-post-thumbnail a:hover .post-title,
.post-navigation .has-post-thumbnail a:focus .post-title {
color: #fff;
}
.post-navigation .has-post-thumbnail .post-title,
.post-navigation .has-post-thumbnail .meta-nav {
color: #fff;
}
.post-navigation .has-post-thumbnail .meta-nav {
.post-navigation .meta-nav {
opacity: 0.8;
}
.post-navigation .nav-previous:not(.has-post-thumbnail) + .nav-next:not(.has-post-thumbnail) {
.post-navigation .nav-previous + .nav-next {
border-top: 1px solid #eaeaea;
border-top: 1px solid rgba(51, 51, 51, 0.1);
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-alpha-30215';
$wp_version = '4.1-alpha-30216';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.