[], 'blocks' => [], 'patterns' => [] ]; $bytes = 0; $per_plugin = []; foreach ( get_included_files() as $file ) { $file = wp_normalize_path( $file ); if ( str_starts_with( $file, $theme_dir . '/' ) ) { $rel = substr( $file, strlen( $theme_dir ) + 1 ); $bytes += (int) @filesize( $file ); if ( str_starts_with( $rel, 'blocks/' ) ) { $files['blocks'][] = $rel; } elseif ( str_starts_with( $rel, 'patterns/' ) ) { $files['patterns'][] = $rel; } else { $files['inc'][] = $rel; } } elseif ( str_starts_with( $file, $plugins . '/' ) ) { $plugin = explode( '/', substr( $file, strlen( $plugins ) + 1 ), 2 )[0]; $per_plugin[ $plugin ] = ( $per_plugin[ $plugin ] ?? 0 ) + 1; } } $styles = []; $scripts = []; foreach ( wp_styles()->done as $handle ) { $src = (string) ( wp_styles()->registered[ $handle ]->src ?? '' ); if ( str_starts_with( $handle, 'rooster' ) || str_contains( $src, '/themes/' ) ) { $styles[] = [ 'handle' => $handle, 'src' => $src ]; } } foreach ( wp_scripts()->done as $handle ) { $src = (string) ( wp_scripts()->registered[ $handle ]->src ?? '' ); if ( str_starts_with( $handle, 'rooster' ) || str_contains( $src, '/themes/' ) ) { $scripts[] = [ 'handle' => $handle, 'src' => $src ]; } } arsort( $per_plugin ); $report = [ 'theme' => ROOSTER_VERSION, 'device' => rooster_device_class(), 'layer' => Defer::is_full() ? 'full' : 'critical', 'theme_files' => $files['inc'], 'block_files' => $files['blocks'], 'pattern_files' => $files['patterns'], 'theme_kb' => round( $bytes / 1024, 1 ), 'styles' => $styles, 'scripts' => $scripts, 'modules' => array_values( array_filter( array_keys( (array) apply_filters( 'rooster/footprint/modules', Modules::loaded() ) ) ) ), 'plugins' => $per_plugin, 'rooster_one' => class_exists( 'AIEO_Theme_Adapters' ) ? [ 'adapter' => (string) ( \AIEO_Theme_Adapters::active_adapter()['id'] ?? '' ), 'purge' => has_action( 'aieo_purge_page_cache' ) ? true : false, 'consent' => (bool) apply_filters( 'rooster/consent/provider_active', false ), ] : null, 'notices' => self::$notices, 'memory_kb' => round( memory_get_peak_usage( true ) / 1024 ), 'php_ms' => round( ( microtime( true ) - (float) ( $_SERVER['REQUEST_TIME_FLOAT'] ?? microtime( true ) ) ) * 1000 ), ]; echo "\n\n"; } }