delete_transients(); return; } $this->delete_network_transients(); $site_ids = get_sites( [ 'fields' => 'ids', 'number' => 0, 'update_site_cache' => false, 'update_site_meta_cache' => false, ] ); foreach ( $site_ids as $site_id ) { // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.switch_to_blog_switch_to_blog switch_to_blog( $site_id ); $this->delete_transients(); } restore_current_blog(); } /** * Delete transients. * * @since 1.26.0 */ protected function delete_transients(): void { global $wpdb; // phpcs:ignore WordPress.DB.DirectDatabaseQuery $transients = $wpdb->get_col( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s", '_transient_' . self::PREFIX, '_transient_timeout_' . self::PREFIX ) ); if ( ! empty( $transients ) ) { array_map( 'delete_option', (array) $transients ); } } /** * Delete transients on multisite. * * @since 1.26.0 */ protected function delete_network_transients(): void { global $wpdb; // phpcs:ignore WordPress.DB.DirectDatabaseQuery $transients = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM $wpdb->sitemeta WHERE meta_key LIKE %s OR meta_key LIKE %s", '_site_transient_' . self::PREFIX, '_site_transient_timeout_' . self::PREFIX ) ); if ( ! empty( $transients ) ) { array_map( 'delete_site_option', (array) $transients ); } } }