Edit File by line
/home/barbar84/www/wp-conte.../plugins/ninja-fo.../deprecat.../classes
File: forms.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
/**
[1] Fix | Delete
* Handles adding and removing forms.
[2] Fix | Delete
*
[3] Fix | Delete
* @package Ninja Forms
[4] Fix | Delete
* @subpackage Classes/Form
[5] Fix | Delete
* @copyright Copyright (c) 2014, WPNINJAS
[6] Fix | Delete
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
[7] Fix | Delete
* @since 2.9
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
class NF_Forms {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Store our array of form ids
[14] Fix | Delete
*
[15] Fix | Delete
* @since 2.9
[16] Fix | Delete
*/
[17] Fix | Delete
var $forms = array();
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Get things started
[21] Fix | Delete
*
[22] Fix | Delete
* @access public
[23] Fix | Delete
* @since 2.9
[24] Fix | Delete
* @return void
[25] Fix | Delete
*/
[26] Fix | Delete
public function __construct() {
[27] Fix | Delete
add_action( 'nf_maybe_delete_form', array( $this, 'maybe_delete' ) );
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Get all forms
[32] Fix | Delete
*
[33] Fix | Delete
* @access public
[34] Fix | Delete
* @since 2.9
[35] Fix | Delete
* @return array $forms
[36] Fix | Delete
*/
[37] Fix | Delete
public function get_all( $show_new = false ) {
[38] Fix | Delete
global $wpdb;
[39] Fix | Delete
[40] Fix | Delete
$debug = ! empty ( $_REQUEST['debug'] ) ? true : false;
[41] Fix | Delete
[42] Fix | Delete
if ( empty ( $this->forms ) ) {
[43] Fix | Delete
$forms = nf_get_objects_by_type( 'form' );
[44] Fix | Delete
[45] Fix | Delete
$tmp_array = array();
[46] Fix | Delete
foreach ( $forms as $form ) {
[47] Fix | Delete
$form_id = $form['id'];
[48] Fix | Delete
[49] Fix | Delete
$status = Ninja_Forms()->form( $form_id )->get_setting( 'status' );
[50] Fix | Delete
if ( ( $status == 'new' && $show_new ) || $status != 'new' ) {
[51] Fix | Delete
$title = Ninja_Forms()->form( $form_id )->get_setting( 'form_title' );
[52] Fix | Delete
if ( strpos( $title, '_' ) === 0 ) {
[53] Fix | Delete
if ( $debug )
[54] Fix | Delete
$tmp_array[] = $form_id;
[55] Fix | Delete
} else {
[56] Fix | Delete
$tmp_array[] = $form_id;
[57] Fix | Delete
}
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
$this->forms = $tmp_array;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
return $this->forms;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Delete a form if it is created and not saved within 24 hrs.
[68] Fix | Delete
*
[69] Fix | Delete
* @access public
[70] Fix | Delete
* @since 2.9
[71] Fix | Delete
* @return void
[72] Fix | Delete
*/
[73] Fix | Delete
public function maybe_delete( $form_id ) {
[74] Fix | Delete
$status = Ninja_Forms()->form( $form_id )->get_setting( 'status' );
[75] Fix | Delete
if ( 'new' == $status ) {
[76] Fix | Delete
Ninja_Forms()->form( $form_id )->delete();
[77] Fix | Delete
}
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Update cached forms
[82] Fix | Delete
*
[83] Fix | Delete
* @access public
[84] Fix | Delete
* @since 2.9
[85] Fix | Delete
* @return void
[86] Fix | Delete
*/
[87] Fix | Delete
public function update_cache( $debug = false, $show_new = false ) {
[88] Fix | Delete
$this->forms = array();
[89] Fix | Delete
$this->get_all( $debug, $show_new );
[90] Fix | Delete
}
[91] Fix | Delete
}
[92] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function