Skip to content

Commit 80c8473

Browse files
committed
Simply use WP_Theme::cache_delete
1 parent 8e52a63 commit 80c8473

1 file changed

Lines changed: 2 additions & 28 deletions

File tree

‎src/Scaffold_Command.php‎

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -539,40 +539,14 @@ public function child_theme( $args, $assoc_args ) {
539539
$this->log_whether_files_written( $files_written, $skip_message, $success_message );
540540

541541
if ( Utils\get_flag_value( $assoc_args, 'activate' ) ) {
542-
$this->refresh_theme_cache( $theme_slug );
542+
wp_get_theme( $theme_slug )->cache_delete();
543543
WP_CLI::run_command( [ 'theme', 'activate', $theme_slug ] );
544544
} elseif ( Utils\get_flag_value( $assoc_args, 'enable-network' ) ) {
545-
$this->refresh_theme_cache( $theme_slug );
545+
wp_get_theme( $theme_slug )->cache_delete();
546546
WP_CLI::run_command( [ 'theme', 'enable', $theme_slug ], [ 'network' => true ] );
547547
}
548548
}
549549

550-
/**
551-
* Refreshes WordPress theme cache.
552-
*
553-
* Clears PHP's filesystem cache, WordPress theme_roots transient, object cache,
554-
* individual theme caches, and rebuilds the theme directory cache. This ensures
555-
* newly created themes are recognized by WordPress before attempting to activate
556-
* or enable them.
557-
*
558-
* @param string $theme_slug The theme slug to clear individual caches for.
559-
*/
560-
private function refresh_theme_cache( $theme_slug ) {
561-
clearstatcache();
562-
delete_site_transient( 'theme_roots' );
563-
wp_cache_delete( 'themes', 'themes' );
564-
565-
// Clear individual theme caches to prevent "missing theme" objects.
566-
// This is especially important when a theme was previously deleted and is being recreated.
567-
$theme_root = get_theme_root( $theme_slug );
568-
$cache_hash = md5( $theme_root . '/' . $theme_slug );
569-
foreach ( [ 'theme', 'screenshot', 'headers', 'page_templates' ] as $key ) {
570-
wp_cache_delete( $key . '-' . $cache_hash, 'themes' );
571-
}
572-
573-
search_theme_directories( true );
574-
}
575-
576550
private function get_output_path( $assoc_args, $subdir ) {
577551
if ( $assoc_args['theme'] ) {
578552
$theme = $assoc_args['theme'];

0 commit comments

Comments
 (0)