/**
* Change the pattern_post_id on front end to be able to get different language versions of patterns
*/
public function multilingual_pattern_post_id() {
// The problem is only front end
if ( is_admin() ) {
return;
}
// Append current language to post id
$dl = acf_get_setting( 'default_language' );
$cl = acf_get_setting( 'current_language' );
// Add Language
if ( $cl && $cl !== $dl ) {
$this->pattern_post_id .= '_' . $cl;
}
}
2) Cleanest but needs to be tested furthermore (Konrad's recommandations) :
Describe the bug The Site Template id in default language is
pip_pattern
and let's say translated in english ispip_pattern_en_GB
The id retrieved is always the default language.
To Reproduce Multilangual website, logged out
Expected behavior To get the values from the translated version of the Site Template
Slack conversation about it: https://pilodev.slack.com/archives/D9G2V3MGA/p1649682470683449
Fixes 1) Works right away but is not the cleanest :
Before this line in the constructor : https://github.com/Pilot-in/PiloPress/blob/068f8d1734d460d861de4a071e3efd6b8dbedbef/includes/classes/pattern/class-pattern.php#L34
add_action( 'init', array( $this, 'multilingual_pattern_post_id' ) );
2) Cleanest but needs to be tested furthermore (Konrad's recommandations) :
Change
init
foracf/init
here : https://github.com/Pilot-in/PiloPress/blob/master/includes/classes/pattern/class-pattern.php#L34And for both
https://github.com/Pilot-in/PiloPress/blob/master/includes/classes/pattern/class-flexible-header.php#L268 and https://github.com/Pilot-in/PiloPress/blob/master/includes/classes/pattern/class-flexible-header.php#L268
stocking the
$pip_pattern->pattern_post_id
in a var and applyacf_get_valid_post_id()
to it