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 / Notifications.php

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

99 lines 2.5 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 /**
6 * Notification Class
7 */
8 class Notifications {
9
10 /**
11 * Option key to hold the notifications
12 */
13 const OPTION_KEY = 'texty_notifications';
14
15 /**
16 * Notifications
17 *
18 * @var array
19 */
20 private $notifications = [];
21
22 /**
23 * Get a notification class
24 *
25 * @param string $key
26 *
27 * @return false|string
28 */
29 public function get( $key ) {
30 $notifications = $this->all();
31
32 if ( array_key_exists( $key, $notifications ) ) {
33 return $notifications[ $key ];
34 }
35
36 return false;
37 }
38
39 /**
40 * Get available notification classes
41 *
42 * @return array
43 */
44 public function all() {
45 if ( $this->notifications ) {
46 return $this->notifications;
47 }
48
49 $notifications = [
50 'registration' => __NAMESPACE__ . '\Notifications\Registration',
51 'comment' => __NAMESPACE__ . '\Notifications\Comment',
52 ];
53
54 if ( class_exists( 'WooCommerce' ) ) {
55 // WC Admin
56 $notifications['order_admin_processing'] = __NAMESPACE__ . '\Notifications\OrderProcessingAdmin';
57 $notifications['order_admin_complete'] = __NAMESPACE__ . '\Notifications\OrderCompleteAdmin';
58
59 // WC Customers
60 $notifications['order_customer_hold'] = __NAMESPACE__ . '\Notifications\OrderHoldCustomer';
61 $notifications['order_customer_processing'] = __NAMESPACE__ . '\Notifications\OrderProcessingCustomer';
62 $notifications['order_customer_complete'] = __NAMESPACE__ . '\Notifications\OrderCompleteCustomer';
63 }
64
65 $this->notifications = apply_filters( 'texty_available_notifications', $notifications );
66
67 return $this->notifications;
68 }
69
70 /**
71 * Get the name of the groups
72 *
73 * @return void
74 */
75 public function get_groups() {
76 return apply_filters( 'texty_notification_groups', [ // phpcs:ignore
77 'wp' => [
78 'title' => __( 'WordPress', 'texty' ),
79 'description' => '',
80 'available' => true,
81 ],
82 'wc' => [
83 'title' => __( 'WooCommerce', 'texty' ),
84 'description' => '',
85 'available' => class_exists( 'WooCommerce' ) ? true : false,
86 ],
87 ] ); // phpcs:ignore
88 }
89
90 /**
91 * Retreive all the settings
92 *
93 * @return array
94 */
95 public function settings() {
96 return get_option( self::OPTION_KEY, [] );
97 }
98 }
99