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

976 lines 24.8 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.14
7 * Author: WP Charitable
8 * Author URI: https://wpcharitable.com
9 * Requires at least: 4.1
10 * Tested up to: 5.1.1
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.14';
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 $endpoints->register( new Charitable_Webhook_Listener_Endpoint );
655
656 $this->registry->register_object( $endpoints );
657 }
658
659 return $this->registry->get( 'endpoints' );
660 }
661
662 /**
663 * Returns a registered object.
664 *
665 * @since 1.0.0
666 *
667 * @param string $class The type of class to be retrieved.
668 * @return object
669 */
670 public function get_registered_object( $class ) {
671 return $this->registry->get( $class );
672 }
673
674 /**
675 * Registers our donormeta table as a meta data table.
676 *
677 * @since 1.6.0
678 *
679 * @global WPDB $wpdb
680 * @return void
681 */
682 public function register_donormeta_table() {
683 global $wpdb;
684
685 $wpdb->donormeta = $wpdb->prefix . 'charitable_donormeta';
686 }
687
688 /**
689 * Returns the model for one of Charitable's database tables.
690 *
691 * @since 1.0.0
692 *
693 * @param string $table The database table to retrieve.
694 * @return Charitable_DB
695 */
696 public function get_db_table( $table ) {
697 $tables = $this->get_tables();
698
699 if ( ! isset( $tables[ $table ] ) ) {
700 charitable_get_deprecated()->doing_it_wrong(
701 __METHOD__,
702 sprintf( 'Invalid table %s passed', $table ),
703 '1.0.0'
704 );
705 return null;
706 }
707
708 return $this->registry->get( $tables[ $table ] );
709 }
710
711 /**
712 * Return the filtered list of registered tables.
713 *
714 * @since 1.0.0
715 *
716 * @return string[]
717 */
718 private function get_tables() {
719 /**
720 * Filter the array of available Charitable table classes.
721 *
722 * @since 1.0.0
723 *
724 * @param array $tables List of tables as a key=>value array.
725 */
726 return apply_filters( 'charitable_db_tables', array(
727 'campaign_donations' => 'Charitable_Campaign_Donations_DB',
728 'donors' => 'Charitable_Donors_DB',
729 'donormeta' => 'Charitable_Donormeta_DB',
730 ) );
731 }
732
733 /**
734 * Maybe activate Charitable when a new site is added in a multisite network.
735 *
736 * @since 1.4.6
737 *
738 * @param int $blog_id The blog to activate Charitable on.
739 * @return void
740 */
741 public function maybe_activate_charitable_on_new_site( $blog_id ) {
742 if ( is_plugin_active_for_network( basename( $this->directory_path ) . '/charitable.php' ) ) {
743 switch_to_blog( $blog_id );
744 $this->activate( false );
745 restore_current_blog();
746 }
747 }
748
749 /**
750 * Runs on plugin activation.
751 *
752 * @see register_activation_hook
753 *
754 * @since 1.0.0
755 *
756 * @param boolean $network_wide Whether to enable the plugin for all sites in the network
757 * or just the current site. Multisite only. Default is false.
758 * @return void
759 */
760 public function activate( $network_wide = false ) {
761 require_once( $this->get_path( 'includes' ) . 'class-charitable-install.php' );
762
763 if ( is_multisite() && $network_wide ) {
764 global $wpdb;
765
766 foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) {
767 switch_to_blog( $blog_id );
768 new Charitable_Install();
769 restore_current_blog();
770 }
771 } else {
772 new Charitable_Install();
773 }
774 }
775
776 /**
777 * Runs on plugin deactivation.
778 *
779 * @see register_deactivation_hook
780 *
781 * @since 1.0.0
782 *
783 * @return void
784 */
785 public function deactivate() {
786 require_once( $this->get_path( 'includes' ) . 'class-charitable-uninstall.php' );
787 new Charitable_Uninstall();
788 }
789
790 /**
791 * If a charitable_action event is triggered, delegate the event using do_action.
792 *
793 * @since 1.0.0
794 *
795 * @return void
796 */
797 public function do_charitable_actions() {
798 if ( isset( $_REQUEST['charitable_action'] ) ) {
799
800 $action = $_REQUEST['charitable_action'];
801
802 /**
803 * Handle Charitable action.
804 *
805 * @since 1.0.0
806 */
807 do_action( 'charitable_' . $action );
808 }
809 }
810
811 /**
812 * Throw error on object clone.
813 *
814 * This class is specifically designed to be instantiated once. You can retrieve the instance using charitable()
815 *
816 * @since 1.0.0
817 *
818 * @return void
819 */
820 public function __clone() {
821 charitable_get_deprecated()->doing_it_wrong(
822 __FUNCTION__,
823 __( 'Cloning this object is forbidden.', 'charitable' ),
824 '1.0.0'
825 );
826 }
827
828 /**
829 * Disable unserializing of the class.
830 *
831 * @since 1.0.0
832 *
833 * @return void
834 */
835 public function __wakeup() {
836 charitable_get_deprecated()->doing_it_wrong(
837 __FUNCTION__,
838 __( 'Unserializing instances of this class is forbidden.', 'charitable' ),
839 '1.0.0'
840 );
841 }
842
843 /**
844 * DEPRECATED METHODS
845 */
846
847 /**
848 * Load plugin compatibility files on plugins_loaded hook.
849 *
850 * @deprecated 1.8.0
851 *
852 * @since 1.4.18
853 * @since 1.5.0 Deprecated.
854 *
855 * @return void
856 */
857 public function load_plugin_compat_files() {
858 charitable_get_deprecated()->deprecated_function(
859 __METHOD__,
860 '1.5.0.',
861 'charitable_load_compat_functions'
862 );
863
864 charitable_load_compat_functions();
865 }
866
867 /**
868 * Stores an object in the plugin's registry.
869 *
870 * @deprecated 1.8.0
871 *
872 * @since 1.0.0
873 * @since 1.5.0 Deprecated.
874 *
875 * @param mixed $object Object to be registered.
876 * @return void
877 */
878 public function register_object( $object ) {
879 charitable_get_deprecated()->deprecated_function(
880 __METHOD__,
881 '1.5.0',
882 'charitable()->registry()->register_object()'
883 );
884
885 $this->registry->register_object( $object );
886 }
887
888 /**
889 * Returns the public class.
890 *
891 * @deprecated 1.8.0
892 *
893 * @since 1.0.0
894 * @since 1.5.0 Deprecated.
895 *
896 * @return Charitable_Public
897 */
898 public function get_public() {
899 charitable_get_deprecated()->deprecated_function(
900 __METHOD__,
901 '1.5.0',
902 'charitable_get_helper'
903 );
904
905 return $this->registry->get( 'Charitable_Public' );
906 }
907
908 /**
909 * Returns the admin class.
910 *
911 * @deprecated 1.8.0
912 *
913 * @since 1.0.0
914 * @since 1.5.0 Deprecated.
915 *
916 * @return Charitable_Admin
917 */
918 public function get_admin() {
919 charitable_get_deprecated()->deprecated_function(
920 __METHOD__,
921 '1.5.0',
922 'charitable_get_helper'
923 );
924
925 return $this->registry->get( 'Charitable_Admin' );
926 }
927
928 /**
929 * Return the current request object.
930 *
931 * @deprecated 1.8.0
932 *
933 * @since 1.0.0
934 * @since 1.5.0 Deprecated.
935 *
936 * @return Charitable_Request
937 */
938 public function get_request() {
939 charitable_get_deprecated()->deprecated_function(
940 __METHOD__,
941 '1.5.0',
942 'charitable_get_helper'
943 );
944
945 return $this->registry->get( 'Charitable_Request' );
946 }
947
948 /**
949 * Returns the instance of Charitable_Currency.
950 *
951 * @deprecated 1.7.0
952 *
953 * @since 1.4.0 Deprecated.
954 */
955 public function get_currency_helper() {
956 charitable_get_deprecated()->deprecated_function( __METHOD__, '1.4.0', 'charitable_get_currency_helper' );
957 return charitable_get_currency_helper();
958 }
959
960 /**
961 * Returns the instance of Charitable_Locations.
962 *
963 * @deprecated 1.6.0
964 *
965 * @since 1.2.0 Deprecated.
966 */
967 public function get_location_helper() {
968 charitable_get_deprecated()->deprecated_function( __METHOD__, '1.2.0', 'charitable_get_location_helper' );
969 return charitable_get_location_helper();
970 }
971 }
972
973 $charitable = new Charitable();
974
975 endif;
976