Skip to content

Commit dd141ce

Browse files
committed
fix: Check wp_cache_flush_group function exists for granular flushing
Replace wp_cache_supports check with direct function existence check. wp_cache_flush_group was added in WordPress 6.1, so checking if it exists is simpler and more direct than checking cache support via wp_cache_supports.
1 parent 9afec2a commit dd141ce

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎src/Cache_Command.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ public function flush_post( $args ) {
641641
clean_post_cache( $post_id );
642642
WP_CLI::success( "Post cache for ID $post_id cleared." );
643643
} else {
644-
if ( ! function_exists( 'wp_cache_supports' ) || ! wp_cache_supports( 'flush_group' ) ) {
644+
if ( ! function_exists( 'wp_cache_flush_group' ) ) {
645645
WP_CLI::error( 'Flushing all post caches requires WordPress 6.1+' );
646646
}
647647
wp_cache_flush_group( 'posts' );
@@ -679,7 +679,7 @@ public function flush_term( $args ) {
679679
clean_term_cache( $term_id );
680680
WP_CLI::success( "Term cache for ID $term_id cleared." );
681681
} else {
682-
if ( ! function_exists( 'wp_cache_supports' ) || ! wp_cache_supports( 'flush_group' ) ) {
682+
if ( ! function_exists( 'wp_cache_flush_group' ) ) {
683683
WP_CLI::error( 'Flushing all term caches requires WordPress 6.1+' );
684684
}
685685
wp_cache_flush_group( 'terms' );
@@ -717,7 +717,7 @@ public function flush_comment( $args ) {
717717
clean_comment_cache( $comment_id );
718718
WP_CLI::success( "Comment cache for ID $comment_id cleared." );
719719
} else {
720-
if ( ! function_exists( 'wp_cache_supports' ) || ! wp_cache_supports( 'flush_group' ) ) {
720+
if ( ! function_exists( 'wp_cache_flush_group' ) ) {
721721
WP_CLI::error( 'Flushing all comment caches requires WordPress 6.1+' );
722722
}
723723
wp_cache_flush_group( 'comment' );
@@ -755,7 +755,7 @@ public function flush_user( $args ) {
755755
clean_user_cache( $user_id );
756756
WP_CLI::success( "User cache for ID $user_id cleared." );
757757
} else {
758-
if ( ! function_exists( 'wp_cache_supports' ) || ! wp_cache_supports( 'flush_group' ) ) {
758+
if ( ! function_exists( 'wp_cache_flush_group' ) ) {
759759
WP_CLI::error( 'Flushing all user caches requires WordPress 6.1+' );
760760
}
761761
wp_cache_flush_group( 'users' );
@@ -794,7 +794,7 @@ public function flush_option( $args ) {
794794
wp_cache_delete( $option_name, 'options' );
795795
WP_CLI::success( "Option cache for '$option_name' cleared." );
796796
} else {
797-
if ( ! function_exists( 'wp_cache_supports' ) || ! wp_cache_supports( 'flush_group' ) ) {
797+
if ( ! function_exists( 'wp_cache_flush_group' ) ) {
798798
WP_CLI::error( 'Flushing all option caches requires WordPress 6.1+' );
799799
}
800800
wp_cache_flush_group( 'options' );

0 commit comments

Comments
 (0)