-
Notifications
You must be signed in to change notification settings - Fork 92
gppa-use-choice-value-instead-of-label.php: Added new snippet.
#1057
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
Conversation
WalkthroughThis change modifies a PHP file in the Gravity Forms Populate Anything integration for WordPress. It introduces a WordPress action hook alteration that removes two filters— Changes
Sequence Diagram(s)sequenceDiagram
participant Admin as "Admin User"
participant WP as "WordPress Core"
participant GF as "Gravity Forms Plugin"
participant Hook as "gp_populate_anything()"
Admin->>WP: Request Entry List/Detail View
WP->>GF: Invoke Populate Anything process
GF->>Hook: Trigger gp_populate_anything() hook
Note right of Hook: Filters removed:<br>gform_entry_field_value, gform_entries_field_value
Hook-->>GF: Return unmodified choice value
GF-->>WP: Provide entry data with choice values
WP-->>Admin: Render view using choice values
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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 (
|
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: 0
🧹 Nitpick comments (2)
gp-populate-anything/gppa-use-choice-value-instead-of-label.php (2)
9-12: Add dependency check for more robust implementation.The code works as intended, but it assumes that
gp_populate_anything()will always be available when theadmin_inithook fires. To make this snippet more robust, consider adding a check to verify that the function exists before attempting to use it.- add_action('admin_init', function() { + add_action('admin_init', function() { + if (!function_exists('gp_populate_anything') || !is_callable(array(gp_populate_anything(), 'entry_field_value'))) { + return; + } + remove_filter( 'gform_entry_field_value', array( gp_populate_anything(), 'entry_field_value' ), 20 ); remove_filter( 'gform_entries_field_value', array( gp_populate_anything(), 'entries_field_value' ), 20 ); });
9-9: Consider using a later priority for more reliable execution.Since this code depends on the Gravity Forms Populate Anything plugin being loaded, you might want to use a later priority for the
admin_inithook to ensure the plugin is fully initialized before attempting to remove its filters.- add_action('admin_init', function() { + add_action('admin_init', function() {This isn't necessary if you're not experiencing any issues, but it's a good practice for plugin-dependent code.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
gp-populate-anything/gppa-use-choice-value-instead-of-label.php(1 hunks)
🔇 Additional comments (1)
gp-populate-anything/gppa-use-choice-value-instead-of-label.php (1)
1-12: Implementation correctly achieves the stated goal.The implementation effectively reverts to showing choice values instead of labels in the admin interface by removing the appropriate filters from Gravity Forms Populate Anything. This approach is clean and targeted.
Context
📓 Notion: https://www.notion.so/gravitywiz/Doc-Update-GPPA-How-to-display-choice-values-instead-of-labels-when-viewing-an-entry-1af00ab68edf819d9673d7c674855483?pvs=4
Summary
This snippet shows field values rather than labels on GPPA enabled fields when viewing an entry in the backend.