exists( $pcm_mu_plugin_index ) ) { $wp_filesystem->delete( $pcm_mu_plugin_index ); } $pcm_cache_mu_plugins = WP_CONTENT_DIR . '/mu-plugins/pressable-cache-management'; if ( $wp_filesystem->exists( $pcm_cache_mu_plugins ) ) { rrmdir( $pcm_cache_mu_plugins ); } /** * Recursively removes a directory. * * @param string $dir Directory to remove. */ function rrmdir( $dir ) { global $wp_filesystem; if ( ! $wp_filesystem->is_dir( $dir ) ) { return; } $objects = $wp_filesystem->dirlist( $dir ); if ( ! empty( $objects ) ) { foreach ( $objects as $object ) { if ( 'f' === $object['type'] ) { $wp_filesystem->delete( $dir . '/' . $object['name'] ); } elseif ( 'd' === $object['type'] ) { rrmdir( $dir . '/' . $object['name'] ); } } } $wp_filesystem->rmdir( $dir ); } // Remove batcache manager plugin from mu-plugins directory. $mu_plugins = array( 'pcm-batcache-manager.php' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited foreach ( $mu_plugins as $mu_plugin ) { $file = WP_CONTENT_DIR . '/mu-plugins/' . $mu_plugin; if ( $wp_filesystem->exists( $file ) ) { $wp_filesystem->delete( $file ); } }