mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-02-01 06:27:27 +00:00
This change ensures custom styles for all third-party blocks are rendered on the front end if assets are set to be loaded on a per-block basis. Additionally, this change includes new unit tests to help prevent a similar bug in the future. Props scruffian, aristath, poena, wildworks, ajlende, andraganescu, ndiego, gigitux, cbravobernal, ramonopoly, andrewserong, oandregal, hellofromTonya, bernhard-reiter. Fixes #56915. git-svn-id: https://develop.svn.wordpress.org/trunk@54703 602fd350-edb4-49c9-b593-d223f7449a82
67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
|
|
abstract class WP_Theme_UnitTestCase extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* Theme root directory.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $theme_root;
|
|
|
|
/**
|
|
* Original theme directory.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $orig_theme_dir;
|
|
|
|
public function set_up() {
|
|
parent::set_up();
|
|
|
|
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
|
|
$this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
|
|
|
|
// /themes is necessary as theme.php functions assume /themes is the root if there is only one root.
|
|
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
|
|
|
|
// Set up the new root.
|
|
add_filter( 'theme_root', array( $this, 'filter_set_theme_root' ) );
|
|
add_filter( 'stylesheet_root', array( $this, 'filter_set_theme_root' ) );
|
|
add_filter( 'template_root', array( $this, 'filter_set_theme_root' ) );
|
|
|
|
// Clear caches.
|
|
wp_clean_themes_cache();
|
|
unset( $GLOBALS['wp_themes'] );
|
|
}
|
|
|
|
public function tear_down() {
|
|
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
|
|
|
// Clear up the filters to modify the theme root.
|
|
remove_filter( 'theme_root', array( $this, 'filter_set_theme_root' ) );
|
|
remove_filter( 'stylesheet_root', array( $this, 'filter_set_theme_root' ) );
|
|
remove_filter( 'template_root', array( $this, 'filter_set_theme_root' ) );
|
|
|
|
wp_clean_themes_cache();
|
|
unset( $GLOBALS['wp_themes'] );
|
|
|
|
parent::tear_down();
|
|
}
|
|
|
|
/**
|
|
* Cleans up global scope.
|
|
*
|
|
* @global WP_Styles $wp_styles
|
|
*/
|
|
public function clean_up_global_scope() {
|
|
global $wp_styles;
|
|
parent::clean_up_global_scope();
|
|
$wp_styles = null;
|
|
}
|
|
|
|
public function filter_set_theme_root() {
|
|
return $this->theme_root;
|
|
}
|
|
}
|