Added ACF repeater field support#2774
Conversation
Bundle Size Diff
|
|
Plugin build for f17e161 is ready 🛎️!
|
There was a problem hiding this comment.
Pull request overview
Adds ACF repeater field support to Dynamic Content (text, link, and media/image) by surfacing nested sub-fields in the editor UI and updating server-side evaluation to traverse repeater sub-fields.
Changes:
- Add recursive ACF field option flattening in Dynamic Content editors (value/link) and ACF image selector.
- Flatten ACF fields (including sub-fields) in the Pro data store for easier lookup.
- Extend PHP dynamic content evaluation to resolve repeater sub-field values (including images) and propagate array values through rendering.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pro/plugins/dynamic-content/value-edit.js | Adds recursive ACF <option> rendering intended to expose repeater sub-fields in the value picker. |
| src/pro/plugins/dynamic-content/link-edit.js | Adds recursive ACF <option> rendering intended to expose repeater sub-fields in the link picker. |
| src/pro/plugins/data/index.js | Flattens ACF fields recursively (including sub_fields) into the acfFields lookup map. |
| src/pro/components/acf-image-select/index.js | Reworks ACF image field selection to support nested options and optgroups. |
| plugins/otter-pro/inc/plugins/class-dynamic-content.php | Adds ACF repeater sub-field traversal for text and media evaluation and helper methods for attachment extraction. |
| inc/server/class-dynamic-content-server.php | Adjusts dynamic image REST response handling to accept array paths. |
| inc/plugins/class-dynamic-content.php | Updates core dynamic rendering to propagate array values through content/link/image replacement. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public function apply_data( $data, $magic_tags = false ) { | ||
| $value = $this->get_data( $data, $magic_tags ); | ||
|
|
||
| if ( is_array( $value ) ) { | ||
| $updated_value = array(); | ||
| foreach ( $value as $key => $val ) { | ||
| $_value = $this->apply_formatting( $val, $data ); | ||
|
|
||
| if ( isset( $data['default'] ) && false !== strpos( $data['default'], '<o-dynamic-link' ) ) { | ||
| $link = $this->apply_dynamic_link( $data['default'], $key ); | ||
| if ( ! empty( $link ) ) { | ||
| $_value = preg_replace( '/(<a.*?>).*?(<\/a>)/', '$1' . $_value . '$2', $link ); | ||
| } | ||
| } | ||
|
|
||
| $updated_value[] = $_value; | ||
| } | ||
| return $updated_value; | ||
| } |
There was a problem hiding this comment.
This PR introduces new array-returning behavior (apply_data() can now return string[] and apply_dynamic_content() has special handling for array replacements), but there are no unit tests covering the new repeater/array paths. Since this file already has PHPUnit coverage for dynamic content, please add tests to assert correct output for array values (including multiple placeholders in the same content) to prevent regressions.
E2E TestsPlaywright Test Status: Performance ResultsserverResponse: {"q25":414.2,"q50":419.85,"q75":451.7,"cnt":10}, firstPaint: {"q25":333,"q50":362.65,"q75":386.8,"cnt":10}, domContentLoaded: {"q25":1559.2,"q50":1579.15,"q75":1602.6,"cnt":10}, loaded: {"q25":1559.6,"q50":1579.55,"q75":1603,"cnt":10}, firstContentfulPaint: {"q25":3267.1,"q50":3296.95,"q75":3333.6,"cnt":10}, firstBlock: {"q25":6708.2,"q50":6777.2,"q75":6835.9,"cnt":10}, type: {"q25":13.07,"q50":13.21,"q75":13.51,"cnt":10}, typeWithoutInspector: {"q25":11.82,"q50":12.27,"q75":12.83,"cnt":10}, typeWithTopToolbar: {"q25":15.7,"q50":16.76,"q75":17.82,"cnt":10}, typeContainer: {"q25":7.34,"q50":7.72,"q75":8.67,"cnt":10}, focus: {"q25":52.21,"q50":53.6,"q75":59,"cnt":10}, inserterOpen: {"q25":15.94,"q50":17.47,"q75":19.11,"cnt":10}, inserterSearch: {"q25":5.46,"q50":5.56,"q75":5.92,"cnt":10}, inserterHover: {"q25":2.86,"q50":2.93,"q75":3.26,"cnt":20}, loadPatterns: {"q25":1034.64,"q50":1081.45,"q75":1144.45,"cnt":10}, listViewOpen: {"q25":82.75,"q50":87.11,"q75":97.08,"cnt":10} |
Closes #2236
Summary
Added ACF repeater support to the dynamic content.
Test instructions
Advanced Custom Fieldand select the repeater field from the settings.Checklist before the final review