add finished_callback
Этот коммит содержится в:
@@ -79,6 +79,39 @@ function batch_operations_test_page_view() {
|
||||
batch_operations_start($batch,get_admin_url( null, 'tools.php' ) . "?page=batch-operations-test");
|
||||
break;
|
||||
|
||||
case 11:
|
||||
$batch = array(
|
||||
'title' => "Test finished_callback without errors",
|
||||
'init_message' => 'Custom Init Message',
|
||||
'progress_message' => 'Step %current% of %total%.',
|
||||
'operations' => array(
|
||||
array('test_batch_operation_params',array('a',1)),
|
||||
array(array('TestBatch','Operations'),array()),
|
||||
array('test_batch_operation_context_finished',array()),
|
||||
array('test_batch_operation',array()),
|
||||
),
|
||||
'finished' => 'test_batch_operations_callback'
|
||||
);
|
||||
|
||||
batch_operations_start($batch,get_admin_url( null, 'tools.php' ) . "?page=batch-operations-test");
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$batch = array(
|
||||
'title' => "Test finished_callback with errors",
|
||||
'init_message' => 'Custom Init Message',
|
||||
'progress_message' => 'Step %current% of %total%.',
|
||||
'operations' => array(
|
||||
array('test_batch_operation_params',array('a')),
|
||||
array('test_batch_operation_params',array('Hello','World')),
|
||||
array(array('TestBatch','Operations'),array()),
|
||||
array('test_batch_operationh',array()),
|
||||
),
|
||||
'finished' => 'test_batch_operations_callback'
|
||||
);
|
||||
batch_operations_start($batch,get_admin_url( null, 'tools.php' ) . "?page=batch-operations-test");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -97,7 +130,8 @@ function batch_operations_test_page_view() {
|
||||
<li><a href="tools.php?page=batch-operations-test&test=8">Test operations in class</a>
|
||||
<li><a href="tools.php?page=batch-operations-test&test=9">Test redirect</a>
|
||||
<li><a href="tools.php?page=batch-operations-test&test=10">Test messages</a>
|
||||
<li><a href="tools.php?page=batch-operations-test&test=11">Test finished_callback</a>
|
||||
<li><a href="tools.php?page=batch-operations-test&test=11">Test finished_callback without errors</a>
|
||||
<li><a href="tools.php?page=batch-operations-test&test=12">Test finished_callback with errors</a>
|
||||
</ol>
|
||||
</div>
|
||||
<?php
|
||||
@@ -136,6 +170,17 @@ function test_batch_operation_context_finished( &$context ) {
|
||||
function test_batch_operation_params( $a, $b, &$context ) {
|
||||
sleep(2);
|
||||
$context['message'] = '$a=' . $a . ' $b=' . $b ;
|
||||
$context['results'][] = $a . ', ' . $b . '!';return true;
|
||||
}
|
||||
|
||||
function test_batch_operations_callback( $success, $results, $errors ){
|
||||
if ( $success ) {
|
||||
batch_operations_notice('Test finished_callback without errors success.');
|
||||
} else {
|
||||
batch_operations_notice('Test finished_callback with errors success.');
|
||||
batch_operations_notice('<h3>results</h3><pre>' . print_r( $results, true ) . '</pre><h3>errors</h3><pre>' .
|
||||
print_r( $errors, true ) . '</pre>', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
class TestBatch {
|
||||
|
Ссылка в новой задаче
Block a user