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

202 lines 8.5 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 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
99 $this->extension_classes = apply_filters( 'nx_extension_classes', $this->extension_classes );
100 foreach ($this->extension_classes as $extension) {
101 // initializing extension.
102 if(class_exists($extension)){
103 $obj = $extension::get_instance();
104 if(Modules::get_instance()->is_enabled($obj->module)){
105 $this->add($obj);
106 }
107 }
108 }
109 }
110
111 /**
112 * This function is responsible for adding an extension to the extensions array!
113 *
114 * @param array $extensions
115 * @param string $classname
116 * @return void
117 */
118 protected function add( $extension) {
119 $this->extensions[ $extension->id ] = $extension;
120 $this->types[$extension->types][ $extension->id ] = $extension;
121 return $this->extensions;
122 }
123
124 /**
125 * Get Extensions data
126 *
127 * @param Extension $extension The notifications type.
128 * @param array $args Settings arguments for notificationx.
129 * @return array
130 */
131 public static function getExtension( Extension $extension, $args = array() ){
132 return $extension->get_data( $args );
133 }
134
135 /**
136 * This function is responsible for getting the extension from loaded extension.
137 *
138 * @param string $key
139 * @return Extension
140 */
141 public function get( $key ){
142 if( empty( $key ) ) {
143 return false;
144 }
145 try {
146 $class = $this->extension_classes[$key];
147 if(class_exists($class)){
148 return $class::get_instance();
149 }
150 }
151 catch (\Exception $e) {
152
153 }
154 return isset( $this->extensions[ $key ] ) ? $this->extensions[ $key ] : false;
155 }
156
157 /**
158 * This function is responsible for getting the extension from loaded extension.
159 *
160 * @param string $key
161 * @return array|bool
162 */
163 public function get_type( $type ){
164 if( empty( $type ) ) {
165 return false;
166 }
167 return isset( $this->types[ $type ] ) ? $this->types[ $type ] : false;
168 }
169
170 /**
171 * This function is responsible for getting the extension from loaded extension.
172 *
173 * @param string $key
174 * @return array
175 */
176 public function get_themes_for_type( $type ){
177 $themes = [];
178
179 $extensions = $this->get_type($type);
180
181 if(is_array($extensions)){
182 foreach($extensions as $extension){
183 if(!$extension->exclude_custom_themes){
184 $themes = array_merge($themes, $extension->get_themes_name());
185 }
186 }
187 }
188
189 return array_unique($themes);
190 }
191
192 /**
193 * This function is responsible for getting the extension from loaded extension.
194 *
195 * @param string $key
196 * @return bool|void
197 */
198 public function get_all(){
199 return $this->extensions;
200 }
201 }
202