Skip to content

Commit 02bd910

Browse files
swissspidyCopilot
andauthored
Update src/Theme_Cache_Command.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 63c6211 commit 02bd910

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/Theme_Cache_Command.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,20 @@ public function flush( $args, $assoc_args ) {
9999
// Only added in WordPress 6.1.
100100
if ( function_exists( 'wp_cache_flush_group' ) ) {
101101
wp_cache_flush_group( 'themes' );
102+
WP_CLI::success( 'The theme cache was flushed.' );
103+
return;
104+
}
105+
106+
// Fallback for WordPress versions prior to 6.1: clear cache for all themes.
107+
if ( function_exists( 'wp_get_themes' ) ) {
108+
$all_themes = wp_get_themes();
109+
foreach ( $all_themes as $theme ) {
110+
$this->clear_theme_cache( $theme );
111+
}
112+
WP_CLI::success( 'The theme cache was flushed.' );
113+
} else {
114+
WP_CLI::warning( 'Your WordPress version does not support flushing the theme cache group.' );
102115
}
103-
WP_CLI::success( 'The theme cache was flushed.' );
104116
}
105117

106118
/**

0 commit comments

Comments
 (0)