Opened 10 years ago
Closed 10 years ago
#37413 closed enhancement (invalid)
Use `get_site()` instead of global `$current_blog`
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.6 |
| Component: | Networks and Sites | Keywords: | needs-patch |
| Focuses: | multisite | Cc: |
Description
get_site() falls back to the current site if no parameter is provided. That means we can use it anywhere we currently work with globals (or maybe even get_current_blog_id()).
Change History (2)
Note: See
TracTickets for help on using
tickets.
I just searched through the WordPress codebase and actually wasn't able to find any occurrence of the
$current_blogglobal where the code was not part of the global scope anyway. Therefore I would consider this an invalid ticket - when I opened it, I assumed there were cases where this change was necessary, so it's great that there aren't. :)Although I mentioned this in the ticket description, I don't think we should (and even can) replace
get_current_blog_id()occurrences. While it would be nice for more usage of current naming conventions in the code,get_current_blog_id()is easier to use thanget_site()->idand, more importantly, also works outside of Multisite.