PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.8.1
GiveWP – Donation Plugin and Fundraising Platform v2.8.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 5 years ago blocks 5 years ago includes 5 years ago languages 5 years ago sample-data 6 years ago src 5 years ago templates 6 years ago trunk 5 years ago vendor 5 years ago .stylelintignore 6 years ago give.php 5 years ago license.txt 6 years ago readme.txt 5 years ago uninstall.php 5 years ago wpml-config.xml 6 years ago
give.php
491 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.8.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
28 * anyone. Open source software is made by many people, and distributed under licenses that comply with the Open Source
29 * Definition."
30 *
31 * -- The Open Source Initiative
32 *
33 * Give is a tribute to the spirit and philosophy of Open Source. We at GiveWP gladly embrace the Open Source
34 * philosophy both 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
37 * and their talented developers. Thank you all for your contribution to WordPress.
38 *
39 * - The GiveWP Team
40 */
41
42 use Give\Container\Container;
43 use Give\Form\Templates;
44 use Give\Route\Form as FormRoute;
45 use Give\Controller\Form as FormRouteController;
46 use Give\ServiceProviders\LegacyServiceProvider;
47 use Give\ServiceProviders\RestAPI;
48 use Give\ServiceProviders\Onboarding;
49 use Give\ServiceProviders\ServiceProvider;
50
51 // Exit if accessed directly.
52 if ( ! defined( 'ABSPATH' ) ) {
53 exit;
54 }
55
56 /**
57 * Main Give Class
58 *
59 * @since 2.8.0 build in a service container
60 * @since 1.0
61 *
62 * @property-read Give_API $api
63 * @property-read Give_Async_Process $async_process
64 * @property-read Give_Comment $comment
65 * @property-read Give_DB_Donors $donors
66 * @property-read Give_DB_Donor_Meta $donor_meta
67 * @property-read Give_Emails $emails
68 * @property-read Give_Email_Template_Tags $email_tags
69 * @property-read Give_DB_Form_Meta $form_meta
70 * @property-read Give_Admin_Settings $give_settings
71 * @property-read Give_HTML_Elements $html
72 * @property-read Give_Logging $logs
73 * @property-read Give_DB_Logs $log_db
74 * @property-read Give_DB_Log_Meta $logmeta_db
75 * @property-read Give_Notices $notices
76 * @property-read Give_DB_Payment_Meta $payment_meta
77 * @property-read Give_Roles $roles
78 * @property-read FormRoute $routeForm
79 * @property-read Templates $templates
80 * @property-read Give_Scripts $scripts
81 * @property-read Give_DB_Sequential_Ordering $sequential_donation_db
82 * @property-read Give_Sequential_Donation_Number $seq_donation_number
83 * @property-read Give_Session $session
84 * @property-read Give_DB_Sessions $session_db
85 * @property-read Give_Tooltips $tooltips
86 *
87 * @mixin Container
88 */
89 final class Give {
90 /**
91 * Give Template Loader Object
92 *
93 * @since 1.0
94 * @access public
95 *
96 * @var Give_Template_Loader object
97 */
98 public $template_loader;
99
100 /**
101 * Give No Login Object
102 *
103 * @since 1.0
104 * @access public
105 *
106 * @var Give_Email_Access object
107 */
108 public $email_access;
109
110 /**
111 * Give_Stripe Object.
112 *
113 * @since 2.5.0
114 * @access public
115 *
116 * @var Give_Stripe
117 */
118 public $stripe;
119
120 /**
121 * @since 2.8.0
122 *
123 * @var Container
124 */
125 private $container;
126
127 /**
128 * @since 2.8.0
129 *
130 * @var array Array of Service Providers to load
131 */
132 private $serviceProviders = [
133 LegacyServiceProvider::class,
134 RestAPI::class,
135 Onboarding::class,
136 ];
137
138 /**
139 * @since 2.8.0
140 *
141 * @var bool Make sure the providers are loaded only once
142 */
143 private $providersLoaded = false;
144
145 /**
146 * Give constructor.
147 *
148 * Sets up the Container to be used for managing all other instances and data
149 *
150 * @since 2.8.0
151 */
152 public function __construct() {
153 $this->container = new Container();
154 }
155
156 /**
157 * Bootstraps the Give Plugin
158 *
159 * @since 2.8.0
160 */
161 public function boot() {
162 // PHP version
163 if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) {
164 define( 'GIVE_REQUIRED_PHP_VERSION', '5.6.0' );
165 }
166
167 // Bailout: Need minimum php version to load plugin.
168 if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) {
169 add_action( 'admin_notices', [ $this, 'minimum_phpversion_notice' ] );
170
171 return;
172 }
173
174 $this->setup_constants();
175
176 // Add compatibility notice for recurring and stripe support with Give 2.5.0.
177 add_action( 'admin_notices', [ $this, 'display_old_recurring_compatibility_notice' ] );
178
179 add_action( 'plugins_loaded', [ $this, 'init' ], 0 );
180
181 register_activation_hook( GIVE_PLUGIN_FILE, [ $this, 'install' ] );
182
183 do_action( 'give_loaded' );
184 }
185
186 /**
187 * Init Give when WordPress Initializes.
188 *
189 * @since 1.8.9
190 */
191 public function init() {
192 /**
193 * Fires before the Give core is initialized.
194 *
195 * @since 1.8.9
196 */
197 do_action( 'before_give_init' );
198
199 // Set up localization.
200 $this->load_textdomain();
201
202 $this->bindClasses();
203
204 $this->loadServiceProviders();
205
206 // Load form template
207 $this->templates->load();
208
209 // Load routes.
210 $this->routeForm->init( new FormRouteController() );
211
212 /**
213 * Fire the action after Give core loads.
214 *
215 * @since 1.8.7
216 *
217 * @param Give class instance.
218 *
219 */
220 do_action( 'give_init', $this );
221 }
222
223 /**
224 * Binds the initial classes to the service provider.
225 *
226 * @since 2.8.0
227 */
228 private function bindClasses() {
229 $this->container->singleton( 'templates', Templates::class );
230 $this->container->singleton( 'routeForm', FormRoute::class );
231 }
232
233 /**
234 * Setup plugin constants
235 *
236 * @since 1.0
237 * @access private
238 *
239 * @return void
240 */
241 private function setup_constants() {
242 // Plugin version.
243 if ( ! defined( 'GIVE_VERSION' ) ) {
244 define( 'GIVE_VERSION', '2.8.1' );
245 }
246
247 // Plugin Root File.
248 if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
249 define( 'GIVE_PLUGIN_FILE', __FILE__ );
250 }
251
252 // Plugin Folder Path.
253 if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
254 define( 'GIVE_PLUGIN_DIR', plugin_dir_path( GIVE_PLUGIN_FILE ) );
255 }
256
257 // Plugin Folder URL.
258 if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
259 define( 'GIVE_PLUGIN_URL', plugin_dir_url( GIVE_PLUGIN_FILE ) );
260 }
261
262 // Plugin Basename aka: "give/give.php".
263 if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
264 define( 'GIVE_PLUGIN_BASENAME', plugin_basename( GIVE_PLUGIN_FILE ) );
265 }
266
267 // Make sure CAL_GREGORIAN is defined.
268 if ( ! defined( 'CAL_GREGORIAN' ) ) {
269 define( 'CAL_GREGORIAN', 1 );
270 }
271 }
272
273 /**
274 * Loads the plugin language files.
275 *
276 * @since 1.0
277 * @access public
278 *
279 * @return void
280 */
281 public function load_textdomain() {
282 // Set filter for Give's languages directory
283 $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
284 $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
285
286 // Traditional WordPress plugin locale filter.
287 $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
288 $locale = apply_filters( 'plugin_locale', $locale, 'give' );
289
290 unload_textdomain( 'give' );
291 load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' );
292 load_plugin_textdomain( 'give', false, $give_lang_dir );
293 }
294
295
296 /**
297 * Show minimum PHP version notice.
298 *
299 * @since 1.8.12
300 * @access public
301 */
302 public function minimum_phpversion_notice() {
303 // Bailout.
304 if ( ! is_admin() ) {
305 return;
306 }
307
308 $notice_desc = '<p><strong>' . __(
309 'Your site could be faster and more secure with a newer PHP version.',
310 'give'
311 ) . '</strong></p>';
312 $notice_desc .= '<p>' . __(
313 '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.',
314 'give'
315 ) . '</p>';
316 $notice_desc .= '<p>' . __(
317 '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.',
318 'give'
319 ) . '</p>';
320 $notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>';
321 $notice_desc .= '<p>' . __(
322 '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.',
323 'give'
324 ) . '</p>';
325 $notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>';
326 $notice_desc .= '<p>' . sprintf(
327 __(
328 '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.',
329 'give'
330 ),
331 sprintf(
332 '<a href="%1$s" target="_blank">',
333 esc_url( 'https://wordpress.org/hosting/' )
334 ),
335 '</a>'
336 ) . '</p>';
337
338 echo sprintf(
339 '<div class="notice notice-error">%1$s</div>',
340 wp_kses_post( $notice_desc )
341 );
342 }
343
344 /**
345 * Display compatibility notice for Give 2.5.0 and Recurring 1.8.13 when Stripe premium is not active.
346 *
347 * @since 2.5.0
348 *
349 * @return void
350 */
351 public function display_old_recurring_compatibility_notice() {
352 // Show notice, if incompatibility found.
353 if (
354 defined( 'GIVE_RECURRING_VERSION' )
355 && version_compare( GIVE_RECURRING_VERSION, '1.9.0', '<' )
356 && defined( 'GIVE_STRIPE_VERSION' )
357 && version_compare( GIVE_STRIPE_VERSION, '2.2.0', '<' )
358 ) {
359 $message = sprintf(
360 __(
361 '<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.',
362 'give'
363 ),
364 esc_url( 'https://givewp.com/wp-login.php' ),
365 esc_url( 'https://givewp.com/my-account/#tab_downloads' )
366 );
367
368 Give()->notices->register_notice(
369 [
370 'id' => 'give-compatibility-with-old-recurring',
371 'description' => $message,
372 'dismissible_type' => 'user',
373 'dismiss_interval' => 'shortly',
374 ]
375 );
376 }
377 }
378
379 public function install() {
380 $this->loadServiceProviders();
381 give_install();
382 }
383
384 /**
385 * Load all the service providers to bootstrap the various parts of the application.
386 *
387 * @since 2.8.0
388 */
389 private function loadServiceProviders() {
390 if ( $this->providersLoaded ) {
391 return;
392 }
393
394 $providers = [];
395
396 foreach ( $this->serviceProviders as $serviceProvider ) {
397 if ( ! is_subclass_of( $serviceProvider, ServiceProvider::class ) ) {
398 throw new InvalidArgumentException( "$serviceProvider class must implement the ServiceProvider interface" );
399 }
400
401 /** @var ServiceProvider $serviceProvider */
402 $serviceProvider = new $serviceProvider();
403
404 $serviceProvider->register();
405
406 $providers[] = $serviceProvider;
407 }
408
409 foreach ( $providers as $serviceProvider ) {
410 $serviceProvider->boot();
411 }
412
413 $this->providersLoaded = true;
414 }
415
416 /**
417 * Register a Service Provider for bootstrapping
418 *
419 * @since 2.8.0
420 *
421 * @param $serviceProvider
422 */
423 public function registerServiceProvider( $serviceProvider ) {
424 $this->serviceProviders[] = $serviceProvider;
425 }
426
427 /**
428 * Magic properties are passed to the service container to retrieve the data.
429 *
430 * @since 2.8.0 retrieve from the service container
431 * @since 2.7.0
432 *
433 * @param string $propertyName
434 *
435 * @return mixed
436 * @throws Exception
437 */
438 public function __get( $propertyName ) {
439 return $this->container->get( $propertyName );
440 }
441
442 /**
443 * Magic methods are passed to the service container.
444 *
445 * @since 2.8.0
446 *
447 * @param $name
448 * @param $arguments
449 *
450 * @return mixed
451 */
452 public function __call( $name, $arguments ) {
453 return call_user_func_array( [ $this->container, $name ], $arguments );
454 }
455 }
456
457 /**
458 * Start Give
459 *
460 * The main function responsible for returning the one true Give instance to functions everywhere.
461 *
462 * Use this function like you would a global variable, except without needing
463 * to declare the global.
464 *
465 * Example: <?php $give = Give(); ?>
466 *
467 * @since 2.8.0 add parameter for quick retrieval from container
468 * @since 1.0
469 *
470 * @param null $abstract Selector for data to retrieve from the service container
471 *
472 * @return object|Give
473 */
474 function Give( $abstract = null ) {
475 static $instance = null;
476
477 if ( $instance === null ) {
478 $instance = new Give();
479 }
480
481 if ( $abstract !== null ) {
482 return $instance->make( $abstract );
483 }
484
485 return $instance;
486 }
487
488 require 'vendor/autoload.php';
489
490 Give()->boot();
491