first()['value'] ?? null; }), Setting::classAttribute(), Setting::description(), ]; } public function sanitizeValue($value, array $field) { if (!Collection::make($field['table_list'])->pluck('value')->contains($value)) { return; } return $value; } /** * The stored value, when it is one of the choices. */ public function displayValue($value, array $field, array $args): string { return Display::choice($value, $field); } public function render(array $field, $value): void { $rows = Collection::make($field['table_list']); print('
'); printf('%s', esc_html($this->text($field, 'field_label'))); $rows->map(function ($row) use ($field, $value, $rows) { $checked = checked($row['value'], $value, false); if ($value === false) { $checked = checked($row['value'], $rows->first()['value'], false); } printf( '
', esc_attr($field['field_name']), esc_attr($row['value']), esc_attr($checked), esc_html(Display::choiceLabel($row)) ); }); print(wp_kses_post($this->descriptionHtml($field['description'] ?? ''))); print('
'); } }