PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.2.11
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.2.11
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 / Extensions / ExtensionFactory.php

ExtensionFactory.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar 3.2.11, at includes/Extensions/ExtensionFactory.php

201 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Extension Factory
4 *
5 * @package NotificationX\Extensions
6 */
7
8 namespace NotificationX\Extensions;
9
10 use Exception;
11 use NotificationX\Core\Database;
12 use NotificationX\GetInstance;
13 use NotificationX\Core\Modules;
14
15 /**
16 * ExtensionFactory Class
17 *
18 * @method static ExtensionFactory get_instance($args = null)
19 */
20 class ExtensionFactory {
21 /**
22 * Instance of Admin
23 *
24 * @var Admin
25 */
26 use GetInstance;
27
28 public $active_items;
29 public $types = [];
30 public $extensions = [];
31 public $extension_classes = [
32 'woo_inline' => 'NotificationX\Extensions\WooCommerce\WooInline',
33 'edd_inline' => 'NotificationX\Extensions\EDD\EDDInline',
34 'tutor_inline' => 'NotificationX\Extensions\Tutor\TutorInline',
35 'learndash_inline' => 'NotificationX\Extensions\LearnDash\LearnDashInline',
36 'learnpress_inline' => 'NotificationX\Extensions\LearnPress\LearnPressInline',
37 'cf7' => 'NotificationX\Extensions\CF7\CF7',
38 'convertkit' => 'NotificationX\Extensions\ConvertKit\ConvertKit',
39 'custom_notification' => 'NotificationX\Extensions\CustomNotification\CustomNotification',
40 'custom_notification_conversions' => 'NotificationX\Extensions\CustomNotification\CustomNotificationConversions',
41 'announcements' => 'NotificationX\Extensions\OfferAnnouncement\Announcements',
42 'edd' => 'NotificationX\Extensions\EDD\EDD',
43 'envato' => 'NotificationX\Extensions\Envato\Envato',
44 'freemius_conversions' => 'NotificationX\Extensions\Freemius\FreemiusConversions',
45 'freemius_reviews' => 'NotificationX\Extensions\Freemius\FreemiusReviews',
46 'freemius_stats' => 'NotificationX\Extensions\Freemius\FreemiusStats',
47 'grvf' => 'NotificationX\Extensions\GRVF\GravityForms',
48 'give' => 'NotificationX\Extensions\Give\Give',
49 'google' => 'NotificationX\Extensions\Google_Analytics\Google_Analytics',
50 'google_reviews' => 'NotificationX\Extensions\Google\GoogleReviews',
51 'learndash' => 'NotificationX\Extensions\LearnDash\LearnDash',
52 'learnpress' => 'NotificationX\Extensions\LearnPress\LearnPress',
53 'mailchimp' => 'NotificationX\Extensions\MailChimp\MailChimp',
54 'njf' => 'NotificationX\Extensions\NJF\NinjaForms',
55 'press_bar' => 'NotificationX\Extensions\PressBar\PressBar',
56 'tutor' => 'NotificationX\Extensions\Tutor\Tutor',
57 'wpf' => 'NotificationX\Extensions\WPF\WPForms',
58 'reviewx' => 'NotificationX\Extensions\ReviewX\ReviewX',
59 'woocommerce' => 'NotificationX\Extensions\WooCommerce\WooCommerce',
60 'woocommerce_sales' => 'NotificationX\Extensions\WooCommerce\WooCommerceSales',
61 'woocommerce_sales_reviews' => 'NotificationX\Extensions\WooCommerce\WooCommerceSalesReviews',
62 'woocommerce_sales_inline' => 'NotificationX\Extensions\WooCommerce\WooCommerceSalesInline',
63 'woo_reviews' => 'NotificationX\Extensions\WooCommerce\WooReviews',
64 'wp_comments' => 'NotificationX\Extensions\WordPress\WPComments',
65 'wp_reviews' => 'NotificationX\Extensions\WordPress\WPOrgReview',
66 'wp_stats' => 'NotificationX\Extensions\WordPress\WPOrgStats',
67 'zapier_conversions' => 'NotificationX\Extensions\Zapier\ZapierConversions',
68 'zapier_email_subscription' => 'NotificationX\Extensions\Zapier\ZapierEmailSubscription',
69 'zapier_reviews' => 'NotificationX\Extensions\Zapier\ZapierReviews',
70 'exit_intent_custom' => 'NotificationX\Extensions\ExitIntent\ExitIntentNotification',
71 'elementor_form' => 'NotificationX\Extensions\Elementor\From',
72 'flashing_tab' => 'NotificationX\Extensions\FlashingTab\FlashingTab',
73 'fluentform' => 'NotificationX\Extensions\FluentForm\FluentForm',
74 'youtube' => 'NotificationX\Extensions\Google\YouTube',
75 'vimeo' => 'NotificationX\Extensions\Vimeo\Vimeo',
76 'wistia' => 'NotificationX\Extensions\Wistia\Wistia',
77 'surecart' => 'NotificationX\Extensions\SureCart\SureCart',
78 'ActiveCampaign' => 'NotificationX\Extensions\ActiveCampaign\ActiveCampaign',
79 'popup_notification' => 'NotificationX\Extensions\Popup\PopupNotification',
80 'fluentcart' => 'NotificationX\Extensions\FluentCart\FluentCart',
81 'fluentcart_inline' => 'NotificationX\Extensions\FluentCart\FluentCartInline',
82 'gdpr_notification' => 'NotificationX\Extensions\GDPR\GDPR_Notification',
83 'ccpa_notification' => 'NotificationX\Extensions\CCPA\CCPA_Notification',
84 'bitintegrations_conversions' => 'NotificationX\Extensions\BitIntegrations\BitIntegrationsConversions',
85 'bitintegrations_email_subscription' => 'NotificationX\Extensions\BitIntegrations\BitIntegrationsEmailSubscription',
86 'bitintegrations_reviews' => 'NotificationX\Extensions\BitIntegrations\BitIntegrtionsReviews',
87 ];
88
89 /**
90 * Initially Invoked when initialized.
91 */
92 public function __construct(){
93 // GlobalFields::get_instance();
94 $this->register_extensions();
95 }
96
97 public function register_extensions(){
98 $this->extension_classes = apply_filters( 'nx_extension_classes', $this->extension_classes );
99 foreach ($this->extension_classes as $extension) {
100 // initializing extension.
101 if(class_exists($extension)){
102 $obj = $extension::get_instance();
103 if(Modules::get_instance()->is_enabled($obj->module)){
104 $this->add($obj);
105 }
106 }
107 }
108 }
109
110 /**
111 * This function is responsible for adding an extension to the extensions array!
112 *
113 * @param array $extensions
114 * @param string $classname
115 * @return void
116 */
117 protected function add( $extension) {
118 $this->extensions[ $extension->id ] = $extension;
119 $this->types[$extension->types][ $extension->id ] = $extension;
120 return $this->extensions;
121 }
122
123 /**
124 * Get Extensions data
125 *
126 * @param Extension $extension The notifications type.
127 * @param array $args Settings arguments for notificationx.
128 * @return array
129 */
130 public static function getExtension( Extension $extension, $args = array() ){
131 return $extension->get_data( $args );
132 }
133
134 /**
135 * This function is responsible for getting the extension from loaded extension.
136 *
137 * @param string $key
138 * @return Extension
139 */
140 public function get( $key ){
141 if( empty( $key ) ) {
142 return false;
143 }
144 try {
145 $class = $this->extension_classes[$key];
146 if(class_exists($class)){
147 return $class::get_instance();
148 }
149 }
150 catch (\Exception $e) {
151
152 }
153 return isset( $this->extensions[ $key ] ) ? $this->extensions[ $key ] : false;
154 }
155
156 /**
157 * This function is responsible for getting the extension from loaded extension.
158 *
159 * @param string $key
160 * @return array|bool
161 */
162 public function get_type( $type ){
163 if( empty( $type ) ) {
164 return false;
165 }
166 return isset( $this->types[ $type ] ) ? $this->types[ $type ] : false;
167 }
168
169 /**
170 * This function is responsible for getting the extension from loaded extension.
171 *
172 * @param string $key
173 * @return array
174 */
175 public function get_themes_for_type( $type ){
176 $themes = [];
177
178 $extensions = $this->get_type($type);
179
180 if(is_array($extensions)){
181 foreach($extensions as $extension){
182 if(!$extension->exclude_custom_themes){
183 $themes = array_merge($themes, $extension->get_themes_name());
184 }
185 }
186 }
187
188 return array_unique($themes);
189 }
190
191 /**
192 * This function is responsible for getting the extension from loaded extension.
193 *
194 * @param string $key
195 * @return bool|void
196 */
197 public function get_all(){
198 return $this->extensions;
199 }
200 }
201