wpsharks / comment-mail

A WordPress plugin enabling email subscriptions for comments.
http://comment-mail.com
GNU General Public License v3.0
8 stars 3 forks source link

Add subInserter() to API #290

Open raamdev opened 8 years ago

raamdev commented 8 years ago

Right now the SubInserter() method can be used from anywhere outside of the plugin itself like this:

<?php
use WebSharks\CommentMail\Pro\SubInserter;

$sub_insert_data = array(
  'post_id'        => 123,
  'status'         => 'subscribed',
  'deliver'        => 'asap',
  'fname'          => 'John',
  'email'          => 'john@example.com',
);
$SubInserter = new SubInserter($sub_insert_data); // Inserts new subscriber.

if ($SubInserter->hasErrors()) {
    print_r($SubInserter->errors());
    //print_r($SubInserter->errorCodes());
    //print_r($SubInserter->errorsHtml());
}

It would nice if we updated the API class and added a new method that was designed to create a new class instance via the API call instead.

public static function subInserter($data, $args = [])
    {
        return new SubInserter($data, $args);
    }

See docs for argument definitions: https://github.com/websharks/comment-mail-pro/blob/160618/src/includes/classes/SubInserter.php#L288