diff --git a/batch.php b/batch.php index 5430b03..79eec8a 100644 --- a/batch.php +++ b/batch.php @@ -58,7 +58,7 @@ function batch_operations_page_view() { ?>

@@ -185,8 +185,9 @@ function batch_operations_process () { * * * @param array $batch_arr array operations and more + * @param string $redirect Url to redirect to when the batch has finished processing */ -function batch_operations_start($batch_arr) +function batch_operations_start( $batch_arr, $redirect = NULL ) { $id = rand( 100, 999 ) . strtoupper( md5( date( 'YMDBs' ) ) ) . rand( 1000, 9999 ); @@ -199,6 +200,12 @@ function batch_operations_start($batch_arr) $batch_arr['count'] = count( $batch_arr['operations'] ); $batch_arr['current'] = 0; + if ( empty( $redirect ) ) { + $batch_arr['successful_page'] = get_admin_url(); + } else { + $batch_arr['successful_page'] = $redirect; + } + if ( empty( $batch_arr['progress_message'] ) ) { $batch_arr['progress_message'] = __( 'Completed %current% of %total%.' ); } diff --git a/batch_test.php b/batch_test.php index fafd7b1..1242158 100644 --- a/batch_test.php +++ b/batch_test.php @@ -69,6 +69,11 @@ function batch_operations_test_page_view() { batch_operations_start($batch); break; + case 9: + $batch['operations'][]=array('test_batch_operation_params',array('c',3)); + batch_operations_start($batch,get_admin_url( null, 'tools.php' ) . "?page=batch-operations-test"); + break; + default: break; } @@ -85,6 +90,7 @@ function batch_operations_test_page_view() {
  • Test $context['finished']
  • Test params
  • Test operations in class +
  • Test redirect