get_var( "SELECT SUM(LENGTH(option_value)) FROM {$wpdb->options} WHERE autoload IN ('yes', 'on', 'auto', 'auto-on');" ); $autoload_size = (int) $autoload_size; // Count autoloaded options. $autoload_count = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->options} WHERE autoload IN ('yes', 'on', 'auto', 'auto-on');" ); // Get top offenders (largest autoloaded options). $top_options = $wpdb->get_results( "SELECT option_name, LENGTH(option_value) as size FROM {$wpdb->options} WHERE autoload IN ('yes', 'on', 'auto', 'auto-on') ORDER BY LENGTH(option_value) DESC LIMIT 5" ); $details = array( 'total_size' => $autoload_size, 'total_size_mb' => round( $autoload_size / 1024 / 1024, 2 ), 'option_count' => $autoload_count, 'top_options' => $top_options, ); // Convert to MB for comparison. $size_mb = $autoload_size / 1024 / 1024; if ( $size_mb > 2 ) { return static::fail( 'high', sprintf( /* translators: %s: size in MB */ __( 'Your site loads %s MB of data on every single page request. This is well above the recommended 800 KB and is significantly slowing down your site.', '0-day-analytics' ), $details['total_size_mb'] ), __( 'This is usually caused by plugins storing large amounts of data incorrectly. Contact a developer to identify and fix the problematic plugins, or use Table Viewer to investigate.', '0-day-analytics' ), $details ); } if ( $size_mb > 1.5 ) { return static::fail( 'high', sprintf( /* translators: %s: size in MB */ __( 'Your site loads %s MB of data on every single page request. This is well above the recommended 800 KB and is significantly slowing down your site.', '0-day-analytics' ), $details['total_size_mb'] ), sprintf( /* translators: %s: link to Table Viewer */ __( 'This is usually caused by plugins storing large amounts of data incorrectly. Contact a developer to identify and fix the problematic plugins, or use Table Viewer to investigate.', '0-day-analytics' ), \network_admin_url( 'admin.php?page=advan_table' ) ), $details ); } if ( $size_mb > 1 ) { return static::fail( 'medium', sprintf( /* translators: %s: size in MB */ \__( 'Your site loads %s MB of data on every page request. This is above the recommended 800 KB limit and is adding unnecessary overhead.', '0-day-analytics' ), $details['total_size_mb'] ), \__( 'Consider auditing your plugins - some may be storing too much autoloaded data. A developer can help identify and optimize this.', '0-day-analytics' ), $details ); } if ( $size_mb > 0.8 ) { return static::warning( sprintf( /* translators: %s: size in KB */ \__( 'Your site loads %s KB of data on every page request. This is at the upper limit of what\'s recommended.', '0-day-analytics' ), round( $autoload_size / 1024 ) ), \__( 'Keep an eye on this metric as you add more plugins. Some plugins don\'t properly manage their autoloaded data.', '0-day-analytics' ), $details ); } return static::pass( sprintf( /* translators: %s: size in KB */ \__( 'Your site loads %s KB of settings data per page request, which is within the healthy range (under 800 KB).', '0-day-analytics' ), round( $autoload_size / 1024 ) ), $details ); } } }