Edit File by line
/home/barbar84/www/wp-conte.../plugins/ninja-fo.../lib/StepProc...
File: step-processing.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
/**
[1] Fix | Delete
* Class for performing actions incrementally. Internally used for converting submissions, exporting submissions, etc.
[2] Fix | Delete
* Very useful when interacting with large amounts of data.
[3] Fix | Delete
*
[4] Fix | Delete
* @package Ninja Forms
[5] Fix | Delete
* @subpackage Classes/Step Processing
[6] Fix | Delete
* @copyright Copyright (c) 2014, WPNINJAS
[7] Fix | Delete
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
[8] Fix | Delete
* @since 2.7.4
[9] Fix | Delete
*/
[10] Fix | Delete
[11] Fix | Delete
class NF_Step_Processing
[12] Fix | Delete
{
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* @var action
[16] Fix | Delete
*/
[17] Fix | Delete
var $action = '';
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* @var step
[21] Fix | Delete
*/
[22] Fix | Delete
var $step = '';
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* @var total_steps
[26] Fix | Delete
*/
[27] Fix | Delete
var $total_steps = '';
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* @var redirect
[31] Fix | Delete
*/
[32] Fix | Delete
var $redirect = '';
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* @var array
[36] Fix | Delete
*/
[37] Fix | Delete
var $errors = array();
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* @var args
[41] Fix | Delete
*/
[42] Fix | Delete
var $args = array();
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Get things rolling
[46] Fix | Delete
*
[47] Fix | Delete
* @since 2.7.4
[48] Fix | Delete
* @return void
[49] Fix | Delete
*/
[50] Fix | Delete
function __construct() {
[51] Fix | Delete
[52] Fix | Delete
//Bail if we aren't in the admin.
[53] Fix | Delete
if ( ! is_admin() )
[54] Fix | Delete
return false;
[55] Fix | Delete
[56] Fix | Delete
if ( ! WPN_Helper::is_func_disabled( 'ignore_user_abort' ) ) {
[57] Fix | Delete
ignore_user_abort( true );
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
// if ( ! nf_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
[61] Fix | Delete
// //set_time_limit( 0 );
[62] Fix | Delete
// }
[63] Fix | Delete
[64] Fix | Delete
// Ajax call handled in 'processing' in this file
[65] Fix | Delete
add_action( 'wp_ajax_nf_' . $this->action, array( $this, 'processing' ) );
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Process our request.
[70] Fix | Delete
* Call the appropriate loading or step functions.
[71] Fix | Delete
*
[72] Fix | Delete
* @since 2.7.6
[73] Fix | Delete
* @return void
[74] Fix | Delete
*/
[75] Fix | Delete
public function processing() {
[76] Fix | Delete
[77] Fix | Delete
// Get our passed arguments. These come from the querysting of the processing page.
[78] Fix | Delete
if ( isset ( $_REQUEST['args'] ) ) {
[79] Fix | Delete
$this->args = WPN_Helper::sanitize_text_field($_REQUEST['args']);
[80] Fix | Delete
if ( isset ( $this->args['redirect'] ) ) {
[81] Fix | Delete
if( wp_validate_redirect( $this->args['redirect'] ) ){
[82] Fix | Delete
$this->redirect = wp_sanitize_redirect( $this->args['redirect'] );
[83] Fix | Delete
}
[84] Fix | Delete
}
[85] Fix | Delete
} else {
[86] Fix | Delete
$this->args = array();
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
// Get our current step.
[90] Fix | Delete
$this->step = isset ( $_REQUEST['step'] )? esc_html( $_REQUEST['step'] ) : 'loading';
[91] Fix | Delete
[92] Fix | Delete
// Get our total steps
[93] Fix | Delete
$this->total_steps = isset ( $_REQUEST['total_steps'] )? esc_html( $_REQUEST['total_steps'] ) : 0;
[94] Fix | Delete
[95] Fix | Delete
// If our step is loading, then we need to return how many total steps there are along with the next step, which is 1.
[96] Fix | Delete
if ( 'loading' == $this->step ) {
[97] Fix | Delete
$return = $this->loading();
[98] Fix | Delete
if ( ! isset ( $return['step'] ) ) {
[99] Fix | Delete
$saved_step = get_user_option( 'nf_step_processing_' . $this->action . '_step' );
[100] Fix | Delete
if ( ! empty ( $saved_step ) ) {
[101] Fix | Delete
$this->step = $saved_step;
[102] Fix | Delete
} else {
[103] Fix | Delete
$this->step = 1;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
$return['step'] = $this->step;
[107] Fix | Delete
}
[108] Fix | Delete
if ( ! isset ( $return['complete'] ) ) {
[109] Fix | Delete
$return['complete'] = false;
[110] Fix | Delete
}
[111] Fix | Delete
} else { // We aren't on the loading step, so do our processing.
[112] Fix | Delete
$return = $this->step();
[113] Fix | Delete
if ( ! isset ( $return['step'] ) ) {
[114] Fix | Delete
$this->step++;
[115] Fix | Delete
$return['step'] = $this->step;
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
if ( ! isset ( $return['complete'] ) ) {
[119] Fix | Delete
if ( $this->step > $this->total_steps ) {
[120] Fix | Delete
$complete = true;
[121] Fix | Delete
} else {
[122] Fix | Delete
$complete = false;
[123] Fix | Delete
}
[124] Fix | Delete
$return['complete'] = $complete;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
$return['total_steps'] = $this->total_steps;
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
$user_id = get_current_user_id();
[131] Fix | Delete
[132] Fix | Delete
if ( $return['complete'] ) {
[133] Fix | Delete
// Delete our step option
[134] Fix | Delete
delete_user_option( $user_id, 'nf_step_processing_' . $this->action . '_step' );
[135] Fix | Delete
// Set our redirect variable.
[136] Fix | Delete
$return['redirect'] = $this->redirect;
[137] Fix | Delete
// Run our complete function
[138] Fix | Delete
$this->complete();
[139] Fix | Delete
} else {
[140] Fix | Delete
// Save our current step so that we can resume if necessary
[141] Fix | Delete
update_user_option( $user_id, 'nf_step_processing_' . $this->action . '_step', $this->step );
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
if ( isset ( $this->redirect ) && ! empty ( $this->redirect ) ) {
[145] Fix | Delete
$this->args['redirect'] = $this->redirect;
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
$return['errors'] = ( $this->errors ) ? $this->errors : FALSE;
[149] Fix | Delete
[150] Fix | Delete
$return['args'] = $this->args;
[151] Fix | Delete
[152] Fix | Delete
echo json_encode( $return );
[153] Fix | Delete
die();
[154] Fix | Delete
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* Run our loading process.
[159] Fix | Delete
* This function should be overwritten in child classes.
[160] Fix | Delete
*
[161] Fix | Delete
* @since 2.7.4
[162] Fix | Delete
* @return array $args
[163] Fix | Delete
*/
[164] Fix | Delete
public function loading() {
[165] Fix | Delete
// This space left intentionally blank.
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
/**
[169] Fix | Delete
* This function is called for every step.
[170] Fix | Delete
* This function should be overwritten in child classes.
[171] Fix | Delete
*
[172] Fix | Delete
* @since 2.7.4
[173] Fix | Delete
* @return array $args
[174] Fix | Delete
*/
[175] Fix | Delete
public function step() {
[176] Fix | Delete
// This space left intentionally blank.
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* This function is called for every step.
[181] Fix | Delete
* This function should be overwritten in child classes.
[182] Fix | Delete
*
[183] Fix | Delete
* @since 2.7.4
[184] Fix | Delete
* @return array $args
[185] Fix | Delete
*/
[186] Fix | Delete
public function complete() {
[187] Fix | Delete
// This space left intentionally blank.
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
[191] Fix | Delete
[192] Fix | Delete
}
[193] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function