Skip to content

Network & Sites: Introduce a general pre_site_option filter in get_network_option()#10030

Closed
audrasjb wants to merge 3 commits intoWordPress:trunkfrom
audrasjb:56870
Closed

Network & Sites: Introduce a general pre_site_option filter in get_network_option()#10030
audrasjb wants to merge 3 commits intoWordPress:trunkfrom
audrasjb:56870

Conversation

@audrasjb
Copy link
Contributor

@github-actions
Copy link

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 audrasjb.

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

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Comment on lines +2043 to +2044
* Returning a truthy value from the filter will effectively short-circuit retrieval
* and return the passed value instead.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Returning a truthy value from the filter will effectively short-circuit retrieval
* and return the passed value instead.
* Returning a value other than false from the filter will short-circuit retrieval
* and return that value instead.

It's a strict check on false, so some none truthy values (such as an empty array) would still short-circuit retrieval. I think we should use the same langauge as the filter above.

Copy link
Member

Choose a reason for hiding this comment

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

Noting that the pre_option filter also needs to get fixed up for this as well since it too uses truthy.

* from `$default`, which is used as the fallback value in the event
* the option doesn't exist elsewhere in get_network_option().
* Default false (to skip past the short-circuit).
* @param string $option Name of the option.
Copy link
Member

Choose a reason for hiding this comment

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

nit: In pre_site_option_{$option} this is documented as "Option name." I think it would be for these two to be named the same. I prefer this one, so maybe we change the other filter?

* @param mixed $pre The value to return instead of the network option value. This differs
* from `$default`, which is used as the fallback value in the event
* the option doesn't exist elsewhere in get_network_option().
* Default false (to skip past the short-circuit).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Default false (to skip past the short-circuit).
* Default false (to skip past the short-circuit). If this is not false, it was changed by `pre_site_option_{$option}`

I think there is value on being clear about when this wouldn't be false.

@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 60959
GitHub commit: ebe36e8

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Oct 17, 2025
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.

2 participants