pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

Repeatable fields and WPML #7342

Open jefferyto opened 2 months ago

jefferyto commented 2 months ago

Description

On a site using WPML, I added a custom post type with a repeatable Plain Text field. After creating a post (of the CPT) with several values for the (repeatable) Plain Text field, and translating the post and field values, the translated post will have only one (translated) value for the Plain Text field.

After looking at the post meta / custom fields for the custom post type, it appears that the Pods repeatable field sets multiple post meta fields with the same key. (The translated post ends up with only one value for the key.) I tried manually setting custom fields (multiple values with a different key) and all of the (translated) values appear in the translated post, so it does not appear to be an issue with WPML.

At some point the "Watch WP Metadata calls" setting was enabled (I believe because I added a Relationship field to a custom post type). After disabling this setting this issue no longer exists, i.e. it appears that the post meta hook(s) that Pods is adding is somehow causing WPML to see only one field value and not all of the multiple values of the repeatable field.

Version

3.2.6 (WPML 4.6.13)

Testing Instructions

  1. Enable "Watch WP Metadata calls" in Pods settings
  2. Create a new Pod for a custom post type with a repeatable Plain Text field
  3. Add a template in the active theme for the new custom post type, showing the repeatable field values
  4. Add a post for the new custom post type, setting multiple values for the repeatable field (e.g. "A", "B", "C")
  5. Translate the post to a different language using WPML (all three repeatable field values should be translatable in the Advanced Translation Editor)
  6. View the translated post in the front end

The three translated field values should be shown; instead only one is displayed.

Screenshots / Screencast

No response

Possible Workaround

Disable the "Watch WP Metadata calls" setting

Site Health Information

(some client-identifying information removed)

### wp-core ###

version: 6.6.1
site_language: en_US
user_language: en_US
timezone: +08:00
permalink: /%postname%/
https_status: true
multisite: true
user_registration: false
blog_public: 0
default_comment_status: undefined
environment_type: staging
site_id: 2
site_count: 3
network_count: 1
user_count: 3
dotorg_communication: true

### wp-dropins (1) ###

db.php: true

### wp-active-theme ###

name: [custom theme]
version: 1.0.0
author: Yarn Labs Limited
author_website: https://yarn-labs.com/
parent_theme: none
theme_features: core-block-patterns, widgets-block-editor, title-tag, html5, responsive-embeds, align-wide, custom-logo, editor-color-palette, editor-font-sizes, editor-styles, editor-style, menus, post-thumbnails
theme_path: [theme path]
auto_update: Disabled

### wp-themes-inactive (3) ###

Twenty Twenty-Four: version: 1.2, author: the WordPress team, Auto-updates disabled
Twenty Twenty-Three: version: 1.5, author: the WordPress team, Auto-updates disabled
Twenty Twenty-Two: version: 1.8, author: the WordPress team, Auto-updates disabled

### wp-plugins-active (10) ###

Category Order and Taxonomy Terms Order: version: 1.8.2, author: Nsp-Code, Auto-updates disabled
Lazy Blocks: version: 3.7.0, author: Lazy Blocks Team, Auto-updates disabled
Pods - Custom Content Types and Fields: version: 3.2.6, author: Pods Framework Team, Auto-updates disabled
Post Types Order: version: 2.2.6, author: Nsp Code, Auto-updates disabled
Query Monitor: version: 3.16.4, author: John Blackbourn, Auto-updates disabled
Regenerate Thumbnails: version: 3.1.6, author: Alex Mills (Viper007Bond), Auto-updates disabled
SVG Support: version: 2.5.8, author: Benbodhi, Auto-updates disabled
WPML Multilingual CMS: version: 4.6.13, author: OnTheGoSystems, Auto-updates disabled
WPML String Translation: version: 3.2.14, author: OnTheGoSystems, Auto-updates disabled
Yoast Duplicate Post: version: 4.5, author: Enrico Battocchi & Team Yoast, Auto-updates disabled

### wp-plugins-inactive (3) ###

Akismet Anti-spam: Spam Protection: version: 5.3.3, author: Automattic - Anti-spam Team, Auto-updates disabled
Hello Dolly: version: 1.7.2, author: Matt Mullenweg, Auto-updates disabled
OTGS Installer: version: 3.1.3, author: OnTheGoSystems, Auto-updates disabled

### wp-media ###

image_editor: WP_Image_Editor_GD
imagick_module_version: Not available
imagemagick_version: Not available
imagick_version: Not available
file_uploads: 1
post_max_size: 8M
upload_max_filesize: 2M
max_effective_size: 2 MB
max_file_uploads: 20
gd_version: 2.3.0
gd_formats: GIF, JPEG, PNG, WebP, BMP, XPM
ghostscript_version: not available

### wp-server ###

server_architecture: Linux 5.15.0-118-generic x86_64
httpd_software: Apache
php_version: 8.1.2-1ubuntu2.18 64bit
php_sapi: fpm-fcgi
max_input_variables: 1000
time_limit: 30
memory_limit: 128M
admin_memory_limit: 256M
max_input_time: 60
upload_max_filesize: 2M
php_post_max_size: 8M
curl_version: 7.81.0 OpenSSL/3.0.2
suhosin: false
imagick_availability: false
pretty_permalinks: true
htaccess_extra_rules: true
current: 2024-08-24T09:47:09+00:00
utc-time: Saturday, 24-Aug-24 09:47:09 UTC
server-time: 2024-08-24T17:47:08+08:00

### wp-database ###

extension: mysqli
server_version: 10.6.18-MariaDB-0ubuntu0.22.04.1
client_version: mysqlnd 8.1.2-1ubuntu2.18
max_allowed_packet: 16777216
max_connections: 151

### wp-constants ###

WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: [wp-content path]
WP_PLUGIN_DIR: [wp-content/plugins path]
WP_MEMORY_LIMIT: 64M
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG: false
WP_DEBUG_DISPLAY: true
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: staging
WP_DEVELOPMENT_MODE: undefined
DB_CHARSET: utf8mb4
DB_COLLATE: undefined

### wp-filesystem ###

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
fonts: not writable

### pods ###

pods-version: 3.2.6
pods-first-version: 3.0.10
pods-last-version: 3.2.1.1
pods-server-software: Apache
pods-user-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0
pods-session-save-path: /var/lib/php/sessions
pods-session-save-path-exists: Yes
pods-session-save-path-writable: Yes
pods-session-max-lifetime: 1440
pods-opcode-cache-apc: No
pods-opcode-cache-memcached: No
pods-opcode-cache-opcache: Yes
pods-opcode-cache-redis: No
pods-object-cache-apc: No
pods-object-cache-apcu: Yes
pods-object-cache-memcache: No
pods-object-cache-memcached: No
pods-object-cache-redis: No
pods-memory-current-usage: 15.144M / 64M
pods-memory-current-usage-real: 20.000M
pods-network-wide: Yes
pods-install-location: /wp-content/plugins/pods/
pods-developer: No
pods-tableless-mode: No
pods-relationship-table-enabled: Yes
pods-relationship-table-status: 28
pods-light-mode: No
pods-strict: No
pods-allow-deprecated: Yes
pods-api-cache: Yes
pods-shortcode-allow-evaluate-tags: No
pods-can-use-sessions: Yes
pods-settings-types_only: Enable [types_only=0]
pods-settings-watch_changed_fields: Disable [watch_changed_fields=0]
pods-settings-metadata_integration: Disable [metadata_integration=0]
pods-settings-metadata_override_get: Disable [metadata_override_get=0]
pods-settings-register_meta_integration: Disable [register_meta_integration=0]
pods-settings-media_modal_fields: Enable [media_modal_fields=0]
pods-settings-session_auto_start: Disable [session_auto_start=0]
pods-settings-dynamic_features_allow: Enable [dynamic_features_allow=1]
pods-settings-dynamic_features_enabled: Display and Form [dynamic_features_enabled=display,form]
pods-settings-show_access_restricted_messages: Disable [show_access_restricted_messages=0]
pods-settings-show_access_admin_notices: Enable [show_access_admin_notices=1]
pods-settings-dynamic_features_allow_sql_clauses: Restricted [dynamic_features_allow_sql_clauses=simple]
pods-settings-display_callbacks: Restricted [display_callbacks=restricted]
pods-settings-display_callbacks_allowed: esc_attr,esc_html

Pods Package

I have multiple Pods active and affected by this issue, this is one of the simpler ones (with the "partners" field):

{
    "@meta": {
        "version": "3.2.6",
        "build": 1724493125
    },
    "settings": {
        "types_only": "0",
        "watch_changed_fields": "0",
        "metadata_integration": "0",
        "metadata_override_get": "0",
        "media_modal_fields": "0",
        "session_auto_start": "0",
        "wisdom_opt_out": "1",
        "register_meta_integration": "0",
        "dynamic_features_allow": "1",
        "dynamic_features_enabled": [
            "display",
            "form"
        ],
        "show_access_restricted_messages": "0",
        "show_access_admin_notices": "1",
        "dynamic_features_allow_sql_clauses": "simple",
        "display_callbacks": "restricted",
        "display_callbacks_allowed": "esc_attr,esc_html",
        "active_components": [
            "migrate-packages",
            "templates"
        ]
    },
    "pods": [
        {
            "name": "partnership",
            "id": 223,
            "label": "Partnerships",
            "description": "",
            "type": "post_type",
            "storage": "meta",
            "label_singular": "Partnership",
            "public": "1",
            "show_ui": "1",
            "rest_enable": "1",
            "supports_title": "1",
            "supports_editor": "1",
            "_migrated_28": "1",
            "meta_box_context": "normal",
            "meta_box_priority": "default",
            "pick_object": "custom-simple",
            "required": "0",
            "show_in_menu": "1",
            "menu_position": "0",
            "show_in_nav_menus": "1",
            "show_in_admin_bar": "1",
            "menu_icon": "dashicons-groups",
            "publicly_queryable": "1",
            "exclude_from_search": "0",
            "capability_type": "post",
            "capability_type_extra": "1",
            "disable_create_posts": "0",
            "has_archive": "1",
            "hierarchical": "0",
            "can_export": "1",
            "rewrite": "1",
            "rewrite_with_front": "1",
            "rewrite_feeds": "1",
            "rewrite_pages": "1",
            "query_var": "1",
            "default_status": "draft",
            "supports_thumbnail": "1",
            "supports_revisions": "1",
            "supports_quick_edit": "1",
            "revisions_to_keep_limit": "0",
            "delete_with_user": "1",
            "supports_excerpt": "1",
            "groups": [
                {
                    "name": "partnership_details",
                    "id": 224,
                    "label": "Partnership Details",
                    "description": "",
                    "weight": 0,
                    "meta_box_context": "normal",
                    "meta_box_priority": "default",
                    "roles_allowed": "administrator",
                    "fields": [
                        {
                            "name": "partners",
                            "id": 225,
                            "label": "Partners",
                            "description": "",
                            "weight": 0,
                            "type": "text",
                            "sister_id": "-- Select One --",
                            "required": "0",
                            "text_allowed_html_tags": "strong em a ul ol li b i",
                            "text_max_length": "255",
                            "repeatable": "1",
                            "repeatable_format": "ul",
                            "roles_allowed": "administrator",
                            "enable_conditional_logic": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "1"
                        },
                        {
                            "name": "related_partnerships",
                            "id": 744,
                            "label": "Related Partnerships",
                            "description": "",
                            "weight": 1,
                            "type": "pick",
                            "pick_object": "post_type",
                            "pick_val": "partnership",
                            "sister_id": "-- Select One --",
                            "pick_table": "-- Select One --",
                            "required": "0",
                            "pick_format_type": "multi",
                            "pick_format_single": "dropdown",
                            "pick_format_multi": "list",
                            "pick_display_format_multi": "ul",
                            "pick_display_format_separator": ", ",
                            "pick_allow_add_new": "1",
                            "pick_taggable": "0",
                            "pick_show_icon": "1",
                            "pick_show_edit_link": "1",
                            "pick_show_view_link": "1",
                            "pick_limit": "4",
                            "pick_user_role": "Administrator",
                            "pick_post_status": "publish",
                            "pick_post_author": "0",
                            "repeatable": "0",
                            "repeatable_format": "default",
                            "roles_allowed": "administrator",
                            "enable_conditional_logic": "0",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "1"
                        }
                    ]
                }
            ]
        }
    ]
}