Skip to content

Return null from wp_get_global_settings() and wp_get_global_styles() for missing paths - #13752

Open
devansh016 wants to merge 3 commits into
WordPress:trunkfrom
devansh016:fix/66183-global-settings-missing-path
Open

devansh016 wants to merge 3 commits into
WordPress:trunkfrom
devansh016:fix/66183-global-settings-missing-path

Conversation

@devansh016

Copy link
Copy Markdown

When a $path is passed to wp_get_global_settings() or wp_get_global_styles() and that path does not exist, both functions return the entire settings/styles array. This happens because the full array is passed as the fallback to _wp_array_get(). Callers cannot tell "not set" apart from "all settings"

This PR:

  • Returns null from both functions when the requested path does not exist. An empty $path still returns everything, as before.
  • Updates block_core_image_get_lightbox_settings() in the Image block. It relied on the old behaviour to fall back to the top-level lightbox setting, and now also falls back when the block-level lookup returns null. It works under both the old and new behaviour. A matching change is needed in Gutenberg (packages/block-library/src/image/index.php), since that file is synced from there.
  • Adds unit tests for existing, missing (top-level and nested), and empty paths, for a missing block, and for the Image lightbox fallback.

Other core callers that pass a path (button.php, block-supports/states.php, block-supports/block-visibility.php, and the wp_get_global_styles( array( 'color' ) ) call in image.php) already handle null.

Trac ticket: https://core.trac.wordpress.org/ticket/66183

Use of AI Tools

AI assistance: Yes
Tool(s): Claude
Model(s): Opus 5.5
Used for: Initial code skeleton and test suggestions; final implementation and tests were reviewed and edited by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props devansh2002.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant