Skip to content

Added ACF repeater field support#2774

Open
girishpanchal30 wants to merge 3 commits intodevelopmentfrom
feat/2236
Open

Added ACF repeater field support#2774
girishpanchal30 wants to merge 3 commits intodevelopmentfrom
feat/2236

Conversation

@girishpanchal30
Copy link
Copy Markdown
Contributor

Closes #2236

Summary

Added ACF repeater support to the dynamic content.

Test instructions

  • Add ACF PRO plugin and create a repeater field.
  • Add dynamic content field in post or page.
  • select the Advanced Custom Field and select the repeater field from the settings.
  • Verify the content in frontend.
  • Verify the dynamic content with the buttons group, icons, and image block.

Checklist before the final review

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.
  • PR is following the best practices

@girishpanchal30 girishpanchal30 requested a review from Copilot April 15, 2026 13:13
@girishpanchal30 girishpanchal30 added the pr-checklist-skip Allow this Pull Request to skip checklist. label Apr 15, 2026
@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Apr 15, 2026
@pirate-bot
Copy link
Copy Markdown
Contributor

pirate-bot commented Apr 15, 2026

Bundle Size Diff

Package Old Size New Size Diff
Animations 276.77 KB 276.77 KB 0 B (0.00%)
Blocks 1.55 MB 1.55 MB 0 B (0.00%)
CSS 105.9 KB 105.9 KB 0 B (0.00%)
Dashboard 204.08 KB 204.08 KB 0 B (0.00%)
Onboarding 165.94 KB 165.94 KB 0 B (0.00%)
Export Import 102.86 KB 102.86 KB 0 B (0.00%)
Pro 412.55 KB 412.87 KB 320 B (0.08%)

@pirate-bot
Copy link
Copy Markdown
Contributor

pirate-bot commented Apr 15, 2026

Plugin build for f17e161 is ready 🛎️!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread inc/plugins/class-dynamic-content.php Outdated
Comment on lines 323 to +341
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;
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread plugins/otter-pro/inc/plugins/class-dynamic-content.php Outdated
Comment thread src/pro/plugins/dynamic-content/value-edit.js Outdated
Comment thread src/pro/plugins/dynamic-content/link-edit.js Outdated
Comment thread inc/plugins/class-dynamic-content.php Outdated
Comment thread src/pro/components/acf-image-select/index.js Outdated
Comment thread src/pro/plugins/dynamic-content/value-edit.js Outdated
Comment thread plugins/otter-pro/inc/plugins/class-dynamic-content.php Outdated
Comment thread inc/server/class-dynamic-content-server.php Outdated
@pirate-bot
Copy link
Copy Markdown
Contributor

pirate-bot commented Apr 15, 2026

E2E Tests

Playwright Test Status:

Performance Results serverResponse: {"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}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for the ACF Repeater

3 participants