PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.6.10
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.6.10
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.10, at charitable.php

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