: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Wrapper for MailerLite's API.
* @package ET\Core\API\Email
class ET_Core_API_Email_MailerLite extends ET_Core_API_Email_Provider {
public $BASE_URL = 'https://api.mailerlite.com/api/v2';
public $FIELDS_URL = 'https://api.mailerlite.com/api/v2/fields';
public $LISTS_URL = 'https://api.mailerlite.com/api/v2/groups';
public $custom_fields_scope = 'account';
public $name = 'MailerLite';
public $slug = 'mailerlite';
* @internal If true, oauth endpoints properties must also be defined.
public $uses_oauth = false;
public function __construct( $owner = '', $account_name = '', $api_key = '' ) {
parent::__construct( $owner, $account_name, $api_key );
$this->_maybe_set_custom_headers();
protected function _maybe_set_custom_headers() {
if ( empty( $this->custom_headers ) && isset( $this->data['api_key'] ) ) {
$this->custom_headers = array( 'X-MailerLite-ApiKey' => "{$this->data['api_key']}" );
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 );
if ( count( $value ) > 1 ) {
$value = implode( ',', $value );
$value = array_pop( $value );
self::$_->array_set( $args, "fields.{$field_id}", $value );
public function get_account_fields() {
'label' => esc_html__( 'API Key', 'et_core' ),
public function get_data_keymap( $keymap = array() ) {
'subscribers_count' => 'active',
'last_name' => 'fields.last_name',
'custom_fields' => 'custom_fields',
'error_message' => 'error.message',
return parent::get_data_keymap( $keymap );
public function fetch_subscriber_lists() {
if ( empty( $this->data['api_key'] ) ) {
return $this->API_KEY_REQUIRED;
$this->_maybe_set_custom_headers();
$this->response_data_key = false;
return parent::fetch_subscriber_lists();
public function subscribe( $args, $url = '' ) {
$url = "{$this->LISTS_URL}/{$args['list_id']}/subscribers";
return parent::subscribe( $args, $url );