Show Heirachy of categories in WP Download Monitor

From the documentation and its sample code, I cannot see an option to get the downloads categories tree.

The function get_downloads returns a one-dimensional array. Maybe a routine could be built to convert it into a multi-dimensional array.

Use this to see its contents:

$dl = get_downloads();
echo '<pre>' . print_r($dl, true ) . '</pre>';

Another possibility is given by a global variable of the plugin that holds all the categories:

global $download_taxonomies;
echo '<!-- <pre>' . print_r( $download_taxonomies->categories, true ) . '</pre> -->';

And the results are:

Array
(
    [1] => download_category Object
        (
            [id] => 1
            [name] => util
            [parent] => 0
            [decendents] => 
            [direct_decendents] => 
            [size] => 51
        )

    [2] => download_category Object
        (
            [id] => 2
            [name] => sys
            [parent] => 0
            [decendents] => Array
                (
                    [0] => 5
                    [1] => 7
                    [2] => 8
                )

            [direct_decendents] => Array
                (
                    [0] => 5
                    [1] => 7
                )

            [size] => 3
        )

    [5] => download_category Object
        (
            [id] => 5
            [name] => mac
            [parent] => 2
            [decendents] => Array
                (
                    [0] => 8
                )

            [direct_decendents] => Array
                (
                    [0] => 8
                )

            [size] => 4
        )

    [7] => download_category Object
        (
            [id] => 7
            [name] => windows
            [parent] => 2
            [decendents] => 
            [direct_decendents] => 
            [size] => 0
        )

    [8] => download_category Object
        (
            [id] => 8
            [name] => ipad
            [parent] => 5
            [decendents] => 
            [direct_decendents] => 
            [size] => 0
        )

)

Using this array, a logic can be built to iterate through the elements and display the categories hierarchy.

Demonstration with a shortcode. Note that digforcats has to be a null value:

add_shortcode('download_cats', 'wpse_73425_download_categories');

function wpse_73425_download_categories( $atts ) 
{
    global $download_taxonomies;

    foreach( $atts as $key=>$value )
        $query .= '&' . $key . '=' . $value;

    $the_cats="<br><br>Download Categories:";

    foreach( $download_taxonomies->categories as $category )
    {
        if( $category->parent == 0 )
        {
            $the_cats .= '<br><b>' . $category->name . '</b><br>';
            $dl = get_downloads('category='.$category->id.$query.'&digforcats=");

            foreach($dl as $d) 
            {
                $the_cats .= "<br><a href="'
                .$d->url . '" title="Version '
                .$d->version . ' downloaded '
                .$d->hits.' times" >'
                .$d->title.' ('.$d->hits.')</a>';
            }

            if( isset( $category->direct_decendents ) )
            {
                foreach( $category->direct_decendents as $cat )
                {
                    $the_cats .= '<br>- - <i>' 
                    . $download_taxonomies->categories[$cat]->name 
                    . '</i><br>';

                   $dl = get_downloads('category='.$cat.$query.'&digforcats=");

                    foreach($dl as $d) 
                    {
                        $the_cats .= "<br><a href="'
                        .$d->url.'" title="Version '
                        .$d->version . ' downloaded '
                        .$d->hits.' times" >'
                        .$d->title.' ('.$d->hits.')</a>';
                    }
                }
            }
        }
    }
    return $the_cats;
}

Screenshots of the plugin page and the shortcode output:

plugin settings
final result