PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 3.19.3
GiveWP – Donation Plugin and Fundraising Platform v3.19.3
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / src / ServiceProviders / LegacyServiceProvider.php
give / src / ServiceProviders Last commit date
Exceptions 3 years ago GlobalStyles.php 3 years ago LegacyServiceProvider.php 1 year ago Onboarding.php 3 years ago PaymentGateways.php 2 years ago RequestType.php 3 years ago RestAPI.php 3 years ago Routes.php 4 years ago ServiceProvider.php 4 years ago
LegacyServiceProvider.php
268 lines
1 <?php
2
3 namespace Give\ServiceProviders;
4
5 use Closure;
6 use Give\PaymentGateways\Gateways\Stripe\LegacyStripeAdapter;
7 use Give\Route\Form;
8
9 /**
10 * Class LegacyServiceProvider
11 *
12 * This handles the loading of all of the legacy codebase included in the /includes directory.
13 * DO NOT EXTEND THIS WITH NEW CODE as it is intended to shrink over time as we migrate over
14 * to the new ways of doing things.
15 */
16 class LegacyServiceProvider implements ServiceProvider
17 {
18 /**
19 * @inheritDoc
20 */
21 public function register()
22 {
23 // TODO: move this
24 // this needs to load before the LegacyServiceProvider loads in GiveWP.
25 give(LegacyStripeAdapter::class)->addToStripeSupportedPaymentMethodsList();
26
27 $this->includeLegacyFiles();
28 $this->bindClasses();
29 }
30
31 /**
32 * @inheritDoc
33 */
34 public function boot()
35 {
36 }
37
38 /**
39 * Load all the legacy class files since they don't have auto-loading
40 *
41 * @since 3.1.2 remove WP_Background_Process & WP_Async_Request in favor of namespaced versions.
42 * @since 3.0.0 remove the manual (Test Donations) gateway from loading in favor of the new Test Donations gateway
43 * @since 2.8.0
44 */
45 private function includeLegacyFiles()
46 {
47 global $give_options;
48
49 require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache-setting.php';
50
51 require_once GIVE_PLUGIN_DIR . 'includes/setting-functions.php';
52 require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
53 require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
54 require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
55 require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
56 require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
57 require_once GIVE_PLUGIN_DIR . 'includes/currency-functions.php';
58 require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
59 require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
60 require_once GIVE_PLUGIN_DIR . 'includes/donors/frontend-donor-functions.php';
61 require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
62 require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
63
64 /**
65 * Load plugin files
66 */
67 require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
68 $give_options = give_get_settings();
69
70 require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
71 require_once GIVE_PLUGIN_DIR . 'includes/class-give-async-process.php';
72 require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
73 require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
74 require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
75 require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-v2.php';
76 require_once GIVE_PLUGIN_DIR . 'includes/class-give-tooltips.php';
77 require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php';
78 require_once GIVE_PLUGIN_DIR . 'includes/class-give-translation.php';
79 require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
80 require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-html-elements.php';
81
82 require_once GIVE_PLUGIN_DIR . 'includes/class-give-scripts.php';
83 require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
84 require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
85
86 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db.php';
87 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-meta.php';
88 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-comments.php';
89 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-comments-meta.php';
90 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-donors.php';
91 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-donor-meta.php';
92 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-form-meta.php';
93 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-sequential-ordering.php';
94 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-sessions.php';
95 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-payment-meta.php';
96
97 require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php';
98 require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
99 require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
100 require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
101 require_once GIVE_PLUGIN_DIR . 'includes/class-give-comment.php';
102
103 require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
104 require_once GIVE_PLUGIN_DIR . 'includes/forms/class-give-forms-query.php';
105 require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
106 require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
107 require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
108 require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
109 require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
110 require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
111 require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php';
112 require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
113 require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
114 require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
115
116 require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
117 require_once GIVE_PLUGIN_DIR . 'includes/payments/backward-compatibility.php';
118 require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
119 require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
120 require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
121 require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
122 require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-sequential-donation-number.php';
123
124 require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
125 require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal/paypal-standard.php';
126 require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
127 require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
128 require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
129 require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notifications.php';
130 require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
131 require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
132 require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
133
134 require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donors-query.php';
135 require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donor-wall.php';
136 require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donor-stats.php';
137 require_once GIVE_PLUGIN_DIR . 'includes/donors/backward-compatibility.php';
138 require_once GIVE_PLUGIN_DIR . 'includes/donors/actions.php';
139
140 require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php';
141
142 require_once GIVE_PLUGIN_DIR . 'blocks/load.php';
143
144 // Include Views
145 require_once GIVE_PLUGIN_DIR . 'src/Views/Views.php';
146
147 if (defined('WP_CLI') && WP_CLI) {
148 require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
149 }
150
151 // Load file for frontend
152 if ($this->is_request('frontend')) {
153 require_once GIVE_PLUGIN_DIR . 'includes/frontend/class-give-frontend.php';
154 }
155
156 if ($this->is_request('admin') || $this->is_request('wpcli')) {
157 require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-admin.php';
158 }// End if().
159
160 require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
161 require_once GIVE_PLUGIN_DIR . 'includes/install.php';
162
163 // This conditional check will add backward compatibility to older Stripe versions (i.e. < 2.2.0) when used with Give 2.5.0.
164 if (
165 !defined('GIVE_STRIPE_VERSION') ||
166 (
167 defined('GIVE_STRIPE_VERSION') &&
168 version_compare(GIVE_STRIPE_VERSION, '2.2.0', '>=')
169 )
170 ) {
171 require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/class-give-stripe.php';
172 }
173 }
174
175 /**
176 * Binds the legacy classes to the service provider
177 *
178 * @since 2.19.6 - remove donors in favor of DonorRepositoryProxy
179 *
180 * @since 2.8.0
181 */
182 private function bindClasses()
183 {
184 give()->singleton('routeForm', Form::class);
185
186 $this->bindInstance('roles', 'Give_Roles', 'class-give-roles.php');
187 $this->bindInstance('give_settings', 'Give_Admin_Settings', 'admin/class-admin-settings.php');
188 $this->bindInstance('api', 'Give_API', 'api/class-give-api.php');
189 $this->bindInstance('emails', 'Give_Emails', 'emails/class-give-emails.php');
190 $this->bindInstance('email_tags', 'Give_Email_Template_Tags', 'emails/class-give-email-tags.php');
191 $this->bindInstance('html', 'Give_HTML_Elements', 'admin/class-give-html-elements.php', true);
192 $this->bindInstance('donor_meta', 'Give_DB_Donor_Meta', 'database/class-give-db-donor-meta.php');
193 $this->bindInstance('tooltips', 'Give_Tooltips', 'class-give-tooltips.php');
194 $this->bindInstance('notices', 'Give_Notices', 'class-notices.php');
195 $this->bindInstance('payment_meta', 'Give_DB_Payment_Meta', 'database/class-give-db-payment-meta.php');
196 $this->bindInstance('logs', 'Give_Logging', 'class-give-logging.php');
197 $this->bindInstance('form_meta', 'Give_DB_Form_Meta', 'database/class-give-db-form-meta.php');
198 $this->bindInstance(
199 'sequential_donation_db',
200 'Give_DB_Sequential_Ordering',
201 'database/class-give-db-sequential-ordering.php'
202 );
203 $this->bindInstance('async_process', 'Give_Async_Process', 'class-give-async-process.php');
204 $this->bindInstance('scripts', 'Give_Scripts', 'class-give-scripts.php');
205 $this->bindInstance(
206 'seq_donation_number',
207 'Give_Sequential_Donation_Number',
208 'payments/class-give-sequential-donation-number.php',
209 true
210 );
211 $this->bindInstance('comment', 'Give_Comment', 'class-give-comment.php', true);
212 $this->bindInstance('session_db', 'Give_DB_Sessions', 'database/class-give-db-sessions.php');
213 $this->bindInstance('session', 'Give_Session', 'class-give-session.php', true);
214 }
215
216 /**
217 * A helper for loading legacy classes that do not use autoloading, then binding their instance
218 * to the container.
219 *
220 * @since 2.8.0
221 *
222 * @param string $alias
223 * @param string|Closure $class
224 * @param string $includesPath
225 * @param bool $singleton
226 */
227 private function bindInstance($alias, $class, $includesPath, $singleton = false)
228 {
229 require_once GIVE_PLUGIN_DIR . "includes/$includesPath";
230
231 if ($class instanceof Closure) {
232 give()->instance($alias, $class());
233 } elseif ($singleton) {
234 give()->instance($alias, $class::get_instance());
235 } else {
236 give()->instance($alias, new $class());
237 }
238 }
239
240 /**
241 * What type of request is this?
242 *
243 * @since 2.8.0
244 *
245 * @param string $type admin, ajax, cron or frontend.
246 *
247 * @return bool
248 * @throws UnknownRequestTypeException
249 */
250 private function is_request($type)
251 {
252 switch ($type) {
253 case RequestType::ADMIN:
254 return is_admin();
255 case RequestType::AJAX:
256 return defined('DOING_AJAX');
257 case RequestType::CRON:
258 return defined('DOING_CRON');
259 case RequestType::FRONTEND:
260 return (!is_admin() || defined('DOING_AJAX')) && !defined('DOING_CRON') && !defined('REST_REQUEST');
261 case RequestType::WPCLI:
262 return defined('WP_CLI') && WP_CLI;
263 default:
264 throw new UnknownRequestTypeException($type);
265 }
266 }
267 }
268