: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Wrapper for Emma's API.
* @package ET\Core\API\Email
class ET_Core_API_Email_Emma extends ET_Core_API_Email_Provider {
public $BASE_URL = 'https://api.e2ma.net';
public $custom_fields_scope = 'account';
public $http_auth = array(
'password' => 'private_api_key',
protected function _fetch_custom_fields( $list_id = '', $list = array() ) {
$this->response_data_key = false;
$this->prepare_request( $this->_get_custom_fields_url() );
return parent::_fetch_custom_fields( $list_id, $list );
protected function _get_custom_fields_url() {
return "https://api.e2ma.net/{$this->data['user_id']}/fields?group_types=all";
protected function _get_lists_url() {
return "https://api.e2ma.net/{$this->data['user_id']}/groups?group_types=all";
protected function _get_subscribe_url() {
return "https://api.e2ma.net/{$this->data['user_id']}/members/signup";
protected function _process_custom_fields( $args ) {
if ( ! isset( $args['custom_fields'] ) ) {
$fields = $args['custom_fields'];
unset( $args['custom_fields'] );
foreach ( $fields as $field_id => $value ) {
if ( is_array( $value ) && $value ) {
// This is a multiple choice field (eg. checkbox, radio, select)
$value = array_values( $value );
self::$_->array_set( $args, "fields.{$field_id}", $value );
public function get_account_fields() {
'label' => esc_html__( 'Public API Key', 'et_core' ),
'private_api_key' => array(
'label' => esc_html__( 'Private API Key', 'et_core' ),
'label' => esc_html__( 'Account ID', 'et_core' ),
public function get_data_keymap( $keymap = array() ) {
'list_id' => 'member_group_id',
'subscribers_count' => 'active_count',
'name' => 'fields.first_name',
'last_name' => 'fields.last_name',
'list_id' => '@group_ids',
'custom_fields' => 'custom_fields',
'field_id' => 'shortcut_name',
'name' => 'display_name',
'custom_field_type' => array(
'select' => 'select one',
'checkbox' => 'check_multiple',
'check_multiple' => 'checkbox',
'select one' => 'select',
return parent::get_data_keymap( $keymap );
public function fetch_subscriber_lists() {
if ( empty( $this->data['api_key'] ) ) {
return $this->API_KEY_REQUIRED;
$this->LISTS_URL = $this->_get_lists_url();
$this->response_data_key = false;
return parent::fetch_subscriber_lists();
public function subscribe( $args, $url = '' ) {
$url = $this->_get_subscribe_url();
$this->response_data_key = 'member_id';
$args = $this->transform_data_to_provider_format( $args, 'subscriber' );
$args = $this->_process_custom_fields( $args );
$this->prepare_request( $url, 'POST', false, $args, true );
return parent::subscribe( $args, $url );