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

@@ -126,6 +126,15 @@ class Umzugsliste {
}
if ( $use_standalone ) {
// Extract lang from shortcode if present and switch locale before template loads
$post = get_queried_object();
if ( $post && isset( $post->post_content ) && preg_match( '/\[umzugsliste[^\]]*lang=["\'](\w+)["\']/', $post->post_content, $m ) ) {
$locale_map = array( 'de' => 'de_DE', 'en' => 'en_US' );
if ( isset( $locale_map[ $m[1] ] ) && $locale_map[ $m[1] ] !== get_locale() ) {
switch_to_locale( $locale_map[ $m[1] ] );
}
}
$custom_template = UMZUGSLISTE_PLUGIN_DIR . 'templates/form-page.php';
if ( file_exists( $custom_template ) ) {
return $custom_template;