, errors: array} */ public function rollback_many( array $log_ids, bool $force = false ): array { // Ensure numeric values, then sort descending (most-recent-first). $ids = array_map( 'intval', $log_ids ); rsort( $ids ); $summary = array( 'rolled_back' => array(), 'skipped' => array(), 'errors' => array(), ); foreach ( $ids as $id ) { $result = $this->rollback->rollback( $id, $force ); if ( true === $result ) { $summary['rolled_back'][] = $id; continue; } // WP_Error - sort into skipped vs errors. $code = $result->get_error_code(); if ( in_array( $code, self::SKIP_CODES, true ) ) { $summary['skipped'][ $id ] = (string) $code; } else { $summary['errors'][ $id ] = (string) $code; } } /** * Fires after all bulk rollback attempts are complete. * * @param array{rolled_back: int[], skipped: array, errors: array} $summary Summary. */ do_action( 'abilityguard_bulk_rollback_complete', $summary ); return $summary; } /** * Build a default-wired instance using real repositories. */ public static function default(): self { return new self( new RollbackService( new LogRepository(), new SnapshotStore() ) ); } }