Changeset 16100 for trunk/wp-includes/post-template.php
- Timestamp:
- 10/30/2010 02:06:08 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post-template.php
r16066 r16100 922 922 } 923 923 924 /** 925 * Create HTML list of pages. 926 * 927 * @package WordPress 928 * @since 2.1.0 929 * @uses Walker 930 */ 931 class Walker_Page extends Walker { 932 /** 933 * @see Walker::$tree_type 934 * @since 2.1.0 935 * @var string 936 */ 937 var $tree_type = 'page'; 938 939 /** 940 * @see Walker::$db_fields 941 * @since 2.1.0 942 * @todo Decouple this. 943 * @var array 944 */ 945 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); 946 947 /** 948 * @see Walker::start_lvl() 949 * @since 2.1.0 950 * 951 * @param string $output Passed by reference. Used to append additional content. 952 * @param int $depth Depth of page. Used for padding. 953 */ 954 function start_lvl(&$output, $depth) { 955 $indent = str_repeat("\t", $depth); 956 $output .= "\n$indent<ul class='children'>\n"; 957 } 958 959 /** 960 * @see Walker::end_lvl() 961 * @since 2.1.0 962 * 963 * @param string $output Passed by reference. Used to append additional content. 964 * @param int $depth Depth of page. Used for padding. 965 */ 966 function end_lvl(&$output, $depth) { 967 $indent = str_repeat("\t", $depth); 968 $output .= "$indent</ul>\n"; 969 } 970 971 /** 972 * @see Walker::start_el() 973 * @since 2.1.0 974 * 975 * @param string $output Passed by reference. Used to append additional content. 976 * @param object $page Page data object. 977 * @param int $depth Depth of page. Used for padding. 978 * @param int $current_page Page ID. 979 * @param array $args 980 */ 981 function start_el(&$output, $page, $depth, $args, $current_page) { 982 if ( $depth ) 983 $indent = str_repeat("\t", $depth); 984 else 985 $indent = ''; 986 987 extract($args, EXTR_SKIP); 988 $css_class = array('page_item', 'page-item-'.$page->ID); 989 if ( !empty($current_page) ) { 990 $_current_page = get_page( $current_page ); 991 if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) ) 992 $css_class[] = 'current_page_ancestor'; 993 if ( $page->ID == $current_page ) 994 $css_class[] = 'current_page_item'; 995 elseif ( $_current_page && $page->ID == $_current_page->post_parent ) 996 $css_class[] = 'current_page_parent'; 997 } elseif ( $page->ID == get_option('page_for_posts') ) { 998 $css_class[] = 'current_page_parent'; 999 } 1000 1001 $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page)); 1002 1003 $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '" title="' . esc_attr( wp_strip_all_tags( apply_filters( 'the_title', $page->post_title, $page->ID ) ) ) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>'; 1004 1005 if ( !empty($show_date) ) { 1006 if ( 'modified' == $show_date ) 1007 $time = $page->post_modified; 1008 else 1009 $time = $page->post_date; 1010 1011 $output .= " " . mysql2date($date_format, $time); 1012 } 1013 } 1014 1015 /** 1016 * @see Walker::end_el() 1017 * @since 2.1.0 1018 * 1019 * @param string $output Passed by reference. Used to append additional content. 1020 * @param object $page Page data object. Not used. 1021 * @param int $depth Depth of page. Not Used. 1022 */ 1023 function end_el(&$output, $page, $depth) { 1024 $output .= "</li>\n"; 1025 } 1026 1027 } 1028 1029 /** 1030 * Create HTML dropdown list of pages. 1031 * 1032 * @package WordPress 1033 * @since 2.1.0 1034 * @uses Walker 1035 */ 1036 class Walker_PageDropdown extends Walker { 1037 /** 1038 * @see Walker::$tree_type 1039 * @since 2.1.0 1040 * @var string 1041 */ 1042 var $tree_type = 'page'; 1043 1044 /** 1045 * @see Walker::$db_fields 1046 * @since 2.1.0 1047 * @todo Decouple this 1048 * @var array 1049 */ 1050 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); 1051 1052 /** 1053 * @see Walker::start_el() 1054 * @since 2.1.0 1055 * 1056 * @param string $output Passed by reference. Used to append additional content. 1057 * @param object $page Page data object. 1058 * @param int $depth Depth of page in reference to parent pages. Used for padding. 1059 * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element. 1060 */ 1061 function start_el(&$output, $page, $depth, $args) { 1062 $pad = str_repeat(' ', $depth * 3); 1063 1064 $output .= "\t<option class=\"level-$depth\" value=\"$page->ID\""; 1065 if ( $page->ID == $args['selected'] ) 1066 $output .= ' selected="selected"'; 1067 $output .= '>'; 1068 $title = esc_html($page->post_title); 1069 $output .= "$pad$title"; 1070 $output .= "</option>\n"; 1071 } 1072 } 1073 924 1074 // 925 1075 // Attachments
Note: See TracChangeset
for help on using the changeset viewer.