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

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