PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.19.6
GiveWP – Donation Plugin and Fundraising Platform v2.19.6
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 4 years ago blocks 4 years ago includes 4 years ago languages 4 years ago sample-data 6 years ago src 4 years ago templates 5 years ago vendor 4 years ago .phpstorm.meta.php 4 years ago changelog.txt 5 years ago give.php 4 years ago license.txt 6 years ago readme.txt 4 years ago uninstall.php 5 years ago wpml-config.xml 6 years ago
give.php
574 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.19.6
10 * Requires at least: 5.0
11 * Requires PHP: 5.6
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\ServiceProvider as DonorDashboardsServiceProvider;
52 use Give\Donors\Repositories\DonorRepositoryProxy;
53 use Give\Donors\ServiceProvider as DonorsServiceProvider;
54 use Give\Form\LegacyConsumer\ServiceProvider as FormLegacyConsumerServiceProvider;
55 use Give\Form\Templates;
56 use Give\Framework\Exceptions\UncaughtExceptionLogger;
57 use Give\Framework\Migrations\MigrationsServiceProvider;
58 use Give\LegacySubscriptions\ServiceProvider as LegacySubscriptionsServiceProvider;
59 use Give\License\LicenseServiceProvider;
60 use Give\Log\LogServiceProvider;
61 use Give\MigrationLog\MigrationLogServiceProvider;
62 use Give\MultiFormGoals\ServiceProvider as MultiFormGoalsServiceProvider;
63 use Give\PaymentGateways\ServiceProvider as PaymentGatewaysServiceProvider;
64 use Give\Promotions\ServiceProvider as PromotionsServiceProvider;
65 use Give\Revenue\RevenueServiceProvider;
66 use Give\Route\Form as FormRoute;
67 use Give\ServiceProviders\LegacyServiceProvider;
68 use Give\ServiceProviders\Onboarding;
69 use Give\ServiceProviders\PaymentGateways;
70 use Give\ServiceProviders\RestAPI;
71 use Give\ServiceProviders\Routes;
72 use Give\ServiceProviders\ServiceProvider;
73 use Give\Shims\ShimsServiceProvider;
74 use Give\Subscriptions\Repositories\SubscriptionRepository;
75 use Give\Subscriptions\ServiceProvider as SubscriptionServiceProvider;
76 use Give\TestData\ServiceProvider as TestDataServiceProvider;
77 use Give\Tracking\TrackingServiceProvider;
78
79 // Exit if accessed directly.
80 if (!defined('ABSPATH')) {
81 exit;
82 }
83
84 /**
85 * Main Give Class
86 *
87 * @since 2.19.6 add $donations, $subscriptions, and replace $donors class with DonorRepositoryProxy
88 * @since 2.8.0 build in a service container
89 * @since 1.0
90 *
91 * @property-read Give_API $api
92 * @property-read Give_Async_Process $async_process
93 * @property-read Give_Comment $comment
94 * @property-read Give_DB_Donor_Meta $donor_meta
95 * @property-read Give_Emails $emails
96 * @property-read Give_Email_Template_Tags $email_tags
97 * @property-read Give_DB_Form_Meta $form_meta
98 * @property-read Give_Admin_Settings $give_settings
99 * @property-read Give_HTML_Elements $html
100 * @property-read Give_Logging $logs
101 * @property-read Give_Notices $notices
102 * @property-read Give_DB_Payment_Meta $payment_meta
103 * @property-read Give_Roles $roles
104 * @property-read FormRoute $routeForm
105 * @property-read Templates $templates
106 * @property-read Give_Scripts $scripts
107 * @property-read Give_DB_Sequential_Ordering $sequential_donation_db
108 * @property-read Give_Sequential_Donation_Number $seq_donation_number
109 * @property-read Give_Session $session
110 * @property-read Give_DB_Sessions $session_db
111 * @property-read Give_Tooltips $tooltips
112 * @property-read DonationRepository $donations
113 * @property-read DonorRepositoryProxy $donors
114 * @property-read SubscriptionRepository $subscriptions
115 * @property-read DonationFormsRepository $donationFormsRepository
116 * @property-read Give_Recurring_DB_Subscription_Meta $subscription_meta
117 *
118 * @mixin Container
119 */
120 final class Give
121 {
122 /**
123 * Give Template Loader Object
124 *
125 * @since 1.0
126 * @access public
127 *
128 * @var Give_Template_Loader object
129 */
130 public $template_loader;
131
132 /**
133 * Give No Login Object
134 *
135 * @since 1.0
136 * @access public
137 *
138 * @var Give_Email_Access object
139 */
140 public $email_access;
141
142 /**
143 * Give_Stripe Object.
144 *
145 * @since 2.5.0
146 * @access public
147 *
148 * @var Give_Stripe
149 */
150 public $stripe;
151
152 /**
153 * @since 2.8.0
154 *
155 * @var Container
156 */
157 private $container;
158
159 /**
160 * @since 2.19.6 added Donors, Donations, and Subscriptions
161 * @since 2.8.0
162 *
163 * @var array Array of Service Providers to load
164 */
165 private $serviceProviders = [
166 LegacyServiceProvider::class,
167 RestAPI::class,
168 Routes::class,
169 PaymentGateways::class,
170 Onboarding::class,
171 MigrationsServiceProvider::class,
172 RevenueServiceProvider::class,
173 MultiFormGoalsServiceProvider::class,
174 DonorDashboardsServiceProvider::class,
175 TrackingServiceProvider::class,
176 TestDataServiceProvider::class,
177 MigrationLogServiceProvider::class,
178 LogServiceProvider::class,
179 FormLegacyConsumerServiceProvider::class,
180 ShimsServiceProvider::class,
181 LicenseServiceProvider::class,
182 Give\Email\ServiceProvider::class,
183 DonationSummaryServiceProvider::class,
184 PaymentGatewaysServiceProvider::class,
185 DonationServiceProvider::class,
186 DonorsServiceProvider::class,
187 SubscriptionServiceProvider::class,
188 DonationFormsServiceProvider::class,
189 PromotionsServiceProvider::class,
190 LegacySubscriptionsServiceProvider::class
191 ];
192
193 /**
194 * @since 2.8.0
195 *
196 * @var bool Make sure the providers are loaded only once
197 */
198 private $providersLoaded = false;
199
200 /**
201 * Give constructor.
202 *
203 * Sets up the Container to be used for managing all other instances and data
204 *
205 * @since 2.8.0
206 */
207 public function __construct()
208 {
209 $this->container = new Container();
210 }
211
212 /**
213 * Bootstraps the Give Plugin
214 *
215 * @since 2.8.0
216 */
217 public function boot()
218 {
219 // PHP version
220 if (!defined('GIVE_REQUIRED_PHP_VERSION')) {
221 define('GIVE_REQUIRED_PHP_VERSION', '5.6.0');
222 }
223
224 // Bailout: Need minimum php version to load plugin.
225 if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) {
226 add_action('admin_notices', [$this, 'minimum_phpversion_notice']);
227
228 return;
229 }
230
231 $this->setup_constants();
232
233 // Add compatibility notice for recurring and stripe support with Give 2.5.0.
234 add_action('admin_notices', [$this, 'display_old_recurring_compatibility_notice']);
235
236 add_action('plugins_loaded', [$this, 'init'], 0);
237
238 register_activation_hook(GIVE_PLUGIN_FILE, [$this, 'install']);
239
240 do_action('give_loaded');
241 }
242
243 /**
244 * Init Give when WordPress Initializes.
245 *
246 * @since 1.8.9
247 */
248 public function init()
249 {
250 /**
251 * Fires before the Give core is initialized.
252 *
253 * @since 1.8.9
254 */
255 do_action('before_give_init');
256
257 // Set up localization.
258 $this->load_textdomain();
259
260 $this->bindClasses();
261
262 $this->setupExceptionHandler();
263
264 $this->loadServiceProviders();
265
266 // Load form template
267 $this->templates->load();
268
269 // Load routes.
270 $this->routeForm->init();
271
272 /**
273 * Fire the action after Give core loads.
274 *
275 * @param Give class instance.
276 *
277 * @since 1.8.7
278 *
279 */
280 do_action('give_init', $this);
281 }
282
283 /**
284 * Binds the initial classes to the service provider.
285 *
286 * @since 2.8.0
287 */
288 private function bindClasses()
289 {
290 $this->container->singleton('templates', Templates::class);
291 $this->container->singleton('routeForm', FormRoute::class);
292 }
293
294 /**
295 * Setup plugin constants
296 *
297 * @return void
298 * @since 1.0
299 * @access private
300 *
301 */
302 private function setup_constants()
303 {
304 // Plugin version.
305 if (!defined('GIVE_VERSION')) {
306 define('GIVE_VERSION', '2.19.6');
307 }
308
309 // Plugin Root File.
310 if (!defined('GIVE_PLUGIN_FILE')) {
311 define('GIVE_PLUGIN_FILE', __FILE__);
312 }
313
314 // Plugin Folder Path.
315 if (!defined('GIVE_PLUGIN_DIR')) {
316 define('GIVE_PLUGIN_DIR', plugin_dir_path(GIVE_PLUGIN_FILE));
317 }
318
319 // Plugin Folder URL.
320 if (!defined('GIVE_PLUGIN_URL')) {
321 define('GIVE_PLUGIN_URL', plugin_dir_url(GIVE_PLUGIN_FILE));
322 }
323
324 // Plugin Basename aka: "give/give.php".
325 if (!defined('GIVE_PLUGIN_BASENAME')) {
326 define('GIVE_PLUGIN_BASENAME', plugin_basename(GIVE_PLUGIN_FILE));
327 }
328
329 // Make sure CAL_GREGORIAN is defined.
330 if (!defined('CAL_GREGORIAN')) {
331 define('CAL_GREGORIAN', 1);
332 }
333 }
334
335 /**
336 * Loads the plugin language files.
337 *
338 * @return void
339 * @since 1.0
340 * @access public
341 *
342 */
343 public function load_textdomain()
344 {
345 // Set filter for Give's languages directory
346 $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)) . '/languages/';
347 $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
348
349 // Traditional WordPress plugin locale filter.
350 $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
351 $locale = apply_filters('plugin_locale', $locale, 'give');
352
353 unload_textdomain('give');
354 load_textdomain('give', WP_LANG_DIR . '/give/give-' . $locale . '.mo');
355 load_plugin_textdomain('give', false, $give_lang_dir);
356 }
357
358 /**
359 * Show minimum PHP version notice.
360 *
361 * @since 1.8.12
362 * @access public
363 */
364 public function minimum_phpversion_notice()
365 {
366 // Bailout.
367 if (!is_admin()) {
368 return;
369 }
370
371 $notice_desc = '<p><strong>' . __(
372 'Your site could be faster and more secure with a newer PHP version.',
373 'give'
374 ) . '</strong></p>';
375 $notice_desc .= '<p>' . __(
376 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and GiveWP are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.',
377 'give'
378 ) . '</p>';
379 $notice_desc .= '<p>' . __(
380 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.',
381 'give'
382 ) . '</p>';
383 $notice_desc .= '<p><strong>' . __('To which version should I update?', 'give') . '</strong></p>';
384 $notice_desc .= '<p>' . __(
385 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.',
386 'give'
387 ) . '</p>';
388 $notice_desc .= '<p><strong>' . __('Can\'t update? Ask your host!', 'give') . '</strong></p>';
389 $notice_desc .= '<p>' . sprintf(
390 __(
391 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.',
392 'give'
393 ),
394 sprintf(
395 '<a href="%1$s" target="_blank">',
396 esc_url('https://wordpress.org/hosting/')
397 ),
398 '</a>'
399 ) . '</p>';
400
401 echo sprintf(
402 '<div class="notice notice-error">%1$s</div>',
403 wp_kses_post($notice_desc)
404 );
405 }
406
407 /**
408 * Display compatibility notice for Give 2.5.0 and Recurring 1.8.13 when Stripe premium is not active.
409 *
410 * @return void
411 * @since 2.5.0
412 *
413 */
414 public function display_old_recurring_compatibility_notice()
415 {
416 // Show notice, if incompatibility found.
417 if (
418 defined('GIVE_RECURRING_VERSION')
419 && version_compare(GIVE_RECURRING_VERSION, '1.9.0', '<')
420 && defined('GIVE_STRIPE_VERSION')
421 && version_compare(GIVE_STRIPE_VERSION, '2.2.0', '<')
422 ) {
423 $message = sprintf(
424 __(
425 '<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.',
426 'give'
427 ),
428 esc_url('https://givewp.com/wp-login.php'),
429 esc_url('https://givewp.com/my-account/#tab_downloads')
430 );
431
432 Give()->notices->register_notice(
433 [
434 'id' => 'give-compatibility-with-old-recurring',
435 'description' => $message,
436 'dismissible_type' => 'user',
437 'dismiss_interval' => 'shortly',
438 ]
439 );
440 }
441 }
442
443 public function install()
444 {
445 $this->loadServiceProviders();
446 give_install();
447 }
448
449 /**
450 * Load all the service providers to bootstrap the various parts of the application.
451 *
452 * @since 2.8.0
453 */
454 private function loadServiceProviders()
455 {
456 if ($this->providersLoaded) {
457 return;
458 }
459
460 $providers = [];
461
462 foreach ($this->serviceProviders as $serviceProvider) {
463 if (!is_subclass_of($serviceProvider, ServiceProvider::class)) {
464 throw new InvalidArgumentException(
465 "$serviceProvider class must implement the ServiceProvider interface"
466 );
467 }
468
469 /** @var ServiceProvider $serviceProvider */
470 $serviceProvider = new $serviceProvider();
471
472 $serviceProvider->register();
473
474 $providers[] = $serviceProvider;
475 }
476
477 foreach ($providers as $serviceProvider) {
478 $serviceProvider->boot();
479 }
480
481 $this->providersLoaded = true;
482 }
483
484 /**
485 * Register a Service Provider for bootstrapping
486 *
487 * @param string $serviceProvider
488 * @since 2.8.0
489 *
490 */
491 public function registerServiceProvider($serviceProvider)
492 {
493 $this->serviceProviders[] = $serviceProvider;
494 }
495
496 /**
497 * Magic properties are passed to the service container to retrieve the data.
498 *
499 * @param string $propertyName
500 *
501 * @return mixed
502 * @throws Exception
503 * @since 2.7.0
504 *
505 * @since 2.8.0 retrieve from the service container
506 */
507 public function __get($propertyName)
508 {
509 return $this->container->get($propertyName);
510 }
511
512 /**
513 * Magic methods are passed to the service container.
514 *
515 * @param $name
516 * @param $arguments
517 *
518 * @return mixed
519 * @since 2.8.0
520 *
521 */
522 public function __call($name, $arguments)
523 {
524 return call_user_func_array([$this->container, $name], $arguments);
525 }
526
527 /**
528 * Sets up the Exception Handler to catch and handle uncaught exceptions
529 *
530 * @since 2.11.1
531 */
532 private function setupExceptionHandler()
533 {
534 $handler = new UncaughtExceptionLogger();
535 $handler->setupExceptionHandler();
536 }
537 }
538
539 /**
540 * Start Give
541 *
542 * The main function responsible for returning the one true Give instance to functions everywhere.
543 *
544 * Use this function like you would a global variable, except without needing
545 * to declare the global.
546 *
547 * Example: <?php $give = Give(); ?>
548 *
549 * @since 2.8.0 add parameter for quick retrieval from container
550 * @since 1.0
551 *
552 * @param null $abstract Selector for data to retrieve from the service container
553 *
554 * @return object|Give
555 */
556 function give($abstract = null)
557 {
558 static $instance = null;
559
560 if ($instance === null) {
561 $instance = new Give();
562 }
563
564 if ($abstract !== null) {
565 return $instance->make($abstract);
566 }
567
568 return $instance;
569 }
570
571 require __DIR__ . '/vendor/autoload.php';
572
573 give()->boot();
574