| @@ -1,12 +1,15 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | /** |
| 3 | 4 | * Plugin Name: Give - Donation Plugin |
| 4 | 5 | * Plugin URI: https://givewp.com |
| 5 | 6 | * Description: The most robust, flexible, and intuitive way to accept donations on WordPress. |
| 6 | 7 | * Author: GiveWP |
| 7 | - * Author URI: https://wordimpress.com | |
| 8 | - * Version: 2.3.0 | |
| 8 | + * Author URI: https://givewp.com/ | |
| 9 | + * Version: 4.16.9 | |
| 10 | + * Requires at least: 6.9 | |
| 11 | + * Requires PHP: 7.4 | |
| 9 | 12 | * Text Domain: give |
| 10 | 13 | * Domain Path: /languages |
| 11 | 14 | * |
| 12 | 15 | * Give is free software: you can redistribute it and/or modify |
| @@ -23,677 +26,567 @@ | ||
| 23 | 26 | * along with Give. If not, see <https://www.gnu.org/licenses/>. |
| 24 | 27 | * |
| 25 | 28 | * A Tribute to Open Source: |
| 26 | 29 | * |
| 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." | |
| 30 | + * "Open source software is software that can be freely used, changed, and shared (in modified or unmodified form) by | |
| 31 | + * anyone. Open source software is made by many people, and distributed under licenses that comply with the Open Source | |
| 32 | + * Definition." | |
| 29 | 33 | * |
| 30 | 34 | * -- The Open Source Initiative |
| 31 | 35 | * |
| 32 | - * Give is a tribute to the spirit and philosophy of Open Source. We at WordImpress 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. | |
| 36 | + * Give is a tribute to the spirit and philosophy of Open Source. We at GiveWP gladly embrace the Open Source | |
| 37 | + * philosophy both in how Give itself was developed, and how we hope to see others build more from our code base. | |
| 34 | 38 | * |
| 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. | |
| 39 | + * Give would not have been possible without the tireless efforts of WordPress and the surrounding Open Source projects | |
| 40 | + * and their talented developers. Thank you all for your contribution to WordPress. | |
| 36 | 41 | * |
| 37 | - * - The WordImpress Team | |
| 42 | + * - The GiveWP Team | |
| 38 | 43 | */ |
| 39 | 44 | |
| 45 | +use Give\Campaigns\Repositories\CampaignRepository; | |
| 46 | +use Give\Container\Container; | |
| 47 | +use Give\DonationForms\ServiceProvider as DonationFormsServiceProvider; | |
| 48 | +use Give\DonationForms\V2\Repositories\DonationFormsRepository; | |
| 49 | +use Give\DonationForms\V2\ServiceProvider as DonationFormsServiceProviderV2; | |
| 50 | +use Give\Donations\Repositories\DonationRepository; | |
| 51 | +use Give\Donations\ServiceProvider as DonationServiceProvider; | |
| 52 | +use Give\DonationSummary\ServiceProvider as DonationSummaryServiceProvider; | |
| 53 | +use Give\DonorDashboards\Profile; | |
| 54 | +use Give\DonorDashboards\ServiceProvider as DonorDashboardsServiceProvider; | |
| 55 | +use Give\DonorDashboards\Tabs\TabsRegister; | |
| 56 | +use Give\Donors\Repositories\DonorRepositoryProxy; | |
| 57 | +use Give\Donors\ServiceProvider as DonorsServiceProvider; | |
| 58 | +use Give\Form\LegacyConsumer\ServiceProvider as FormLegacyConsumerServiceProvider; | |
| 59 | +use Give\Form\Templates; | |
| 60 | +use Give\FormBuilder\ServiceProvider as FormBuilderServiceProvider; | |
| 61 | +use Give\FormMigration\ServiceProvider as FormMigrationServiceProvider; | |
| 62 | +use Give\Framework\Database\ServiceProvider as DatabaseServiceProvider; | |
| 63 | +use Give\Framework\DesignSystem\DesignSystemServiceProvider; | |
| 64 | +use Give\Framework\Exceptions\Primitives\InvalidArgumentException; | |
| 65 | +use Give\Framework\Exceptions\UncaughtExceptionLogger; | |
| 66 | +use Give\Framework\FormDesigns\ServiceProvider as FormDesignServiceProvider; | |
| 67 | +use Give\Framework\Http\ServiceProvider as HttpServiceProvider; | |
| 68 | +use Give\Framework\Migrations\MigrationsServiceProvider; | |
| 69 | +use Give\Framework\PaymentGateways\PaymentGatewayRegister; | |
| 70 | +use Give\Framework\ValidationRules\ValidationRulesServiceProvider; | |
| 71 | +use Give\Framework\WordPressShims\ServiceProvider as WordPressShimsServiceProvider; | |
| 72 | +use Give\Helpers\Language; | |
| 73 | +use Give\LegacySubscriptions\ServiceProvider as LegacySubscriptionsServiceProvider; | |
| 74 | +use Give\License\LicenseServiceProvider; | |
| 75 | +use Give\Log\LogServiceProvider; | |
| 76 | +use Give\MigrationLog\MigrationLogServiceProvider; | |
| 77 | +use Give\MultiFormGoals\ServiceProvider as MultiFormGoalsServiceProvider; | |
| 78 | +use Give\PaymentGateways\Gateways\TestOffsiteGateway\TestOffsiteGateway; | |
| 79 | +use Give\PaymentGateways\ServiceProvider as PaymentGatewaysServiceProvider; | |
| 80 | +use Give\Promotions\ServiceProvider as PromotionsServiceProvider; | |
| 81 | +use Give\Revenue\RevenueServiceProvider; | |
| 82 | +use Give\Route\Form as FormRoute; | |
| 83 | +use Give\ServiceProviders\GlobalStyles as GlobalStylesServiceProvider; | |
| 84 | +use Give\ServiceProviders\LegacyServiceProvider; | |
| 85 | +use Give\ServiceProviders\Onboarding; | |
| 86 | +use Give\ServiceProviders\PaymentGateways; | |
| 87 | +use Give\ServiceProviders\RestAPI; | |
| 88 | +use Give\ServiceProviders\Routes; | |
| 89 | +use Give\ServiceProviders\ServiceProvider; | |
| 90 | +use Give\Subscriptions\Repositories\SubscriptionRepository; | |
| 91 | +use Give\Subscriptions\ServiceProvider as SubscriptionServiceProvider; | |
| 92 | +use Give\TestData\ServiceProvider as TestDataServiceProvider; | |
| 93 | +use Give\Tracking\TrackingServiceProvider; | |
| 94 | +use Give\VendorOverrides\AdminNotices\AdminNoticesServiceProvider; | |
| 95 | +use Give\VendorOverrides\FieldConditions\FieldConditionsServiceProvider; | |
| 96 | +use Give\VendorOverrides\Validation\ValidationServiceProvider; | |
| 97 | + | |
| 40 | 98 | // Exit if accessed directly. |
| 41 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 42 | - exit; | |
| 99 | +if (!defined('ABSPATH')) { | |
| 100 | + exit; | |
| 43 | 101 | } |
| 44 | 102 | |
| 45 | -if ( ! class_exists( 'Give' ) ) : | |
| 103 | +/** | |
| 104 | + * Main Give Class | |
| 105 | + * | |
| 106 | + * @since 2.21.0 Remove php dependency validation logic and constant | |
| 107 | + * @since 2.19.6 add $donations, $subscriptions, and replace $donors class with DonorRepositoryProxy | |
| 108 | + * @since 2.8.0 build in a service container | |
| 109 | + * @since 1.0 | |
| 110 | + * | |
| 111 | + * @property-read Give_API $api | |
| 112 | + * @property-read Give_Async_Process $async_process | |
| 113 | + * @property-read Give_Comment $comment | |
| 114 | + * @property-read Give_DB_Donor_Meta $donor_meta | |
| 115 | + * @property-read Give_Emails $emails | |
| 116 | + * @property-read Give_Email_Template_Tags $email_tags | |
| 117 | + * @property-read Give_DB_Form_Meta $form_meta | |
| 118 | + * @property-read Give_Admin_Settings $give_settings | |
| 119 | + * @property-read Give_HTML_Elements $html | |
| 120 | + * @property-read Give_Logging $logs | |
| 121 | + * @property-read Give_Notices $notices | |
| 122 | + * @property-read Give_DB_Payment_Meta $payment_meta | |
| 123 | + * @property-read Give_Roles $roles | |
| 124 | + * @property-read FormRoute $routeForm | |
| 125 | + * @property-read Templates $templates | |
| 126 | + * @property-read Give_Scripts $scripts | |
| 127 | + * @property-read Give_DB_Sequential_Ordering $sequential_donation_db | |
| 128 | + * @property-read Give_Sequential_Donation_Number $seq_donation_number | |
| 129 | + * @property-read Give_Session $session | |
| 130 | + * @property-read Give_DB_Sessions $session_db | |
| 131 | + * @property-read Give_Tooltips $tooltips | |
| 132 | + * @property-read PaymentGatewayRegister $gateways | |
| 133 | + * @property-read DonationRepository $donations | |
| 134 | + * @property-read DonorRepositoryProxy $donors | |
| 135 | + * @property-read SubscriptionRepository $subscriptions | |
| 136 | + * @property-read DonationFormsRepository $donationForms | |
| 137 | + * @property-read CampaignRepository $campaigns | |
| 138 | + * @property-read Profile $donorDashboard | |
| 139 | + * @property-read TabsRegister $donorDashboardTabs | |
| 140 | + * @property-read Give_Recurring_DB_Subscription_Meta $subscription_meta | |
| 141 | + * | |
| 142 | + * @mixin Container | |
| 143 | + */ | |
| 144 | +final class Give | |
| 145 | +{ | |
| 146 | + /** | |
| 147 | + * Give Template Loader Object | |
| 148 | + * | |
| 149 | + * @since 1.0 | |
| 150 | + * @access public | |
| 151 | + * | |
| 152 | + * @var Give_Template_Loader object | |
| 153 | + */ | |
| 154 | + public $template_loader; | |
| 46 | 155 | |
| 47 | - /** | |
| 48 | - * Main Give Class | |
| 49 | - * | |
| 50 | - * @since 1.0 | |
| 51 | - */ | |
| 52 | - final class Give { | |
| 156 | + /** | |
| 157 | + * Give No Login Object | |
| 158 | + * | |
| 159 | + * @since 1.0 | |
| 160 | + * @access public | |
| 161 | + * | |
| 162 | + * @var Give_Email_Access object | |
| 163 | + */ | |
| 164 | + public $email_access; | |
| 53 | 165 | |
| 54 | - /** Singleton *************************************************************/ | |
| 166 | + /** | |
| 167 | + * Give_Stripe Object. | |
| 168 | + * | |
| 169 | + * @since 2.5.0 | |
| 170 | + * @access public | |
| 171 | + * | |
| 172 | + * @var Give_Stripe | |
| 173 | + */ | |
| 174 | + public $stripe; | |
| 55 | 175 | |
| 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; | |
| 176 | + /** | |
| 177 | + * @var Give_DB_Customers | |
| 178 | + * @deprecated use give()->donors instead | |
| 179 | + */ | |
| 180 | + public $customers; | |
| 65 | 181 | |
| 66 | - /** | |
| 67 | - * Give Roles Object | |
| 68 | - * | |
| 69 | - * @since 1.0 | |
| 70 | - * @access public | |
| 71 | - * | |
| 72 | - * @var Give_Roles object | |
| 73 | - */ | |
| 74 | - public $roles; | |
| 182 | + /** | |
| 183 | + * @var Give_DB_Customer_Meta | |
| 184 | + * @deprecated use give()->donor_meta instead | |
| 185 | + */ | |
| 186 | + public $customer_meta; | |
| 75 | 187 | |
| 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; | |
| 188 | + /** | |
| 189 | + * @since 2.8.0 | |
| 190 | + * | |
| 191 | + * @var Container | |
| 192 | + */ | |
| 193 | + private $container; | |
| 85 | 194 | |
| 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; | |
| 195 | + /** | |
| 196 | + * @since 3.17.0 added Settings service provider | |
| 197 | + * @since 2.25.0 added HttpServiceProvider | |
| 198 | + * @since 2.19.6 added Donors, Donations, and Subscriptions | |
| 199 | + * @since 2.8.0 | |
| 200 | + * | |
| 201 | + * @var array Array of Service Providers to load | |
| 202 | + */ | |
| 203 | + private $serviceProviders = [ | |
| 204 | + LegacyServiceProvider::class, | |
| 205 | + RestAPI::class, | |
| 206 | + Routes::class, | |
| 207 | + PaymentGateways::class, | |
| 208 | + Onboarding::class, | |
| 209 | + MigrationsServiceProvider::class, | |
| 210 | + RevenueServiceProvider::class, | |
| 211 | + MultiFormGoalsServiceProvider::class, | |
| 212 | + DonorDashboardsServiceProvider::class, | |
| 213 | + TrackingServiceProvider::class, | |
| 214 | + TestDataServiceProvider::class, | |
| 215 | + MigrationLogServiceProvider::class, | |
| 216 | + LogServiceProvider::class, | |
| 217 | + FormLegacyConsumerServiceProvider::class, | |
| 218 | + LicenseServiceProvider::class, | |
| 219 | + Give\Email\ServiceProvider::class, | |
| 220 | + DonationSummaryServiceProvider::class, | |
| 221 | + PaymentGatewaysServiceProvider::class, | |
| 222 | + LegacySubscriptionsServiceProvider::class, | |
| 223 | + Give\Exports\ServiceProvider::class, | |
| 224 | + DonationServiceProvider::class, | |
| 225 | + DonorsServiceProvider::class, | |
| 226 | + SubscriptionServiceProvider::class, | |
| 227 | + DonationFormsServiceProviderV2::class, | |
| 228 | + PromotionsServiceProvider::class, | |
| 229 | + LegacySubscriptionsServiceProvider::class, | |
| 230 | + WordPressShimsServiceProvider::class, | |
| 231 | + DatabaseServiceProvider::class, | |
| 232 | + GlobalStylesServiceProvider::class, | |
| 233 | + ValidationServiceProvider::class, | |
| 234 | + ValidationRulesServiceProvider::class, | |
| 235 | + AdminNoticesServiceProvider::class, | |
| 236 | + HttpServiceProvider::class, | |
| 237 | + DesignSystemServiceProvider::class, | |
| 238 | + FieldConditionsServiceProvider::class, | |
| 239 | + FormBuilderServiceProvider::class, | |
| 240 | + DonationFormsServiceProvider::class, | |
| 241 | + FormDesignServiceProvider::class, | |
| 242 | + FormMigrationServiceProvider::class, | |
| 243 | + //TODO: merge this service provider | |
| 244 | + Give\PaymentGateways\Gateways\ServiceProvider::class, | |
| 245 | + Give\EventTickets\ServiceProvider::class, | |
| 246 | + Give\BetaFeatures\ServiceProvider::class, | |
| 247 | + Give\FormTaxonomies\ServiceProvider::class, | |
| 248 | + Give\DonationSpam\ServiceProvider::class, | |
| 249 | + Give\Settings\ServiceProvider::class, | |
| 250 | + Give\Campaigns\ServiceProvider::class, | |
| 251 | + Give\FeatureFlags\OptionBasedFormEditor\ServiceProvider::class, | |
| 252 | + Give\ThirdPartySupport\ServiceProvider::class, | |
| 253 | + Give\ThirdPartyCompatibility\ServiceProvider::class, | |
| 254 | + Give\API\REST\V3\Routes\ServiceProvider::class, | |
| 255 | + Give\Framework\PaymentGateways\ServiceProvider::class, | |
| 256 | + Give\ThirdPartySupport\Elementor\ServiceProvider::class, | |
| 257 | + Give\MCP\ServiceProvider::class, | |
| 258 | + Give\VendorOverrides\Harbor\HarborServiceProvider::class, | |
| 259 | + ]; | |
| 97 | 260 | |
| 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; | |
| 261 | + /** | |
| 262 | + * @since 2.8.0 | |
| 263 | + * | |
| 264 | + * @var bool Make sure the providers are loaded only once | |
| 265 | + */ | |
| 266 | + private $providersLoaded = false; | |
| 109 | 267 | |
| 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; | |
| 268 | + /** | |
| 269 | + * Give constructor. | |
| 270 | + * | |
| 271 | + * Sets up the Container to be used for managing all other instances and data | |
| 272 | + * | |
| 273 | + * @since 2.8.0 | |
| 274 | + */ | |
| 275 | + public function __construct() | |
| 276 | + { | |
| 277 | + $this->container = new Container(); | |
| 278 | + } | |
| 119 | 279 | |
| 120 | - /** | |
| 121 | - * Give Emails Object | |
| 122 | - * | |
| 123 | - * @since 1.0 | |
| 124 | - * @access public | |
| 125 | - * | |
| 126 | - * @var Give_Emails object | |
| 127 | - */ | |
| 128 | - public $emails; | |
| 280 | + /** | |
| 281 | + * Init Give when WordPress Initializes. | |
| 282 | + * | |
| 283 | + * @since 3.19.0 Move the loading of the `give` textdomain to the `init` action hook. | |
| 284 | + * @since 1.8.9 | |
| 285 | + */ | |
| 286 | + public function init() | |
| 287 | + { | |
| 288 | + /** | |
| 289 | + * Fires before the Give core is initialized. | |
| 290 | + * | |
| 291 | + * @since 1.8.9 | |
| 292 | + */ | |
| 293 | + do_action('before_give_init'); | |
| 129 | 294 | |
| 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; | |
| 295 | + $this->bindClasses(); | |
| 139 | 296 | |
| 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; | |
| 297 | + $this->setupExceptionHandler(); | |
| 149 | 298 | |
| 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; | |
| 299 | + $this->loadServiceProviders(); | |
| 159 | 300 | |
| 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; | |
| 301 | + // Load form template | |
| 302 | + $this->templates->load(); | |
| 169 | 303 | |
| 170 | - /** | |
| 171 | - * Give API Object | |
| 172 | - * | |
| 173 | - * @since 1.0 | |
| 174 | - * @access public | |
| 175 | - * | |
| 176 | - * @var Give_API object | |
| 177 | - */ | |
| 178 | - public $api; | |
| 304 | + // Load routes. | |
| 305 | + $this->routeForm->init(); | |
| 179 | 306 | |
| 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; | |
| 307 | + /** | |
| 308 | + * Fire the action after Give core loads. | |
| 309 | + * | |
| 310 | + * @since 1.8.7 | |
| 311 | + * | |
| 312 | + * @param Give class instance. | |
| 313 | + * | |
| 314 | + */ | |
| 315 | + do_action('give_init', $this); | |
| 189 | 316 | |
| 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; | |
| 317 | + // Activate any bundled licenses if not already activated. | |
| 318 | + add_action('admin_init', 'Give_License::activate_bundled_licenses'); | |
| 319 | + } | |
| 199 | 320 | |
| 200 | - /** | |
| 201 | - * Give_tooltips Object | |
| 202 | - * | |
| 203 | - * @since 1.8.9 | |
| 204 | - * @access public | |
| 205 | - * | |
| 206 | - * @var Give_Tooltips object | |
| 207 | - */ | |
| 208 | - public $tooltips; | |
| 321 | + /** | |
| 322 | + * Loads the plugin language files. | |
| 323 | + * | |
| 324 | + * @since 3.0.0 Use Language class | |
| 325 | + * @since 1.0 | |
| 326 | + * @access public | |
| 327 | + * | |
| 328 | + * @return void | |
| 329 | + */ | |
| 330 | + public function load_textdomain() | |
| 331 | + { | |
| 332 | + Language::load(); | |
| 333 | + } | |
| 209 | 334 | |
| 210 | - /** | |
| 211 | - * Give notices Object | |
| 212 | - * | |
| 213 | - * @var Give_Notices $notices | |
| 214 | - */ | |
| 215 | - public $notices; | |
| 335 | + /** | |
| 336 | + * Binds the initial classes to the service provider. | |
| 337 | + * | |
| 338 | + * @since 2.8.0 | |
| 339 | + */ | |
| 340 | + private function bindClasses() | |
| 341 | + { | |
| 342 | + $this->container->singleton('templates', Templates::class); | |
| 343 | + $this->container->singleton('routeForm', FormRoute::class); | |
| 344 | + } | |
| 216 | 345 | |
| 346 | + /** | |
| 347 | + * Sets up the Exception Handler to catch and handle uncaught exceptions | |
| 348 | + * | |
| 349 | + * @since 2.11.1 | |
| 350 | + */ | |
| 351 | + private function setupExceptionHandler() | |
| 352 | + { | |
| 353 | + $handler = new UncaughtExceptionLogger(); | |
| 354 | + $handler->setupExceptionHandler(); | |
| 355 | + } | |
| 217 | 356 | |
| 218 | - /** | |
| 219 | - * Give logging Object | |
| 220 | - * | |
| 221 | - * @var Give_Logging $logs | |
| 222 | - */ | |
| 223 | - public $logs; | |
| 357 | + /** | |
| 358 | + * Load all the service providers to bootstrap the various parts of the application. | |
| 359 | + * | |
| 360 | + * @since 2.8.0 | |
| 361 | + */ | |
| 362 | + private function loadServiceProviders() | |
| 363 | + { | |
| 364 | + if ($this->providersLoaded) { | |
| 365 | + return; | |
| 366 | + } | |
| 224 | 367 | |
| 225 | - /** | |
| 226 | - * Give payment Object | |
| 227 | - * | |
| 228 | - * @var Give_DB_Payment_Meta $payment_meta | |
| 229 | - */ | |
| 230 | - public $payment_meta; | |
| 368 | + $providers = []; | |
| 231 | 369 | |
| 232 | - /** | |
| 233 | - * Give form Object | |
| 234 | - * | |
| 235 | - * @var Give_DB_Form_Meta $form_meta | |
| 236 | - */ | |
| 237 | - public $form_meta; | |
| 370 | + foreach ($this->serviceProviders as $serviceProvider) { | |
| 371 | + if (!is_subclass_of($serviceProvider, ServiceProvider::class)) { | |
| 372 | + throw new InvalidArgumentException( | |
| 373 | + "$serviceProvider class must implement the ServiceProvider interface" | |
| 374 | + ); | |
| 375 | + } | |
| 238 | 376 | |
| 239 | - /** | |
| 240 | - * Give form Object | |
| 241 | - * | |
| 242 | - * @var Give_Async_Process $async_process | |
| 243 | - */ | |
| 244 | - public $async_process; | |
| 377 | + /** @var ServiceProvider $serviceProvider */ | |
| 378 | + $serviceProvider = new $serviceProvider(); | |
| 245 | 379 | |
| 246 | - /** | |
| 247 | - * Give scripts Object. | |
| 248 | - * | |
| 249 | - * @var Give_Scripts | |
| 250 | - */ | |
| 251 | - public $scripts; | |
| 380 | + $serviceProvider->register(); | |
| 252 | 381 | |
| 253 | - /** | |
| 254 | - * Give_Seq_Donation_Number Object. | |
| 255 | - * | |
| 256 | - * @var Give_Sequential_Donation_Number | |
| 257 | - */ | |
| 258 | - public $seq_donation_number; | |
| 382 | + $providers[] = $serviceProvider; | |
| 383 | + } | |
| 259 | 384 | |
| 260 | - /** | |
| 261 | - * Give_Comment Object | |
| 262 | - * | |
| 263 | - * @var Give_Comment | |
| 264 | - */ | |
| 265 | - public $comment; | |
| 385 | + foreach ($providers as $serviceProvider) { | |
| 386 | + $serviceProvider->boot(); | |
| 387 | + } | |
| 266 | 388 | |
| 267 | - /** | |
| 268 | - * Main Give Instance | |
| 269 | - * | |
| 270 | - * Ensures that only one instance of Give exists in memory at any one | |
| 271 | - * time. Also prevents needing to define globals all over the place. | |
| 272 | - * | |
| 273 | - * @since 1.0 | |
| 274 | - * @access public | |
| 275 | - * | |
| 276 | - * @static | |
| 277 | - * @see Give() | |
| 278 | - * | |
| 279 | - * @return Give | |
| 280 | - */ | |
| 281 | - public static function instance() { | |
| 282 | - if ( is_null( self::$_instance ) ) { | |
| 283 | - self::$_instance = new self(); | |
| 284 | - } | |
| 389 | + $this->providersLoaded = true; | |
| 390 | + } | |
| 285 | 391 | |
| 286 | - return self::$_instance; | |
| 287 | - } | |
| 392 | + /** | |
| 393 | + * Bootstraps the Give Plugin | |
| 394 | + * | |
| 395 | + * @since 3.19.0 Load the `give` textdomain on the `init` action hook. | |
| 396 | + * @since 2.8.0 | |
| 397 | + */ | |
| 398 | + public function boot() | |
| 399 | + { | |
| 400 | + $this->setup_constants(); | |
| 288 | 401 | |
| 289 | - /** | |
| 290 | - * Give Constructor. | |
| 291 | - */ | |
| 292 | - public function __construct() { | |
| 293 | - // PHP version | |
| 294 | - if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) { | |
| 295 | - define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' ); | |
| 296 | - } | |
| 402 | + $this->disableVisualDonationFormBuilderFeaturePlugin(); | |
| 297 | 403 | |
| 298 | - // Bailout: Need minimum php version to load plugin. | |
| 299 | - if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) { | |
| 300 | - add_action( 'admin_notices', array( $this, 'minimum_phpversion_notice' ) ); | |
| 404 | + // Add compatibility notice for recurring and stripe support with Give 2.5.0. | |
| 405 | + add_action('admin_notices', [$this, 'display_old_recurring_compatibility_notice']); | |
| 301 | 406 | |
| 302 | - return; | |
| 303 | - } | |
| 407 | + add_action('plugins_loaded', [$this, 'init'], 0); | |
| 304 | 408 | |
| 305 | - $this->setup_constants(); | |
| 306 | - $this->includes(); | |
| 307 | - $this->init_hooks(); | |
| 409 | + // Set up localization. | |
| 410 | + add_action('init', [$this, 'load_textdomain']); | |
| 308 | 411 | |
| 309 | - do_action( 'give_loaded' ); | |
| 310 | - } | |
| 412 | + register_activation_hook(GIVE_PLUGIN_FILE, [$this, 'install']); | |
| 311 | 413 | |
| 312 | - /** | |
| 313 | - * Hook into actions and filters. | |
| 314 | - * | |
| 315 | - * @since 1.8.9 | |
| 316 | - */ | |
| 317 | - private function init_hooks() { | |
| 318 | - register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); | |
| 319 | - add_action( 'plugins_loaded', array( $this, 'init' ), 0 ); | |
| 414 | + do_action('give_loaded'); | |
| 415 | + } | |
| 320 | 416 | |
| 321 | - // Set up localization on init Hook. | |
| 322 | - add_action( 'init', array( $this, 'load_textdomain' ), 0 ); | |
| 323 | - } | |
| 417 | + /** | |
| 418 | + * Setup plugin constants | |
| 419 | + * | |
| 420 | + * @since 1.0 | |
| 421 | + * @access private | |
| 422 | + * | |
| 423 | + * @return void | |
| 424 | + */ | |
| 425 | + private function setup_constants() | |
| 426 | + { | |
| 427 | + // Plugin version. | |
| 428 | + if (!defined('GIVE_VERSION')) { | |
| 429 | + define('GIVE_VERSION', '4.16.9'); | |
| 430 | + } | |
| 324 | 431 | |
| 432 | + // Plugin Root File. | |
| 433 | + if (!defined('GIVE_PLUGIN_FILE')) { | |
| 434 | + define('GIVE_PLUGIN_FILE', __FILE__); | |
| 435 | + } | |
| 325 | 436 | |
| 326 | - /** | |
| 327 | - * Init Give when WordPress Initializes. | |
| 328 | - * | |
| 329 | - * @since 1.8.9 | |
| 330 | - */ | |
| 331 | - public function init() { | |
| 437 | + // Plugin Folder Path. | |
| 438 | + if (!defined('GIVE_PLUGIN_DIR')) { | |
| 439 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(GIVE_PLUGIN_FILE)); | |
| 440 | + } | |
| 332 | 441 | |
| 333 | - /** | |
| 334 | - * Fires before the Give core is initialized. | |
| 335 | - * | |
| 336 | - * @since 1.8.9 | |
| 337 | - */ | |
| 338 | - do_action( 'before_give_init' ); | |
| 442 | + // Plugin Folder URL. | |
| 443 | + if (!defined('GIVE_PLUGIN_URL')) { | |
| 444 | + define('GIVE_PLUGIN_URL', plugin_dir_url(GIVE_PLUGIN_FILE)); | |
| 445 | + } | |
| 339 | 446 | |
| 340 | - // Set up localization. | |
| 341 | - $this->load_textdomain(); | |
| 447 | + // Plugin Basename aka: "give/give.php". | |
| 448 | + if (!defined('GIVE_PLUGIN_BASENAME')) { | |
| 449 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(GIVE_PLUGIN_FILE)); | |
| 450 | + } | |
| 342 | 451 | |
| 343 | - $this->roles = new Give_Roles(); | |
| 344 | - $this->api = new Give_API(); | |
| 345 | - $this->give_settings = new Give_Admin_Settings(); | |
| 346 | - $this->html = new Give_HTML_Elements(); | |
| 347 | - $this->emails = new Give_Emails(); | |
| 348 | - $this->email_tags = new Give_Email_Template_Tags(); | |
| 349 | - $this->donors = new Give_DB_Donors(); | |
| 350 | - $this->donor_meta = new Give_DB_Donor_Meta(); | |
| 351 | - $this->template_loader = new Give_Template_Loader(); | |
| 352 | - $this->email_access = new Give_Email_Access(); | |
| 353 | - $this->tooltips = new Give_Tooltips(); | |
| 354 | - $this->notices = new Give_Notices(); | |
| 355 | - $this->payment_meta = new Give_DB_Payment_Meta(); | |
| 356 | - $this->logs = new Give_Logging(); | |
| 357 | - $this->form_meta = new Give_DB_Form_Meta(); | |
| 358 | - $this->sequential_donation_db = new Give_DB_Sequential_Ordering(); | |
| 359 | - $this->async_process = new Give_Async_Process(); | |
| 360 | - $this->scripts = new Give_Scripts(); | |
| 361 | - $this->seq_donation_number = Give_Sequential_Donation_Number::get_instance(); | |
| 362 | - $this->comment = Give_Comment::get_instance(); | |
| 363 | - $this->session_db = new Give_DB_Sessions(); | |
| 364 | - $this->session = Give_Session::get_instance(); | |
| 452 | + // Make sure CAL_GREGORIAN is defined. | |
| 453 | + if (!defined('CAL_GREGORIAN')) { | |
| 454 | + define('CAL_GREGORIAN', 1); | |
| 455 | + } | |
| 456 | + } | |
| 365 | 457 | |
| 366 | - /** | |
| 367 | - * Fire the action after Give core loads. | |
| 368 | - * | |
| 369 | - * @param Give class instance. | |
| 370 | - * | |
| 371 | - * @since 1.8.7 | |
| 372 | - */ | |
| 373 | - do_action( 'give_init', $this ); | |
| 458 | + protected function disableVisualDonationFormBuilderFeaturePlugin() | |
| 459 | + { | |
| 460 | + // Include plugin.php to use is_plugin_active() below. | |
| 461 | + include_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 374 | 462 | |
| 375 | - } | |
| 463 | + // Prevent fatal error due to a renamed class. | |
| 464 | + class_alias(TestOffsiteGateway::class, 'Give\PaymentGateways\Gateways\TestGateway\TestGatewayOffsite', true); | |
| 376 | 465 | |
| 377 | - /** | |
| 378 | - * Throw error on object clone | |
| 379 | - * | |
| 380 | - * The whole idea of the singleton design pattern is that there is a single | |
| 381 | - * object, therefore we don't want the object to be cloned. | |
| 382 | - * | |
| 383 | - * @since 1.0 | |
| 384 | - * @access protected | |
| 385 | - * | |
| 386 | - * @return void | |
| 387 | - */ | |
| 388 | - public function __clone() { | |
| 389 | - // Cloning instances of the class is forbidden. | |
| 390 | - give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); | |
| 391 | - } | |
| 466 | + if (is_plugin_active('givewp-next-gen/give-visual-form-builder.php')) { | |
| 467 | + deactivate_plugins(['givewp-next-gen/give-visual-form-builder.php']); | |
| 392 | 468 | |
| 393 | - /** | |
| 394 | - * Disable unserializing of the class | |
| 395 | - * | |
| 396 | - * @since 1.0 | |
| 397 | - * @access protected | |
| 398 | - * | |
| 399 | - * @return void | |
| 400 | - */ | |
| 401 | - public function __wakeup() { | |
| 402 | - // Unserializing instances of the class is forbidden. | |
| 403 | - give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); | |
| 404 | - } | |
| 469 | + add_action('admin_notices', function () { | |
| 470 | + Give()->notices->register_notice([ | |
| 471 | + 'id' => 'give-visual-donation-form-builder-feature-plugin-deactivated', | |
| 472 | + 'description' => __( | |
| 473 | + 'The Visual Form Builder Beta plugin is no longer needed, since the form builder is included in your current version of GiveWP. To prevent conflicts, the Beta plugin has been deactivated and can be safely deleted.', | |
| 474 | + 'give' | |
| 475 | + ), | |
| 476 | + 'type' => 'info', | |
| 477 | + ]); | |
| 478 | + }); | |
| 479 | + } | |
| 480 | + } | |
| 405 | 481 | |
| 406 | - /** | |
| 407 | - * Setup plugin constants | |
| 408 | - * | |
| 409 | - * @since 1.0 | |
| 410 | - * @access private | |
| 411 | - * | |
| 412 | - * @return void | |
| 413 | - */ | |
| 414 | - private function setup_constants() { | |
| 482 | + /** | |
| 483 | + * Display compatibility notice for Give 2.5.0 and Recurring 1.8.13 when Stripe premium is not active. | |
| 484 | + * | |
| 485 | + * @since 2.5.0 | |
| 486 | + * | |
| 487 | + * @return void | |
| 488 | + */ | |
| 489 | + public function display_old_recurring_compatibility_notice() | |
| 490 | + { | |
| 491 | + // Show notice, if incompatibility found. | |
| 492 | + if ( | |
| 493 | + defined('GIVE_RECURRING_VERSION') | |
| 494 | + && version_compare(GIVE_RECURRING_VERSION, '1.9.0', '<') | |
| 495 | + && defined('GIVE_STRIPE_VERSION') | |
| 496 | + && version_compare(GIVE_STRIPE_VERSION, '2.2.0', '<') | |
| 497 | + ) { | |
| 498 | + $message = sprintf( | |
| 499 | + __( | |
| 500 | + '<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.', | |
| 501 | + 'give' | |
| 502 | + ), | |
| 503 | + esc_url('https://givewp.com/wp-login.php'), | |
| 504 | + esc_url('https://givewp.com/my-account/#tab_downloads') | |
| 505 | + ); | |
| 415 | 506 | |
| 416 | - // Plugin version. | |
| 417 | - if ( ! defined( 'GIVE_VERSION' ) ) { | |
| 418 | - define( 'GIVE_VERSION', '2.3.0' ); | |
| 419 | - } | |
| 507 | + Give()->notices->register_notice( | |
| 508 | + [ | |
| 509 | + 'id' => 'give-compatibility-with-old-recurring', | |
| 510 | + 'description' => $message, | |
| 511 | + 'dismissible_type' => 'user', | |
| 512 | + 'dismiss_interval' => 'shortly', | |
| 513 | + ] | |
| 514 | + ); | |
| 515 | + } | |
| 516 | + } | |
| 420 | 517 | |
| 421 | - // Plugin Root File. | |
| 422 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { | |
| 423 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); | |
| 424 | - } | |
| 518 | + /** | |
| 519 | + * Install Give | |
| 520 | + * | |
| 521 | + * Runs on plugin activation and performs initial setup. | |
| 522 | + * | |
| 523 | + * @since 3.4.0 check if installing in WP multisite | |
| 524 | + * @since 2.33.3 set network_wide parameter to true, enabling installing in WP multisite | |
| 525 | + * @since 1.0.0 | |
| 526 | + */ | |
| 527 | + public function install() | |
| 528 | + { | |
| 529 | + $this->loadServiceProviders(); | |
| 530 | + give_install(is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)); | |
| 531 | + } | |
| 425 | 532 | |
| 426 | - // Plugin Folder Path. | |
| 427 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { | |
| 428 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( GIVE_PLUGIN_FILE ) ); | |
| 429 | - } | |
| 533 | + /** | |
| 534 | + * Register a Service Provider for bootstrapping | |
| 535 | + * | |
| 536 | + * @since 2.8.0 | |
| 537 | + * | |
| 538 | + * @param string $serviceProvider | |
| 539 | + */ | |
| 540 | + public function registerServiceProvider($serviceProvider) | |
| 541 | + { | |
| 542 | + $this->serviceProviders[] = $serviceProvider; | |
| 543 | + } | |
| 430 | 544 | |
| 431 | - // Plugin Folder URL. | |
| 432 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { | |
| 433 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( GIVE_PLUGIN_FILE ) ); | |
| 434 | - } | |
| 545 | + /** | |
| 546 | + * Magic properties are passed to the service container to retrieve the data. | |
| 547 | + * | |
| 548 | + * @since 2.7.0 | |
| 549 | + * | |
| 550 | + * @since 2.8.0 retrieve from the service container | |
| 551 | + * @param string $propertyName | |
| 552 | + * | |
| 553 | + * @return mixed | |
| 554 | + * @throws Exception | |
| 555 | + */ | |
| 556 | + public function __get($propertyName) | |
| 557 | + { | |
| 558 | + return $this->container->get($propertyName); | |
| 559 | + } | |
| 435 | 560 | |
| 436 | - // Plugin Basename aka: "give/give.php". | |
| 437 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { | |
| 438 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( GIVE_PLUGIN_FILE ) ); | |
| 439 | - } | |
| 561 | + /** | |
| 562 | + * Magic methods are passed to the service container. | |
| 563 | + * | |
| 564 | + * @since 2.8.0 | |
| 565 | + * | |
| 566 | + * @param $name | |
| 567 | + * | |
| 568 | + * @param $arguments | |
| 569 | + * | |
| 570 | + * @return mixed | |
| 571 | + */ | |
| 572 | + public function __call($name, $arguments) | |
| 573 | + { | |
| 574 | + return call_user_func_array([$this->container, $name], $arguments); | |
| 575 | + } | |
| 440 | 576 | |
| 441 | - // Make sure CAL_GREGORIAN is defined. | |
| 442 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { | |
| 443 | - define( 'CAL_GREGORIAN', 1 ); | |
| 444 | - } | |
| 445 | - } | |
| 577 | + /** | |
| 578 | + * Retrieves the underlying container instance. This isn't usually necessary, but sometimes we want to pass along | |
| 579 | + * the container itself. | |
| 580 | + * | |
| 581 | + * @since 2.24.0 | |
| 582 | + */ | |
| 583 | + public function getContainer(): Container | |
| 584 | + { | |
| 585 | + return $this->container; | |
| 586 | + } | |
| 587 | +} | |
| 446 | 588 | |
| 447 | - /** | |
| 448 | - * Include required files | |
| 449 | - * | |
| 450 | - * @since 1.0 | |
| 451 | - * @access private | |
| 452 | - * | |
| 453 | - * @return void | |
| 454 | - */ | |
| 455 | - private function includes() { | |
| 456 | - global $give_options; | |
| 457 | - | |
| 458 | - /** | |
| 459 | - * Composer's autoload.php. | |
| 460 | - */ | |
| 461 | - if ( file_exists( GIVE_PLUGIN_DIR . 'vendor/autoload.php' ) ) { | |
| 462 | - require_once GIVE_PLUGIN_DIR . 'vendor/autoload.php'; | |
| 463 | - } else { | |
| 464 | - // Load autoloader. | |
| 465 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/tcpdf/tcpdf.php'; | |
| 466 | - } | |
| 467 | - | |
| 468 | - /** | |
| 469 | - * Load libraries. | |
| 470 | - */ | |
| 471 | - if ( ! class_exists( 'WP_Async_Request' ) ) { | |
| 472 | - include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-async-request.php' ); | |
| 473 | - } | |
| 474 | - | |
| 475 | - if ( ! class_exists( 'WP_Background_Process' ) ) { | |
| 476 | - include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-background-process.php' ); | |
| 477 | - } | |
| 478 | - | |
| 479 | - /** | |
| 480 | - * Load plugin files | |
| 481 | - */ | |
| 482 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; | |
| 483 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; | |
| 484 | - $give_options = give_get_settings(); | |
| 485 | - | |
| 486 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; | |
| 487 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-async-process.php'; | |
| 488 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; | |
| 489 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php'; | |
| 490 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; | |
| 491 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; | |
| 492 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; | |
| 493 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; | |
| 494 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; | |
| 495 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-v2.php'; | |
| 496 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-tooltips.php'; | |
| 497 | - require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php'; | |
| 498 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-translation.php'; | |
| 499 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-readme-parser.php'; | |
| 500 | - | |
| 501 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-scripts.php'; | |
| 502 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; | |
| 503 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; | |
| 504 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; | |
| 505 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; | |
| 506 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-meta.php'; | |
| 507 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-comments.php'; | |
| 508 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-comments-meta.php'; | |
| 509 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php'; | |
| 510 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php'; | |
| 511 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-form-meta.php'; | |
| 512 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-sequential-ordering.php'; | |
| 513 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php'; | |
| 514 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor-wall-widget.php'; | |
| 515 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; | |
| 516 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-sessions.php'; | |
| 517 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; | |
| 518 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; | |
| 519 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; | |
| 520 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; | |
| 521 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; | |
| 522 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-payment-meta.php'; | |
| 523 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-comment.php'; | |
| 524 | - | |
| 525 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; | |
| 526 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; | |
| 527 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; | |
| 528 | - require_once GIVE_PLUGIN_DIR . 'includes/import-functions.php'; | |
| 529 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; | |
| 530 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; | |
| 531 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; | |
| 532 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; | |
| 533 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; | |
| 534 | - require_once GIVE_PLUGIN_DIR . 'includes/currency-functions.php'; | |
| 535 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; | |
| 536 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; | |
| 537 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; | |
| 538 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; | |
| 539 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; | |
| 540 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; | |
| 541 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php'; | |
| 542 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; | |
| 543 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; | |
| 544 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; | |
| 545 | - | |
| 546 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/backward-compatibility.php'; | |
| 547 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; | |
| 548 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; | |
| 549 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; | |
| 550 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; | |
| 551 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; | |
| 552 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-sequential-donation-number.php'; | |
| 553 | - | |
| 554 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; | |
| 555 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; | |
| 556 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; | |
| 557 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; | |
| 558 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; | |
| 559 | - | |
| 560 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; | |
| 561 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; | |
| 562 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notifications.php'; | |
| 563 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; | |
| 564 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; | |
| 565 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; | |
| 566 | - | |
| 567 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donors-query.php'; | |
| 568 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donor-wall.php'; | |
| 569 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donor-stats.php'; | |
| 570 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/backward-compatibility.php'; | |
| 571 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/frontend-donor-functions.php'; | |
| 572 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/actions.php'; | |
| 573 | - | |
| 574 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php'; | |
| 575 | - | |
| 576 | - require_once GIVE_PLUGIN_DIR . 'blocks/load.php'; | |
| 577 | - | |
| 578 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { | |
| 579 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; | |
| 580 | - } | |
| 581 | - | |
| 582 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { | |
| 583 | - | |
| 584 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; | |
| 585 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; | |
| 586 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; | |
| 587 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; | |
| 588 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; | |
| 589 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; | |
| 590 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php'; | |
| 591 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; | |
| 592 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; | |
| 593 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; | |
| 594 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-blank-slate.php'; | |
| 595 | - | |
| 596 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; | |
| 597 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; | |
| 598 | - | |
| 599 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php'; | |
| 600 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php'; | |
| 601 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php'; | |
| 602 | - | |
| 603 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; | |
| 604 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-give-form-duplicator.php'; | |
| 605 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; | |
| 606 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; | |
| 607 | - | |
| 608 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php'; | |
| 609 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php'; | |
| 610 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php'; | |
| 611 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php'; | |
| 612 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/give-export-donations-functions.php'; | |
| 613 | - | |
| 614 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php'; | |
| 615 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php'; | |
| 616 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php'; | |
| 617 | - | |
| 618 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php'; | |
| 619 | - | |
| 620 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php'; | |
| 621 | - | |
| 622 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; | |
| 623 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; | |
| 624 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; | |
| 625 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; | |
| 626 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; | |
| 627 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; | |
| 628 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; | |
| 629 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-grid.php'; | |
| 630 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; | |
| 631 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; | |
| 632 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-totals.php'; | |
| 633 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donor-wall.php'; | |
| 634 | - }// End if(). | |
| 635 | - | |
| 636 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; | |
| 637 | - | |
| 638 | - } | |
| 639 | - | |
| 640 | - /** | |
| 641 | - * Loads the plugin language files. | |
| 642 | - * | |
| 643 | - * @since 1.0 | |
| 644 | - * @access public | |
| 645 | - * | |
| 646 | - * @return void | |
| 647 | - */ | |
| 648 | - public function load_textdomain() { | |
| 649 | - | |
| 650 | - // Set filter for Give's languages directory | |
| 651 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; | |
| 652 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); | |
| 653 | - | |
| 654 | - // Traditional WordPress plugin locale filter. | |
| 655 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); | |
| 656 | - $locale = apply_filters( 'plugin_locale', $locale, 'give' ); | |
| 657 | - | |
| 658 | - unload_textdomain( 'give' ); | |
| 659 | - load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' ); | |
| 660 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); | |
| 661 | - | |
| 662 | - } | |
| 663 | - | |
| 664 | - | |
| 665 | - /** | |
| 666 | - * Show minimum PHP version notice. | |
| 667 | - * | |
| 668 | - * @since 1.8.12 | |
| 669 | - * @access public | |
| 670 | - */ | |
| 671 | - public function minimum_phpversion_notice() { | |
| 672 | - // Bailout. | |
| 673 | - if ( ! is_admin() ) { | |
| 674 | - return; | |
| 675 | - } | |
| 676 | - | |
| 677 | - $notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>'; | |
| 678 | - $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>'; | |
| 679 | - $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>'; | |
| 680 | - $notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>'; | |
| 681 | - $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>'; | |
| 682 | - $notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>'; | |
| 683 | - $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>'; | |
| 684 | - | |
| 685 | - echo sprintf( | |
| 686 | - '<div class="notice notice-error">%1$s</div>', | |
| 687 | - wp_kses_post( $notice_desc ) | |
| 688 | - ); | |
| 689 | - } | |
| 690 | - | |
| 691 | - } | |
| 692 | - | |
| 693 | -endif; // End if class_exists check | |
| 694 | - | |
| 695 | - | |
| 696 | 589 | /** |
| 697 | 590 | * Start Give |
| 698 | 591 | * |
| 699 | 592 | * The main function responsible for returning the one true Give instance to functions everywhere. |
| @@ -702,12 +595,34 @@ | ||
| 702 | 595 | * to declare the global. |
| 703 | 596 | * |
| 704 | 597 | * Example: <?php $give = Give(); ?> |
| 705 | 598 | * |
| 706 | - * @since 1.0 | |
| 707 | - * @return object|Give | |
| 599 | + * @since 4.6.0 add explicit nullable type to give function | |
| 600 | + * @since 2.8.0 add parameter for quick retrieval from container | |
| 601 | + * @since 1.0 | |
| 602 | + * | |
| 603 | + * @template T | |
| 604 | + * | |
| 605 | + * @param class-string<T>|null $abstract Selector for data to retrieve from the service container | |
| 606 | + * | |
| 607 | + * @return Give|T | |
| 708 | 608 | */ |
| 709 | -function Give() { | |
| 710 | - return Give::instance(); | |
| 609 | +function give(?string $abstract = null) | |
| 610 | +{ | |
| 611 | + static $instance = null; | |
| 612 | + | |
| 613 | + if ($instance === null) { | |
| 614 | + $instance = new Give(); | |
| 615 | + } | |
| 616 | + | |
| 617 | + if ($abstract !== null) { | |
| 618 | + return $instance->make($abstract); | |
| 619 | + } | |
| 620 | + | |
| 621 | + return $instance; | |
| 711 | 622 | } |
| 712 | 623 | |
| 713 | -Give(); | |
| 624 | +require __DIR__ . '/vendor/autoload.php'; | |
| 625 | +require __DIR__ . '/vendor/vendor-prefixed/autoload.php'; | |
| 626 | +require __DIR__ . '/vendor/woocommerce/action-scheduler/action-scheduler.php'; | |
| 627 | + | |
| 628 | +give()->boot(); | |