feat(03-01): add settings sections and fields with German labels
- Three sections: Email, Captcha, Form settings - Email: receiver address field with validation - Captcha: provider dropdown (none/reCAPTCHA v2/v3/hCaptcha) with dynamic key fields - Form: thank you URL field - JavaScript to show/hide captcha keys based on provider selection - All labels and descriptions in German
This commit is contained in:
@@ -93,6 +93,75 @@ class Umzugsliste_Settings {
|
||||
'default' => home_url(),
|
||||
)
|
||||
);
|
||||
|
||||
// Add Email Settings section
|
||||
add_settings_section(
|
||||
'umzugsliste_email_section',
|
||||
'Email-Einstellungen',
|
||||
array( $this, 'render_email_section_description' ),
|
||||
'umzugsliste_settings'
|
||||
);
|
||||
|
||||
// Add receiver email field
|
||||
add_settings_field(
|
||||
'umzugsliste_receiver_email',
|
||||
'Empfänger-E-Mail',
|
||||
array( $this, 'render_receiver_email_field' ),
|
||||
'umzugsliste_settings',
|
||||
'umzugsliste_email_section'
|
||||
);
|
||||
|
||||
// Add Captcha Settings section
|
||||
add_settings_section(
|
||||
'umzugsliste_captcha_section',
|
||||
'Captcha-Einstellungen',
|
||||
array( $this, 'render_captcha_section_description' ),
|
||||
'umzugsliste_settings'
|
||||
);
|
||||
|
||||
// Add captcha provider field
|
||||
add_settings_field(
|
||||
'umzugsliste_captcha_provider',
|
||||
'Captcha-Anbieter',
|
||||
array( $this, 'render_captcha_provider_field' ),
|
||||
'umzugsliste_settings',
|
||||
'umzugsliste_captcha_section'
|
||||
);
|
||||
|
||||
// Add captcha site key field
|
||||
add_settings_field(
|
||||
'umzugsliste_captcha_site_key',
|
||||
'Site Key',
|
||||
array( $this, 'render_captcha_site_key_field' ),
|
||||
'umzugsliste_settings',
|
||||
'umzugsliste_captcha_section'
|
||||
);
|
||||
|
||||
// Add captcha secret key field
|
||||
add_settings_field(
|
||||
'umzugsliste_captcha_secret_key',
|
||||
'Secret Key',
|
||||
array( $this, 'render_captcha_secret_key_field' ),
|
||||
'umzugsliste_settings',
|
||||
'umzugsliste_captcha_section'
|
||||
);
|
||||
|
||||
// Add Form Settings section
|
||||
add_settings_section(
|
||||
'umzugsliste_form_section',
|
||||
'Formular-Einstellungen',
|
||||
array( $this, 'render_form_section_description' ),
|
||||
'umzugsliste_settings'
|
||||
);
|
||||
|
||||
// Add thank you URL field
|
||||
add_settings_field(
|
||||
'umzugsliste_thankyou_url',
|
||||
'Danke-Seite URL',
|
||||
array( $this, 'render_thankyou_url_field' ),
|
||||
'umzugsliste_settings',
|
||||
'umzugsliste_form_section'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,6 +171,95 @@ class Umzugsliste_Settings {
|
||||
return sanitize_text_field( trim( $value ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Email section description
|
||||
*/
|
||||
public function render_email_section_description() {
|
||||
echo '<p>Konfigurieren Sie die E-Mail-Adresse für Formularanfragen.</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Captcha section description
|
||||
*/
|
||||
public function render_captcha_section_description() {
|
||||
echo '<p>Wählen Sie einen Captcha-Anbieter zum Schutz vor Spam.</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Form section description
|
||||
*/
|
||||
public function render_form_section_description() {
|
||||
echo '<p>Konfigurieren Sie das Verhalten des Formulars.</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render receiver email field
|
||||
*/
|
||||
public function render_receiver_email_field() {
|
||||
$value = get_option( 'umzugsliste_receiver_email', '' );
|
||||
?>
|
||||
<input type="email" name="umzugsliste_receiver_email" value="<?php echo esc_attr( $value ); ?>" class="regular-text" required />
|
||||
<p class="description">Die E-Mail-Adresse, an die Formularanfragen gesendet werden.</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render captcha provider field
|
||||
*/
|
||||
public function render_captcha_provider_field() {
|
||||
$value = get_option( 'umzugsliste_captcha_provider', 'none' );
|
||||
?>
|
||||
<select name="umzugsliste_captcha_provider" id="umzugsliste_captcha_provider">
|
||||
<option value="none" <?php selected( $value, 'none' ); ?>>Kein Captcha</option>
|
||||
<option value="recaptcha_v2" <?php selected( $value, 'recaptcha_v2' ); ?>>reCAPTCHA v2</option>
|
||||
<option value="recaptcha_v3" <?php selected( $value, 'recaptcha_v3' ); ?>>reCAPTCHA v3</option>
|
||||
<option value="hcaptcha" <?php selected( $value, 'hcaptcha' ); ?>>hCaptcha</option>
|
||||
</select>
|
||||
<p class="description">Wählen Sie einen Captcha-Dienst oder deaktivieren Sie Captcha.</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render captcha site key field
|
||||
*/
|
||||
public function render_captcha_site_key_field() {
|
||||
$value = get_option( 'umzugsliste_captcha_site_key', '' );
|
||||
$provider = get_option( 'umzugsliste_captcha_provider', 'none' );
|
||||
$display = ( 'none' === $provider ) ? 'none' : 'block';
|
||||
?>
|
||||
<div id="captcha_site_key_wrapper" style="display: <?php echo esc_attr( $display ); ?>;">
|
||||
<input type="text" name="umzugsliste_captcha_site_key" value="<?php echo esc_attr( $value ); ?>" class="regular-text" />
|
||||
<p class="description">Der Site Key von Ihrem Captcha-Anbieter.</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render captcha secret key field
|
||||
*/
|
||||
public function render_captcha_secret_key_field() {
|
||||
$value = get_option( 'umzugsliste_captcha_secret_key', '' );
|
||||
$provider = get_option( 'umzugsliste_captcha_provider', 'none' );
|
||||
$display = ( 'none' === $provider ) ? 'none' : 'block';
|
||||
?>
|
||||
<div id="captcha_secret_key_wrapper" style="display: <?php echo esc_attr( $display ); ?>;">
|
||||
<input type="text" name="umzugsliste_captcha_secret_key" value="<?php echo esc_attr( $value ); ?>" class="regular-text" />
|
||||
<p class="description">Der Secret Key von Ihrem Captcha-Anbieter.</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render thank you URL field
|
||||
*/
|
||||
public function render_thankyou_url_field() {
|
||||
$value = get_option( 'umzugsliste_thankyou_url', home_url() );
|
||||
?>
|
||||
<input type="url" name="umzugsliste_thankyou_url" value="<?php echo esc_attr( $value ); ?>" class="regular-text" />
|
||||
<p class="description">Die URL, zu der nach erfolgreicher Formularübermittlung weitergeleitet wird.</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render settings page
|
||||
*/
|
||||
@@ -122,6 +280,21 @@ class Umzugsliste_Settings {
|
||||
?>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
(function() {
|
||||
const providerSelect = document.getElementById('umzugsliste_captcha_provider');
|
||||
const siteKeyWrapper = document.getElementById('captcha_site_key_wrapper');
|
||||
const secretKeyWrapper = document.getElementById('captcha_secret_key_wrapper');
|
||||
|
||||
function toggleCaptchaFields() {
|
||||
const isNone = providerSelect.value === 'none';
|
||||
siteKeyWrapper.style.display = isNone ? 'none' : 'block';
|
||||
secretKeyWrapper.style.display = isNone ? 'none' : 'block';
|
||||
}
|
||||
|
||||
providerSelect.addEventListener('change', toggleCaptchaFields);
|
||||
})();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user