Changeset 16100
- Timestamp:
- 10/30/2010 02:06:08 PM (14 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/category-template.php
r15855 r16100 744 744 } 745 745 746 /** 747 * Create HTML list of categories. 748 * 749 * @package WordPress 750 * @since 2.1.0 751 * @uses Walker 752 */ 753 class Walker_Category extends Walker { 754 /** 755 * @see Walker::$tree_type 756 * @since 2.1.0 757 * @var string 758 */ 759 var $tree_type = 'category'; 760 761 /** 762 * @see Walker::$db_fields 763 * @since 2.1.0 764 * @todo Decouple this 765 * @var array 766 */ 767 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); 768 769 /** 770 * @see Walker::start_lvl() 771 * @since 2.1.0 772 * 773 * @param string $output Passed by reference. Used to append additional content. 774 * @param int $depth Depth of category. Used for tab indentation. 775 * @param array $args Will only append content if style argument value is 'list'. 776 */ 777 function start_lvl(&$output, $depth, $args) { 778 if ( 'list' != $args['style'] ) 779 return; 780 781 $indent = str_repeat("\t", $depth); 782 $output .= "$indent<ul class='children'>\n"; 783 } 784 785 /** 786 * @see Walker::end_lvl() 787 * @since 2.1.0 788 * 789 * @param string $output Passed by reference. Used to append additional content. 790 * @param int $depth Depth of category. Used for tab indentation. 791 * @param array $args Will only append content if style argument value is 'list'. 792 */ 793 function end_lvl(&$output, $depth, $args) { 794 if ( 'list' != $args['style'] ) 795 return; 796 797 $indent = str_repeat("\t", $depth); 798 $output .= "$indent</ul>\n"; 799 } 800 801 /** 802 * @see Walker::start_el() 803 * @since 2.1.0 804 * 805 * @param string $output Passed by reference. Used to append additional content. 806 * @param object $category Category data object. 807 * @param int $depth Depth of category in reference to parents. 808 * @param array $args 809 */ 810 function start_el(&$output, $category, $depth, $args) { 811 extract($args); 812 813 $cat_name = esc_attr( $category->name ); 814 $cat_name = apply_filters( 'list_cats', $cat_name, $category ); 815 $link = '<a href="' . esc_attr( get_term_link($category) ) . '" '; 816 if ( $use_desc_for_title == 0 || empty($category->description) ) 817 $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"'; 818 else 819 $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"'; 820 $link .= '>'; 821 $link .= $cat_name . '</a>'; 822 823 if ( !empty($feed_image) || !empty($feed) ) { 824 $link .= ' '; 825 826 if ( empty($feed_image) ) 827 $link .= '('; 828 829 $link .= '<a href="' . get_term_feed_link( $category->term_id, $category->taxonomy, $feed_type ) . '"'; 830 831 if ( empty($feed) ) { 832 $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"'; 833 } else { 834 $title = ' title="' . $feed . '"'; 835 $alt = ' alt="' . $feed . '"'; 836 $name = $feed; 837 $link .= $title; 838 } 839 840 $link .= '>'; 841 842 if ( empty($feed_image) ) 843 $link .= $name; 844 else 845 $link .= "<img src='$feed_image'$alt$title" . ' />'; 846 847 $link .= '</a>'; 848 849 if ( empty($feed_image) ) 850 $link .= ')'; 851 } 852 853 if ( !empty($show_count) ) 854 $link .= ' (' . intval($category->count) . ')'; 855 856 if ( !empty($show_date) ) 857 $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp); 858 859 if ( 'list' == $args['style'] ) { 860 $output .= "\t<li"; 861 $class = 'cat-item cat-item-' . $category->term_id; 862 if ( !empty($current_category) ) { 863 $_current_category = get_term( $current_category, $category->taxonomy ); 864 if ( $category->term_id == $current_category ) 865 $class .= ' current-cat'; 866 elseif ( $category->term_id == $_current_category->parent ) 867 $class .= ' current-cat-parent'; 868 } 869 $output .= ' class="' . $class . '"'; 870 $output .= ">$link\n"; 871 } else { 872 $output .= "\t$link<br />\n"; 873 } 874 } 875 876 /** 877 * @see Walker::end_el() 878 * @since 2.1.0 879 * 880 * @param string $output Passed by reference. Used to append additional content. 881 * @param object $page Not used. 882 * @param int $depth Depth of category. Not used. 883 * @param array $args Only uses 'list' for whether should append to output. 884 */ 885 function end_el(&$output, $page, $depth, $args) { 886 if ( 'list' != $args['style'] ) 887 return; 888 889 $output .= "</li>\n"; 890 } 891 892 } 893 894 /** 895 * Create HTML dropdown list of Categories. 896 * 897 * @package WordPress 898 * @since 2.1.0 899 * @uses Walker 900 */ 901 class Walker_CategoryDropdown extends Walker { 902 /** 903 * @see Walker::$tree_type 904 * @since 2.1.0 905 * @var string 906 */ 907 var $tree_type = 'category'; 908 909 /** 910 * @see Walker::$db_fields 911 * @since 2.1.0 912 * @todo Decouple this 913 * @var array 914 */ 915 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); 916 917 /** 918 * @see Walker::start_el() 919 * @since 2.1.0 920 * 921 * @param string $output Passed by reference. Used to append additional content. 922 * @param object $category Category data object. 923 * @param int $depth Depth of category. Used for padding. 924 * @param array $args Uses 'selected', 'show_count', and 'show_last_update' keys, if they exist. 925 */ 926 function start_el(&$output, $category, $depth, $args) { 927 $pad = str_repeat(' ', $depth * 3); 928 929 $cat_name = apply_filters('list_cats', $category->name, $category); 930 $output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\""; 931 if ( $category->term_id == $args['selected'] ) 932 $output .= ' selected="selected"'; 933 $output .= '>'; 934 $output .= $pad.$cat_name; 935 if ( $args['show_count'] ) 936 $output .= ' ('. $category->count .')'; 937 if ( $args['show_last_update'] ) { 938 $format = 'Y-m-d'; 939 $output .= ' ' . gmdate($format, $category->last_update_timestamp); 940 } 941 $output .= "</option>\n"; 942 } 943 } 944 746 945 // 747 946 // Tags -
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.