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