PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.6.40
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.6.40
1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 1.8.0 All 210 releases
charitable / charitable.php

charitable.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.6.40, at charitable.php

962 lines 24.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Charitable
4 * Plugin URI: https://www.wpcharitable.com
5 * Description: The WordPress fundraising alternative for non-profits, created to help non-profits raise money on their own website.
6 * Version: 1.6.40
7 * Author: WP Charitable
8 * Author URI: https://wpcharitable.com
9 * Requires at least: 4.1
10 * Tested up to: 5.4.1
11 *
12 * Text Domain: charitable
13 * Domain Path: /i18n/languages/
14 *
15 * @package Charitable
16 * @author Eric Daams
17 * @copyright Copyright (c) 2020, Studio 164a
18 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
19 */
20
21 // Exit if accessed directly.
22 if ( ! defined( 'ABSPATH' ) ) {
23 exit;
24 }
25
26 if ( ! class_exists( 'Charitable' ) ) :
27
28 /**
29 * Main Charitable class.
30 */
31 class Charitable {
32
33 /* Plugin version. */
34 const VERSION = '1.6.40';
35
36 /* Version of database schema. */
37 const DB_VERSION = '20180522';
38
39 /* Campaign post type. */
40 const CAMPAIGN_POST_TYPE = 'campaign';
41
42 /* Donation post type. */
43 const DONATION_POST_TYPE = 'donation';
44
45 /**
46 * Single instance of this class.
47 *
48 * @since 1.0.0
49 *
50 * @var Charitable
51 */
52 private static $instance = null;
53
54 /**
55 * The absolute path to this plugin's directory.
56 *
57 * @since 1.0.0
58 *
59 * @var string
60 */
61 private $directory_path;
62
63 /**
64 * The URL of this plugin's directory.
65 *
66 * @since 1.0.0
67 *
68 * @var string
69 */
70 private $directory_url;
71
72 /**
73 * Directory path for the includes folder of the plugin.
74 *
75 * @since 1.0.0
76 *
77 * @var string
78 */
79 private $includes_path;
80
81 /**
82 * Store of registered objects.
83 *
84 * @since 1.0.0
85 * @since 1.5.0 Changed to Charitable_Registry object. Previously it was an array.
86 *
87 * @var Charitable_Registry
88 */
89 private $registry;
90
91 /**
92 * Classmap.
93 *
94 * @since 1.5.0
95 *
96 * @var array
97 */
98 private $classmap;
99
100 /**
101 * Create class instance.
102 *
103 * @since 1.0.0
104 */
105 public function __construct() {
106 $this->directory_path = plugin_dir_path( __FILE__ );
107 $this->directory_url = plugin_dir_url( __FILE__ );
108 $this->includes_path = $this->directory_path . 'includes/';
109
110 spl_autoload_register( array( $this, 'autoloader' ) );
111
112 $this->load_dependencies();
113
114 register_activation_hook( __FILE__, array( $this, 'activate' ) );
115 register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
116
117 add_action( 'plugins_loaded', array( $this, 'start' ), 1 );
118 }
119
120 /**
121 * Returns the original instance of this class.
122 *
123 * @since 1.0.0
124 *
125 * @return Charitable
126 */
127 public static function get_instance() {
128 return self::$instance;
129 }
130
131 /**
132 * Run the startup sequence.
133 *
134 * This is only ever executed once.
135 *
136 * @since 1.0.0
137 *
138 * @return void
139 */
140 public function start() {
141 /* If we've already started (i.e. run this function once before), do not pass go. */
142 if ( $this->started() ) {
143 return;
144 }
145
146 /* Set static instance. */
147 self::$instance = $this;
148
149 /* Set up the registry and instantiate objects we need straight away. */
150 $this->registry();
151
152 $this->maybe_start_ajax();
153
154 $this->attach_hooks_and_filters();
155
156 $this->maybe_start_admin();
157
158 $this->maybe_start_public();
159
160 Charitable_Addons::load( $this );
161 }
162
163 /**
164 * Include necessary files.
165 *
166 * @since 1.0.0
167 *
168 * @return void
169 */
170 private function load_dependencies() {
171 $includes_path = $this->get_path( 'includes' );
172
173 /* Load files with hooks & functions. Classes are autoloaded. */
174 require_once( $includes_path . 'charitable-core-functions.php' );
175 require_once( $includes_path . 'api/charitable-api-functions.php' );
176 require_once( $includes_path . 'campaigns/charitable-campaign-functions.php' );
177 require_once( $includes_path . 'campaigns/charitable-campaign-hooks.php' );
178 require_once( $includes_path . 'compat/charitable-compat-functions.php' );
179 require_once( $includes_path . 'currency/charitable-currency-functions.php' );
180 require_once( $includes_path . 'deprecated/charitable-deprecated-functions.php' );
181 require_once( $includes_path . 'donations/charitable-donation-hooks.php' );
182 require_once( $includes_path . 'donations/charitable-donation-functions.php' );
183 require_once( $includes_path . 'emails/charitable-email-hooks.php' );
184 require_once( $includes_path . 'endpoints/charitable-endpoints-functions.php' );
185 require_once( $includes_path . 'privacy/charitable-privacy-functions.php' );
186 require_once( $includes_path . 'public/charitable-template-helpers.php' );
187 require_once( $includes_path . 'shortcodes/charitable-shortcodes-hooks.php' );
188 require_once( $includes_path . 'upgrades/charitable-upgrade-hooks.php' );
189 require_once( $includes_path . 'users/charitable-user-functions.php' );
190 require_once( $includes_path . 'user-management/charitable-user-management-hooks.php' );
191 require_once( $includes_path . 'utilities/charitable-utility-functions.php' );
192 }
193
194 /**
195 * Load the template functions after theme is loaded.
196 *
197 * This gives themes time to override the functions.
198 *
199 * @since 1.6.10
200 *
201 * @return void
202 */
203 public function load_template_files() {
204 $includes_path = $this->get_path( 'includes' );
205
206 require_once( $includes_path . 'public/charitable-template-functions.php' );
207 require_once( $includes_path . 'public/charitable-template-hooks.php' );
208 }
209
210 /**
211 * Dynamically loads the class attempting to be instantiated elsewhere in the
212 * plugin by looking at the $class_name parameter being passed as an argument.
213 *
214 * @since 1.5.0
215 *
216 * @param string $class_name The fully-qualified name of the class to load.
217 * @return boolean
218 */
219 public function autoloader( $class_name ) {
220 /* If the specified $class_name already exists, bail. */
221 if ( class_exists( $class_name ) ) {
222 return false;
223 }
224
225 /* If the specified $class_name does not include our namespace, duck out. */
226 if ( false === strpos( $class_name, 'Charitable_' ) ) {
227 return false;
228 }
229
230 /* Autogenerated class map. */
231 if ( ! isset( $this->classmap ) ) {
232 $this->classmap = include( 'includes/autoloader/charitable-class-map.php' );
233 }
234
235 $file_path = isset( $this->classmap[ $class_name ] ) ? $this->get_path( 'includes' ) . $this->classmap[ $class_name ] : false;
236
237 if ( false !== $file_path && file_exists( $file_path ) && is_file( $file_path ) ) {
238 require_once( $file_path );
239 return true;
240 }
241
242 return false;
243 }
244
245 /**
246 * Returns a registered class object.
247 *
248 * @since 1.5.0
249 *
250 * @return Charitable_Registry
251 */
252 public function registry() {
253 if ( ! isset( $this->registry ) ) {
254 $this->registry = new Charitable_Registry();
255 $this->registry->register_object( Charitable_Emails::get_instance() );
256 $this->registry->register_object( Charitable_Request::get_instance() );
257 $this->registry->register_object( Charitable_Gateways::get_instance() );
258 $this->registry->register_object( Charitable_i18n::get_instance() );
259 $this->registry->register_object( Charitable_Post_Types::get_instance() );
260 $this->registry->register_object( Charitable_Cron::get_instance() );
261 $this->registry->register_object( Charitable_Widgets::get_instance() );
262 $this->registry->register_object( Charitable_Licenses::get_instance() );
263 $this->registry->register_object( Charitable_User_Dashboard::get_instance() );
264 $this->registry->register_object( Charitable_Locations::get_instance() );
265 $this->registry->register_object( Charitable_Currency::get_instance() );
266
267 $this->registry->register_object( new Charitable_Privacy );
268 }
269
270 return $this->registry;
271 }
272
273 /**
274 * Set up hook and filter callback functions.
275 *
276 * @since 1.0.0
277 *
278 * @return void
279 */
280 private function attach_hooks_and_filters() {
281 add_action( 'wpmu_new_blog', array( $this, 'maybe_activate_charitable_on_new_site' ) );
282 add_action( 'plugins_loaded', array( $this, 'charitable_install' ), 100 );
283 add_action( 'plugins_loaded', array( $this, 'charitable_start' ), 100 );
284 add_action( 'plugins_loaded', array( $this, 'endpoints' ), 100 );
285 add_action( 'plugins_loaded', array( $this, 'donation_fields' ), 100 );
286 add_action( 'plugins_loaded', array( $this, 'campaign_fields' ), 100 );
287 add_action( 'plugins_loaded', array( $this, 'register_donormeta_table' ) );
288 add_action( 'plugins_loaded', 'charitable_load_compat_functions' );
289 add_action( 'setup_theme', array( 'Charitable_Customizer', 'start' ) );
290 add_action( 'after_setup_theme', array( $this, 'load_template_files' ) );
291 add_action( 'wp_enqueue_scripts', array( $this, 'maybe_start_qunit' ), 100 );
292 add_action( 'rest_api_init', 'charitable_register_api_routes' );
293
294 /**
295 * We do this on priority 20 so that any functionality that is loaded on init (such
296 * as addons) has a chance to run before the event.
297 */
298 add_action( 'init', array( $this, 'do_charitable_actions' ), 20 );
299 }
300
301 /**
302 * Checks whether we're in the admin area and if so, loads the admin-only functionality.
303 *
304 * @since 1.0.0
305 *
306 * @return Charitable_Admin|false
307 */
308 private function maybe_start_admin() {
309 if ( ! is_admin() ) {
310 return false;
311 }
312
313 require_once( $this->get_path( 'admin' ) . 'class-charitable-admin.php' );
314 require_once( $this->get_path( 'admin' ) . 'charitable-admin-hooks.php' );
315
316 $admin = Charitable_Admin::get_instance();
317
318 $this->registry->register_object( $admin );
319
320 return $admin;
321 }
322
323 /**
324 * Checks whether we're on the public-facing side and if so, loads the public-facing functionality.
325 *
326 * @since 1.0.0
327 *
328 * @return Charitable_Public|false
329 */
330 private function maybe_start_public() {
331 if ( is_admin() && ! $this->is_ajax() ) {
332 return false;
333 }
334
335 require_once( $this->get_path( 'public' ) . 'class-charitable-public.php' );
336
337 $public = Charitable_Public::get_instance();
338
339 $this->registry->register_object( $public );
340
341 return $public;
342 }
343
344 /**
345 * Load the QUnit tests if ?qunit is appended to the request.
346 *
347 * @since 1.4.17
348 *
349 * @return boolean
350 */
351 public function maybe_start_qunit() {
352 /* Skip out early if ?qunit isn't included in the request. */
353 if ( ! array_key_exists( 'qunit', $_GET ) ) {
354 return false;
355 }
356
357 /* The unit tests have to exist. */
358 if ( ! file_exists( $this->get_path( 'directory' ) . 'tests/qunit/tests.js' ) ) {
359 return false;
360 }
361
362 wp_register_script( 'qunit', 'https://code.jquery.com/qunit/qunit-2.3.3.js', array(), '2.3.3', true );
363 /* Version: '20170615-15:44' */
364 wp_register_script( 'qunit-tests', $this->get_path( 'directory', false ) . 'tests/qunit/tests.js', array( 'jquery-core', 'qunit' ), time(), true );
365 wp_enqueue_script( 'qunit-tests' );
366
367 wp_register_style( 'qunit', 'https://code.jquery.com/qunit/qunit-2.3.3.css', array(), '2.3.3', 'all' );
368 wp_enqueue_style( 'qunit' );
369 }
370
371 /**
372 * Checks whether the current request is an AJAX request.
373 *
374 * @since 1.5.0
375 *
376 * @return boolean
377 */
378 private function is_ajax() {
379 return false !== ( defined( 'DOING_AJAX' ) && DOING_AJAX );
380 }
381
382 /**
383 * Checks whether we're executing an AJAX hook and if so, loads some AJAX functionality.
384 *
385 * @since 1.0.0
386 *
387 * @return void
388 */
389 private function maybe_start_ajax() {
390 if ( ! $this->is_ajax() ) {
391 return;
392 }
393
394 require_once( $this->get_path( 'includes' ) . 'ajax/charitable-ajax-functions.php' );
395 require_once( $this->get_path( 'includes' ) . 'ajax/charitable-ajax-hooks.php' );
396 }
397
398 /**
399 * This method is fired after all plugins are loaded and simply fires the charitable_start hook.
400 *
401 * Extensions can use the charitable_start event to load their own functionality.
402 *
403 * @since 1.0.0
404 *
405 * @return void
406 */
407 public function charitable_start() {
408 do_action( 'charitable_start', $this );
409 }
410
411 /**
412 * Fires off an action right after Charitable is installed, allowing other
413 * plugins/themes to do something at this point.
414 *
415 * @since 1.0.1
416 *
417 * @return void
418 */
419 public function charitable_install() {
420 $install = get_transient( 'charitable_install' );
421
422 if ( ! $install ) {
423 return;
424 }
425
426 require_once( $this->get_path( 'includes' ) . 'class-charitable-install.php' );
427
428 Charitable_Install::finish_installing();
429
430 do_action( 'charitable_install' );
431
432 delete_transient( 'charitable_install' );
433 }
434
435 /**
436 * Returns whether we are currently in the start phase of the plugin.
437 *
438 * @since 1.0.0
439 *
440 * @return boolean
441 */
442 public function is_start() {
443 return current_filter() == 'charitable_start';
444 }
445
446 /**
447 * Returns whether the plugin has already started.
448 *
449 * @since 1.0.0
450 *
451 * @return boolean
452 */
453 public function started() {
454 return did_action( 'charitable_start' ) || current_filter() == 'charitable_start';
455 }
456
457 /**
458 * Returns whether the plugin is being activated.
459 *
460 * @since 1.0.0
461 *
462 * @return boolean
463 */
464 public function is_activation() {
465 return current_filter() == 'activate_charitable/charitable.php';
466 }
467
468 /**
469 * Returns whether the plugin is being deactivated.
470 *
471 * @since 1.0.0
472 *
473 * @return boolean
474 */
475 public function is_deactivation() {
476 return current_filter() == 'deactivate_charitable/charitable.php';
477 }
478
479 /**
480 * Returns plugin paths.
481 *
482 * @since 1.0.0
483 *
484 * @param string $type If empty, returns the path to the plugin.
485 * @param boolean $absolute_path If true, returns the file system path. If false, returns it as a URL.
486 * @return string
487 */
488 public function get_path( $type = '', $absolute_path = true ) {
489 $base = $absolute_path ? $this->directory_path : $this->directory_url;
490
491 switch ( $type ) {
492 case 'includes':
493 $path = $base . 'includes/';
494 break;
495
496 case 'admin':
497 $path = $base . 'includes/admin/';
498 break;
499
500 case 'public':
501 $path = $base . 'includes/public/';
502 break;
503
504 case 'assets':
505 $path = $base . 'assets/';
506 break;
507
508 case 'templates':
509 $path = $base . 'templates/';
510 break;
511
512 case 'directory':
513 $path = $base;
514 break;
515
516 default:
517 $path = __FILE__;
518
519 }//end switch
520
521 return $path;
522 }
523
524 /**
525 * Returns the plugin's version number.
526 *
527 * @since 1.0.0
528 *
529 * @return string
530 */
531 public function get_version() {
532 $version = self::VERSION;
533
534 if ( false !== strpos( $version, '-' ) ) {
535 $parts = explode( '-', $version );
536 $version = $parts[0];
537 }
538
539 return $version;
540 }
541
542 /**
543 * Get the campaign fields registry
544 *
545 * If the registry has not been set up yet, this will also
546 * perform the task of setting it up initially.
547 *
548 * This method is called on the plugins_loaded hook.
549 *
550 * @since 1.6.0
551 *
552 * @return Charitable_Campaign_Field_Registry
553 */
554 public function campaign_fields() {
555 if ( ! $this->registry->has( 'campaign_field_registry' ) ) {
556 $campaign_fields = new Charitable_Campaign_Field_Registry();
557
558 /* Register it immediately to avoid endless recursion. */
559 $this->registry->register_object( $campaign_fields );
560
561 $fields = include( $this->get_path( 'includes' ) . 'fields/default-fields/campaign-fields.php' );
562
563 foreach ( $fields as $key => $args ) {
564 $campaign_fields->register_field( new Charitable_Campaign_Field( $key, $args ) );
565 }
566 }
567
568 return $this->registry->get( 'campaign_field_registry' );
569 }
570
571 /**
572 * Get the donation fields registry
573 *
574 * If the registry has not been set up yet, this will also
575 * perform the task of setting it up initially.
576 *
577 * This method is called on the plugins_loaded hook.
578 *
579 * @since 1.5.0
580 *
581 * @return Charitable_Donation_Field_Registry
582 */
583 public function donation_fields() {
584 if ( ! $this->registry->has( 'donation_field_registry' ) ) {
585 $donation_fields = new Charitable_Donation_Field_Registry();
586
587 /* Register it immediately to avoid endless recursion. */
588 $this->registry->register_object( $donation_fields );
589
590 $fields = include( $this->get_path( 'includes' ) . 'fields/default-fields/donation-fields.php' );
591
592 foreach ( $fields as $key => $args ) {
593 $donation_fields->register_field( new Charitable_Donation_Field( $key, $args ) );
594 }
595 }
596
597 return $this->registry->get( 'donation_field_registry' );
598 }
599
600 /**
601 * Return the Endpoints API object.
602 *
603 * If the Endpoints API has not been set up yet, this will also
604 * perform the task of setting it up initially.
605 *
606 * This method is called on the plugins_loaded hook.
607 *
608 * @since 1.5.0
609 *
610 * @return Charitable_Endpoints
611 */
612 public function endpoints() {
613 if ( ! $this->registry->has( 'endpoints' ) ) {
614 /**
615 * The order in which we register endpoints is important, because
616 * it determines the order in which the endpoints are checked to
617 * find whether they are the current page.
618 *
619 * Any endpoint that builds on another endpoint should be registered
620 * BEFORE the endpoint it builds on. In other words, move from
621 * most specific to least specific.
622 */
623 $endpoints = new Charitable_Endpoints();
624 $endpoints->register( new Charitable_Campaign_Donation_Endpoint );
625 $endpoints->register( new Charitable_Campaign_Widget_Endpoint );
626 $endpoints->register( new Charitable_Campaign_Endpoint );
627 $endpoints->register( new Charitable_Donation_Cancellation_Endpoint );
628 $endpoints->register( new Charitable_Donation_Processing_Endpoint );
629 $endpoints->register( new Charitable_Donation_Receipt_Endpoint );
630 $endpoints->register( new Charitable_Email_Preview_Endpoint );
631 $endpoints->register( new Charitable_Email_Verification_Endpoint );
632 $endpoints->register( new Charitable_Forgot_Password_Endpoint );
633 $endpoints->register( new Charitable_Reset_Password_Endpoint );
634 $endpoints->register( new Charitable_Registration_Endpoint );
635 $endpoints->register( new Charitable_Login_Endpoint );
636 $endpoints->register( new Charitable_Profile_Endpoint );
637 $endpoints->register( new Charitable_Webhook_Listener_Endpoint );
638
639 $this->registry->register_object( $endpoints );
640 }
641
642 return $this->registry->get( 'endpoints' );
643 }
644
645 /**
646 * Returns a registered object.
647 *
648 * @since 1.0.0
649 *
650 * @param string $class The type of class to be retrieved.
651 * @return object
652 */
653 public function get_registered_object( $class ) {
654 return $this->registry->get( $class );
655 }
656
657 /**
658 * Registers our donormeta table as a meta data table.
659 *
660 * @since 1.6.0
661 *
662 * @global WPDB $wpdb
663 * @return void
664 */
665 public function register_donormeta_table() {
666 global $wpdb;
667
668 $wpdb->donormeta = $wpdb->prefix . 'charitable_donormeta';
669 }
670
671 /**
672 * Returns the model for one of Charitable's database tables.
673 *
674 * @since 1.0.0
675 *
676 * @param string $table The database table to retrieve.
677 * @return Charitable_DB
678 */
679 public function get_db_table( $table ) {
680 $tables = $this->get_tables();
681
682 if ( ! isset( $tables[ $table ] ) ) {
683 charitable_get_deprecated()->doing_it_wrong(
684 __METHOD__,
685 sprintf( 'Invalid table %s passed', $table ),
686 '1.0.0'
687 );
688 return null;
689 }
690
691 return $this->registry->get( $tables[ $table ] );
692 }
693
694 /**
695 * Return the filtered list of registered tables.
696 *
697 * @since 1.0.0
698 *
699 * @return string[]
700 */
701 private function get_tables() {
702 /**
703 * Filter the array of available Charitable table classes.
704 *
705 * @since 1.0.0
706 *
707 * @param array $tables List of tables as a key=>value array.
708 */
709 return apply_filters(
710 'charitable_db_tables',
711 array(
712 'campaign_donations' => 'Charitable_Campaign_Donations_DB',
713 'donors' => 'Charitable_Donors_DB',
714 'donormeta' => 'Charitable_Donormeta_DB',
715 )
716 );
717 }
718
719 /**
720 * Maybe activate Charitable when a new site is added in a multisite network.
721 *
722 * @since 1.4.6
723 *
724 * @param int $blog_id The blog to activate Charitable on.
725 * @return void
726 */
727 public function maybe_activate_charitable_on_new_site( $blog_id ) {
728 if ( is_plugin_active_for_network( basename( $this->directory_path ) . '/charitable.php' ) ) {
729 switch_to_blog( $blog_id );
730 $this->activate( false );
731 restore_current_blog();
732 }
733 }
734
735 /**
736 * Runs on plugin activation.
737 *
738 * @see register_activation_hook
739 *
740 * @since 1.0.0
741 *
742 * @param boolean $network_wide Whether to enable the plugin for all sites in the network
743 * or just the current site. Multisite only. Default is false.
744 * @return void
745 */
746 public function activate( $network_wide = false ) {
747 require_once( $this->get_path( 'includes' ) . 'class-charitable-install.php' );
748
749 if ( is_multisite() && $network_wide ) {
750 global $wpdb;
751
752 foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) {
753 switch_to_blog( $blog_id );
754 new Charitable_Install();
755 restore_current_blog();
756 }
757 } else {
758 new Charitable_Install();
759 }
760 }
761
762 /**
763 * Runs on plugin deactivation.
764 *
765 * @see register_deactivation_hook
766 *
767 * @since 1.0.0
768 *
769 * @return void
770 */
771 public function deactivate() {
772 require_once( $this->get_path( 'includes' ) . 'class-charitable-uninstall.php' );
773 new Charitable_Uninstall();
774 }
775
776 /**
777 * If a charitable_action event is triggered, delegate the event using do_action.
778 *
779 * @since 1.0.0
780 *
781 * @return void
782 */
783 public function do_charitable_actions() {
784 if ( isset( $_REQUEST['charitable_action'] ) ) {
785
786 $action = $_REQUEST['charitable_action'];
787
788 /**
789 * Handle Charitable action.
790 *
791 * @since 1.0.0
792 */
793 do_action( 'charitable_' . $action );
794 }
795 }
796
797 /**
798 * Throw error on object clone.
799 *
800 * This class is specifically designed to be instantiated once. You can retrieve the instance using charitable()
801 *
802 * @since 1.0.0
803 *
804 * @return void
805 */
806 public function __clone() {
807 charitable_get_deprecated()->doing_it_wrong(
808 __FUNCTION__,
809 __( 'Cloning this object is forbidden.', 'charitable' ),
810 '1.0.0'
811 );
812 }
813
814 /**
815 * Disable unserializing of the class.
816 *
817 * @since 1.0.0
818 *
819 * @return void
820 */
821 public function __wakeup() {
822 charitable_get_deprecated()->doing_it_wrong(
823 __FUNCTION__,
824 __( 'Unserializing instances of this class is forbidden.', 'charitable' ),
825 '1.0.0'
826 );
827 }
828
829 /**
830 * DEPRECATED METHODS
831 */
832
833 /**
834 * Load plugin compatibility files on plugins_loaded hook.
835 *
836 * @deprecated 1.8.0
837 *
838 * @since 1.4.18
839 * @since 1.5.0 Deprecated.
840 *
841 * @return void
842 */
843 public function load_plugin_compat_files() {
844 charitable_get_deprecated()->deprecated_function(
845 __METHOD__,
846 '1.5.0.',
847 'charitable_load_compat_functions'
848 );
849
850 charitable_load_compat_functions();
851 }
852
853 /**
854 * Stores an object in the plugin's registry.
855 *
856 * @deprecated 1.8.0
857 *
858 * @since 1.0.0
859 * @since 1.5.0 Deprecated.
860 *
861 * @param mixed $object Object to be registered.
862 * @return void
863 */
864 public function register_object( $object ) {
865 charitable_get_deprecated()->deprecated_function(
866 __METHOD__,
867 '1.5.0',
868 'charitable()->registry()->register_object()'
869 );
870
871 $this->registry->register_object( $object );
872 }
873
874 /**
875 * Returns the public class.
876 *
877 * @deprecated 1.8.0
878 *
879 * @since 1.0.0
880 * @since 1.5.0 Deprecated.
881 *
882 * @return Charitable_Public
883 */
884 public function get_public() {
885 charitable_get_deprecated()->deprecated_function(
886 __METHOD__,
887 '1.5.0',
888 'charitable_get_helper'
889 );
890
891 return $this->registry->get( 'Charitable_Public' );
892 }
893
894 /**
895 * Returns the admin class.
896 *
897 * @deprecated 1.8.0
898 *
899 * @since 1.0.0
900 * @since 1.5.0 Deprecated.
901 *
902 * @return Charitable_Admin
903 */
904 public function get_admin() {
905 charitable_get_deprecated()->deprecated_function(
906 __METHOD__,
907 '1.5.0',
908 'charitable_get_helper'
909 );
910
911 return $this->registry->get( 'Charitable_Admin' );
912 }
913
914 /**
915 * Return the current request object.
916 *
917 * @deprecated 1.8.0
918 *
919 * @since 1.0.0
920 * @since 1.5.0 Deprecated.
921 *
922 * @return Charitable_Request
923 */
924 public function get_request() {
925 charitable_get_deprecated()->deprecated_function(
926 __METHOD__,
927 '1.5.0',
928 'charitable_get_helper'
929 );
930
931 return $this->registry->get( 'Charitable_Request' );
932 }
933
934 /**
935 * Returns the instance of Charitable_Currency.
936 *
937 * @deprecated 1.7.0
938 *
939 * @since 1.4.0 Deprecated.
940 */
941 public function get_currency_helper() {
942 charitable_get_deprecated()->deprecated_function( __METHOD__, '1.4.0', 'charitable_get_currency_helper' );
943 return charitable_get_currency_helper();
944 }
945
946 /**
947 * Returns the instance of Charitable_Locations.
948 *
949 * @deprecated 1.6.0
950 *
951 * @since 1.2.0 Deprecated.
952 */
953 public function get_location_helper() {
954 charitable_get_deprecated()->deprecated_function( __METHOD__, '1.2.0', 'charitable_get_location_helper' );
955 return charitable_get_location_helper();
956 }
957 }
958
959 $charitable = new Charitable();
960
961 endif;
962