PluginProbe
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more / 0.2
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more v0.2
2.0.2 trunk 0.2 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 2.0.0 2.0.1
texty / includes / Dispatcher.php

Dispatcher.php in Texty – SMS Notification for WordPress, WooCommerce, Dokan and more 0.2, at includes/Dispatcher.php

55 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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