fix: step navigation back-click bug and add shortcode lang attribute

Track highestStep so navigating backward preserves completed dots and
allows clicking forward to any previously visited step. Add [umzugsliste
lang="de|en"] shortcode attribute that switches locale via
switch_to_locale() for per-page language control.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-07 22:54:55 +09:00
parent 39f94a6b2e
commit b9ae7d707d
3 changed files with 34 additions and 8 deletions

View File

@@ -51,11 +51,26 @@ class Umzugsliste_Shortcode {
* @return string Form HTML
*/
public function render_form( $atts ) {
// Ensure assets are enqueued
$this->enqueue_assets();
$atts = shortcode_atts( array( 'lang' => '' ), $atts, 'umzugsliste' );
$switched = false;
// Render the form
return Umzugsliste_Form_Renderer::render();
if ( ! empty( $atts['lang'] ) ) {
$locale_map = array( 'de' => 'de_DE', 'en' => 'en_US' );
$locale = isset( $locale_map[ $atts['lang'] ] ) ? $locale_map[ $atts['lang'] ] : '';
if ( $locale && $locale !== get_locale() ) {
switch_to_locale( $locale );
$switched = true;
}
}
$this->enqueue_assets();
$html = Umzugsliste_Form_Renderer::render();
if ( $switched ) {
restore_previous_locale();
}
return $html;
}
/**