PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.25.2
GiveWP – Donation Plugin and Fundraising Platform v2.25.2
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 / give.php
give Last commit date
assets 3 years ago blocks 3 years ago includes 3 years ago languages 3 years ago sample-data 6 years ago src 3 years ago templates 3 years ago vendor 3 years ago give.php 3 years ago license.txt 6 years ago readme.txt 3 years ago uninstall.php 3 years ago wpml-config.xml 6 years ago
give.php
547 lines
1 <?php
2
3 /**
4 * Plugin Name: Give - Donation Plugin
5 * Plugin URI: https://givewp.com
6 * Description: The most robust, flexible, and intuitive way to accept donations on WordPress.
7 * Author: GiveWP
8 * Author URI: https://givewp.com/
9 * Version: 2.25.2
10 * Requires at least: 5.0
11 * Requires PHP: 7.0
12 * Text Domain: give
13 * Domain Path: /languages
14 *
15 * Give is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * any later version.
19 *
20 * Give is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with Give. If not, see <https://www.gnu.org/licenses/>.
27 *
28 * A Tribute to Open Source:
29 *
30 * "Open source software is software that can be freely used, changed, and shared (in modified or unmodified form) by
31 * anyone. Open source software is made by many people, and distributed under licenses that comply with the Open Source
32 * Definition."
33 *
34 * -- The Open Source Initiative
35 *
36 * Give is a tribute to the spirit and philosophy of Open Source. We at GiveWP gladly embrace the Open Source
37 * philosophy both in how Give itself was developed, and how we hope to see others build more from our code base.
38 *
39 * Give would not have been possible without the tireless efforts of WordPress and the surrounding Open Source projects
40 * and their talented developers. Thank you all for your contribution to WordPress.
41 *
42 * - The GiveWP Team
43 */
44
45 use Give\Container\Container;
46 use Give\DonationForms\Repositories\DonationFormsRepository;
47 use Give\DonationForms\ServiceProvider as DonationFormsServiceProvider;
48 use Give\Donations\Repositories\DonationRepository;
49 use Give\Donations\ServiceProvider as DonationServiceProvider;
50 use Give\DonationSummary\ServiceProvider as DonationSummaryServiceProvider;
51 use Give\DonorDashboards\Profile;
52 use Give\DonorDashboards\ServiceProvider as DonorDashboardsServiceProvider;
53 use Give\DonorDashboards\Tabs\TabsRegister;
54 use Give\Donors\Repositories\DonorRepositoryProxy;
55 use Give\Donors\ServiceProvider as DonorsServiceProvider;
56 use Give\Form\LegacyConsumer\ServiceProvider as FormLegacyConsumerServiceProvider;
57 use Give\Form\Templates;
58 use Give\Framework\Database\ServiceProvider as DatabaseServiceProvider;
59 use Give\Framework\Exceptions\Primitives\InvalidArgumentException;
60 use Give\Framework\Exceptions\UncaughtExceptionLogger;
61 use Give\Framework\Http\ServiceProvider as HttpServiceProvider;
62 use Give\Framework\Migrations\MigrationsServiceProvider;
63 use Give\Framework\PaymentGateways\PaymentGatewayRegister;
64 use Give\Framework\ValidationRules\ValidationRulesServiceProvider;
65 use Give\Framework\WordPressShims\ServiceProvider as WordPressShimsServiceProvider;
66 use Give\LegacySubscriptions\ServiceProvider as LegacySubscriptionsServiceProvider;
67 use Give\License\LicenseServiceProvider;
68 use Give\Log\LogServiceProvider;
69 use Give\MigrationLog\MigrationLogServiceProvider;
70 use Give\MultiFormGoals\ServiceProvider as MultiFormGoalsServiceProvider;
71 use Give\PaymentGateways\ServiceProvider as PaymentGatewaysServiceProvider;
72 use Give\Promotions\ServiceProvider as PromotionsServiceProvider;
73 use Give\Revenue\RevenueServiceProvider;
74 use Give\Route\Form as FormRoute;
75 use Give\ServiceProviders\GlobalStyles as GlobalStylesServiceProvider;
76 use Give\ServiceProviders\LegacyServiceProvider;
77 use Give\ServiceProviders\Onboarding;
78 use Give\ServiceProviders\PaymentGateways;
79 use Give\ServiceProviders\RestAPI;
80 use Give\ServiceProviders\Routes;
81 use Give\ServiceProviders\ServiceProvider;
82 use Give\Subscriptions\Repositories\SubscriptionRepository;
83 use Give\Subscriptions\ServiceProvider as SubscriptionServiceProvider;
84 use Give\TestData\ServiceProvider as TestDataServiceProvider;
85 use Give\Tracking\TrackingServiceProvider;
86 use Give\VendorOverrides\Validation\ValidationServiceProvider;
87
88 // Exit if accessed directly.
89 if (!defined('ABSPATH')) {
90 exit;
91 }
92
93 /**
94 * Main Give Class
95 *
96 * @since 2.21.0 Remove php dependency validation logic and constant
97 * @since 2.19.6 add $donations, $subscriptions, and replace $donors class with DonorRepositoryProxy
98 * @since 2.8.0 build in a service container
99 * @since 1.0
100 *
101 * @property-read Give_API $api
102 * @property-read Give_Async_Process $async_process
103 * @property-read Give_Comment $comment
104 * @property-read Give_DB_Donor_Meta $donor_meta
105 * @property-read Give_Emails $emails
106 * @property-read Give_Email_Template_Tags $email_tags
107 * @property-read Give_DB_Form_Meta $form_meta
108 * @property-read Give_Admin_Settings $give_settings
109 * @property-read Give_HTML_Elements $html
110 * @property-read Give_Logging $logs
111 * @property-read Give_Notices $notices
112 * @property-read Give_DB_Payment_Meta $payment_meta
113 * @property-read Give_Roles $roles
114 * @property-read FormRoute $routeForm
115 * @property-read Templates $templates
116 * @property-read Give_Scripts $scripts
117 * @property-read Give_DB_Sequential_Ordering $sequential_donation_db
118 * @property-read Give_Sequential_Donation_Number $seq_donation_number
119 * @property-read Give_Session $session
120 * @property-read Give_DB_Sessions $session_db
121 * @property-read Give_Tooltips $tooltips
122 * @property-read PaymentGatewayRegister $gateways
123 * @property-read DonationRepository $donations
124 * @property-read DonorRepositoryProxy $donors
125 * @property-read SubscriptionRepository $subscriptions
126 * @property-read DonationFormsRepository $donationForms
127 * @property-read Profile $donorDashboard
128 * @property-read TabsRegister $donorDashboardTabs
129 * @property-read Give_Recurring_DB_Subscription_Meta $subscription_meta
130 *
131 * @mixin Container
132 */
133 final class Give
134 {
135 /**
136 * Give Template Loader Object
137 *
138 * @since 1.0
139 * @access public
140 *
141 * @var Give_Template_Loader object
142 */
143 public $template_loader;
144
145 /**
146 * Give No Login Object
147 *
148 * @since 1.0
149 * @access public
150 *
151 * @var Give_Email_Access object
152 */
153 public $email_access;
154
155 /**
156 * Give_Stripe Object.
157 *
158 * @since 2.5.0
159 * @access public
160 *
161 * @var Give_Stripe
162 */
163 public $stripe;
164
165 /**
166 * @since 2.8.0
167 *
168 * @var Container
169 */
170 private $container;
171
172 /**
173 * @since 2.25.0 added HttpServiceProvider
174 * @since 2.19.6 added Donors, Donations, and Subscriptions
175 * @since 2.8.0
176 *
177 * @var array Array of Service Providers to load
178 */
179 private $serviceProviders = [
180 LegacyServiceProvider::class,
181 RestAPI::class,
182 Routes::class,
183 PaymentGateways::class,
184 Onboarding::class,
185 MigrationsServiceProvider::class,
186 RevenueServiceProvider::class,
187 MultiFormGoalsServiceProvider::class,
188 DonorDashboardsServiceProvider::class,
189 TrackingServiceProvider::class,
190 TestDataServiceProvider::class,
191 MigrationLogServiceProvider::class,
192 LogServiceProvider::class,
193 FormLegacyConsumerServiceProvider::class,
194 LicenseServiceProvider::class,
195 Give\Email\ServiceProvider::class,
196 DonationSummaryServiceProvider::class,
197 PaymentGatewaysServiceProvider::class,
198 LegacySubscriptionsServiceProvider::class,
199 Give\Exports\ServiceProvider::class,
200 DonationServiceProvider::class,
201 DonorsServiceProvider::class,
202 SubscriptionServiceProvider::class,
203 DonationFormsServiceProvider::class,
204 PromotionsServiceProvider::class,
205 LegacySubscriptionsServiceProvider::class,
206 WordPressShimsServiceProvider::class,
207 DatabaseServiceProvider::class,
208 GlobalStylesServiceProvider::class,
209 ValidationServiceProvider::class,
210 ValidationRulesServiceProvider::class,
211 HttpServiceProvider::class,
212 ];
213
214 /**
215 * @since 2.8.0
216 *
217 * @var bool Make sure the providers are loaded only once
218 */
219 private $providersLoaded = false;
220
221 /**
222 * Give constructor.
223 *
224 * Sets up the Container to be used for managing all other instances and data
225 *
226 * @since 2.8.0
227 */
228 public function __construct()
229 {
230 $this->container = new Container();
231 }
232
233 /**
234 * Bootstraps the Give Plugin
235 *
236 * @since 2.8.0
237 */
238 public function boot()
239 {
240 $this->setup_constants();
241
242 // Add compatibility notice for recurring and stripe support with Give 2.5.0.
243 add_action('admin_notices', [$this, 'display_old_recurring_compatibility_notice']);
244
245 add_action('plugins_loaded', [$this, 'init'], 0);
246
247 register_activation_hook(GIVE_PLUGIN_FILE, [$this, 'install']);
248
249 do_action('give_loaded');
250 }
251
252 /**
253 * Init Give when WordPress Initializes.
254 *
255 * @since 1.8.9
256 */
257 public function init()
258 {
259 /**
260 * Fires before the Give core is initialized.
261 *
262 * @since 1.8.9
263 */
264 do_action('before_give_init');
265
266 // Set up localization.
267 $this->load_textdomain();
268
269 $this->bindClasses();
270
271 $this->setupExceptionHandler();
272
273 $this->loadServiceProviders();
274
275 // Load form template
276 $this->templates->load();
277
278 // Load routes.
279 $this->routeForm->init();
280
281 /**
282 * Fire the action after Give core loads.
283 *
284 * @since 1.8.7
285 *
286 * @param Give class instance.
287 *
288 */
289 do_action('give_init', $this);
290 }
291
292 /**
293 * Binds the initial classes to the service provider.
294 *
295 * @since 2.8.0
296 */
297 private function bindClasses()
298 {
299 $this->container->singleton('templates', Templates::class);
300 $this->container->singleton('routeForm', FormRoute::class);
301 }
302
303 /**
304 * Setup plugin constants
305 *
306 * @since 1.0
307 * @access private
308 *
309 * @return void
310 */
311 private function setup_constants()
312 {
313 // Plugin version.
314 if (!defined('GIVE_VERSION')) {
315 define('GIVE_VERSION', '2.25.2');
316 }
317
318 // Plugin Root File.
319 if (!defined('GIVE_PLUGIN_FILE')) {
320 define('GIVE_PLUGIN_FILE', __FILE__);
321 }
322
323 // Plugin Folder Path.
324 if (!defined('GIVE_PLUGIN_DIR')) {
325 define('GIVE_PLUGIN_DIR', plugin_dir_path(GIVE_PLUGIN_FILE));
326 }
327
328 // Plugin Folder URL.
329 if (!defined('GIVE_PLUGIN_URL')) {
330 define('GIVE_PLUGIN_URL', plugin_dir_url(GIVE_PLUGIN_FILE));
331 }
332
333 // Plugin Basename aka: "give/give.php".
334 if (!defined('GIVE_PLUGIN_BASENAME')) {
335 define('GIVE_PLUGIN_BASENAME', plugin_basename(GIVE_PLUGIN_FILE));
336 }
337
338 // Make sure CAL_GREGORIAN is defined.
339 if (!defined('CAL_GREGORIAN')) {
340 define('CAL_GREGORIAN', 1);
341 }
342 }
343
344 /**
345 * Loads the plugin language files.
346 *
347 * @since 1.0
348 * @access public
349 *
350 * @return void
351 */
352 public function load_textdomain()
353 {
354 // Set filter for Give's languages directory
355 $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)) . '/languages/';
356 $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
357
358 // Traditional WordPress plugin locale filter.
359 $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
360 $locale = apply_filters('plugin_locale', $locale, 'give');
361
362 unload_textdomain('give');
363 load_textdomain('give', WP_LANG_DIR . '/give/give-' . $locale . '.mo');
364 load_plugin_textdomain('give', false, $give_lang_dir);
365 }
366
367 /**
368 * Display compatibility notice for Give 2.5.0 and Recurring 1.8.13 when Stripe premium is not active.
369 *
370 * @since 2.5.0
371 *
372 * @return void
373 */
374 public function display_old_recurring_compatibility_notice()
375 {
376 // Show notice, if incompatibility found.
377 if (
378 defined('GIVE_RECURRING_VERSION')
379 && version_compare(GIVE_RECURRING_VERSION, '1.9.0', '<')
380 && defined('GIVE_STRIPE_VERSION')
381 && version_compare(GIVE_STRIPE_VERSION, '2.2.0', '<')
382 ) {
383 $message = sprintf(
384 __(
385 '<strong>Attention:</strong> GiveWP 2.5.0+ requires the latest version of the Recurring Donations add-on to process payments properly with Stripe. Please update to the latest version add-on to resolve compatibility issues. If your license is active, you should see the update available in WordPress. Otherwise, you can access the latest version by <a href="%1$s" target="_blank">logging into your account</a> and visiting <a href="%1$s" target="_blank">your downloads</a> page on the GiveWP website.',
386 'give'
387 ),
388 esc_url('https://givewp.com/wp-login.php'),
389 esc_url('https://givewp.com/my-account/#tab_downloads')
390 );
391
392 Give()->notices->register_notice(
393 [
394 'id' => 'give-compatibility-with-old-recurring',
395 'description' => $message,
396 'dismissible_type' => 'user',
397 'dismiss_interval' => 'shortly',
398 ]
399 );
400 }
401 }
402
403 public function install()
404 {
405 $this->loadServiceProviders();
406 give_install();
407 }
408
409 /**
410 * Load all the service providers to bootstrap the various parts of the application.
411 *
412 * @since 2.8.0
413 */
414 private function loadServiceProviders()
415 {
416 if ($this->providersLoaded) {
417 return;
418 }
419
420 $providers = [];
421
422 foreach ($this->serviceProviders as $serviceProvider) {
423 if (!is_subclass_of($serviceProvider, ServiceProvider::class)) {
424 throw new InvalidArgumentException(
425 "$serviceProvider class must implement the ServiceProvider interface"
426 );
427 }
428
429 /** @var ServiceProvider $serviceProvider */
430 $serviceProvider = new $serviceProvider();
431
432 $serviceProvider->register();
433
434 $providers[] = $serviceProvider;
435 }
436
437 foreach ($providers as $serviceProvider) {
438 $serviceProvider->boot();
439 }
440
441 $this->providersLoaded = true;
442 }
443
444 /**
445 * Register a Service Provider for bootstrapping
446 *
447 * @since 2.8.0
448 *
449 * @param string $serviceProvider
450 */
451 public function registerServiceProvider($serviceProvider)
452 {
453 $this->serviceProviders[] = $serviceProvider;
454 }
455
456 /**
457 * Magic properties are passed to the service container to retrieve the data.
458 *
459 * @since 2.8.0 retrieve from the service container
460 * @since 2.7.0
461 *
462 * @param string $propertyName
463 *
464 * @return mixed
465 * @throws Exception
466 */
467 public function __get($propertyName)
468 {
469 return $this->container->get($propertyName);
470 }
471
472 /**
473 * Magic methods are passed to the service container.
474 *
475 * @since 2.8.0
476 *
477 * @param $arguments
478 *
479 * @param $name
480 *
481 * @return mixed
482 */
483 public function __call($name, $arguments)
484 {
485 return call_user_func_array([$this->container, $name], $arguments);
486 }
487
488 /**
489 * Retrieves the underlying container instance. This isn't usually necessary, but sometimes we want to pass along
490 * the container itself.
491 *
492 * @since 2.24.0
493 */
494 public function getContainer(): Container
495 {
496 return $this->container;
497 }
498
499 /**
500 * Sets up the Exception Handler to catch and handle uncaught exceptions
501 *
502 * @since 2.11.1
503 */
504 private function setupExceptionHandler()
505 {
506 $handler = new UncaughtExceptionLogger();
507 $handler->setupExceptionHandler();
508 }
509 }
510
511 /**
512 * Start Give
513 *
514 * The main function responsible for returning the one true Give instance to functions everywhere.
515 *
516 * Use this function like you would a global variable, except without needing
517 * to declare the global.
518 *
519 * Example: <?php $give = Give(); ?>
520 *
521 * @since 2.8.0 add parameter for quick retrieval from container
522 * @since 1.0
523 *
524 * @param null $abstract Selector for data to retrieve from the service container
525 *
526 * @return object|Give
527 */
528 function give($abstract = null)
529 {
530 static $instance = null;
531
532 if ($instance === null) {
533 $instance = new Give();
534 }
535
536 if ($abstract !== null) {
537 return $instance->make($abstract);
538 }
539
540 return $instance;
541 }
542
543 require __DIR__ . '/vendor/autoload.php';
544 require __DIR__ . '/vendor/vendor-prefixed/autoload.php';
545
546 give()->boot();
547