| 1 |
<?php |
| 2 |
|
| 3 |
namespace Texty; |
| 4 |
|
| 5 |
use Texty\Integrations\WooCommerce; |
| 6 |
|
| 7 |
/** |
| 8 |
* Dispatcher Class |
| 9 |
*/ |
| 10 |
class Dispatcher { |
| 11 |
|
| 12 |
/** |
| 13 |
* Initialize |
| 14 |
*/ |
| 15 |
public function __construct() { |
| 16 |
|
| 17 |
// WordPress Events |
| 18 |
add_action( 'user_register', [ $this, 'user_register' ] ); |
| 19 |
add_action( 'comment_post', [ $this, 'new_comment' ] ); |
| 20 |
|
| 21 |
// WooCommerce |
| 22 |
new WooCommerce(); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Send message upon user registration |
| 27 |
* |
| 28 |
* @param int $user_id |
| 29 |
* |
| 30 |
* @return void |
| 31 |
*/ |
| 32 |
public function user_register( $user_id ) { |
| 33 |
$class = texty()->notifications()->get( 'registration' ); |
| 34 |
$notifier = new $class(); |
| 35 |
|
| 36 |
$notifier->set_user( $user_id ); |
| 37 |
$notifier->send(); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Send message upon a new comment |
| 42 |
* |
| 43 |
* @param int $comment_id |
| 44 |
* |
| 45 |
* @return void |
| 46 |
*/ |
| 47 |
public function new_comment( $comment_id ) { |
| 48 |
$class = texty()->notifications()->get( 'comment' ); |
| 49 |
$notifier = new $class(); |
| 50 |
|
| 51 |
$notifier->set_comment( $comment_id ); |
| 52 |
$notifier->send(); |
| 53 |
} |
| 54 |
} |
| 55 |
|