Completed
Push — hotfix/give_currency_filter ( 2ab3ef )
by Ravinder
49:07 queued 29:09
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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 54 and the first side effect is on line 44.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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.8
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 contribution to WordPress.
37
 *
38
 * - The WordImpress Team
39
 *
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
		/** Singleton *************************************************************/
56
57
		/**
58
		 * Give Instance
59
		 *
60
		 * @since  1.0
61
		 * @access private
62
		 *
63
		 * @var    Give The one true Give
64
		 */
65
		private static $instance;
66
67
		/**
68
		 * Give Roles Object
69
		 *
70
		 * @since  1.0
71
		 * @access public
72
		 *
73
		 * @var    Give_Roles object
74
		 */
75
		public $roles;
76
77
		/**
78
		 * Give Settings Object
79
		 *
80
		 * @since  1.0
81
		 * @access public
82
		 *
83
		 * @var    Give_Plugin_Settings object
84
		 */
85
		public $give_settings;
86
87
		/**
88
		 * Give Session Object
89
		 *
90
		 * This holds donation data for user's session.
91
		 *
92
		 * @since  1.0
93
		 * @access public
94
		 *
95
		 * @var    Give_Session object
96
		 */
97
		public $session;
98
99
		/**
100
		 * Give HTML Element Helper Object
101
		 *
102
		 * @since  1.0
103
		 * @access public
104
		 *
105
		 * @var    Give_HTML_Elements object
106
		 */
107
		public $html;
108
109
		/**
110
		 * Give Emails Object
111
		 *
112
		 * @since  1.0
113
		 * @access public
114
		 *
115
		 * @var    Give_Emails object
116
		 */
117
		public $emails;
118
119
		/**
120
		 * Give Email Template Tags Object
121
		 *
122
		 * @since  1.0
123
		 * @access public
124
		 *
125
		 * @var    Give_Email_Template_Tags object
126
		 */
127
		public $email_tags;
128
129
		/**
130
		 * Give Customers DB Object
131
		 *
132
		 * @since  1.0
133
		 * @access public
134
		 *
135
		 * @var    Give_DB_Customers object
136
		 */
137
		public $customers;
138
139
		/**
140
		 * Give Customer meta DB Object
141
		 *
142
		 * @since  1.6
143
		 * @access public
144
		 *
145
		 * @var    Give_DB_Customer_Meta object
146
		 */
147
		public $customer_meta;
148
149
		/**
150
		 * Give API Object
151
		 *
152
		 * @since  1.0
153
		 * @access public
154
		 *
155
		 * @var    Give_API object
156
		 */
157
		public $api;
158
159
		/**
160
		 * Give Template Loader Object
161
		 *
162
		 * @since  1.0
163
		 * @access public
164
		 *
165
		 * @var    Give_Template_Loader object
166
		 */
167
		public $template_loader;
168
169
		/**
170
		 * Give No Login Object
171
		 *
172
		 * @since  1.0
173
		 * @access public
174
		 *
175
		 * @var    Give_Email_Access object
176
		 */
177
		public $email_access;
178
179
		/**
180
		 * Main Give Instance
181
		 *
182
		 * Insures that only one instance of Give exists in memory at any one
183
		 * time. Also prevents needing to define globals all over the place.
184
		 *
185
		 * @since     1.0
186
		 * @access    public
187
		 *
188
		 * @static
189
		 * @staticvar array $instance
190
		 * @uses      Give::setup_constants() Setup the constants needed.
191
		 * @uses      Give::includes() Include the required files.
192
		 * @uses      Give::load_textdomain() load the language files.
193
		 * @see       Give()
194
		 *
195
		 * @return    Give
196
		 */
197
		public static function instance() {
198
			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) {
199
				self::$instance = new Give;
200
				self::$instance->setup_constants();
201
202
				add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );
203
204
				self::$instance->includes();
205
				self::$instance->roles           = new Give_Roles();
206
				self::$instance->api             = new Give_API();
207
				self::$instance->give_settings   = new Give_Admin_Settings();
208
				self::$instance->session         = new Give_Session();
209
				self::$instance->html            = new Give_HTML_Elements();
210
				self::$instance->emails          = new Give_Emails();
211
				self::$instance->email_tags      = new Give_Email_Template_Tags();
212
				self::$instance->customers       = new Give_DB_Customers();
213
				self::$instance->customer_meta   = new Give_DB_Customer_Meta();
214
				self::$instance->template_loader = new Give_Template_Loader();
215
				self::$instance->email_access    = new Give_Email_Access();
216
217
218
				/**
219
				 * Fire the action after Give core loads
220
				 *
221
				 * @since 1.8.7
222
				 */
223
				do_action( 'give_init', self::$instance );
224
225
			}
226
227
			return self::$instance;
228
		}
229
230
		/**
231
		 * Throw error on object clone
232
		 *
233
		 * The whole idea of the singleton design pattern is that there is a single
234
		 * object, therefore we don't want the object to be cloned.
235
		 *
236
		 * @since  1.0
237
		 * @access protected
238
		 *
239
		 * @return void
240
		 */
241
		public function __clone() {
242
			// Cloning instances of the class is forbidden
243
			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
244
		}
245
246
		/**
247
		 * Disable unserializing of the class
248
		 *
249
		 * @since  1.0
250
		 * @access protected
251
		 *
252
		 * @return void
253
		 */
254
		public function __wakeup() {
255
			// Unserializing instances of the class is forbidden.
256
			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
257
		}
258
259
		/**
260
		 * Setup plugin constants
261
		 *
262
		 * @since  1.0
263
		 * @access private
264
		 *
265
		 * @return void
266
		 */
267
		private function setup_constants() {
268
269
			// Plugin version
270
			if ( ! defined( 'GIVE_VERSION' ) ) {
271
				define( 'GIVE_VERSION', '1.8.8' );
272
			}
273
274
			// Plugin Folder Path
275
			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
276
				define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
277
			}
278
279
			// Plugin Folder URL
280
			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
281
				define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
282
			}
283
284
			// Plugin Basename aka: "give/give.php"
285
			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
286
				define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
287
			}
288
289
			// Plugin Root File
290
			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
291
				define( 'GIVE_PLUGIN_FILE', __FILE__ );
292
			}
293
294
			// Make sure CAL_GREGORIAN is defined
295
			if ( ! defined( 'CAL_GREGORIAN' ) ) {
296
				define( 'CAL_GREGORIAN', 1 );
297
			}
298
		}
299
300
		/**
301
		 * Include required files
302
		 *
303
		 * @since  1.0
304
		 * @access private
305
		 *
306
		 * @return void
307
		 */
308
		private function includes() {
309
			global $give_options;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
310
311
			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
312
			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';
313
			$give_options = give_get_settings();
314
315
			require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';
316
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
317
			require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
318
			require_once GIVE_PLUGIN_DIR . 'includes/scripts.php';
319
			require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
320
			require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
321
			require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
322
			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
323
324
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
325
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';
326
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
327
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';
328
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php';
329
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customer-meta.php';
330
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php';
331
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
332
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
333
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';
334
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
335
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
336
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
337
			require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';
338
339
			require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
340
			require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
341
			require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
342
			require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
343
			require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
344
			require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
345
			require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
346
			require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
347
			require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
348
			require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
349
			require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
350
			require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
351
			require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
352
			require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
353
			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
354
			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
355
			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
356
357
			require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
358
			require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
359
			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
360
			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
361
			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
362
363
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
364
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
365
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
366
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
367
			require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
368
369
			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
370
			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
371
			require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
372
			require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
373
			require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
374
375
			if ( defined( 'WP_CLI' ) && WP_CLI ) {
376
				require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
377
			}
378
379
			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
380
381
				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';
382
				require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';
383
				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';
384
				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php';
385
				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
386
				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';
387
				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';
388
				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';
389
				require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php';
390
				require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';
391
				require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';
392
				require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';
393
394
				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';
395
				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';
396
397
				require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php';
398
				require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php';
399
				require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php';
400
401
				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';
402
				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';
403
				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';
404
405
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php';
406
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php';
407
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php';
408
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php';
409
410
				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php';
411
				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php';
412
				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php';
413
414
				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php';
415
416
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
417
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
418
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';
419
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';
420
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';
421
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';
422
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';
423
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';
424
				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';
425
426
				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
427
				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php';
428
429
			}
430
431
			require_once GIVE_PLUGIN_DIR . 'includes/install.php';
432
433
		}
434
435
		/**
436
		 * Loads the plugin language files
437
		 *
438
		 * @since  1.0
439
		 * @access public
440
		 *
441
		 * @return void
442
		 */
443
		public function load_textdomain() {
444
			// Set filter for Give's languages directory
445
			$give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
446
			$give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
447
448
			// Traditional WordPress plugin locale filter
449
			$locale = apply_filters( 'plugin_locale', get_locale(), 'give' );
450
			$mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale );
451
452
			// Setup paths to current locale file
453
			$mofile_local  = $give_lang_dir . $mofile;
454
			$mofile_global = WP_LANG_DIR . '/give/' . $mofile;
455
456
			if ( file_exists( $mofile_global ) ) {
457
				// Look in global /wp-content/languages/give folder
458
				load_textdomain( 'give', $mofile_global );
459
			} elseif ( file_exists( $mofile_local ) ) {
460
				// Look in local location from filter `give_languages_directory`
461
				load_textdomain( 'give', $mofile_local );
462
			} else {
463
				// Load the default language files packaged up w/ Give
464
				load_plugin_textdomain( 'give', false, $give_lang_dir );
465
			}
466
		}
467
468
	}
469
470
endif; // End if class_exists check
471
472
473
/**
474
 * Start Give
475
 *
476
 * The main function responsible for returning the one true Give instance to functions everywhere.
477
 *
478
 * Use this function like you would a global variable, except without needing
479
 * to declare the global.
480
 *
481
 * Example: <?php $give = Give(); ?>
482
 *
483
 * @since 1.0
484
 * @return object|Give
485
 */
486
function Give() {
487
	return Give::instance();
488
}
489
490
// Get Give Running
491
Give();
492