diff --git a/classes/main.php b/classes/main.php index aabdca6..70df8d7 100644 --- a/classes/main.php +++ b/classes/main.php @@ -81,15 +81,17 @@ public function get_default_value( $value, $post_id, $field ) { return $value; } + $original_post_id = Helpers::original_option_id( $post_id ); + /** * Activate or deactivate the default value (all languages) for the given post id * - * @param bool $show_default : whatever to show default for the given post id - * @param string $post_id : the original post id without lang attributes + * @param bool $show_default : whatever to show default for the given post id + * @param string $original_post_id : the original post id without lang attributes * * @since 1.0.4 */ - if ( ! apply_filters( 'bea.aofp.get_default', true, Helpers::original_option_id( $post_id ) ) ) { + if ( ! apply_filters( 'bea.aofp.get_default', true, $original_post_id ) ) { return $value; } @@ -127,10 +129,8 @@ public function get_default_value( $value, $post_id, $field ) { remove_filter( 'acf/settings/current_language', [ $this, 'set_current_site_lang' ] ); remove_filter( 'acf/load_value', [ $this, 'get_default_value' ] ); - $all_language_post_id = Helpers::original_option_id( $post_id ); - // Get the "All language" value - $value = acf_get_metadata( $all_language_post_id, $field['name'] ); + $value = acf_get_metadata( $original_post_id, $field['name'] ); /** * Re-add deleted filters @@ -158,10 +158,13 @@ function set_options_id_lang( $future_post_id, $original_post_id ) { return $future_post_id; } - $dl = acf_get_setting( 'default_language' ); - $cl = acf_get_setting( 'current_language' ); - if ( $cl && $cl !== $dl ) { - $future_post_id .= '_' . $cl; + // If no custom acf key, no need while already impacted by Polylang locale + if ( 'options' !== Helpers::original_option_id( $future_post_id ) ) { + $dl = acf_get_setting( 'default_language' ); + $cl = acf_get_setting( 'current_language' ); + if ( $cl && $cl !== $dl ) { + $future_post_id .= '_' . $cl; + } } return $future_post_id;