function get_cat_check($categories_list = "", $parent_id = 0, $i = 0, $cat_id) {
$categories = get_terms( [
'taxonomy' => 'category',
"hide_empty" => 0, // Скрывать пустые. 1 - да, 0 - нет.
"hierarchical" => 1,
"parent" => $parent_id
] );
$catid = $this->strToArray( $cat_id );
var_dump($catid);
if ( count( $categories ) != null ) {
if ( $parent_id == 0 ) {
$categories_list .= '<ul class="main_categories_list">';
$i = 0;
} else {
$i ++;
$categories_list .= '<ul class="sub_categories_list sub_categories_list_' . $i . '" style="padding: 2px 20px">';
}
foreach ( $categories as $categories_item ) {
if ( !in_array( $categories_item->term_id, $catid ) ) {
var_dump($categories_item->term_id);
$categories_list .= '<li style="margin: 0" >
<label> <input type="checkbox" name="bulk_category[]" value="' . $categories_item->term_id . '" />' . $categories_item->name . '</label>';
} else {
$categories_list .= '<li style="margin: 0" >
<label> <input type="checkbox" name="bulk_category[]" checked value="' . $categories_item->term_id . '" />' . $categories_item->name . '</label>';
}
$categories_list .= $this->get_categories( "", $categories_item->term_id, $i, $catid );
$categories_list .= '</li>';
}
}
$categories_list .= '</ul>';
return $categories_list;
}