Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+02:00)
We found that this depends upon _generate_element_display_conditions, _generate_element_exclude_conditions, and _generate_hook that should be set as "copy-once."
To have this working with automatic translation and synchronization, we recommend the following steps:
1. **Change Field Settings:**
- Modify the settings of _generate_element_display_conditions, _generate_element_exclude_conditions, and _generate_hook to "copy" instead of "copy-once."
2. **Code Modification:**
- Open the file `wp-content/plugins/gp-premium/elements/class-conditions.php`.
- Locate the `show_data()` function around line 314.
- Replace:
[php]public static function show_data( $conditionals, $exclude, $roles ) {
$current_location = self::get_current_location();
$show = false;
// Show depending on location conditionals.
if ( ! $show ) {
with:
public static function show_data( $conditionals, $exclude, $roles ) {
$current_location = self::get_current_location();
$show = false;
// WPMl Workaround for compsupp-7109
if ( class_exists('Sitepress') ) {
// Conditionals
foreach ((array) $conditionals as $key => $conditional) {
if (isset( $conditional['object'] ) && ! empty( $conditional['object'] && is_numeric($conditional['object']) )) {
// If ID is a post
if (get_post_status( $conditional['object'] ) ) {
$post_type = get_post_type($conditional['object']);
$conditionals[$key]['object'] = apply_filters( 'wpml_object_id', $conditional['object'], $post_type , TRUE );
}
// If ID is a term
elseif (get_term($conditional['object'])) {
// Terms are automatically translated when using get_term;
$term = get_term($conditional['object']);
$conditionals[$key]['object'] = $term->term_id;
}
}
}
// Exclude conditions
foreach ((array) $exclude as $key => $conditional) {
// Same logic for $exclude, it would be better to have a separate function for that, but I want to simplify the workaround steps
if (isset( $conditional['object'] ) && ! empty( $conditional['object'] && is_numeric($conditional['object']) )) {
// If ID is a post
if (get_post_status( $conditional['object'] ) ) {
$post_type = get_post_type($conditional['object']);
$exclude[$key]['object'] = apply_filters( 'wpml_object_id', $conditional['object'], $post_type , TRUE );
}
// If ID is a term
elseif (get_term($conditional['object'])) {
// Terms are automatically translated when using get_term;
$term = get_term($conditional['object']);
$exclude[$key]['object'] = $term->term_id;
}
}
}
}
// Show depending on location conditionals.
if ( ! $show ) {
Some notes about this though:
- This change will allow condition IDs to be automatically translated
- Please note that the ID translations will occur on the front-end only; the back-end settings will remain unchanged (so will say "vi" e.g. on both languages).
- we are unsure whether this will affect other parts of the site
Please report this to GeneratePress authors so they could have a look.