Created
December 22, 2019 20:16
-
-
Save jbrinley/f2d61d433c05db79b07faf742845e910 to your computer and use it in GitHub Desktop.
WordPress core opcache.preload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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