Opened 5 weeks ago
Closed 5 weeks ago
#64077 closed defect (bug) (maybelater)
Cache is_multisite() and is_network_admin() to reduce redundant calls
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Plugins | Keywords: | has-patch |
| Focuses: | administration, performance | Cc: |
Description
The wp-admin/plugins.php file makes repeated calls to is_multisite() and is_network_admin() throughout the plugin management logic. This leads to redundant function calls that can add up on sites with many plugins.
Change History (2)
This ticket was mentioned in PR #10146 on WordPress/wordpress-develop by @mukesh27.
5 weeks ago
#1
- Keywords has-patch added; needs-patch removed
Note: See
TracTickets for help on using
tickets.
Trac ticket: https://core.trac.wordpress.org/ticket/64077
This PR refactors the
src/wp-admin/plugins.phpfile to improve efficiency and maintainability by caching the results ofis_multisite()andis_network_admin()in local variables. All subsequent checks throughout the file now use these cached variables, reducing repeated function calls and improving readability. No functional behavior is changed.Refactoring for efficiency and readability:
is_multisite()andis_network_admin()results in$is_multisiteand$is_network_adminvariables at the top of the file, and replaced all repeated calls to these functions with the variables throughout the plugin management logic.is_multisite()andis_network_admin()to use the new local variables, including plugin activation, deactivation, automatic updates, and UI display logic.