<?php if ( ! defined( 'ABSPATH' ) ) exit;
* Class NF_Abstracts_Action
abstract class NF_Abstracts_Action
protected $_nicename = '';
protected $_section = 'installed';
protected $_tags = array();
protected $_timing = 'normal';
protected $_priority = '10';
protected $_settings = array();
protected $_settings_all = array( 'label', 'active' );
protected $_settings_exclude = array();
protected $_settings_only = array();
public function __construct()
$this->_settings_all = apply_filters( 'ninja_forms_actions_settings_all', $this->_settings_all );
if( ! empty( $this->_settings_only ) ){
$this->_settings = array_merge( $this->_settings, $this->_settings_only );
$this->_settings = array_merge( $this->_settings_all, $this->_settings );
$this->_settings = array_diff( $this->_settings, $this->_settings_exclude );
$this->_settings = $this->load_settings( $this->_settings );
//-----------------------------------------------------
//-----------------------------------------------------
public function save( $action_settings )
// This section intentionally left blank.
public abstract function process( $action_id, $form_id, $data );
* Returns the timing for an action.
public function get_timing()
$timing = array( 'early' => -1, 'normal' => 0, 'late' => 1 );
return intval( $timing[ $this->_timing ] );
* Returns the priority for an action.
public function get_priority()
return intval( $this->_priority );
* Returns the name of an action.
public function get_name()
* Returns the nicename of an action.
public function get_nicename()
* Returns the drawer section for an action.
public function get_section()
* Returns the url of a branded action's image.
public function get_image()
* Returns the settings for an action.
public function get_settings()
* A static method for sorting two actions by timing, then priority.
public static function sort_actions( $a, $b )
if( ! isset( Ninja_Forms()->actions[ $a->get_setting( 'type' ) ] ) ) return 1;
if( ! isset( Ninja_Forms()->actions[ $b->get_setting( 'type' ) ] ) ) return 1;
$a->timing = Ninja_Forms()->actions[ $a->get_setting( 'type' ) ]->get_timing();
$a->priority = Ninja_Forms()->actions[ $a->get_setting( 'type' ) ]->get_priority();
$b->timing = Ninja_Forms()->actions[ $b->get_setting( 'type' ) ]->get_timing();
$b->priority = Ninja_Forms()->actions[ $b->get_setting( 'type' ) ]->get_priority();
// Compare Priority if Timing is the same
if( $a->timing == $b->timing)
return $a->priority > $b->priority ? 1 : -1;
return $a->timing < $b->timing ? 1 : -1;
protected function load_settings( $only_settings = array() )
// Loads a settings array from the FieldSettings configuration file.
$all_settings = Ninja_Forms::config( 'ActionSettings' );
foreach( $only_settings as $setting ){
if( isset( $all_settings[ $setting ]) ){
$settings[ $setting ] = $all_settings[ $setting ];
} // END CLASS NF_Abstracts_Action