Edit File by line
/home/barbar84/www/wp-conte.../plugins/ninja-fo.../includes/Abstract...
File: Action.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Class NF_Abstracts_Action
[3] Fix | Delete
*/
[4] Fix | Delete
abstract class NF_Abstracts_Action
[5] Fix | Delete
{
[6] Fix | Delete
/**
[7] Fix | Delete
* @var string
[8] Fix | Delete
*/
[9] Fix | Delete
protected $_name = '';
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* @var string
[13] Fix | Delete
*/
[14] Fix | Delete
protected $_nicename = '';
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* @var string
[18] Fix | Delete
*/
[19] Fix | Delete
protected $_section = 'installed';
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* @var string
[23] Fix | Delete
*/
[24] Fix | Delete
protected $_image = '';
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* @var array
[28] Fix | Delete
*/
[29] Fix | Delete
protected $_tags = array();
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* @var string
[33] Fix | Delete
*/
[34] Fix | Delete
protected $_timing = 'normal';
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* @var int
[38] Fix | Delete
*/
[39] Fix | Delete
protected $_priority = '10';
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* @var array
[43] Fix | Delete
*/
[44] Fix | Delete
protected $_settings = array();
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* @var array
[48] Fix | Delete
*/
[49] Fix | Delete
protected $_settings_all = array( 'label', 'active' );
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* @var array
[53] Fix | Delete
*/
[54] Fix | Delete
protected $_settings_exclude = array();
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* @var array
[58] Fix | Delete
*/
[59] Fix | Delete
protected $_settings_only = array();
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Constructor
[63] Fix | Delete
*/
[64] Fix | Delete
public function __construct()
[65] Fix | Delete
{
[66] Fix | Delete
$this->_settings_all = apply_filters( 'ninja_forms_actions_settings_all', $this->_settings_all );
[67] Fix | Delete
[68] Fix | Delete
if( ! empty( $this->_settings_only ) ){
[69] Fix | Delete
[70] Fix | Delete
$this->_settings = array_merge( $this->_settings, $this->_settings_only );
[71] Fix | Delete
} else {
[72] Fix | Delete
[73] Fix | Delete
$this->_settings = array_merge( $this->_settings_all, $this->_settings );
[74] Fix | Delete
$this->_settings = array_diff( $this->_settings, $this->_settings_exclude );
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
$this->_settings = $this->load_settings( $this->_settings );
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
//-----------------------------------------------------
[81] Fix | Delete
// Public Methods
[82] Fix | Delete
//-----------------------------------------------------
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Save
[86] Fix | Delete
*/
[87] Fix | Delete
public function save( $action_settings )
[88] Fix | Delete
{
[89] Fix | Delete
// This section intentionally left blank.
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Process
[94] Fix | Delete
*/
[95] Fix | Delete
public abstract function process( $action_id, $form_id, $data );
[96] Fix | Delete
[97] Fix | Delete
/**
[98] Fix | Delete
* Get Timing
[99] Fix | Delete
*
[100] Fix | Delete
* Returns the timing for an action.
[101] Fix | Delete
*
[102] Fix | Delete
* @return mixed
[103] Fix | Delete
*/
[104] Fix | Delete
public function get_timing()
[105] Fix | Delete
{
[106] Fix | Delete
$timing = array( 'early' => -1, 'normal' => 0, 'late' => 1 );
[107] Fix | Delete
[108] Fix | Delete
return intval( $timing[ $this->_timing ] );
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Get Priority
[113] Fix | Delete
*
[114] Fix | Delete
* Returns the priority for an action.
[115] Fix | Delete
*
[116] Fix | Delete
* @return int
[117] Fix | Delete
*/
[118] Fix | Delete
public function get_priority()
[119] Fix | Delete
{
[120] Fix | Delete
return intval( $this->_priority );
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* Get Name
[125] Fix | Delete
*
[126] Fix | Delete
* Returns the name of an action.
[127] Fix | Delete
*
[128] Fix | Delete
* @return string
[129] Fix | Delete
*/
[130] Fix | Delete
public function get_name()
[131] Fix | Delete
{
[132] Fix | Delete
return $this->_name;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
/**
[136] Fix | Delete
* Get Nicename
[137] Fix | Delete
*
[138] Fix | Delete
* Returns the nicename of an action.
[139] Fix | Delete
*
[140] Fix | Delete
* @return string
[141] Fix | Delete
*/
[142] Fix | Delete
public function get_nicename()
[143] Fix | Delete
{
[144] Fix | Delete
return $this->_nicename;
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* Get Section
[149] Fix | Delete
*
[150] Fix | Delete
* Returns the drawer section for an action.
[151] Fix | Delete
*
[152] Fix | Delete
* @return string
[153] Fix | Delete
*/
[154] Fix | Delete
public function get_section()
[155] Fix | Delete
{
[156] Fix | Delete
return $this->_section;
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
/**
[160] Fix | Delete
* Get Image
[161] Fix | Delete
*
[162] Fix | Delete
* Returns the url of a branded action's image.
[163] Fix | Delete
*
[164] Fix | Delete
* @return string
[165] Fix | Delete
*/
[166] Fix | Delete
public function get_image()
[167] Fix | Delete
{
[168] Fix | Delete
return $this->_image;
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* Get Settings
[173] Fix | Delete
*
[174] Fix | Delete
* Returns the settings for an action.
[175] Fix | Delete
*
[176] Fix | Delete
* @return array|mixed
[177] Fix | Delete
*/
[178] Fix | Delete
public function get_settings()
[179] Fix | Delete
{
[180] Fix | Delete
return $this->_settings;
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
/**
[184] Fix | Delete
* Sort Actions
[185] Fix | Delete
*
[186] Fix | Delete
* A static method for sorting two actions by timing, then priority.
[187] Fix | Delete
*
[188] Fix | Delete
* @param $a
[189] Fix | Delete
* @param $b
[190] Fix | Delete
* @return int
[191] Fix | Delete
*/
[192] Fix | Delete
public static function sort_actions( $a, $b )
[193] Fix | Delete
{
[194] Fix | Delete
if( ! isset( Ninja_Forms()->actions[ $a->get_setting( 'type' ) ] ) ) return 1;
[195] Fix | Delete
if( ! isset( Ninja_Forms()->actions[ $b->get_setting( 'type' ) ] ) ) return 1;
[196] Fix | Delete
[197] Fix | Delete
$a->timing = Ninja_Forms()->actions[ $a->get_setting( 'type' ) ]->get_timing();
[198] Fix | Delete
$a->priority = Ninja_Forms()->actions[ $a->get_setting( 'type' ) ]->get_priority();
[199] Fix | Delete
[200] Fix | Delete
$b->timing = Ninja_Forms()->actions[ $b->get_setting( 'type' ) ]->get_timing();
[201] Fix | Delete
$b->priority = Ninja_Forms()->actions[ $b->get_setting( 'type' ) ]->get_priority();
[202] Fix | Delete
[203] Fix | Delete
// Compare Priority if Timing is the same
[204] Fix | Delete
if( $a->timing == $b->timing)
[205] Fix | Delete
return $a->priority > $b->priority ? 1 : -1;
[206] Fix | Delete
[207] Fix | Delete
// Compare Timing
[208] Fix | Delete
return $a->timing < $b->timing ? 1 : -1;
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
protected function load_settings( $only_settings = array() )
[212] Fix | Delete
{
[213] Fix | Delete
$settings = array();
[214] Fix | Delete
[215] Fix | Delete
// Loads a settings array from the FieldSettings configuration file.
[216] Fix | Delete
$all_settings = Ninja_Forms::config( 'ActionSettings' );
[217] Fix | Delete
[218] Fix | Delete
foreach( $only_settings as $setting ){
[219] Fix | Delete
[220] Fix | Delete
if( isset( $all_settings[ $setting ]) ){
[221] Fix | Delete
[222] Fix | Delete
$settings[ $setting ] = $all_settings[ $setting ];
[223] Fix | Delete
}
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
return $settings;
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
} // END CLASS NF_Abstracts_Action
[230] Fix | Delete
[231] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function