Skip to content

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

@saifsultanc saifsultanc merged commit c06034e into master Feb 25, 2025
3 of 4 checks passed
@saifsultanc saifsultanc deleted the malay/fix/77984-fix-php-fatal-error-when-acf-field-return-value-set-as-both branch February 25, 2025 02:21
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.

4 participants