Skip to content

Instantly share code, notes, and snippets.

@jbrinley
Created December 22, 2019 20:16
Show Gist options
  • Save jbrinley/f2d61d433c05db79b07faf742845e910 to your computer and use it in GitHub Desktop.
Save jbrinley/f2d61d433c05db79b07faf742845e910 to your computer and use it in GitHub Desktop.
WordPress core opcache.preload
<?php
declare( strict_types=1 );
$wp_dir = '/application/www/wp/';
$preload_patterns = [
$wp_dir . "wp-includes/Text/Diff/Renderer.php",
$wp_dir . "wp-includes/Text/Diff/Renderer/inline.php",
$wp_dir . "wp-includes/SimplePie/**/*.php",
$wp_dir . "wp-includes/SimplePie/*.php",
$wp_dir . "wp-includes/Requests/**/*.php",
$wp_dir . "wp-includes/Requests/*.php",
$wp_dir . "wp-includes/**/class-*.php",
$wp_dir . "wp-includes/class-*.php",
];
$exclusions = [
$wp_dir . 'wp-includes/class-simplepie.php',
$wp_dir . 'wp-includes/SimplePie/File.php',
$wp_dir . 'wp-includes/SimplePie/Core.php',
$wp_dir . 'wp-includes/class-wp-simplepie-file.php',
$wp_dir . 'wp-includes/class-snoopy.php',
$wp_dir . 'wp-includes/class-json.php',
];
foreach ( $preload_patterns as $pattern ) {
$files = glob( $pattern );
foreach ( $files as $file ) {
if ( ! in_array( $file, $exclusions, true ) ) {
opcache_compile_file( $file );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment