Home › Forums › Backend Issues (wp-admin) › The "network_admin_menu" hook and performance
Hello, I have a fairly hefty multi site with 2000+ sites and I’m concerned over how the “network_admin_menu” hooks loops over every website and performs upgrade checks on every page load of the network admin page.
the start of the code in question
// Loop over sites and check for upgrades.
$sites = get_sites( array( 'number' => 0 ) );
The speed difference I see is a page load of 0.1 seconds without vs 1.5 seconds with and growing for every site we onboard.
with 2000+ websites thats 2000+ extra select statements to fetch this on every page load.
as an Interim, I’ve suppressed this check which isn’t ideal at all
/**
* This searches and destroys the acf "network_admin_menu" hook used for "upgrading" ACF
* app/web/app/mu-plugins/advanced-custom-fields-pro/includes/admin/admin-upgrade.php
*/
function remove_acf_network_admin_menu_action()
{
if( class_Exists( '\ACF_Admin_Upgrade' ) )
{
global $wp_filter;
if( isset( $wp_filter[ 'network_admin_menu' ] ) and $wp_filter[ 'network_admin_menu' ] instanceof \WP_Hook )
{
foreach( $wp_filter[ 'network_admin_menu' ] as $priority => $actions )
{
if( is_array( $actions ) )
{
foreach( $actions as $action )
{
if( isset( $action['function'][0] ) and $action['function'][0] instanceof \ACF_Admin_Upgrade )
{
remove_action( 'network_admin_menu', $action['function'], $priority );
}
}
}
}
}
}
}
I’d like to make a suggestion for the developers and that is under the context of a network enable multi site installation, that the “acf_version” tracking option is moved to the new “wp_blogmeta” table when available, meaning it could be queried as a single statement for all sites.
https://make.wordpress.org/core/2019/01/28/multisite-support-for-site-metadata-in-5-1/
Does this make sense?
You’d need to make this suggestion to the developer here https://www.advancedcustomfields.com/contact/
The topic ‘The "network_admin_menu" hook and performance’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.