Пример #1
0
    function _show_category($atts)
    {
        extract($atts);
        if (!is_object($cat)) {
            return;
        }
        $checked = '';
        if (is_array($value)) {
            $checked = in_array($cat->cat_ID, $value) ? 'checked="checked" ' : '';
        } else {
            if ($cat->cat_ID == $value) {
                $checked = 'checked="checked" ';
            } else {
                $checked = '';
            }
        }
        $class = '';
        //$class = ' class="frm_selectit"'; //TODO: option to check parent cats
        $sanitized_name = (isset($field['id']) ? $field['id'] : $field['field_options']['taxonomy']) . '-' . $cat->cat_ID;
        ?>
    	<div class="frm_<?php 
        echo $type;
        ?>
" id="frm_<?php 
        echo $type . '_' . $sanitized_name;
        ?>
">
    	    <label<?php 
        echo $class;
        ?>
 for="field_<?php 
        echo $sanitized_name;
        ?>
"><input type="<?php 
        echo $type;
        ?>
" name="<?php 
        echo $field_name;
        ?>
" <?php 
        echo (isset($hide_id) and $hide_id) ? '' : 'id="field_' . $sanitized_name . '"';
        ?>
 value="<?php 
        echo $cat->cat_ID;
        ?>
" <?php 
        echo $checked;
        do_action('frm_field_input_html', $field);
        //echo ($onchange);
        ?>
 /><?php 
        echo $cat->cat_name;
        ?>
</label>
<?php 
        $children = get_categories(array('type' => $post_type, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'exclude' => $exclude, 'parent' => $cat->cat_ID, 'taxonomy' => $taxonomy));
        if ($children) {
            $level++;
            foreach ($children as $key => $cat) {
                ?>
    	<div class="frm_catlevel_<?php 
                echo $level;
                ?>
"><?php 
                FrmProFieldsHelper::_show_category(compact('cat', 'field', 'field_name', 'exclude', 'type', 'value', 'exclude', 'level', 'onchange', 'post_type', 'taxonomy', 'hide_id'));
                ?>
</div>
<?php 
            }
        }
        echo '</div>';
    }