/** * Render a repeatable group */ public static function render_group($args) { if (!isset($args['id'], $args['fields']) || !is_array($args['fields'])) { return; } $args['count'] = 0; $field_group = new cmb_Meta_Box_field($args); $desc = $field_group->args('description'); $label = $field_group->args('name'); $sortable = $field_group->options('sortable') ? ' sortable' : ''; $group_val = (array) $field_group->value(); $nrows = count($group_val); $remove_disabled = $nrows <= 1 ? 'disabled="disabled" ' : ''; echo '<tr><td colspan="2"><table id="', $field_group->id(), '_repeat" class="repeatable-group' . $sortable . '" style="width:100%;">'; if ($desc || $label) { echo '<tr><th>'; if ($label) { echo '<h2 class="cmb-group-name">' . $label . '</h2>'; } if ($desc) { echo '<p class="cmb_metabox_description">' . $desc . '</p>'; } echo '</th></tr>'; } if (!empty($group_val)) { foreach ($group_val as $iterator => $field_id) { self::render_group_row($field_group, $remove_disabled); } } else { self::render_group_row($field_group, $remove_disabled); } echo '<tr><td><p class="add-row"><button data-selector="', $field_group->id(), '_repeat" data-grouptitle="', $field_group->options('group_title'), '" class="add-group-row button">' . $field_group->options('add_button') . '</button></p></td></tr>'; echo '</table></td></tr>'; }