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

965 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.60
7 * Author: WP Charitable
8 * Author URI: https://wpcharitable.com
9 * Requires at least: 4.1
10 * Tested up to: 5.9.3
11 *
12 * Text Domain: charitable
13 * Domain Path: /i18n/languages/
14 *
15 * @package Charitable
16 * @author Eric Daams
17 * @copyright Copyright (c) 2022, 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.60';
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 $this->registry->register_object( new Charitable_Debugging );
269 $this->registry->register_object( new Charitable_Locale );
270 }
271
272 return $this->registry;
273 }
274
275 /**
276 * Set up hook and filter callback functions.
277 *
278 * @since 1.0.0
279 *
280 * @return void
281 */
282 private function attach_hooks_and_filters() {
283 add_action( 'wpmu_new_blog', array( $this, 'maybe_activate_charitable_on_new_site' ) );
284 add_action( 'plugins_loaded', array( $this, 'charitable_install' ), 100 );
285 add_action( 'plugins_loaded', array( $this, 'charitable_start' ), 100 );
286 add_action( 'plugins_loaded', array( $this, 'endpoints' ), 100 );
287 add_action( 'plugins_loaded', array( $this, 'donation_fields' ), 100 );
288 add_action( 'plugins_loaded', array( $this, 'campaign_fields' ), 100 );
289 add_action( 'plugins_loaded', array( $this, 'register_donormeta_table' ) );
290 add_action( 'plugins_loaded', 'charitable_load_compat_functions' );
291 add_action( 'setup_theme', array( 'Charitable_Customizer', 'start' ) );
292 add_action( 'after_setup_theme', array( $this, 'load_template_files' ) );
293 add_action( 'wp_enqueue_scripts', array( $this, 'maybe_start_qunit' ), 100 );
294 add_action( 'rest_api_init', 'charitable_register_api_routes' );
295
296 /**
297 * We do this on priority 20 so that any functionality that is loaded on init (such
298 * as addons) has a chance to run before the event.
299 */
300 add_action( 'init', array( $this, 'do_charitable_actions' ), 20 );
301 }
302
303 /**
304 * Checks whether we're in the admin area and if so, loads the admin-only functionality.
305 *
306 * @since 1.0.0
307 *
308 * @return Charitable_Admin|false
309 */
310 private function maybe_start_admin() {
311 if ( ! is_admin() ) {
312 return false;
313 }
314
315 require_once( $this->get_path( 'admin' ) . 'class-charitable-admin.php' );
316 require_once( $this->get_path( 'admin' ) . 'charitable-admin-hooks.php' );
317
318 $admin = Charitable_Admin::get_instance();
319
320 $this->registry->register_object( $admin );
321
322 return $admin;
323 }
324
325 /**
326 * Checks whether we're on the public-facing side and if so, loads the public-facing functionality.
327 *
328 * @since 1.0.0
329 *
330 * @return Charitable_Public|false
331 */
332 private function maybe_start_public() {
333 if ( is_admin() && ! $this->is_ajax() ) {
334 return false;
335 }
336
337 require_once( $this->get_path( 'public' ) . 'class-charitable-public.php' );
338
339 $public = Charitable_Public::get_instance();
340
341 $this->registry->register_object( $public );
342
343 return $public;
344 }
345
346 /**
347 * Load the QUnit tests if ?qunit is appended to the request.
348 *
349 * @since 1.4.17
350 *
351 * @return boolean
352 */
353 public function maybe_start_qunit() {
354 /* Skip out early if ?qunit isn't included in the request. */
355 if ( ! array_key_exists( 'qunit', $_GET ) ) {
356 return false;
357 }
358
359 /* The unit tests have to exist. */
360 if ( ! file_exists( $this->get_path( 'directory' ) . 'tests/qunit/tests.js' ) ) {
361 return false;
362 }
363
364 wp_register_script( 'qunit', 'https://code.jquery.com/qunit/qunit-2.3.3.js', array(), '2.3.3', true );
365
366 /* Version: '20170615-15:44' */
367 wp_register_script( 'qunit-tests', $this->get_path( 'directory', false ) . 'tests/qunit/tests.js', array( 'jquery', 'qunit' ), time(), true );
368 wp_enqueue_script( 'qunit-tests' );
369
370 wp_register_style( 'qunit', 'https://code.jquery.com/qunit/qunit-2.3.3.css', array(), '2.3.3', 'all' );
371 wp_enqueue_style( 'qunit' );
372 }
373
374 /**
375 * Checks whether the current request is an AJAX request.
376 *
377 * @since 1.5.0
378 *
379 * @return boolean
380 */
381 private function is_ajax() {
382 return false !== ( defined( 'DOING_AJAX' ) && DOING_AJAX );
383 }
384
385 /**
386 * Checks whether we're executing an AJAX hook and if so, loads some AJAX functionality.
387 *
388 * @since 1.0.0
389 *
390 * @return void
391 */
392 private function maybe_start_ajax() {
393 if ( ! $this->is_ajax() ) {
394 return;
395 }
396
397 require_once( $this->get_path( 'includes' ) . 'ajax/charitable-ajax-functions.php' );
398 require_once( $this->get_path( 'includes' ) . 'ajax/charitable-ajax-hooks.php' );
399 }
400
401 /**
402 * This method is fired after all plugins are loaded and simply fires the charitable_start hook.
403 *
404 * Extensions can use the charitable_start event to load their own functionality.
405 *
406 * @since 1.0.0
407 *
408 * @return void
409 */
410 public function charitable_start() {
411 do_action( 'charitable_start', $this );
412 }
413
414 /**
415 * Fires off an action right after Charitable is installed, allowing other
416 * plugins/themes to do something at this point.
417 *
418 * @since 1.0.1
419 *
420 * @return void
421 */
422 public function charitable_install() {
423 $install = get_transient( 'charitable_install' );
424
425 if ( ! $install ) {
426 return;
427 }
428
429 require_once( $this->get_path( 'includes' ) . 'plugin/class-charitable-install.php' );
430
431 Charitable_Install::finish_installing();
432
433 do_action( 'charitable_install' );
434
435 delete_transient( 'charitable_install' );
436 }
437
438 /**
439 * Returns whether we are currently in the start phase of the plugin.
440 *
441 * @since 1.0.0
442 *
443 * @return boolean
444 */
445 public function is_start() {
446 return current_filter() == 'charitable_start';
447 }
448
449 /**
450 * Returns whether the plugin has already started.
451 *
452 * @since 1.0.0
453 *
454 * @return boolean
455 */
456 public function started() {
457 return did_action( 'charitable_start' ) || current_filter() == 'charitable_start';
458 }
459
460 /**
461 * Returns whether the plugin is being activated.
462 *
463 * @since 1.0.0
464 *
465 * @return boolean
466 */
467 public function is_activation() {
468 return current_filter() == 'activate_charitable/charitable.php';
469 }
470
471 /**
472 * Returns whether the plugin is being deactivated.
473 *
474 * @since 1.0.0
475 *
476 * @return boolean
477 */
478 public function is_deactivation() {
479 return current_filter() == 'deactivate_charitable/charitable.php';
480 }
481
482 /**
483 * Returns plugin paths.
484 *
485 * @since 1.0.0
486 *
487 * @param string $type If empty, returns the path to the plugin.
488 * @param boolean $absolute_path If true, returns the file system path. If false, returns it as a URL.
489 * @return string
490 */
491 public function get_path( $type = '', $absolute_path = true ) {
492 $base = $absolute_path ? $this->directory_path : $this->directory_url;
493
494 switch ( $type ) {
495 case 'includes':
496 $path = $base . 'includes/';
497 break;
498
499 case 'admin':
500 $path = $base . 'includes/admin/';
501 break;
502
503 case 'public':
504 $path = $base . 'includes/public/';
505 break;
506
507 case 'assets':
508 $path = $base . 'assets/';
509 break;
510
511 case 'templates':
512 $path = $base . 'templates/';
513 break;
514
515 case 'directory':
516 $path = $base;
517 break;
518
519 default:
520 $path = __FILE__;
521
522 }//end switch
523
524 return $path;
525 }
526
527 /**
528 * Returns the plugin's version number.
529 *
530 * @since 1.0.0
531 *
532 * @return string
533 */
534 public function get_version() {
535 $version = self::VERSION;
536
537 if ( false !== strpos( $version, '-' ) ) {
538 $parts = explode( '-', $version );
539 $version = $parts[0];
540 }
541
542 return $version;
543 }
544
545 /**
546 * Get the campaign fields registry
547 *
548 * If the registry has not been set up yet, this will also
549 * perform the task of setting it up initially.
550 *
551 * This method is called on the plugins_loaded hook.
552 *
553 * @since 1.6.0
554 *
555 * @return Charitable_Campaign_Field_Registry
556 */
557 public function campaign_fields() {
558 if ( ! $this->registry->has( 'campaign_field_registry' ) ) {
559 $campaign_fields = new Charitable_Campaign_Field_Registry();
560
561 /* Register it immediately to avoid endless recursion. */
562 $this->registry->register_object( $campaign_fields );
563
564 $fields = include( $this->get_path( 'includes' ) . 'fields/default-fields/campaign-fields.php' );
565
566 foreach ( $fields as $key => $args ) {
567 $campaign_fields->register_field( new Charitable_Campaign_Field( $key, $args ) );
568 }
569 }
570
571 return $this->registry->get( 'campaign_field_registry' );
572 }
573
574 /**
575 * Get the donation fields registry
576 *
577 * If the registry has not been set up yet, this will also
578 * perform the task of setting it up initially.
579 *
580 * This method is called on the plugins_loaded hook.
581 *
582 * @since 1.5.0
583 *
584 * @return Charitable_Donation_Field_Registry
585 */
586 public function donation_fields() {
587 if ( ! $this->registry->has( 'donation_field_registry' ) ) {
588 $donation_fields = new Charitable_Donation_Field_Registry();
589
590 /* Register it immediately to avoid endless recursion. */
591 $this->registry->register_object( $donation_fields );
592
593 $fields = include( $this->get_path( 'includes' ) . 'fields/default-fields/donation-fields.php' );
594
595 foreach ( $fields as $key => $args ) {
596 $donation_fields->register_field( new Charitable_Donation_Field( $key, $args ) );
597 }
598 }
599
600 return $this->registry->get( 'donation_field_registry' );
601 }
602
603 /**
604 * Return the Endpoints API object.
605 *
606 * If the Endpoints API has not been set up yet, this will also
607 * perform the task of setting it up initially.
608 *
609 * This method is called on the plugins_loaded hook.
610 *
611 * @since 1.5.0
612 *
613 * @return Charitable_Endpoints
614 */
615 public function endpoints() {
616 if ( ! $this->registry->has( 'endpoints' ) ) {
617 /**
618 * The order in which we register endpoints is important, because
619 * it determines the order in which the endpoints are checked to
620 * find whether they are the current page.
621 *
622 * Any endpoint that builds on another endpoint should be registered
623 * BEFORE the endpoint it builds on. In other words, move from
624 * most specific to least specific.
625 */
626 $endpoints = new Charitable_Endpoints();
627 $endpoints->register( new Charitable_Campaign_Donation_Endpoint );
628 $endpoints->register( new Charitable_Campaign_Widget_Endpoint );
629 $endpoints->register( new Charitable_Campaign_Endpoint );
630 $endpoints->register( new Charitable_Donation_Cancellation_Endpoint );
631 $endpoints->register( new Charitable_Donation_Processing_Endpoint );
632 $endpoints->register( new Charitable_Donation_Receipt_Endpoint );
633 $endpoints->register( new Charitable_Email_Preview_Endpoint );
634 $endpoints->register( new Charitable_Email_Verification_Endpoint );
635 $endpoints->register( new Charitable_Forgot_Password_Endpoint );
636 $endpoints->register( new Charitable_Reset_Password_Endpoint );
637 $endpoints->register( new Charitable_Registration_Endpoint );
638 $endpoints->register( new Charitable_Login_Endpoint );
639 $endpoints->register( new Charitable_Profile_Endpoint );
640 $endpoints->register( new Charitable_Webhook_Listener_Endpoint );
641
642 $this->registry->register_object( $endpoints );
643 }
644
645 return $this->registry->get( 'endpoints' );
646 }
647
648 /**
649 * Returns a registered object.
650 *
651 * @since 1.0.0
652 *
653 * @param string $class The type of class to be retrieved.
654 * @return object
655 */
656 public function get_registered_object( $class ) {
657 return $this->registry->get( $class );
658 }
659
660 /**
661 * Registers our donormeta table as a meta data table.
662 *
663 * @since 1.6.0
664 *
665 * @global WPDB $wpdb
666 * @return void
667 */
668 public function register_donormeta_table() {
669 global $wpdb;
670
671 $wpdb->donormeta = $wpdb->prefix . 'charitable_donormeta';
672 }
673
674 /**
675 * Returns the model for one of Charitable's database tables.
676 *
677 * @since 1.0.0
678 *
679 * @param string $table The database table to retrieve.
680 * @return Charitable_DB
681 */
682 public function get_db_table( $table ) {
683 $tables = $this->get_tables();
684
685 if ( ! isset( $tables[ $table ] ) ) {
686 charitable_get_deprecated()->doing_it_wrong(
687 __METHOD__,
688 sprintf( 'Invalid table %s passed', $table ),
689 '1.0.0'
690 );
691 return null;
692 }
693
694 return $this->registry->get( $tables[ $table ] );
695 }
696
697 /**
698 * Return the filtered list of registered tables.
699 *
700 * @since 1.0.0
701 *
702 * @return string[]
703 */
704 private function get_tables() {
705 /**
706 * Filter the array of available Charitable table classes.
707 *
708 * @since 1.0.0
709 *
710 * @param array $tables List of tables as a key=>value array.
711 */
712 return apply_filters(
713 'charitable_db_tables',
714 array(
715 'campaign_donations' => 'Charitable_Campaign_Donations_DB',
716 'donors' => 'Charitable_Donors_DB',
717 'donormeta' => 'Charitable_Donormeta_DB',
718 )
719 );
720 }
721
722 /**
723 * Maybe activate Charitable when a new site is added in a multisite network.
724 *
725 * @since 1.4.6
726 *
727 * @param int $blog_id The blog to activate Charitable on.
728 * @return void
729 */
730 public function maybe_activate_charitable_on_new_site( $blog_id ) {
731 if ( is_plugin_active_for_network( basename( $this->directory_path ) . '/charitable.php' ) ) {
732 switch_to_blog( $blog_id );
733 $this->activate( false );
734 restore_current_blog();
735 }
736 }
737
738 /**
739 * Runs on plugin activation.
740 *
741 * @see register_activation_hook
742 *
743 * @since 1.0.0
744 *
745 * @param boolean $network_wide Whether to enable the plugin for all sites in the network
746 * or just the current site. Multisite only. Default is false.
747 * @return void
748 */
749 public function activate( $network_wide = false ) {
750 require_once( $this->get_path( 'includes' ) . 'plugin/class-charitable-install.php' );
751
752 if ( is_multisite() && $network_wide ) {
753 global $wpdb;
754
755 foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) {
756 switch_to_blog( $blog_id );
757 new Charitable_Install( $this->includes_path );
758 restore_current_blog();
759 }
760 } else {
761 new Charitable_Install( $this->includes_path );
762 }
763 }
764
765 /**
766 * Runs on plugin deactivation.
767 *
768 * @see register_deactivation_hook
769 *
770 * @since 1.0.0
771 *
772 * @return void
773 */
774 public function deactivate() {
775 require_once( $this->get_path( 'includes' ) . 'plugin/class-charitable-uninstall.php' );
776 new Charitable_Uninstall();
777 }
778
779 /**
780 * If a charitable_action event is triggered, delegate the event using do_action.
781 *
782 * @since 1.0.0
783 *
784 * @return void
785 */
786 public function do_charitable_actions() {
787 if ( isset( $_REQUEST['charitable_action'] ) ) {
788
789 $action = $_REQUEST['charitable_action'];
790
791 /**
792 * Handle Charitable action.
793 *
794 * @since 1.0.0
795 */
796 do_action( 'charitable_' . $action );
797 }
798 }
799
800 /**
801 * Throw error on object clone.
802 *
803 * This class is specifically designed to be instantiated once. You can retrieve the instance using charitable()
804 *
805 * @since 1.0.0
806 *
807 * @return void
808 */
809 public function __clone() {
810 charitable_get_deprecated()->doing_it_wrong(
811 __FUNCTION__,
812 __( 'Cloning this object is forbidden.', 'charitable' ),
813 '1.0.0'
814 );
815 }
816
817 /**
818 * Disable unserializing of the class.
819 *
820 * @since 1.0.0
821 *
822 * @return void
823 */
824 public function __wakeup() {
825 charitable_get_deprecated()->doing_it_wrong(
826 __FUNCTION__,
827 __( 'Unserializing instances of this class is forbidden.', 'charitable' ),
828 '1.0.0'
829 );
830 }
831
832 /**
833 * DEPRECATED METHODS
834 */
835
836 /**
837 * Load plugin compatibility files on plugins_loaded hook.
838 *
839 * @deprecated 1.8.0
840 *
841 * @since 1.4.18
842 * @since 1.5.0 Deprecated.
843 *
844 * @return void
845 */
846 public function load_plugin_compat_files() {
847 charitable_get_deprecated()->deprecated_function(
848 __METHOD__,
849 '1.5.0.',
850 'charitable_load_compat_functions'
851 );
852
853 charitable_load_compat_functions();
854 }
855
856 /**
857 * Stores an object in the plugin's registry.
858 *
859 * @deprecated 1.8.0
860 *
861 * @since 1.0.0
862 * @since 1.5.0 Deprecated.
863 *
864 * @param mixed $object Object to be registered.
865 * @return void
866 */
867 public function register_object( $object ) {
868 charitable_get_deprecated()->deprecated_function(
869 __METHOD__,
870 '1.5.0',
871 'charitable()->registry()->register_object()'
872 );
873
874 $this->registry->register_object( $object );
875 }
876
877 /**
878 * Returns the public class.
879 *
880 * @deprecated 1.8.0
881 *
882 * @since 1.0.0
883 * @since 1.5.0 Deprecated.
884 *
885 * @return Charitable_Public
886 */
887 public function get_public() {
888 charitable_get_deprecated()->deprecated_function(
889 __METHOD__,
890 '1.5.0',
891 'charitable_get_helper'
892 );
893
894 return $this->registry->get( 'Charitable_Public' );
895 }
896
897 /**
898 * Returns the admin class.
899 *
900 * @deprecated 1.8.0
901 *
902 * @since 1.0.0
903 * @since 1.5.0 Deprecated.
904 *
905 * @return Charitable_Admin
906 */
907 public function get_admin() {
908 charitable_get_deprecated()->deprecated_function(
909 __METHOD__,
910 '1.5.0',
911 'charitable_get_helper'
912 );
913
914 return $this->registry->get( 'Charitable_Admin' );
915 }
916
917 /**
918 * Return the current request object.
919 *
920 * @deprecated 1.8.0
921 *
922 * @since 1.0.0
923 * @since 1.5.0 Deprecated.
924 *
925 * @return Charitable_Request
926 */
927 public function get_request() {
928 charitable_get_deprecated()->deprecated_function(
929 __METHOD__,
930 '1.5.0',
931 'charitable_get_helper'
932 );
933
934 return $this->registry->get( 'Charitable_Request' );
935 }
936
937 /**
938 * Returns the instance of Charitable_Currency.
939 *
940 * @deprecated 1.7.0
941 *
942 * @since 1.4.0 Deprecated.
943 */
944 public function get_currency_helper() {
945 charitable_get_deprecated()->deprecated_function( __METHOD__, '1.4.0', 'charitable_get_currency_helper' );
946 return charitable_get_currency_helper();
947 }
948
949 /**
950 * Returns the instance of Charitable_Locations.
951 *
952 * @deprecated 1.6.0
953 *
954 * @since 1.2.0 Deprecated.
955 */
956 public function get_location_helper() {
957 charitable_get_deprecated()->deprecated_function( __METHOD__, '1.2.0', 'charitable_get_location_helper' );
958 return charitable_get_location_helper();
959 }
960 }
961
962 $charitable = new Charitable();
963
964 endif;
965