Ticket #13998: 13998.patch
File 13998.patch, 5.3 KB (added by , 11 years ago) |
---|
-
wp-includes/post-template.php
867 867 } 868 868 869 869 /** 870 * Display or retrieve list of pages withoptional home link.870 * Displays or returns a menu with all pages and an optional home link. 871 871 * 872 * The arguments are listed below and part of the arguments are for {@link 873 * wp_list_pages()} function. Check that function for more info on those 874 * arguments. 872 * Optional $args contents: 875 873 * 876 * <ul> 877 * <li><strong>sort_column</strong> - How to sort the list of pages. Defaults 878 * to 'menu_order, post_title'. Use column for posts table.</li> 879 * <li><strong>menu_class</strong> - Class to use for the div ID which contains 880 * the page list. Defaults to 'menu'.</li> 881 * <li><strong>echo</strong> - Whether to echo list or return it. Defaults to 882 * echo.</li> 883 * <li><strong>link_before</strong> - Text before show_home argument text.</li> 884 * <li><strong>link_after</strong> - Text after show_home argument text.</li> 885 * <li><strong>show_home</strong> - If you set this argument, then it will 886 * display the link to the home page. The show_home argument really just needs 887 * to be set to the value of the text of the link.</li> 888 * </ul> 874 * sort_column - How to sort the list of pages. Defaults to 'menu_order, post_title'. See {@link get_pages()} function for arguments. 875 * menu_class - CSS class to use for the div which contains the menu. Defaults to 'menu'. 876 * ul_class - CSS class to use for the ul element which forms the menu. Defaults to blank. 877 * echo - Whether to echo the menu or return it. Defaults to echo. 878 * link_before - Text before the link. 879 * link_after - Text after the link. 880 * show_home - Whether to display a link to the homepage as first menu element. Pass 'true' to use the default link text of 'Home' or pass your own text to use. 889 881 * 890 882 * @since 2.7.0 891 883 * 892 884 * @param array|string $args 893 * @return string html menu885 * @return string HTML content, if not displaying. 894 886 */ 895 887 function wp_page_menu( $args = array() ) { 896 $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 888 $defaults = array( 889 'sort_column' => 'menu_order, post_title', 890 'menu_class' => 'menu', 891 'ul_class' => '', 892 'echo' => true, 893 'link_before' => '', 894 'link_after' => '', 895 ); 897 896 $args = wp_parse_args( $args, $defaults ); 898 897 $args = apply_filters( 'wp_page_menu_args', $args ); 899 898 … … 902 901 $list_args = $args; 903 902 904 903 // Show Home in the menu 905 if ( ! empty( $args['show_home']) ) {904 if ( ! empty( $args['show_home'] ) ) { 906 905 if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) 907 $text = __( 'Home');906 $text = __( 'Home' ); 908 907 else 909 908 $text = $args['show_home']; 910 909 $class = ''; 911 if ( is_front_page() && ! is_paged() )910 if ( is_front_page() && ! is_paged() ) 912 911 $class = 'class="current_page_item"'; 913 $menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '" title="' . esc_attr( $text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';912 $menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '" title="' . esc_attr( $text ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>'; 914 913 // If the front page is a page, add it to the exclude list 915 if ( get_option('show_on_front') == 'page') {916 if ( ! empty( $list_args['exclude'] ) ) {914 if ( 'page' == get_option( 'show_on_front' ) ) { 915 if ( ! empty( $list_args['exclude'] ) ) { 917 916 $list_args['exclude'] .= ','; 918 917 } else { 919 918 $list_args['exclude'] = ''; 920 919 } 921 $list_args['exclude'] .= get_option( 'page_on_front');920 $list_args['exclude'] .= get_option( 'page_on_front' ); 922 921 } 923 922 } 924 923 925 924 $list_args['echo'] = false; 926 925 $list_args['title_li'] = ''; 927 $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages( $list_args) );926 $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages( $list_args ) ); 928 927 929 if ( $menu ) 930 $menu = '<ul>' . $menu . '</ul>'; 928 if ( $menu ) { 929 $ul_class = $args['ul_class'] ? ' class="' . esc_attr( $args['ul_class'] ) . '"' : ''; 930 $menu = '<ul'. $ul_class . '>' . $menu . '</ul>'; 931 } 931 932 932 $menu = '<div class="' . esc_attr( $args['menu_class']) . '">' . $menu . "</div>\n";933 $menu = '<div class="' . esc_attr( $args['menu_class'] ) . '">' . $menu . "</div>\n"; 933 934 $menu = apply_filters( 'wp_page_menu', $menu, $args ); 935 934 936 if ( $args['echo'] ) 935 937 echo $menu; 936 938 else -
wp-includes/nav-menu-template.php
186 186 * - Otherwise, bail. 187 187 */ 188 188 if ( ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) && !$args->theme_location ) ) 189 && $args->fallback_cb && is_callable( $args->fallback_cb ) ) 190 return call_user_func( $args->fallback_cb, (array) $args ); 189 && $args->fallback_cb && is_callable( $args->fallback_cb ) ) { 190 if ( $args->menu_class ) 191 $args->ul_class = $args->menu_class; 191 192 193 return call_user_func( $args->fallback_cb, (array) $args ); 194 } 195 192 196 if ( ! $menu || is_wp_error( $menu ) ) 193 197 return false; 194 198