Make WordPress Core

Ticket #23272: walker_example.php

File walker_example.php, 641 bytes (added by rodrigosprimo, 14 years ago)

Code used to reproduce the bug

Line 
1<?php
2
3class Walker_Simple_Example extends Walker {
4 var $db_fields = array('parent' => 'parent', 'id' => 'term_id');
5
6 function start_lvl(&$output, $depth=0, $args=array()) {
7 $output .= "\n<ul>\n";
8 }
9
10 function end_lvl(&$output, $depth=0, $args=array()) {
11 $output .= "</ul>\n";
12 }
13
14 function start_el(&$output, $item, $depth=0, $args=array()) {
15 $output .= "<li>".esc_attr($item->name);
16 }
17
18 function end_el(&$output, $item, $depth=0, $args=array()) {
19 $output .= "</li>\n";
20 }
21}
22
23$elements = get_categories();
24$walker = new Walker_Simple_Example;
25echo $walker->walk($elements, 0);