Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../deprecat.../classes
File: notification.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
/**
[1] Fix | Delete
* Notification
[2] Fix | Delete
*
[3] Fix | Delete
* Single notification object.
[4] Fix | Delete
* This object lets us call it like: Ninja_Forms()->notification( 33 )->methods()
[5] Fix | Delete
*
[6] Fix | Delete
* @package Ninja Forms
[7] Fix | Delete
* @subpackage Classes/Notifications
[8] Fix | Delete
* @copyright Copyright (c) 2014, WPNINJAS
[9] Fix | Delete
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
[10] Fix | Delete
* @since 2.8
[11] Fix | Delete
*/
[12] Fix | Delete
[13] Fix | Delete
class NF_Notification
[14] Fix | Delete
{
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* @var notification id
[18] Fix | Delete
*/
[19] Fix | Delete
var $id = '';
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* @var type
[23] Fix | Delete
*/
[24] Fix | Delete
var $type = '';
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* @var active
[28] Fix | Delete
* Holds a boolean value.
[29] Fix | Delete
*/
[30] Fix | Delete
var $active = '';
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* @var form_id
[34] Fix | Delete
* Holds the id of our form.
[35] Fix | Delete
*/
[36] Fix | Delete
var $form_id = '';
[37] Fix | Delete
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Get things rolling
[41] Fix | Delete
*
[42] Fix | Delete
* @since 2.8
[43] Fix | Delete
* @return void
[44] Fix | Delete
*/
[45] Fix | Delete
function __construct( $id ) {
[46] Fix | Delete
$this->id = $id;
[47] Fix | Delete
$this->type = nf_get_object_meta_value( $id, 'type' );
[48] Fix | Delete
$this->active = ( nf_get_object_meta_value( $id, 'active' ) == 1 ) ? true : false;
[49] Fix | Delete
$this->form_id = nf_get_object_parent( $id );
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* Ouptut our admin screen
[54] Fix | Delete
*
[55] Fix | Delete
* @access public
[56] Fix | Delete
* @since 2.8
[57] Fix | Delete
* @return void
[58] Fix | Delete
*/
[59] Fix | Delete
public function edit_screen() {
[60] Fix | Delete
$type = $this->type;
[61] Fix | Delete
// Call our type edit screen.
[62] Fix | Delete
Ninja_Forms()->notification_types[ $type ]->edit_screen( $this->id );
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Delete our notification
[67] Fix | Delete
*
[68] Fix | Delete
* @access public
[69] Fix | Delete
* @since 2.8
[70] Fix | Delete
* @return void
[71] Fix | Delete
*/
[72] Fix | Delete
public function delete() {
[73] Fix | Delete
nf_delete_notification( $this->id );
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Activate our notification
[78] Fix | Delete
*
[79] Fix | Delete
* @access public
[80] Fix | Delete
* @since 2.8
[81] Fix | Delete
* @return void
[82] Fix | Delete
*/
[83] Fix | Delete
public function activate() {
[84] Fix | Delete
nf_update_object_meta( $this->id, 'active', 1 );
[85] Fix | Delete
$this->active = true;
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Deactivate our notification
[90] Fix | Delete
*
[91] Fix | Delete
* @access public
[92] Fix | Delete
* @since 2.8
[93] Fix | Delete
* @return void
[94] Fix | Delete
*/
[95] Fix | Delete
public function deactivate() {
[96] Fix | Delete
nf_update_object_meta( $this->id, 'active', 0 );
[97] Fix | Delete
$this->active = false;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Duplicate our notification
[102] Fix | Delete
*
[103] Fix | Delete
* @access public
[104] Fix | Delete
* @since 2.8
[105] Fix | Delete
* @return int $n_id
[106] Fix | Delete
*/
[107] Fix | Delete
public function duplicate() {
[108] Fix | Delete
$n_id = Ninja_Forms()->notifications->create( $this->form_id );
[109] Fix | Delete
$meta = nf_get_notification_by_id( $this->id );
[110] Fix | Delete
foreach ( $meta as $meta_key => $meta_value ) {
[111] Fix | Delete
nf_update_object_meta( $n_id, $meta_key, $meta_value );
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
$name = nf_get_object_meta_value( $n_id, 'name' ) . ' - ' . __( 'duplicate', 'ninja-forms' );
[115] Fix | Delete
nf_update_object_meta( $n_id, 'name', $name );
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* Run our notification processing function
[120] Fix | Delete
*
[121] Fix | Delete
* @access public
[122] Fix | Delete
* @since 2.8
[123] Fix | Delete
* @return void
[124] Fix | Delete
*/
[125] Fix | Delete
public function process() {
[126] Fix | Delete
$type = $this->type;
[127] Fix | Delete
if ( isset ( Ninja_Forms()->notification_types[ $type ] ) && is_object( Ninja_Forms()->notification_types[ $type ] ) ) {
[128] Fix | Delete
Ninja_Forms()->notification_types[ $type ]->process( $this->id );
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* Get a notification setting
[134] Fix | Delete
*
[135] Fix | Delete
* @access public
[136] Fix | Delete
* @since 2.8
[137] Fix | Delete
* @return string $meta_value
[138] Fix | Delete
*/
[139] Fix | Delete
public function get_setting( $meta_key ) {
[140] Fix | Delete
return nf_get_object_meta_value( $this->id, $meta_key );
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* Update a notification setting
[145] Fix | Delete
*
[146] Fix | Delete
* @access public
[147] Fix | Delete
* @since 2.8
[148] Fix | Delete
* @return bool
[149] Fix | Delete
*/
[150] Fix | Delete
public function update_setting( $meta_key, $meta_value ) {
[151] Fix | Delete
nf_update_object_meta( $this->id, $meta_key, $meta_value );
[152] Fix | Delete
return true;
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
/**
[156] Fix | Delete
* Get our notification type name
[157] Fix | Delete
*
[158] Fix | Delete
* @access public
[159] Fix | Delete
* @since 2.9
[160] Fix | Delete
* @return string $name
[161] Fix | Delete
*/
[162] Fix | Delete
public function type_name() {
[163] Fix | Delete
$type = $this->type;
[164] Fix | Delete
// Call our type edit screen.
[165] Fix | Delete
return Ninja_Forms()->notification_types[ $type ]->name;
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
}
[169] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function