get_settings(); $form_fields = $settings_manager->get_settings_form_fields(); // Handle form submission if (isset($_POST['submit']) && isset($_POST['aitm_settings_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['aitm_settings_nonce'])), 'aitm_save_settings')) { $new_settings = array(); foreach ($form_fields as $section_key => $section) { foreach ($section['fields'] as $field_key => $field) { if (isset($_POST[$field_key])) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized below based on type $value = wp_unslash($_POST[$field_key]); $new_settings[$field_key] = is_array($value) ? array_map('sanitize_text_field', $value) : sanitize_text_field($value); } } } $result = $settings_manager->update_settings($new_settings); if ($result) { echo '

' . esc_html__('Settings saved successfully.', 'ai-thumbnails-maker') . '

'; $settings = $settings_manager->get_settings(); // Refresh settings } else { echo '

' . esc_html__('Failed to save settings.', 'ai-thumbnails-maker') . '

'; } } ?>

$section) : ?>

$field) : ?>
> >

%
reset_settings(); if ($result) { echo '

' . esc_html__('Settings have been reset to defaults.', 'ai-thumbnails-maker') . '

'; $settings = $settings_manager->get_settings(); // Refresh settings } else { echo '

' . esc_html__('Failed to reset settings.', 'ai-thumbnails-maker') . '

'; } } ?>