Test Failed
Push — master ( 6a4da5...c6306d )
by Devin
04:22
created

Give::display_old_recurring_compatibility_notice()   A

Complexity

Conditions 5
Paths 2

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

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