Skip to content

Instantly share code, notes, and snippets.

@joemcgill
Last active November 24, 2023 08:53
Show Gist options
  • Save joemcgill/dd569c287013ad545f41495f93d7a27e to your computer and use it in GitHub Desktop.
Save joemcgill/dd569c287013ad545f41495f93d7a27e to your computer and use it in GitHub Desktop.
WP 6.4 Theme Path Fixer
<?php
/*
* Plugin Name: WP 6.4 Theme path fixer
* Plugin URI: https://gist.github.com/joemcgill/dd569c287013ad545f41495f93d7a27e
* Description: Fix problems with theme directory memoization in WP 6.4.
* Version: 1.0
* Requires at least: 6.4
* Author: Joe McGill
* Author URI: https://joemcgill.net
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
// Reset template and stylesheet paths prior to theme setup.
add_action( 'setup_theme', function () {
$GLOBALS['wp_template_path'] = null;
$GLOBALS['wp_stylesheet_path'] = null;
} );
// Add a noop filter to bypass future memoization.
add_filter( 'stylesheet_directory', function ( $dir ) {
return $dir;
} );
// Add a noop filter to bypass future memoization.
add_filter( 'template_directory', function ( $dir ) {
return $dir;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment