Skip to content
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-use-acf-choice-label.php: Fixed PHP fatal error when ACF field set return value as return Both (array). #1023

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

malayladu
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/2846332119/77984

Summary

User is attempting to grab the Label of an ACF field using this snippet: https://gravitywiz.com/snippet-library/gppa-use-acf-choice-label/.

This works as intended when the ACF field's return value is set to label, but their field is set to Both (Array), so the following error is being thrown.

Uncaught Error: str_contains(): Argument #1 ($haystack) must be of type string, array given in /wp-includes/blocks.php on line 1817

This PR fixes this fatal error.

… set return value as return `Both (array)`.
@malayladu malayladu self-assigned this Feb 18, 2025
Copy link
Contributor

@saifsultanc saifsultanc left a comment

Choose a reason for hiding this comment

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

Looks to be working well now! Good job.

I just wonder if we could add some extensibility to the snippet to make it work for "Both" scenarios in "Both" ways as well. Maybe have a different CSS class for this, and then return the both data as label : value.

For now this is good, but just a thought.

Marking approved. Final 👀 from @claygriffiths

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

Successfully merging this pull request may close these issues.

2 participants