Completed
Push — issue/1911 ( ad49de )
by Ravinder
791:04 queued 785:24
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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: WordImpress
7
 * Author URI: https://wordimpress.com
8
 * Version: 1.8.12
9
 * Text Domain: give
10
 * Domain Path: /languages
11
 * GitHub Plugin URI: https://github.com/WordImpress/Give
12
 *
13
 * Give is free software: you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation, either version 3 of the License, or
16
 * any later version.
17
 *
18
 * Give is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with Give. If not, see <https://www.gnu.org/licenses/>.
25
 *
26
 * A Tribute to Open Source:
27
 *
28
 * "Open source software is software that can be freely used, changed, and shared (in modified or unmodified form) by anyone. Open
29
 * source software is made by many people, and distributed under licenses that comply with the Open Source Definition."
30
 *
31
 * -- The Open Source Initiative
32
 *
33
 * Give is a tribute to the spirit and philosophy of Open Source. We at WordImpress gladly embrace the Open Source philosophy both
34
 * in how Give itself was developed, and how we hope to see others build more from our code base.
35
 *
36
 * 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
37
 * contribution to WordPress.
38
 *
39
 * - The WordImpress Team
40
 */
41
42
// Exit if accessed directly.
43
if ( ! defined( 'ABSPATH' ) ) {
44
	exit;
45
}
46
47
if ( ! class_exists( 'Give' ) ) :
48
49
	/**
50
	 * Main Give Class
51
	 *
52
	 * @since 1.0
53
	 */
54
	final class Give {
55
56
		/** Singleton *************************************************************/
57
58
		/**
59
		 * Give Instance
60
		 *
61
		 * @since  1.0
62
		 * @access private
63
		 *
64
		 * @var    Give() The one true Give
65
		 */
66
		protected static $_instance;
67
68
		/**
69
		 * Give Roles Object
70
		 *
71
		 * @since  1.0
72
		 * @access public
73
		 *
74
		 * @var    Give_Roles object
75
		 */
76
		public $roles;
77
78
		/**
79
		 * Give Settings Object
80
		 *
81
		 * @since  1.0
82
		 * @access public
83
		 *
84
		 * @var    Give_Plugin_Settings object
85
		 */
86
		public $give_settings;
87
88
		/**
89
		 * Give Session Object
90
		 *
91
		 * This holds donation data for user's session.
92
		 *
93
		 * @since  1.0
94
		 * @access public
95
		 *
96
		 * @var    Give_Session object
97
		 */
98
		public $session;
99
100
		/**
101
		 * Give HTML Element Helper Object
102
		 *
103
		 * @since  1.0
104
		 * @access public
105
		 *
106
		 * @var    Give_HTML_Elements object
107
		 */
108
		public $html;
109
110
		/**
111
		 * Give Emails Object
112
		 *
113
		 * @since  1.0
114
		 * @access public
115
		 *
116
		 * @var    Give_Emails object
117
		 */
118
		public $emails;
119
120
		/**
121
		 * Give Email Template Tags Object
122
		 *
123
		 * @since  1.0
124
		 * @access public
125
		 *
126
		 * @var    Give_Email_Template_Tags object
127
		 */
128
		public $email_tags;
129
130
		/**
131
		 * Give Donors DB Object
132
		 *
133
		 * @since  1.0
134
		 * @access public
135
		 *
136
		 * @var    Give_DB_Donors object
137
		 */
138
		public $donors;
139
140
		/**
141
		 * Give Donor meta DB Object
142
		 *
143
		 * @since  1.6
144
		 * @access public
145
		 *
146
		 * @var    Give_DB_Donor_Meta object
147
		 */
148
		public $donor_meta;
149
150
		/**
151
		 * Give API Object
152
		 *
153
		 * @since  1.0
154
		 * @access public
155
		 *
156
		 * @var    Give_API object
157
		 */
158
		public $api;
159
160
		/**
161
		 * Give Template Loader Object
162
		 *
163
		 * @since  1.0
164
		 * @access public
165
		 *
166
		 * @var    Give_Template_Loader object
167
		 */
168
		public $template_loader;
169
170
		/**
171
		 * Give No Login Object
172
		 *
173
		 * @since  1.0
174
		 * @access public
175
		 *
176
		 * @var    Give_Email_Access object
177
		 */
178
		public $email_access;
179
180
		/**
181
		* Give notices Object
182
		 *
183
		 * @since  2.0
184
		 * @access public
185
		 *
186
		 * @var    Give_Notices $notices
187
		 */
188
		public $notices;
189
190
		/**
191
		 * Main Give Instance
192
		 *
193
		 * Ensures that only one instance of Give exists in memory at any one
194
		 * time. Also prevents needing to define globals all over the place.
195
		 *
196
		 * @since     1.0
197
		 * @access    public
198
		 *
199
		 * @static
200
		 * @see       Give()
201
		 *
202
		 * @return    Give
203
		 */
204
		public static function instance() {
205
			if ( is_null( self::$_instance ) ) {
206
				self::$_instance = new self();
207
			}
208
209
			return self::$_instance;
210
		}
211
212
		/**
213
		 * Give Constructor.
214
		 */
215
		public function __construct() {
216
			$this->setup_constants();
217
			$this->includes();
218
			$this->init_hooks();
219
220
			do_action( 'give_loaded' );
221
		}
222
223
		/**
224
		 * Hook into actions and filters.
225
		 *
226
		 * @since  1.8.9
227
		 */
228
		private function init_hooks() {
229
			register_activation_hook( __FILE__, 'give_install' );
230
			add_action( 'plugins_loaded', array( $this, 'init' ), 0 );
231
		}
232
		/**
233
		 * Init Give when WordPress Initializes.
234
		 *
235
		 * @since 1.8.9
236
		 */
237
		public function init() {
238
239
			/**
240
			 * Fires before the Give core is initialized.
241
			 *
242
			 * @since 1.8.9
243
			 */
244
			do_action( 'before_give_init' );
245
246
			// Set up localization.
247
			$this->load_textdomain();
248
249
			$this->roles           = new Give_Roles();
250
			$this->api             = new Give_API();
251
			$this->give_settings   = new Give_Admin_Settings();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Give_Admin_Settings() of type object<Give_Admin_Settings> is incompatible with the declared type object<Give_Plugin_Settings> of property $give_settings.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
252
			$this->session         = new Give_Session();
253
			$this->html            = new Give_HTML_Elements();
254
			$this->emails          = new Give_Emails();
255
			$this->email_tags      = new Give_Email_Template_Tags();
256
			$this->donors          = new Give_DB_Donors();
257
			$this->donor_meta      = new Give_DB_Donor_Meta();
258
			$this->template_loader = new Give_Template_Loader();
259
			$this->email_access    = new Give_Email_Access();
260
			$this->notices         = new Give_Notices();
261
262
			/**
263
			 * Fire the action after Give core loads.
264
			 *
265
			 * @param class Give class instance.
266
			 *
267
			 * @since 1.8.7
268
			 */
269
			do_action( 'give_init', $this );
270
271
		}
272
273
		/**
274
		 * Throw error on object clone
275
		 *
276
		 * The whole idea of the singleton design pattern is that there is a single
277
		 * object, therefore we don't want the object to be cloned.
278
		 *
279
		 * @since  1.0
280
		 * @access protected
281
		 *
282
		 * @return void
283
		 */
284
		public function __clone() {
285
			// Cloning instances of the class is forbidden.
286
			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
287
		}
288
289
		/**
290
		 * Disable unserializing of the class
291
		 *
292
		 * @since  1.0
293
		 * @access protected
294
		 *
295
		 * @return void
296
		 */
297
		public function __wakeup() {
298
			// Unserializing instances of the class is forbidden.
299
			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
300
		}
301
302
		/**
303
		 * Setup plugin constants
304
		 *
305
		 * @since  1.0
306
		 * @access private
307
		 *
308
		 * @return void
309
		 */
310
		private function setup_constants() {
311
312
			// Plugin version
313
			if ( ! defined( 'GIVE_VERSION' ) ) {
314
				define( 'GIVE_VERSION', '1.8.12' );
315
			}
316
317
			// Plugin Folder Path
318
			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
319
				define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
320
			}
321
322
			// Plugin Folder URL
323
			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
324
				define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
325
			}
326
327
			// Plugin Basename aka: "give/give.php"
328
			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
329
				define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
330
			}
331
332
			// Plugin Root File
333
			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
334
				define( 'GIVE_PLUGIN_FILE', __FILE__ );
335
			}
336
337
			// Make sure CAL_GREGORIAN is defined
338
			if ( ! defined( 'CAL_GREGORIAN' ) ) {
339
				define( 'CAL_GREGORIAN', 1 );
340
			}
341
342
			// PHP version
343
			if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) {
344
				define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' );
345
			}
346
		}
347
348
		/**
349
		 * Include required files
350
		 *
351
		 * @since  1.0
352
		 * @access private
353
		 *
354
		 * @return void
355
		 */
356
		private function includes() {
357
			global $give_options;
358
359
			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
360
			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';
361
			$give_options = give_get_settings();
362
363
			require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';
364
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
365
			require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
366
			require_once GIVE_PLUGIN_DIR . 'includes/scripts.php';
367
			require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
368
			require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
369
			require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
370
			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
371
			require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php';
372
373
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
374
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';
375
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
376
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';
377
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php';
378
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php';
379
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php';
380
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
381
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
382
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';
383
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
384
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
385
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
386
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';
387
388
			require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
389
			require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
390
			require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
391
			require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
392
			require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
393
			require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
394
			require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
395
			require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
396
			require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
397
			require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
398
			require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
399
			require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
400
			require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
401
			require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
402
			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php';
403
			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
404
			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
405
			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
406
407
			require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
408
			require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
409
			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
410
			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
411
			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
412
413
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
414
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
415
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
416
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
417
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
418
419
			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
420
			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
421
			require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
422
			require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
423
			require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
424
425
			if ( defined( 'WP_CLI' ) && WP_CLI ) {
426
				require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
427
			}
428
429
			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
430
431
				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';
432
				require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';
433
				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';
434
				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
435
				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';
436
				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';
437
				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';
438
				require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';
439
				require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';
440
				require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';
441
442
				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';
443
				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';
444
445
				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php';
446
				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php';
447
				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php';
448
449
				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';
450
				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';
451
				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';
452
453
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php';
454
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php';
455
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php';
456
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php';
457
458
				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php';
459
				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php';
460
				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php';
461
462
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php';
463
464
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php';
465
466
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
467
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
468
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';
469
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';
470
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';
471
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';
472
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';
473
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';
474
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';
475
476
				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php';
477
478
			}// End if().
479
480
			require_once GIVE_PLUGIN_DIR . 'includes/install.php';
481
482
		}
483
484
		/**
485
		 * Loads the plugin language files.
486
		 *
487
		 * @since  1.0
488
		 * @access public
489
		 *
490
		 * @return void
491
		 */
492
		public function load_textdomain() {
493
494
			// Set filter for Give's languages directory
495
			$give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
496
			$give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
497
498
			// Traditional WordPress plugin locale filter.
499
			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
500
			$locale = apply_filters( 'plugin_locale', $locale, 'give' );
501
502
			unload_textdomain( 'give' );
503
			load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' );
504
			load_plugin_textdomain( 'give', false, $give_lang_dir );
505
506
		}
507
508
	}
509
510
endif; // End if class_exists check
511
512
513
/**
514
 * Start Give
515
 *
516
 * The main function responsible for returning the one true Give instance to functions everywhere.
517
 *
518
 * Use this function like you would a global variable, except without needing
519
 * to declare the global.
520
 *
521
 * Example: <?php $give = Give(); ?>
522
 *
523
 * @since 1.0
524
 * @return object|Give
525
 */
526
function Give() {
0 ignored issues
show
The function name Give is in camel caps, but expected _give instead as per the coding standard.
Loading history...
527
	return Give::instance();
528
}
529
530
Give();