I need to integrate this plugin with my WordPress site, and the categories must be in this format:
"Option 1": {"Suboption":200},
"Option 2": {"Suboption 2": {"Subsub 1":201, "Subsub 2":202},
"Suboption 3": {"Subsub 3":203, "Subsub 4":204, "Subsub 5":205}
}
How can I get that?
I tried the options of the json-api.
And this is the walker:
class MyWalker extends Walker_Category {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
function start_lvl( &$output, $depth, $args = array() ) {
if ( 'list' != $args['style'] )
return;
$indent = str_repeat("\t", $depth);
$output .= "$indent:{";
}
function end_lvl( &$output, $depth, $args = array() ) {
if ( 'list' != $args['style'] )
return;
$indent = str_repeat("\t", $depth);
$output .= "$indent}\n";
}
function start_el($output, $category, $depth , $args = array() ) {
extract($args);
$cat_name = esc_attr( $category->name );
$cat_name = apply_filters( 'list_cats', $cat_name, $category );
$output .= '"' . $cat_name.'=>'.$depth . '",';
}
function end_el($output, $page, $depth = 0, $args = array() ) {
if ( 'list' != $args['style'] )
return;
$output .= "\n";
}
}
json_encode? – brasofilo Jan 17 at 0:15Walker_Category... I think, in general sense, every line of code isdynamic, so once again: check the PHP Manual. – brasofilo Jan 17 at 1:01