WordPress.org

Make WordPress Core

Changeset 8848


Ignore:
Timestamp:
09/08/2008 06:56:54 PM (11 years ago)
Author:
ryan
Message:

wp_page_menu(). see #7698

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r8847 r8848  
    622622}
    623623
     624/**
     625 * Create menu of pages
     626 *
     627 * @since 2.7.0
     628 *
     629 * @param array|string $args
     630 */
     631function wp_page_menu( $args = array() ) {
     632    $defaults = array('title_li' => '', 'sort_column' => 'menu_order', 'menu_class' => 'menu', 'echo' => false);
     633    $args = wp_parse_args( $args, $defaults );
     634    $args = apply_filters( 'wp_page_menu_args', $args );
     635
     636    $menu = '';
     637
     638    // Show Home in the menu
     639    if ( !empty($args['show_home']) ) {
     640        if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
     641            $text = __('Home');
     642        else
     643            $text = $args['show_home'];
     644        $class = '';
     645        if ( is_home() && !is_paged() )
     646            $class = 'class="current_page_item"';
     647        $menu = '<li ' . $class . '><a href="' . get_option('home') . '">' . $text . '</a></li>';
     648    }
     649
     650    $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($args) );
     651
     652    if ( $menu )
     653        $menu = '<ul>' . $menu . '</ul>';
     654
     655    $menu = '<div id="' . $args['menu_class'] . '">' . $menu . "</div>\n";
     656    echo apply_filters( 'wp_page_menu', $menu );
     657}
     658
    624659//
    625660// Page helpers
Note: See TracChangeset for help on using the changeset viewer.