RCCWP_CustomWritePanelPage::PrintNestedCats PHP Method

PrintNestedCats() public static method

public static PrintNestedCats ( $cats, $parent, $depth, $customWritePanelCategoryIds )
    public static function PrintNestedCats($cats, $parent = 0, $depth = 0, $customWritePanelCategoryIds)
    {
        foreach ($cats as $cat) {
            if ($cat->parent == $parent) {
                $checked = "";
                if (@in_array($cat->slug, $customWritePanelCategoryIds)) {
                    $checked = "checked=\"checked\"";
                }
                echo str_repeat(' ', $depth * 4);
                ?>
					<input type="checkbox" name="custom-write-panel-categories[]" value="<?php 
                echo $cat->slug;
                ?>
" <?php 
                echo $checked;
                ?>
 /> <?php 
                echo $cat->cat_name;
                ?>
 <br/>
<?php 
                RCCWP_CustomWritePanelPage::PrintNestedCats($cats, $cat->term_id, $depth + 1, $customWritePanelCategoryIds);
            }
        }
    }

Usage Example

    function PrintNestedCats($cats, $parent = 0, $depth = 0, $customWritePanelCategoryIds)
    {
        foreach ($cats as $cat) {
            if ($cat->parent == $parent) {
                $checked = "";
                if (@in_array($cat->slug, $customWritePanelCategoryIds)) {
                    $checked = "checked=\"checked\"";
                }
                echo str_repeat('&nbsp;', $depth * 4);
                ?>
					<input type="checkbox" name="custom-write-panel-categories[]" value="<?php 
                echo $cat->slug;
                ?>
" <?php 
                echo $checked;
                ?>
 /> <?php 
                echo $cat->cat_name;
                ?>
 <br/>
<?php 
                RCCWP_CustomWritePanelPage::PrintNestedCats($cats, $cat->term_id, $depth + 1, $customWritePanelCategoryIds);
            }
        }
    }