Making WordPress.org

Changeset 2508


Ignore:
Timestamp:
02/15/2016 10:38:48 PM (9 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Handle migration of menu-ordered handbook page navigation functionality to handbook plugin.

  • Remove wporg_developer_post_nav_via_menu().
  • Use WPorg_Handbook_Navigation::navigate_via_menu() instead.
  • Adjust related styling references.

See #425.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r2437 r2508  
    6565                    <?php previous_post_link( '%link', _x( '<span class="meta-nav">&larr;</span> %title', 'Previous post link', 'wporg' ) ); ?>
    6666                    <?php next_post_link( '%link', _x( '%title <span class="meta-nav">&rarr;</span>', 'Next post link', 'wporg' ) ); ?>
    67 
    68                 </div>
    69                 <!-- .nav-links -->
    70             </nav><!-- .navigation -->
    71         <?php
    72         }
    73     endif;
    74 
    75     if ( ! function_exists( 'wporg_developer_post_nav_via_menu' ) ) :
    76         /**
    77          * Outputs previous and/or next post navigation links using the
    78          * specified menu to inform navigation ordering.
    79          *
    80          * @param  string $menu_name The name of the menu to use for nav ordering.
    81          */
    82         function wporg_developer_post_nav_via_menu( $menu_name ) {
    83             // Get the items for the specified menu
    84             if ( ! $menu_items = wp_get_nav_menu_items( $menu_name ) ) {
    85                 return;
    86             }
    87 
    88             // Get ids for all menu objects
    89             $menu_ids = wp_list_pluck( $menu_items, 'object_id' );
    90 
    91             // Get current post
    92             if ( ! $post = get_post() ) {
    93                 return;
    94             }
    95 
    96             // Index of current post in menu. Return if not in menu.
    97             $i = array_search( $post->ID, $menu_ids );
    98             if ( false === $i ) {
    99                 return;
    100             }
    101 
    102             // Find the previous post (note: preview menu item may not be a post)
    103             $previous = null;
    104             for ( $n = $i-1; $n >= 0; $n-- ) {
    105                 if ( isset( $menu_items[ $n ] ) && is_a( $menu_items[ $n ], 'WP_Post' ) ) {
    106                     $previous = $menu_items[ $n ];
    107                     break;
    108                 }
    109             }
    110 
    111             // Find the next post (note: next menu item may not be a post)
    112             $next = null;
    113             $max = count( $menu_items );
    114             for ( $n = $i+1; $n < $max; $n++ ) {
    115                 if ( isset( $menu_items[ $n ] ) && is_a( $menu_items[ $n ], 'WP_Post' ) ) {
    116                     $next = $menu_items[ $n ];
    117                     break;
    118                 }
    119             }
    120 
    121             if ( ! $previous && ! $next ) {
    122                 return;
    123             }
    124             ?>
    125 
    126             <nav class="navigation post-navigation" role="navigation">
    127                 <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'wporg' ); ?></h1>
    128                 <div class="nav-links">
    129 
    130                 <?php
    131                 if ( $previous ) {
    132                     printf( '<a href="%s" rel="previous"><span class="meta-nav">&larr;</span> %s</a>',
    133                         esc_url( $previous->url ),
    134                         esc_html( $previous->title )
    135                     );
    136                 }
    137 
    138                 if ( $next ) {
    139                     printf( '<a href="%s" rel="next">%s <span class="meta-nav">&rarr;</span></a>',
    140                         esc_url( $next->url ),
    141                         esc_html( $next->title )
    142                     );
    143                 }
    144                 ?>
    14567
    14668                </div>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss

    r2436 r2508  
    13291329    }
    13301330
    1331     nav.post-navigation .nav-links a {
     1331    nav.handbook-navigation .nav-links a {
    13321332        width: 49%;
    13331333        display: inline-block;
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/single-plugin-handbook.php

    r922 r2508  
    1818            <?php get_template_part( 'content', 'handbook'); ?>
    1919
    20             <?php wporg_developer_post_nav_via_menu( 'Plugin Table of Contents' ); ?>
     20            <?php \WPorg_Handbook_Navigation::navigate_via_menu( 'Plugin Table of Contents' ); ?>
    2121
    2222        <?php endwhile; // end of the loop. ?>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/single-theme-handbook.php

    r922 r2508  
    1818            <?php get_template_part( 'content', 'handbook'); ?>
    1919
    20             <?php wporg_developer_post_nav_via_menu( 'Theme Table of Contents' ); ?>
     20            <?php \WPorg_Handbook_Navigation::navigate_via_menu( 'Theme Table of Contents' ); ?>
    2121
    2222        <?php endwhile; // end of the loop. ?>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css

    r2436 r2508  
    14381438  width: 100%;
    14391439}
    1440 .devhub-wrap nav.post-navigation .nav-links a {
     1440.devhub-wrap nav.handbook-navigation .nav-links a {
    14411441  width: 49%;
    14421442  display: inline-block;
    14431443}
    1444 .devhub-wrap nav.post-navigation .nav-links a[rel="prev"] {
     1444.devhub-wrap nav.handbook-navigation .nav-links a[rel="prev"] {
    14451445  text-align: left;
    14461446}
    1447 .devhub-wrap nav.post-navigation .nav-links a[rel="next"] {
     1447.devhub-wrap nav.handbook-navigation .nav-links a[rel="next"] {
    14481448  text-align: right;
    14491449  float: right;
Note: See TracChangeset for help on using the changeset viewer.