Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../deprecat.../classes
File: session.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* NF Session
[2] Fix | Delete
*
[3] Fix | Delete
* This is a wrapper class for WP_Session / PHP $_SESSION and handles the storage of cart items, purchase sessions, etc
[4] Fix | Delete
*
[5] Fix | Delete
* @package Ninja Forms
[6] Fix | Delete
* @subpackage Classes/Session
[7] Fix | Delete
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
[8] Fix | Delete
* @since 2.9.18
[9] Fix | Delete
*/
[10] Fix | Delete
// Exit if accessed directly
[11] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) exit;
[12] Fix | Delete
/**
[13] Fix | Delete
* NF_Session Class
[14] Fix | Delete
*
[15] Fix | Delete
* @since 1.5
[16] Fix | Delete
*/
[17] Fix | Delete
class NF_Session {
[18] Fix | Delete
/**
[19] Fix | Delete
* Holds our session data
[20] Fix | Delete
*
[21] Fix | Delete
* @var array
[22] Fix | Delete
* @access private
[23] Fix | Delete
* @since 2.9.18
[24] Fix | Delete
*/
[25] Fix | Delete
private $session;
[26] Fix | Delete
/**
[27] Fix | Delete
* Session index prefix
[28] Fix | Delete
*
[29] Fix | Delete
* @var string
[30] Fix | Delete
* @access private
[31] Fix | Delete
* @since 2.9.18
[32] Fix | Delete
*/
[33] Fix | Delete
private $prefix = '';
[34] Fix | Delete
/**
[35] Fix | Delete
* Get things started
[36] Fix | Delete
*
[37] Fix | Delete
* Defines our WP_Session constants, includes the necessary libraries and
[38] Fix | Delete
* retrieves the WP Session instance
[39] Fix | Delete
*
[40] Fix | Delete
* @since 2.9.18
[41] Fix | Delete
*/
[42] Fix | Delete
public function __construct() {
[43] Fix | Delete
// Use WP_Session (default)
[44] Fix | Delete
if ( ! defined( 'WP_SESSION_COOKIE' ) ) {
[45] Fix | Delete
define( 'WP_SESSION_COOKIE', 'nf_wp_session' );
[46] Fix | Delete
}
[47] Fix | Delete
if ( ! class_exists( 'Recursive_ArrayAccess' ) ) {
[48] Fix | Delete
require_once NF_PLUGIN_DIR . 'includes/libraries/class-recursive-arrayaccess.php';
[49] Fix | Delete
}
[50] Fix | Delete
if ( ! class_exists( 'WP_Session' ) ) {
[51] Fix | Delete
require_once NF_PLUGIN_DIR . 'includes/libraries/class-wp-session.php';
[52] Fix | Delete
require_once NF_PLUGIN_DIR . 'includes/libraries/wp-session.php';
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
[56] Fix | Delete
add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
[57] Fix | Delete
[58] Fix | Delete
add_action( 'plugins_loaded', array( $this, 'init' ), -1 );
[59] Fix | Delete
[60] Fix | Delete
}
[61] Fix | Delete
/**
[62] Fix | Delete
* Setup the WP_Session instance
[63] Fix | Delete
*
[64] Fix | Delete
* @access public
[65] Fix | Delete
* @since 2.9.18
[66] Fix | Delete
* @return void
[67] Fix | Delete
*/
[68] Fix | Delete
public function init() {
[69] Fix | Delete
$this->session = WP_Session::get_instance();
[70] Fix | Delete
return $this->session;
[71] Fix | Delete
}
[72] Fix | Delete
/**
[73] Fix | Delete
* Retrieve session ID
[74] Fix | Delete
*
[75] Fix | Delete
* @access public
[76] Fix | Delete
* @since 2.9.18
[77] Fix | Delete
* @return string Session ID
[78] Fix | Delete
*/
[79] Fix | Delete
public function get_id() {
[80] Fix | Delete
return $this->session->session_id;
[81] Fix | Delete
}
[82] Fix | Delete
/**
[83] Fix | Delete
* Retrieve a session variable
[84] Fix | Delete
*
[85] Fix | Delete
* @access public
[86] Fix | Delete
* @since 2.9.18
[87] Fix | Delete
* @param string $key Session key
[88] Fix | Delete
* @return string Session variable
[89] Fix | Delete
*/
[90] Fix | Delete
public function get( $key ) {
[91] Fix | Delete
$key = sanitize_key( $key );
[92] Fix | Delete
return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
[93] Fix | Delete
}
[94] Fix | Delete
/**
[95] Fix | Delete
* Set a session variable
[96] Fix | Delete
*
[97] Fix | Delete
* @since 2.9.18
[98] Fix | Delete
* @param string $key Session key
[99] Fix | Delete
* @param integer $value Session variable
[100] Fix | Delete
* @return string Session variable
[101] Fix | Delete
*/
[102] Fix | Delete
public function set( $key, $value ) {
[103] Fix | Delete
$key = sanitize_key( $key );
[104] Fix | Delete
if ( is_array( $value ) ) {
[105] Fix | Delete
$this->session[ $key ] = serialize( $value );
[106] Fix | Delete
} else {
[107] Fix | Delete
$this->session[ $key ] = $value;
[108] Fix | Delete
}
[109] Fix | Delete
return $this->session[ $key ];
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* Delete a session variable
[114] Fix | Delete
*
[115] Fix | Delete
* @since 2.9.28
[116] Fix | Delete
* @param string $key
[117] Fix | Delete
* @return void
[118] Fix | Delete
*/
[119] Fix | Delete
public function delete() {
[120] Fix | Delete
delete_option( '_wp_session_' . $this->session->session_id );
[121] Fix | Delete
delete_option( '_wp_session_expires_' . $this->session->session_id );
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
/**
[125] Fix | Delete
* Force the cookie expiration variant time to 23 minutes
[126] Fix | Delete
*
[127] Fix | Delete
* @access public
[128] Fix | Delete
* @since 2.9.18
[129] Fix | Delete
* @param int $exp Default expiration (1 hour)
[130] Fix | Delete
* @return int
[131] Fix | Delete
*/
[132] Fix | Delete
public function set_expiration_variant_time( $exp ) {
[133] Fix | Delete
return 60 * 23;
[134] Fix | Delete
}
[135] Fix | Delete
/**
[136] Fix | Delete
* Force the cookie expiration time to 24 minutes
[137] Fix | Delete
*
[138] Fix | Delete
* @access public
[139] Fix | Delete
* @since 2.9.18
[140] Fix | Delete
* @param int $exp Default expiration (1 hour)
[141] Fix | Delete
* @return int
[142] Fix | Delete
*/
[143] Fix | Delete
public function set_expiration_time( $exp ) {
[144] Fix | Delete
return 60 * 24;
[145] Fix | Delete
}
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function