PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.4.9
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.4.9
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 / includes / charitable-core-functions.php

charitable-core-functions.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.4.9, at includes/charitable-core-functions.php

207 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Charitable Core Functions.
5 *
6 * General core functions.
7 *
8 * @package Charitable/Functions/Core
9 * @version 1.0.0
10 * @author Eric Daams
11 * @copyright Copyright (c) 2015, Studio 164a
12 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly
16
17 /**
18 * This returns the original Charitable object.
19 *
20 * Use this whenever you want to get an instance of the class. There is no
21 * reason to instantiate a new object, though you can do so if you're stubborn :)
22 *
23 * @return Charitable
24 * @since 1.0.0
25 */
26 function charitable() {
27 return Charitable::get_instance();
28 }
29
30 /**
31 * This returns the value for a particular Charitable setting.
32 *
33 * @param mixed $key Accepts an array of strings or a single string.
34 * @param mixed $default The value to return if key is not set.
35 * @param array $settings Optional. Used when $key is an array.
36 * @return mixed
37 * @since 1.0.0
38 */
39 function charitable_get_option( $key, $default = false, $settings = array() ) {
40 if ( empty( $settings ) ) {
41 $settings = get_option( 'charitable_settings' );
42 }
43
44 if ( is_array( $key ) ) {
45 $current_key = current( $key );
46
47 /* Key does not exist */
48 if ( ! isset( $settings[ $current_key ] ) ) {
49
50 return $default;
51
52 } else {
53
54 array_shift( $key );
55
56 if ( empty( $key ) ) {
57
58 return $settings[ $current_key ];
59
60 } else {
61
62 return charitable_get_option( $key, $default, $settings[ $current_key ] );
63
64 }
65 }
66 } else {
67
68 return isset( $settings[ $key ] ) ? $settings[ $key ] : $default;
69
70 }
71 }
72
73 /**
74 * Returns a helper class.
75 *
76 * @param string $class_key
77 * @return mixed
78 * @since 1.0.0
79 */
80 function charitable_get_helper( $class_key ) {
81 if ( false !== strpos( $class_key, '_' ) ) {
82
83 $class_words = str_replace( '_', ' ', $class_key );
84
85 } else {
86
87 $class_words = $class_key;
88
89 }
90
91 $class_words = ucwords( $class_words );
92 $class_name = 'Charitable_' . str_replace( ' ', '_', $class_words );
93
94 if ( ! class_exists( $class_name ) ) {
95 return false;
96 }
97
98 return charitable()->get_registered_object( $class_name );
99 }
100
101 /**
102 * Returns the Charitable_Notices class instance.
103 *
104 * @return Charitable_Notices
105 * @since 1.0.0
106 */
107 function charitable_get_notices() {
108 return Charitable_Notices::get_instance();
109 }
110
111 /**
112 * Returns the Charitable_Donation_Processor class instance.
113 *
114 * @return Charitable_Donation_Processor
115 * @since 1.0.0
116 */
117 function charitable_get_donation_processor() {
118 return Charitable_Donation_Processor::get_instance();
119 }
120
121 /**
122 * Return Charitable_Locations helper class.
123 *
124 * @return Charitable_Locations
125 * @since 1.0.0
126 */
127 function charitable_get_location_helper() {
128 return Charitable_Locations::get_instance();
129 }
130
131 /**
132 * Returns the current user's session object.
133 *
134 * @return Charitable_Session
135 * @since 1.0.0
136 */
137 function charitable_get_session() {
138 return Charitable_Session::get_instance();
139 }
140
141 /**
142 * Returns the current request helper object.
143 *
144 * @return Charitable_Request
145 * @since 1.0.0
146 */
147 function charitable_get_request() {
148 return Charitable_Request::get_instance();
149 }
150
151 /**
152 * Returns the Charitable_User_Dashboard object.
153 *
154 * @return Charitable_User_Dashboard
155 * @since 1.0.0
156 */
157 function charitable_get_user_dashboard() {
158 return Charitable_User_Dashboard::get_instance();
159 }
160
161 /**
162 * Return the database table helper object.
163 *
164 * @param string $table
165 * @return Charitable_DB|null
166 * @since 1.0.0
167 */
168 function charitable_get_table( $table ) {
169 return charitable()->get_db_table( $table );
170 }
171
172 /**
173 * Returns the current donation form.
174 *
175 * @return Charitable_Donation_Form_Interface|false
176 * @since 1.0.0
177 */
178 function charitable_get_current_donation_form() {
179 $campaign = charitable_get_current_campaign();
180 return false === $campaign ? false : $campaign->get_donation_form();
181 }
182
183 /**
184 * Returns the provided array as a HTML element attribute.
185 *
186 * @param array $args
187 * @return string
188 * @since 1.0.0
189 */
190 function charitable_get_action_args( $args ) {
191 return sprintf( "data-charitable-args='%s'", json_encode( $args ) );
192 }
193
194 /**
195 * Returns the Charitable_Deprecated class, loading the file if required.
196 *
197 * @return Charitable_Deprecated
198 * @since 1.4.0
199 */
200 function charitable_get_deprecated() {
201 if ( ! class_exists( 'Charitable_Deprecated' ) ) {
202 require_once( charitable()->get_path( 'includes' ) . 'deprecated/class-charitable-deprecated.php' );
203 }
204
205 return Charitable_Deprecated::get_instance();
206 }
207