PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.7.1
GiveWP – Donation Plugin and Fundraising Platform v2.7.1
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 6 years ago blocks 6 years ago includes 6 years ago languages 6 years ago sample-data 6 years ago src 6 years ago templates 6 years ago vendor 6 years ago .stylelintignore 6 years ago changelog.txt 6 years ago give.php 6 years ago license.txt 6 years ago readme.txt 6 years ago uninstall.php 7 years ago wpml-config.xml 6 years ago
give.php
808 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.7.1
9 * Text Domain: give
10 * Domain Path: /languages
11 *
12 * Give is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * any later version.
16 *
17 * Give is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with Give. If not, see <https://www.gnu.org/licenses/>.
24 *
25 * A Tribute to Open Source:
26 *
27 * "Open source software is software that can be freely used, changed, and shared (in modified or unmodified form) by anyone. Open
28 * source software is made by many people, and distributed under licenses that comply with the Open Source Definition."
29 *
30 * -- The Open Source Initiative
31 *
32 * Give is a tribute to the spirit and philosophy of Open Source. We at GiveWP gladly embrace the Open Source philosophy both
33 * in how Give itself was developed, and how we hope to see others build more from our code base.
34 *
35 * Give would not have been possible without the tireless efforts of WordPress and the surrounding Open Source projects and their talented developers. Thank you all for your contribution to WordPress.
36 *
37 * - The GiveWP Team
38 */
39
40 use Give\Form\Templates;
41 use Give\Route\Form as FormRoute;
42 use Give\Controller\Form as FormRouteController;
43
44 // Exit if accessed directly.
45 if ( ! defined( 'ABSPATH' ) ) {
46 exit;
47 }
48
49 if ( ! class_exists( 'Give' ) ) :
50
51 /**
52 * Main Give Class
53 *
54 * @since 1.0
55 *
56 * @property-read Templates $templates
57 * @property-read FormRoute $routeForm
58 */
59 final class Give {
60
61 /** Singleton *************************************************************/
62
63 /**
64 * Give Instance
65 *
66 * @since 1.0
67 * @access private
68 *
69 * @var Give() The one true Give
70 */
71 protected static $_instance;
72
73 /**
74 * Give Roles Object
75 *
76 * @since 1.0
77 * @access public
78 *
79 * @var Give_Roles object
80 */
81 public $roles;
82
83 /**
84 * Give Settings Object
85 *
86 * @since 1.0
87 * @access public
88 *
89 * @var Give_Admin_Settings object
90 */
91 public $give_settings;
92
93 /**
94 * Give Session Object
95 *
96 * This holds donation data for user's session.
97 *
98 * @since 1.0
99 * @access public
100 *
101 * @var Give_Session object
102 */
103 public $session;
104
105 /**
106 * Give Session DB Object
107 *
108 * This holds donation data for user's session.
109 *
110 * @since 1.0
111 * @access public
112 *
113 * @var Give_DB_Sessions object
114 */
115 public $session_db;
116
117 /**
118 * Give HTML Element Helper Object
119 *
120 * @since 1.0
121 * @access public
122 *
123 * @var Give_HTML_Elements object
124 */
125 public $html;
126
127 /**
128 * Give Emails Object
129 *
130 * @since 1.0
131 * @access public
132 *
133 * @var Give_Emails object
134 */
135 public $emails;
136
137 /**
138 * Give Email Template Tags Object
139 *
140 * @since 1.0
141 * @access public
142 *
143 * @var Give_Email_Template_Tags object
144 */
145 public $email_tags;
146
147 /**
148 * Give Donors DB Object
149 *
150 * @since 1.0
151 * @access public
152 *
153 * @var Give_DB_Donors object
154 */
155 public $donors;
156
157 /**
158 * Give Donor meta DB Object
159 *
160 * @since 1.6
161 * @access public
162 *
163 * @var Give_DB_Donor_Meta object
164 */
165 public $donor_meta;
166
167 /**
168 * Give Sequential Donation DB Object
169 *
170 * @since 2.1.0
171 * @access public
172 *
173 * @var Give_DB_Sequential_Ordering object
174 */
175 public $sequential_donation_db;
176
177 /**
178 * Give API Object
179 *
180 * @since 1.0
181 * @access public
182 *
183 * @var Give_API object
184 */
185 public $api;
186
187 /**
188 * Give Template Loader Object
189 *
190 * @since 1.0
191 * @access public
192 *
193 * @var Give_Template_Loader object
194 */
195 public $template_loader;
196
197 /**
198 * Give No Login Object
199 *
200 * @since 1.0
201 * @access public
202 *
203 * @var Give_Email_Access object
204 */
205 public $email_access;
206
207 /**
208 * Give_tooltips Object
209 *
210 * @since 1.8.9
211 * @access public
212 *
213 * @var Give_Tooltips object
214 */
215 public $tooltips;
216
217 /**
218 * Give notices Object
219 *
220 * @var Give_Notices $notices
221 */
222 public $notices;
223
224
225 /**
226 * Give logging Object
227 *
228 * @var Give_Logging $logs
229 */
230 public $logs;
231
232 /**
233 * Give log db Object
234 *
235 * @var Give_DB_Logs $log_db
236 */
237 public $log_db;
238
239 /**
240 * Give log meta db Object
241 *
242 * @var Give_DB_Log_Meta $logmeta_db
243 */
244 public $logmeta_db;
245
246 /**
247 * Give payment Object
248 *
249 * @var Give_DB_Payment_Meta $payment_meta
250 */
251 public $payment_meta;
252
253 /**
254 * Give form Object
255 *
256 * @var Give_DB_Form_Meta $form_meta
257 */
258 public $form_meta;
259
260 /**
261 * Give form Object
262 *
263 * @var Give_Async_Process $async_process
264 */
265 public $async_process;
266
267 /**
268 * Give scripts Object.
269 *
270 * @var Give_Scripts
271 */
272 public $scripts;
273
274 /**
275 * Give_Seq_Donation_Number Object.
276 *
277 * @var Give_Sequential_Donation_Number
278 */
279 public $seq_donation_number;
280
281 /**
282 * Give_Comment Object
283 *
284 * @var Give_Comment
285 */
286 public $comment;
287
288 /**
289 * Give_Stripe Object.
290 *
291 * @since 2.5.0
292 * @access public
293 *
294 * @var Give_Stripe
295 */
296 public $stripe;
297
298 /**
299 * Array of singleton objects
300 *
301 * @since 2.7.0
302 * @var array
303 */
304 private $singletonsCache = [];
305
306
307 /**
308 * Main Give Instance
309 *
310 * Ensures that only one instance of Give exists in memory at any one
311 * time. Also prevents needing to define globals all over the place.
312 *
313 * @since 1.0
314 * @access public
315 *
316 * @static
317 * @see Give()
318 *
319 * @return Give
320 */
321 public static function instance() {
322 if ( is_null( self::$_instance ) ) {
323 self::$_instance = new self();
324 }
325
326 return self::$_instance;
327 }
328
329 /**
330 * Give Constructor.
331 */
332 public function __construct() {
333 // PHP version
334 if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) {
335 define( 'GIVE_REQUIRED_PHP_VERSION', '5.6.0' );
336 }
337
338 // Bailout: Need minimum php version to load plugin.
339 if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) {
340 add_action( 'admin_notices', [ $this, 'minimum_phpversion_notice' ] );
341
342 return;
343 }
344
345 // Add compatibility notice for recurring and stripe support with Give 2.5.0.
346 add_action( 'admin_notices', [ $this, 'display_old_recurring_compatibility_notice' ] );
347
348 $this->setup_constants();
349 $this->includes();
350 $this->init_hooks();
351
352 do_action( 'give_loaded' );
353 }
354
355 /**
356 * Hook into actions and filters.
357 *
358 * @since 1.8.9
359 */
360 private function init_hooks() {
361 register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
362 add_action( 'plugins_loaded', [ $this, 'init' ], 0 );
363 }
364
365
366 /**
367 * Init Give when WordPress Initializes.
368 *
369 * @since 1.8.9
370 */
371 public function init() {
372
373 /**
374 * Fires before the Give core is initialized.
375 *
376 * @since 1.8.9
377 */
378 do_action( 'before_give_init' );
379
380 // Set up localization.
381 $this->load_textdomain();
382
383 $this->roles = new Give_Roles();
384 $this->api = new Give_API();
385 $this->give_settings = new Give_Admin_Settings();
386 $this->emails = new Give_Emails();
387 $this->email_tags = new Give_Email_Template_Tags();
388 $this->html = Give_HTML_Elements::get_instance();
389 $this->donors = new Give_DB_Donors();
390 $this->donor_meta = new Give_DB_Donor_Meta();
391 $this->tooltips = new Give_Tooltips();
392 $this->notices = new Give_Notices();
393 $this->payment_meta = new Give_DB_Payment_Meta();
394 $this->log_db = new Give_DB_Logs();
395 $this->logmeta_db = new Give_DB_Log_Meta();
396 $this->logs = new Give_Logging();
397 $this->form_meta = new Give_DB_Form_Meta();
398 $this->sequential_donation_db = new Give_DB_Sequential_Ordering();
399 $this->async_process = new Give_Async_Process();
400 $this->scripts = new Give_Scripts();
401 $this->seq_donation_number = Give_Sequential_Donation_Number::get_instance();
402 $this->comment = Give_Comment::get_instance();
403 $this->session_db = new Give_DB_Sessions();
404 $this->session = Give_Session::get_instance();
405
406 // Load form template
407 $this->templates->load();
408
409 // Load routes.
410 $this->routeForm->init( new FormRouteController() );
411
412 /**
413 * Fire the action after Give core loads.
414 *
415 * @param Give class instance.
416 *
417 * @since 1.8.7
418 */
419 do_action( 'give_init', $this );
420
421 }
422
423 /**
424 * Throw error on object clone
425 *
426 * The whole idea of the singleton design pattern is that there is a single
427 * object, therefore we don't want the object to be cloned.
428 *
429 * @since 1.0
430 * @access protected
431 *
432 * @return void
433 */
434 public function __clone() {
435 // Cloning instances of the class is forbidden.
436 give_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ) );
437 }
438
439 /**
440 * Disable unserializing of the class
441 *
442 * @since 1.0
443 * @access protected
444 *
445 * @return void
446 */
447 public function __wakeup() {
448 // Unserializing instances of the class is forbidden.
449 give_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ) );
450 }
451
452 /**
453 * Setup plugin constants
454 *
455 * @since 1.0
456 * @access private
457 *
458 * @return void
459 */
460 private function setup_constants() {
461
462 // Plugin version.
463 if ( ! defined( 'GIVE_VERSION' ) ) {
464 define( 'GIVE_VERSION', '2.7.1' );
465 }
466
467 // Plugin Root File.
468 if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
469 define( 'GIVE_PLUGIN_FILE', __FILE__ );
470 }
471
472 // Plugin Folder Path.
473 if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
474 define( 'GIVE_PLUGIN_DIR', plugin_dir_path( GIVE_PLUGIN_FILE ) );
475 }
476
477 // Plugin Folder URL.
478 if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
479 define( 'GIVE_PLUGIN_URL', plugin_dir_url( GIVE_PLUGIN_FILE ) );
480 }
481
482 // Plugin Basename aka: "give/give.php".
483 if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
484 define( 'GIVE_PLUGIN_BASENAME', plugin_basename( GIVE_PLUGIN_FILE ) );
485 }
486
487 // Make sure CAL_GREGORIAN is defined.
488 if ( ! defined( 'CAL_GREGORIAN' ) ) {
489 define( 'CAL_GREGORIAN', 1 );
490 }
491 }
492
493 /**
494 * Include required files
495 *
496 * @since 1.0
497 * @access private
498 *
499 * @return void
500 */
501 private function includes() {
502 global $give_options;
503
504 require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache-setting.php';
505
506 /**
507 * Load libraries.
508 */
509 if ( ! class_exists( 'WP_Async_Request' ) ) {
510 include_once GIVE_PLUGIN_DIR . 'includes/libraries/wp-async-request.php';
511 }
512
513 if ( ! class_exists( 'WP_Background_Process' ) ) {
514 include_once GIVE_PLUGIN_DIR . 'includes/libraries/wp-background-process.php';
515 }
516
517 require_once GIVE_PLUGIN_DIR . 'includes/setting-functions.php';
518 require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
519 require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
520 require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
521 require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
522 require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
523 require_once GIVE_PLUGIN_DIR . 'includes/currency-functions.php';
524 require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
525 require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
526 require_once GIVE_PLUGIN_DIR . 'includes/donors/frontend-donor-functions.php';
527 require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
528 require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
529
530 /**
531 * Load plugin files
532 */
533 require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
534 $give_options = give_get_settings();
535
536 require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
537 require_once GIVE_PLUGIN_DIR . 'includes/class-give-async-process.php';
538 require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
539 require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
540 require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
541 require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
542 require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-v2.php';
543 require_once GIVE_PLUGIN_DIR . 'includes/class-give-tooltips.php';
544 require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php';
545 require_once GIVE_PLUGIN_DIR . 'includes/class-give-translation.php';
546 require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
547 require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-html-elements.php';
548
549 require_once GIVE_PLUGIN_DIR . 'includes/class-give-scripts.php';
550 require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
551 require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
552
553 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db.php';
554 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-meta.php';
555 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-comments.php';
556 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-comments-meta.php';
557 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-donors.php';
558 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-donor-meta.php';
559 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-form-meta.php';
560 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-sequential-ordering.php';
561 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-logs.php';
562 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-logs-meta.php';
563 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-sessions.php';
564 require_once GIVE_PLUGIN_DIR . 'includes/database/class-give-db-payment-meta.php';
565
566 require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php';
567 require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
568 require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
569 require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
570 require_once GIVE_PLUGIN_DIR . 'includes/class-give-comment.php';
571
572 require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor-wall-widget.php';
573 require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
574 require_once GIVE_PLUGIN_DIR . 'includes/forms/class-give-forms-query.php';
575 require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
576 require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
577 require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
578 require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
579 require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
580 require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
581 require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php';
582 require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
583 require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
584 require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
585
586 require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
587 require_once GIVE_PLUGIN_DIR . 'includes/payments/backward-compatibility.php';
588 require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
589 require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
590 require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
591 require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
592 require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-sequential-donation-number.php';
593
594 require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
595 require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
596 require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
597 require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
598 require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
599 require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
600 require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notifications.php';
601 require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
602 require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
603 require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
604
605 require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donors-query.php';
606 require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donor-wall.php';
607 require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donor-stats.php';
608 require_once GIVE_PLUGIN_DIR . 'includes/donors/backward-compatibility.php';
609 require_once GIVE_PLUGIN_DIR . 'includes/donors/actions.php';
610
611 require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php';
612
613 require_once GIVE_PLUGIN_DIR . 'blocks/load.php';
614
615 // Include API
616 require_once GIVE_PLUGIN_DIR . 'src/API/API.php';
617
618 // Include Views
619 require_once GIVE_PLUGIN_DIR . 'src/Views/Views.php';
620
621 if ( defined( 'WP_CLI' ) && WP_CLI ) {
622 require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
623 }
624
625 // Load file for frontend
626 if ( $this->is_request( 'frontend' ) ) {
627 require_once GIVE_PLUGIN_DIR . 'includes/frontend/class-give-frontend.php';
628 }
629
630 if ( $this->is_request( 'admin' ) || $this->is_request( 'wpcli' ) ) {
631 require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-admin.php';
632 }// End if().
633
634 require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
635 require_once GIVE_PLUGIN_DIR . 'includes/install.php';
636
637 // This conditional check will add backward compatibility to older Stripe versions (i.e. < 2.2.0) when used with Give 2.5.0.
638 if (
639 ! defined( 'GIVE_STRIPE_VERSION' ) ||
640 (
641 defined( 'GIVE_STRIPE_VERSION' ) &&
642 version_compare( GIVE_STRIPE_VERSION, '2.2.0', '>=' )
643 )
644 ) {
645 require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/class-give-stripe.php';
646 }
647
648 }
649
650 /**
651 * Loads the plugin language files.
652 *
653 * @since 1.0
654 * @access public
655 *
656 * @return void
657 */
658 public function load_textdomain() {
659
660 // Set filter for Give's languages directory
661 $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
662 $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
663
664 // Traditional WordPress plugin locale filter.
665 $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
666 $locale = apply_filters( 'plugin_locale', $locale, 'give' );
667
668 unload_textdomain( 'give' );
669 load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' );
670 load_plugin_textdomain( 'give', false, $give_lang_dir );
671
672 }
673
674
675 /**
676 * Show minimum PHP version notice.
677 *
678 * @since 1.8.12
679 * @access public
680 */
681 public function minimum_phpversion_notice() {
682 // Bailout.
683 if ( ! is_admin() ) {
684 return;
685 }
686
687 $notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>';
688 $notice_desc .= '<p>' . __( '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.', 'give' ) . '</p>';
689 $notice_desc .= '<p>' . __( '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.', 'give' ) . '</p>';
690 $notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>';
691 $notice_desc .= '<p>' . __( '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.', 'give' ) . '</p>';
692 $notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>';
693 $notice_desc .= '<p>' . sprintf( __( '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.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>';
694
695 echo sprintf(
696 '<div class="notice notice-error">%1$s</div>',
697 wp_kses_post( $notice_desc )
698 );
699 }
700
701 /**
702 * Display compatibility notice for Give 2.5.0 and Recurring 1.8.13 when Stripe premium is not active.
703 *
704 * @since 2.5.0
705 *
706 * @return void
707 */
708 public function display_old_recurring_compatibility_notice() {
709
710 // Show notice, if incompatibility found.
711 if (
712 defined( 'GIVE_RECURRING_VERSION' )
713 && version_compare( GIVE_RECURRING_VERSION, '1.9.0', '<' )
714 && defined( 'GIVE_STRIPE_VERSION' )
715 && version_compare( GIVE_STRIPE_VERSION, '2.2.0', '<' )
716 ) {
717
718 $message = sprintf(
719 __( '<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.', 'give' ),
720 esc_url( 'https://givewp.com/wp-login.php' ),
721 esc_url( 'https://givewp.com/my-account/#tab_downloads' )
722 );
723
724 Give()->notices->register_notice(
725 [
726 'id' => 'give-compatibility-with-old-recurring',
727 'description' => $message,
728 'dismissible_type' => 'user',
729 'dismiss_interval' => 'shortly',
730 ]
731 );
732 }
733
734 }
735
736 /**
737 * What type of request is this?
738 *
739 * @since 2.4.0
740 *
741 * @param string $type admin, ajax, cron or frontend.
742 * @return bool
743 */
744 private function is_request( $type ) {
745 switch ( $type ) {
746 case 'admin':
747 return is_admin();
748 case 'ajax':
749 return defined( 'DOING_AJAX' );
750 case 'cron':
751 return defined( 'DOING_CRON' );
752 case 'frontend':
753 return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ) && ! defined( 'REST_REQUEST' );
754 case 'wpcli':
755 return defined( 'WP_CLI' ) && WP_CLI;
756 }
757 }
758
759 /**
760 * Handle property get request
761 *
762 * @param string $propertyName
763 *
764 * @since 2.7.0
765 * @return mixed
766 */
767 function __get( $propertyName ) {
768 switch ( $propertyName ) {
769 case 'templates':
770 if ( ! isset( $this->singletonsCache[ Templates::class ] ) ) {
771 $this->singletonsCache[ Templates::class ] = new Templates();
772 }
773
774 return $this->singletonsCache[ Templates::class ];
775
776 case 'routeForm':
777 if ( ! isset( $this->singletonsCache[ FormRoute::class ] ) ) {
778 $this->singletonsCache[ FormRoute::class ] = new FormRoute();
779 }
780
781 return $this->singletonsCache[ FormRoute::class ];
782 }
783 }
784
785 }
786
787 endif; // End if class_exists check
788
789
790 /**
791 * Start Give
792 *
793 * The main function responsible for returning the one true Give instance to functions everywhere.
794 *
795 * Use this function like you would a global variable, except without needing
796 * to declare the global.
797 *
798 * Example: <?php $give = Give(); ?>
799 *
800 * @since 1.0
801 * @return object|Give
802 */
803 function Give() { // phpcs:ignore
804 return Give::instance();
805 }
806
807 Give();
808