WordPress.org

Making WordPress.org

Changeset 5913


Ignore:
Timestamp:
09/12/17 16:49:49 (2 months ago)
Author:
coffee2code
Message:

developer.wordpress.org: Remove duplicated handbook home link from breadcrumb for handbook home page.

  • Adds breadcrumb_trail_items_for_handbook_root()
  • Renames breadcrumb_trail_items() to breadcrumb_trail_items_for_hooks()
File:
1 edited

Legend:

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

    r5820 r5913  
    117117    add_theme_support( 'post-thumbnails' ); 
    118118 
    119     add_filter( 'breadcrumb_trail_items',  __NAMESPACE__ . '\\breadcrumb_trail_items', 10, 2 ); 
     119    // Modify default breadcrumbs. 
     120    add_filter( 'breadcrumb_trail_items',  __NAMESPACE__ . '\\breadcrumb_trail_items_for_hooks', 10, 2 ); 
     121    add_filter( 'breadcrumb_trail_items',  __NAMESPACE__ . '\\breadcrumb_trail_items_for_handbook_root', 10, 2 ); 
    120122 
    121123    add_filter( 'wp_parser_skip_duplicate_hooks', '__return_true' ); 
     
    143145 * 
    144146 * @param  array $items The breadcrumb trail items 
    145  * @param  array $args  Original arg 
     147 * @param  array $args  Original args 
    146148 * @return array 
    147149 */ 
    148 function breadcrumb_trail_items( $items, $args ) { 
     150function breadcrumb_trail_items_for_hooks( $items, $args ) { 
    149151    $post_type = 'wp-parser-hook'; 
    150152 
     
    162164    // Unset the last element since it shifted up in trail hierarchy 
    163165    unset( $items[4] ); 
     166 
     167    return $items; 
     168} 
     169 
     170/** 
     171 * Fix breadcrumb for handbook root pages. 
     172 * 
     173 * The handbook root/landing pages do not need a duplicated breadcrumb trail 
     174 * item that simply links to the currently loaded page. The trailing breadcrumb 
     175 * item is already the unlinked handbook name, which is sufficient. 
     176 * 
     177 * @param  array $items The breadcrumb trail items 
     178 * @param  array $args  Original args 
     179 * @return array 
     180 */ 
     181function breadcrumb_trail_items_for_handbook_root( $items, $args ) { 
     182    // Bail early if not a handbook landing page. 
     183    if ( ! function_exists( 'wporg_is_handbook_landing_page' ) || ! wporg_is_handbook_landing_page() ) { 
     184        return $items; 
     185    } 
     186 
     187    // Unset link to current handbook. 
     188    unset( $items[1] ); 
    164189 
    165190    return $items; 
Note: See TracChangeset for help on using the changeset viewer.