PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.2.7
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.2.7
3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 All 156 releases
notificationx / includes / Types / TypesFactory.php

TypesFactory.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar 3.2.7, at includes/Types/TypesFactory.php

108 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Type Factory
4 *
5 * @package NotificationX\Types
6 */
7
8 namespace NotificationX\Types;
9 use NotificationX\GetInstance;
10
11 /**
12 * TypeFactory Class
13 * @method static TypeFactory get_instance($args = null)
14 */
15 class TypeFactory {
16 /**
17 * Instance of Admin
18 *
19 * @var Admin
20 */
21 use GetInstance;
22
23 public $types = [
24 'conversions' => 'NotificationX\Types\Conversions',
25 'woocommerce_sales' => 'NotificationX\Types\WooCommerceSales',
26 'comments' => 'NotificationX\Types\Comments',
27 'reviews' => 'NotificationX\Types\Reviews',
28 'download_stats' => 'NotificationX\Types\DownloadStats',
29 'elearning' => 'NotificationX\Types\ELearning',
30 'donation' => 'NotificationX\Types\Donations',
31 'notification_bar' => 'NotificationX\Types\NotificationBar',
32 'popup' => 'NotificationX\Types\Popup',
33 'form' => 'NotificationX\Types\ContactForm',
34 'email_subscription' => 'NotificationX\Types\EmailSubscription',
35 'exit_intent' => 'NotificationX\Types\ExitIntent',
36 'page_analytics' => 'NotificationX\Types\PageAnalytics',
37 'custom' => 'NotificationX\Types\CustomNotification',
38 'inline' => 'NotificationX\Types\Inline',
39 'flashing_tab' => 'NotificationX\Types\FlashingTab',
40 'video' => 'NotificationX\Types\Video',
41 'offer_announcement' => 'NotificationX\Types\OfferAnnouncement',
42 'gdpr' => 'NotificationX\Types\GDPR',
43 ];
44
45 public $types_enabled = [];
46
47 /**
48 * Initially Invoked when initialized.
49 */
50 public function __construct(){
51 $this->types = apply_filters( 'nx_types_classes', $this->types );
52
53 }
54
55 /**
56 * Registers a type.
57 *
58 * @param string $id
59 * @return mixed
60 */
61 public function register_types($id){
62 if(!isset($this->types_enabled[$id]) && isset($this->types[$id])){
63 $type_class = $this->types[$id];
64 $obj = $type_class::get_instance();
65 return $this->add($obj);
66 }
67 return false;
68 }
69
70 /**
71 * Enable a type.
72 *
73 * @param Type $types
74 * @return Type
75 */
76 protected function add( $type) {
77 $this->types_enabled[ $type->id ] = $type;
78 return $type;
79 }
80
81 /**
82 * This function is responsible for getting the type from loaded type.
83 *
84 * @param string $key
85 * @return Types
86 */
87 public function get( $key ){
88 if( empty( $key ) ) {
89 return false;
90 }
91 if(isset($this->types_enabled[$key])){
92 return isset( $this->types_enabled[ $key ] ) ? $this->types_enabled[ $key ] : false;
93 }
94 else if(isset( $this->types[ $key ] ) && $type_class = $this->types[ $key ]){
95 return $type_class::get_instance();
96 }
97 }
98
99 /**
100 * Get all enabled types.
101 *
102 * @return array
103 */
104 public function get_all(){
105 return $this->types_enabled;
106 }
107 }
108