Ticket #20167: post-template.wp_pages_checklist.diff
File post-template.wp_pages_checklist.diff, 2.4 KB (added by , 13 years ago) |
---|
-
post-template.php
759 759 // 760 760 // Pages 761 761 // 762 function wp_pages_checklist($args = '') { 763 $defaults = array( 764 'depth' => 0, 'child_of' => 0, 765 'selected' => 0, 'echo' => 1, 766 'name' => 'page_id', 'id' => '' 767 ); 762 768 769 $r = wp_parse_args( $args, $defaults ); 770 extract( $r, EXTR_SKIP ); 771 772 $pages = get_pages($r); 773 774 // Back-compat with old system where both id and name were based on $name argument 775 if ( empty($id) ) 776 $id = $name; 777 778 if ( ! empty($pages) ) { 779 $output = walk_page_checklist_tree($pages, $depth, $r); 780 } 781 782 if ( $echo ) 783 echo $output; 784 785 return $output; 786 } 787 763 788 /** 764 789 * Retrieve or display list of pages as a dropdown (select list). 765 790 * … … 969 994 } 970 995 971 996 /** 997 * Retrieve HTML checklist of pages for page list. 998 * 999 * @uses Walker_Page_Checklist to create checklist of pages. 1000 * @since 1001 */ 1002 function walk_page_checklist_tree() { 1003 $args = func_get_args(); 1004 if ( empty($args[2]['walker']) ) // the user's options are the third parameter 1005 $walker = new Walker_Page_Checklist; 1006 else 1007 $walker = $args[2]['walker']; 1008 1009 return call_user_func_array(array(&$walker, 'walk'), $args); 1010 } 1011 1012 /** 972 1013 * Create HTML list of pages. 973 1014 * 974 1015 * @package WordPress … … 1119 1160 } 1120 1161 } 1121 1162 1163 /** 1164 * Creates a checklist of pages. 1165 * 1166 * @package WordPress 1167 * @since 1168 * @uses Walker 1169 */ 1170 class Walker_Page_Checklist extends Walker { 1171 1172 var $tree_type = 'page'; 1173 1174 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); 1175 1176 function start_lvl( &$output, $depth = 0, $args = array() ) { 1177 $indent = str_repeat("\t", $depth); 1178 $output .= "$indent<ul class='children'>\n"; 1179 } 1180 function end_lvl( &$output, $depth = 0, $args = array() ) { 1181 $indent = str_repeat("\t", $depth); 1182 $output .= "$indent</ul>\n"; 1183 } 1184 1185 function start_el(&$output, $page, $depth, $args, $id = 0) { 1186 1187 $output .= "\t<li class=\"level-$depth\"><label class=\"selectit\"><input type=\"checkbox\" value=\"$page->ID\""; 1188 if ( $page->ID == $args['selected'] ) 1189 $output .= ' checked="checked"'; 1190 $output .= '>'; 1191 $title = apply_filters( 'list_pages', $page->post_title, $page ); 1192 $output .= esc_html( $title ); 1193 } 1194 function end_el( &$output, $category, $depth = 0, $args = array() ) { 1195 $output .= "</label></li>\n"; 1196 } 1197 } 1198 1122 1199 // 1123 1200 // Attachments 1124 1201 //