/** * @see Walker::start_el() * * @param string $output Passed by reference. Used to append additional content. * @param object $object Item data object. * @param int $depth Depth of item. * @param int $current_object_id Item ID. * @param array $args */ public function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0) { $label = $this->db_fields['label']; $id = $this->db_fields['id']; $meta = $this->meta; $field = $this->field; $field_class = SWP_Meta_Box::get_class_name($field); $attributes = call_user_func(array($field_class, 'get_attributes'), $field, $object->{$id}); $output .= sprintf('<li><label><input %s %s>%s</label>', SWPMB_Field::render_attributes($attributes), checked(in_array($object->{$id}, $meta), 1, false), $object->{$label}); }
function display_level($options, $parent_id = 0, $active = false) { $id = $this->db_fields['id']; $field = $this->field; $meta = $this->meta; $walker = new SWPMB_Select_Walker($this->db_fields, $this->field, $this->meta); $field_class = SWP_Meta_Box::get_class_name($field); $attributes = call_user_func(array($field_class, 'get_attributes'), $field, $meta); $children = $options[$parent_id]; $output = sprintf('<div class="swpmb-select-tree %s" data-parent-id="%s"><select %s>', $active ? '' : 'hidden', $parent_id, SWPMB_Field::render_attributes($attributes)); $output .= isset($field['placeholder']) ? "<option value=''>{$field['placeholder']}</option>" : '<option></option>'; $output .= $walker->walk($children, -1); $output .= '</select>'; foreach ($children as $c) { if (isset($options[$c->{$id}])) { $output .= $this->display_level($options, $c->{$id}, in_array($c->{$id}, $meta) && $active); } } $output .= '</div>'; return $output; }