Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/ninja-fo.../includes/AJAX/Controll...
File: Form.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
class NF_AJAX_Controllers_Form extends NF_Abstracts_Controller
[2] Fix | Delete
{
[3] Fix | Delete
private $publish_processing;
[4] Fix | Delete
[5] Fix | Delete
public function __construct()
[6] Fix | Delete
{
[7] Fix | Delete
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
[8] Fix | Delete
[9] Fix | Delete
// All Ajax call here are handled in this file
[10] Fix | Delete
add_action( 'wp_ajax_nf_ajax_get_new_nonce', array( $this, 'get_new_nonce' ) );
[11] Fix | Delete
add_action( 'wp_ajax_nopriv_nf_ajax_get_new_nonce', array( $this, 'get_new_nonce' ) );
[12] Fix | Delete
add_action( 'wp_ajax_nf_save_form', array( $this, 'save' ) );
[13] Fix | Delete
add_action( 'wp_ajax_nf_delete_form', array( $this, 'delete' ) );
[14] Fix | Delete
add_action( 'wp_ajax_nf_remove_maintenance_mode', array( $this, 'remove_maintenance_mode' ) );
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
public function plugins_loaded()
[18] Fix | Delete
{
[19] Fix | Delete
$this->publish_processing = new NF_Database_PublishProcessing();
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
public function save()
[23] Fix | Delete
{
[24] Fix | Delete
// Does the current user have admin privileges
[25] Fix | Delete
if (!current_user_can(apply_filters('ninja_forms_admin_all_forms_capabilities', 'manage_options'))) {
[26] Fix | Delete
$this->_data['errors'] = esc_html__('Access denied. You must have admin privileges to view this data.', 'ninja-forms');
[27] Fix | Delete
$this->_respond();
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
check_ajax_referer( 'ninja_forms_builder_nonce', 'security' );
[31] Fix | Delete
[32] Fix | Delete
if( ! isset( $_POST[ 'form' ] ) ){
[33] Fix | Delete
$this->_errors[] = esc_html__( 'Form Not Found', 'ninja-forms' );
[34] Fix | Delete
$this->_respond();
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
$form_data = json_decode( stripslashes( $_POST['form'] ), ARRAY_A );
[38] Fix | Delete
[39] Fix | Delete
if( is_string( $form_data[ 'id' ] ) ) {
[40] Fix | Delete
$tmp_id = $form_data[ 'id' ];
[41] Fix | Delete
$form = Ninja_Forms()->form()->get();
[42] Fix | Delete
$form->save();
[43] Fix | Delete
$form_data[ 'id' ] = $form->get_id();
[44] Fix | Delete
$this->_data[ 'new_ids' ][ 'forms' ][ $tmp_id ] = $form_data[ 'id' ];
[45] Fix | Delete
} else {
[46] Fix | Delete
$form = Ninja_Forms()->form($form_data['id'])->get();
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
unset( $form_data[ 'settings' ][ '_seq_num' ] );
[50] Fix | Delete
[51] Fix | Delete
$form->update_settings( $form_data[ 'settings' ] )->save();
[52] Fix | Delete
[53] Fix | Delete
if( isset( $form_data[ 'fields' ] ) ) {
[54] Fix | Delete
$db_fields_controller = new NF_Database_FieldsController( $form_data[ 'id' ], $form_data[ 'fields' ] );
[55] Fix | Delete
$db_fields_controller->run();
[56] Fix | Delete
$form_data[ 'fields' ] = $db_fields_controller->get_updated_fields_data();
[57] Fix | Delete
$this->_data['new_ids']['fields'] = $db_fields_controller->get_new_field_ids();
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
if( isset( $form_data[ 'deleted_fields' ] ) ){
[61] Fix | Delete
[62] Fix | Delete
foreach( $form_data[ 'deleted_fields' ] as $deleted_field_id ){
[63] Fix | Delete
[64] Fix | Delete
$field = Ninja_Forms()->form( $form_data[ 'id' ])->get_field( $deleted_field_id );
[65] Fix | Delete
$field->delete();
[66] Fix | Delete
}
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
if( isset( $form_data[ 'actions' ] ) ) {
[70] Fix | Delete
[71] Fix | Delete
/*
[72] Fix | Delete
* Loop Actions and fire Save() hooks.
[73] Fix | Delete
*/
[74] Fix | Delete
foreach ($form_data['actions'] as &$action_data) {
[75] Fix | Delete
[76] Fix | Delete
$id = $action_data['id'];
[77] Fix | Delete
[78] Fix | Delete
$action = Ninja_Forms()->form( $form_data[ 'id' ] )->get_action( $id );
[79] Fix | Delete
[80] Fix | Delete
$action->update_settings($action_data['settings'])->save();
[81] Fix | Delete
[82] Fix | Delete
$action_type = $action->get_setting( 'type' );
[83] Fix | Delete
[84] Fix | Delete
if( isset( Ninja_Forms()->actions[ $action_type ] ) ) {
[85] Fix | Delete
$action_class = Ninja_Forms()->actions[ $action_type ];
[86] Fix | Delete
[87] Fix | Delete
$action_settings = $action_class->save( $action_data['settings'] );
[88] Fix | Delete
if( $action_settings ){
[89] Fix | Delete
$action_data['settings'] = $action_settings;
[90] Fix | Delete
$action->update_settings( $action_settings )->save();
[91] Fix | Delete
}
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
if ($action->get_tmp_id()) {
[95] Fix | Delete
[96] Fix | Delete
$tmp_id = $action->get_tmp_id();
[97] Fix | Delete
$this->_data['new_ids']['actions'][$tmp_id] = $action->get_id();
[98] Fix | Delete
$action_data[ 'id' ] = $action->get_id();
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
$this->_data[ 'actions' ][ $action->get_id() ] = $action->get_settings();
[102] Fix | Delete
}
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
/*
[106] Fix | Delete
* Loop Actions and fire Publish() hooks.
[107] Fix | Delete
*/
[108] Fix | Delete
foreach ($form_data['actions'] as &$action_data) {
[109] Fix | Delete
[110] Fix | Delete
$action = Ninja_Forms()->form( $form_data[ 'id' ] )->get_action( $action_data['id'] );
[111] Fix | Delete
[112] Fix | Delete
$action_type = $action->get_setting( 'type' );
[113] Fix | Delete
[114] Fix | Delete
if( isset( Ninja_Forms()->actions[ $action_type ] ) ) {
[115] Fix | Delete
$action_class = Ninja_Forms()->actions[ $action_type ];
[116] Fix | Delete
[117] Fix | Delete
if( $action->get_setting( 'active' ) && method_exists( $action_class, 'publish' ) ) {
[118] Fix | Delete
$data = $action_class->publish( $this->_data );
[119] Fix | Delete
if ($data) {
[120] Fix | Delete
$this->_data = $data;
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
}
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
if( isset( $form_data[ 'deleted_actions' ] ) ){
[127] Fix | Delete
[128] Fix | Delete
foreach( $form_data[ 'deleted_actions' ] as $deleted_action_id ){
[129] Fix | Delete
[130] Fix | Delete
$action = Ninja_Forms()->form()->get_action( $deleted_action_id );
[131] Fix | Delete
$action->delete();
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
delete_user_option( get_current_user_id(), 'nf_form_preview_' . $form_data['id'] );
[136] Fix | Delete
WPN_Helper::update_nf_cache( $form_data[ 'id' ], $form_data );
[137] Fix | Delete
[138] Fix | Delete
do_action( 'ninja_forms_save_form', $form->get_id() );
[139] Fix | Delete
[140] Fix | Delete
$this->_respond();
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
public function delete()
[144] Fix | Delete
{
[145] Fix | Delete
// Does the current user have admin privileges
[146] Fix | Delete
if (!current_user_can(apply_filters('ninja_forms_admin_all_forms_capabilities', 'manage_options'))) {
[147] Fix | Delete
$this->_data['errors'] = esc_html__('Access denied. You must have admin privileges to view this data.', 'ninja-forms');
[148] Fix | Delete
$this->_respond();
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
check_ajax_referer( 'ninja_forms_builder_nonce', 'security' );
[152] Fix | Delete
[153] Fix | Delete
$this->_respond();
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
/**
[157] Fix | Delete
* This function will take all form out of maintenance mode( in case some
[158] Fix | Delete
* are still in maintenance mode after some required updates )
[159] Fix | Delete
*
[160] Fix | Delete
* @since 3.4.0
[161] Fix | Delete
*/
[162] Fix | Delete
public function remove_maintenance_mode() {
[163] Fix | Delete
[164] Fix | Delete
// Does the current user have admin privileges
[165] Fix | Delete
if (!current_user_can(apply_filters('ninja_forms_admin_all_forms_capabilities', 'manage_options'))) {
[166] Fix | Delete
$this->_data['errors'] = esc_html__('Access denied. You must have admin privileges to view this data.', 'ninja-forms');
[167] Fix | Delete
$this->_respond();
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
check_ajax_referer( 'ninja_forms_settings_nonce', 'security' );
[171] Fix | Delete
[172] Fix | Delete
WPN_Helper::set_forms_maintenance_mode();
[173] Fix | Delete
[174] Fix | Delete
$this->_respond();
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
/**
[178] Fix | Delete
* Let's generate a unique nonce for each form render so that we don't get
[179] Fix | Delete
* caught with an expiring nonce accidentally and fail to allow a submission
[180] Fix | Delete
* @since 3.2
[181] Fix | Delete
*/
[182] Fix | Delete
public function get_new_nonce() {
[183] Fix | Delete
// get a timestamp to append to nonce name
[184] Fix | Delete
$current_time_stamp = time();
[185] Fix | Delete
[186] Fix | Delete
// Let's generate a unique nonce
[187] Fix | Delete
$new_nonce_name = 'ninja_forms_display_nonce_' . $current_time_stamp;
[188] Fix | Delete
[189] Fix | Delete
$res = array(
[190] Fix | Delete
'new_nonce' => wp_create_nonce( $new_nonce_name ),
[191] Fix | Delete
'nonce_ts' => $current_time_stamp );
[192] Fix | Delete
[193] Fix | Delete
$this->_respond( $res );
[194] Fix | Delete
}
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function