-
Notifications
You must be signed in to change notification settings - Fork 92
gppa-acf-repeater-mapper.php: Added Image Choice field support in acf repeater mapper.
#1079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gppa-acf-repeater-mapper.php: Added Image Choice field support in acf repeater mapper.
#1079
Conversation
|
""" WalkthroughThe update refactors the logic for constructing choice arrays related to ACF repeater rows. Instead of handling separate label and value variables, the code now builds a unified associative array for each choice, containing keys for text, value, and optionally image and attachment ID. The change introduces support for an image field, resolving image URLs to attachment IDs when present. It also improves the handling of fallback values by adding checks to prevent undefined index errors. No changes are made to public APIs or exported function signatures. Changes
Suggested reviewers
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
4484c25 to
62c15bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
gp-populate-anything/gppa-acf-repeater-mapper.php (1)
70-98: Consider adding a unit test for the Image Choice functionality.While the implementation looks solid, it would be beneficial to add test coverage for this new functionality to ensure it works properly with various image formats and edge cases.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
gp-populate-anything/gppa-acf-repeater-mapper.php(1 hunks)
🔇 Additional comments (3)
gp-populate-anything/gppa-acf-repeater-mapper.php (3)
70-76: Clean refactoring of choice construction logic.The refactoring from separate variables to a unified
$choiceassociative array with 'text' and 'value' keys improves code consistency and readability. Theisset()checks also improve robustness by preventing potential undefined index errors.
78-87: Well-implemented Image Choice field support.Good addition of image support with proper handling of:
- Retrieving the image URL from mapped or custom fields
- Converting the URL to an attachment ID (required by Image Choice fields)
- Adding clear comments explaining the purpose
The implementation follows the same pattern as other field types, maintaining code consistency.
93-95: Consistent handling of price field.The price handling has been updated to match the same pattern used for other fields, maintaining code consistency throughout the snippet. The
isset()check for fallback values prevents potential undefined index errors.
saifsultanc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just that one safety check as suggested by coderabbit please. Thanks!
… GPPA acf repeater mapper.
62c15bc to
bb1bb14
Compare
saifsultanc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S&M
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/2904943955/82068
Summary
This PR added support for
Image Choicefield in GPPA ACF Repeater Mapper snippet.Before
After