Commit cbed64b6 authored by Kevin Stover's avatar Kevin Stover

Moving batch process definition to includes/Config/BatchProcesses.php

parent c6497f86
Pipeline #543 passed with stage
in 1 minute and 19 seconds
......@@ -22,35 +22,19 @@ class NF_AJAX_REST_BatchProcess extends NF_AJAX_REST_Controller
if ( ! isset( $request_data[ 'security' ] ) || ! wp_verify_nonce( $request_data[ 'security' ], 'ninja_forms_batch_nonce' ) ) {
// Kick the request out now.
$data[ 'error' ] = __( 'Request forbidden.', 'ninja-forms' );
return $data;
}
// If we have a batch type...
if ( isset( $request_data[ 'batch_type' ]) ){
$batch_type = $request_data[ 'batch_type' ];
// Route the request to the proper controller.
switch ( $batch_type ) {
case 'chunked_publish':
$batch = new NF_Admin_Processes_ChunkPublish(
$request_data );
break;
case 'data_cleanup':
$batch = new NF_Admin_Processes_DataCleanup(
$request_data );
break;
case 'expired_submission_cleanup':
$batch = new NF_Admin_Processes_ExpiredSubmissionCleanup(
$request_data );
break;
case 'import_form':
$batch = new NF_Admin_Processes_ImportForm(
$request_data );
break;
case 'import_form_template':
$batch = new NF_Admin_Processes_ImportFormTemplate(
$request_data );
break;
default:
$data[ 'error' ] = __( 'Invalid request.', 'ninja-forms' );
break;
$batch_processes = Ninja_Forms()->config( 'BatchProcesses' );
if ( isset ( $batch_processes[ $batch_type ][ 'class_name' ] ) ) {
$batch_class = $batch_processes[ $batch_type ][ 'class_name' ];
$batch = new $batch_class( $request_data );
} else {
$data[ 'error' ] = __( 'Invalid request.', 'ninja-forms' );
}
} // Otherwise... (We don't have a batch type.)
else {
......
......@@ -65,7 +65,7 @@ class NF_Admin_Processes_ImportFormTemplate extends NF_Admin_Processes_ImportFor
$db_stage_one_complete = true;
}
$this->form[ 'stage_one_complete' ] = $db_stage_one_complete;
$this->form[ 'db_stage_one_complete' ] = $db_stage_one_complete;
add_option( 'nf_doing_' . $this->_slug, 'true', false );
}
......
<?php if ( ! defined( 'ABSPATH' ) ) exit;
return apply_filters( 'ninja_forms_batch_processes', array(
'chunked_publish' => array(
'class_name' => 'NF_Admin_Processes_ChunkPublish',
),
'data_cleanup' => array(
'class_name' => 'NF_Admin_Processes_DataCleanup',
),
'expired_submission_cleanup' => array(
'class_name' => 'NF_Admin_Processes_ExpiredSubmissionCleanup',
),
'import_form' => array(
'class_name' => 'NF_Admin_Processes_ImportForm',
),
'import_form_template' => array(
'class_name' => 'NF_Admin_Processes_ImportFormTemplate',
),
));
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment