: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
<?php if ( ! defined( 'ABSPATH' ) ) exit;
* Class NF_Abstracts_ActionNewsletter
abstract class NF_Abstracts_ActionNewsletter extends NF_Abstracts_Action
protected $_tags = array( 'newsletter' );
protected $_timing = 'normal';
protected $_priority = '10';
protected $_settings = array();
protected $_transient = '';
protected $_transient_expiration = '';
protected $_setting_labels = array(
'fields' => 'List Field Mapping',
'groups' => 'Interest Groups',
public function __construct()
if( ! $this->_transient ){
$this->_transient = $this->get_name() . '_newsletter_lists';
* Ajax call handled in '_get_lists', but bulk of work could be done in
* the NewsLetter class that extends this class
add_action( 'wp_ajax_nf_' . $this->_name . '_get_lists', array( $this, '_get_lists' ) );
$this->get_list_settings();
public function save( $action_settings )
public function process( $action_settings, $form_id, $data )
public function _get_lists()
check_ajax_referer( 'ninja_forms_builder_nonce', 'security' );
$lists = $this->get_lists();
array_unshift( $lists, array( 'value' => 0, 'label' => '-', 'fields' => array(), 'groups' => array() ) );
$this->cache_lists( $lists );
echo wp_json_encode( array( 'lists' => $lists ) );
wp_die(); // this is required to terminate immediately and return a proper response
abstract protected function get_lists();
private function get_list_settings()
'fields' => 'List Field Mapping',
'groups' => 'Interest Groups',
$labels = array_merge( $label_defaults, $this->_setting_labels );
$prefix = $this->get_name();
$lists = get_transient( $this->_transient );
$lists = $this->get_lists();
$this->cache_lists( $lists );
if( empty( $lists ) ) return;
$this->_settings[ $prefix . 'newsletter_list' ] = array(
'name' => 'newsletter_list',
'label' => $labels[ 'list' ] . ' <a class="js-newsletter-list-update extra"><span class="dashicons dashicons-update"></span></a>',
foreach( $lists as $list ) {
$this->_settings[ $prefix . 'newsletter_list' ][ 'options' ][] = $list;
//Check to see if list has fields array set.
if ( isset( $list[ 'fields' ] ) ) {
foreach ( $list[ 'fields' ] as $field ) {
$name = $list[ 'value' ] . '_' . $field[ 'value' ];
'label' => $field[ 'label' ],
'use_merge_tags' => array(
'user', 'post', 'system', 'querystrings'
$this->_settings[ $prefix . 'newsletter_list_fields' ] = array(
'name' => 'newsletter_list_fields',
'label' => esc_html__( 'List Field Mapping', 'ninja-forms' ),
$this->_settings[ $prefix . 'newsletter_list_groups' ] = array(
'name' => 'newsletter_list_groups',
'label' => esc_html__( 'Interest Groups', 'ninja-forms' ),
private function cache_lists( $lists )
set_transient( $this->_transient, $lists, $this->_transient_expiration );