close
Skip to content

Commit ba1861e

Browse files
refactor: switch nav labels while preserving DOM order
1 parent 7eab0e3 commit ba1861e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

‎src/wp-content/themes/twentyeleven/functions.php‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,11 +647,29 @@ function twentyeleven_content_nav( $html_id ) {
647647

648648
$new_posts_text = __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' );
649649
$old_posts_text = __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' );
650+
651+
$prev_link = $is_desc ? get_next_posts_link( $old_posts_text ) : get_previous_posts_link( $old_posts_text );
652+
$next_link = $is_desc ? get_previous_posts_link( $new_posts_text ) : get_next_posts_link( $new_posts_text );
653+
654+
$allowed_html_tags = array(
655+
'a' => array(
656+
'href' => array(),
657+
'title' => array(),
658+
),
659+
'span' => array(
660+
'class' => array(),
661+
),
662+
)
650663
?>
651664
<nav id="<?php echo esc_attr( $html_id ); ?>">
652665
<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
653-
<div class="<?php echo esc_attr( $is_desc ? 'nav-previous' : 'nav-next' ); ?>"><?php next_posts_link( $is_desc ? $old_posts_text : $new_posts_text ); ?></div>
654-
<div class="<?php echo esc_attr( $is_desc ? 'nav-next' : 'nav-previous' ); ?>"><?php previous_posts_link( $is_desc ? $new_posts_text : $old_posts_text ); ?></div>
666+
<?php if ( $prev_link ) : ?>
667+
<div class="nav-previous"><?php echo wp_kses( $prev_link, $allowed_html_tags ); ?></div>
668+
<?php endif; ?>
669+
670+
<?php if ( $next_link ) : ?>
671+
<div class="nav-next"><?php echo wp_kses( $next_link, $allowed_html_tags ); ?></div>
672+
<?php endif; ?>
655673
</nav><!-- #nav-above -->
656674
<?php
657675
endif;

0 commit comments

Comments
 (0)