PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.7.0.1
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.7.0.1
1.8.13.1 1.8.13 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 All 212 releases
charitable / includes / endpoints / charitable-endpoints-functions.php

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

412 lines 12.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Endpoint Functions.
4 *
5 * @package Charitable/Functions/Endpoints
6 * @author David Bisset
7 * @copyright Copyright (c) 2022, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @version 1.5.0
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 /**
17 * Register a new endpoint.
18 *
19 * @since 1.5.0
20 *
21 * @param Charitable_Endpoint $endpoint The endpoint object to be registered.
22 * @return void
23 */
24 function charitable_register_endpoint( Charitable_Endpoint $endpoint ) {
25 return charitable()->endpoints()->register( $endpoint );
26 }
27
28 /**
29 * Return the URL for a given page.
30 *
31 * Example usage:
32 *
33 * - charitable_get_permalink( 'campaign_donation_page' );
34 * - charitable_get_permalink( 'login_page' );
35 * - charitable_get_permalink( 'registration_page' );
36 * - charitable_get_permalink( 'profile_page' );
37 * - charitable_get_permalink( 'donation_receipt_page' );
38 * - charitable_get_permalink( 'donation_cancellation_page' );
39 *
40 * @since 1.0.0
41 *
42 * @param string $page The endpoint id.
43 * @param array $args Optional array of arguments.
44 * @return string|false String if page is found. False if none found.
45 */
46 function charitable_get_permalink( $page, $args = array() ) {
47 return charitable()->endpoints()->get_page_url( $page, $args );
48 }
49
50 /**
51 * Checks whether we are currently looking at the given page.
52 *
53 * Example usage:
54 *
55 * - charitable_is_page( 'campaign_donation_page' );
56 * - charitable_is_page( 'login_page' );
57 * - charitable_is_page( 'registration_page' );
58 * - charitable_is_page( 'profile_page' );
59 * - charitable_is_page( 'donation_receipt_page' );
60 * - charitable_is_page( 'donation_cancellation_page' );
61 *
62 * @since 1.0.0
63 *
64 * @param string $page The endpoint id.
65 * @param array $args Optional array of arguments.
66 * @return boolean
67 */
68 function charitable_is_page( $page, $args = array() ) {
69 return charitable()->endpoints()->is_page( $page, $args );
70 }
71
72 /**
73 * Checks whether the current request is for a single campaign.
74 *
75 * @since 1.0.0
76 *
77 * @return boolean
78 */
79 function charitable_is_campaign_page() {
80 return is_singular() && Charitable::CAMPAIGN_POST_TYPE == get_post_type();
81 }
82
83 /**
84 * Returns the URL for the campaign donation page.
85 *
86 * This is functionally equivalent to using charitable_get_permalink( 'campaign_donation' ).
87 * It will produce the same results.
88 *
89 * We keep both for backwards compatibility (pre 1.5).
90 *
91 * @uses Charitable_Endpoints::get_page_url()
92 *
93 * @since 1.0.0
94 *
95 * @param string $url Deprecated argument.
96 * @param array $args Mixed arguments.
97 * @return string
98 */
99 function charitable_get_campaign_donation_page_permalink( $url = null, $args = array() ) {
100 return charitable()->endpoints()->get_page_url( 'campaign_donation', $args );
101 }
102
103 /**
104 * Checks whether the current request is for a campaign donation page.
105 *
106 * This is functionally equivalent to using charitable_is_page( 'campaign_donation' ).
107 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
108 *
109 * By default, this will return true when viewing a campaign with the `donate`
110 * query var set, or when the donation form is shown on the campaign page or
111 * in a modal.
112 *
113 * Pass `'strict' => true` in `$args` to only return true when the `donate`
114 * query var is set.
115 *
116 * @uses Charitable_Endpoints::is_page()
117 *
118 * @since 1.0.0
119 *
120 * @param boolean $ret Unused argument.
121 * @param array $args Mixed args.
122 * @return boolean
123 */
124 function charitable_is_campaign_donation_page( $ret = null, $args = array() ) {
125 return charitable()->endpoints()->is_page( 'campaign_donation', $args );
126 }
127
128 /**
129 * Returns the URL for the campaign donation page.
130 *
131 * This is functionally equivalent to using charitable_get_permalink( 'donation_receipt' ).
132 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
133 *
134 * @since 1.0.0
135 *
136 * @param string $url Deprecated argument.
137 * @param array $args Mixed arguments.
138 * @return string
139 */
140 function charitable_get_donation_receipt_page_permalink( $url = null, $args = array() ) {
141 return charitable()->endpoints()->get_page_url( 'donation_receipt', $args );
142 }
143
144 /**
145 * Checks whether the current request is for the donation receipt page.
146 *
147 * This is used when you call charitable_is_page( 'donation_receipt_page' ).
148 * In general, you should use charitable_is_page() instead since it will
149 * take into account any filtering by plugins/themes.
150 *
151 * @since 1.0.0
152 *
153 * @return boolean
154 */
155 function charitable_is_donation_receipt_page() {
156 return charitable()->endpoints()->is_page( 'donation_receipt' );
157 }
158
159 /**
160 * Returns the URL for the campaign donation page.
161 *
162 * This is functionally equivalent to using charitable_get_permalink( 'donation_processing' ).
163 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
164 *
165 * @since 1.2.0
166 *
167 * @param string $url Deprecated argument.
168 * @param array $args Mixed arguments.
169 * @return string
170 */
171 function charitable_get_donation_processing_page_permalink( $url = null, $args = array() ) {
172 return charitable()->endpoints()->get_page_url( 'donation_processing', $args );
173 }
174
175 /**
176 * Checks whether the current request is for the donation receipt page.
177 *
178 * This is functionally equivalent to using charitable_is_page( 'donation_processing' ).
179 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
180 *
181 * @since 1.0.0
182 *
183 * @return boolean
184 */
185 function charitable_is_donation_processing_page() {
186 return charitable()->endpoints()->is_page( 'donation_processing' );
187 }
188
189 /**
190 * Returns the URL for the donation cancellation page.
191 *
192 * This is functionally equivalent to using charitable_get_permalink( 'donation_cancellation' ).
193 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
194 *
195 * @since 1.4.0
196 *
197 * @param string $url Deprecated argument.
198 * @param array $args Mixed arguments.
199 * @return string
200 */
201 function charitable_get_donation_cancel_page_permalink( $url = null, $args = array() ) {
202 return charitable()->endpoints()->get_page_url( 'donation_cancellation', $args );
203 }
204
205 /**
206 * Checks whether the current request is for the donation cancellation page.
207 *
208 * This is functionally equivalent to using charitable_is_page( 'donation_cancellation' ).
209 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
210 *
211 * @since 1.4.0
212 *
213 * @return boolean
214 */
215 function charitable_is_donation_cancel_page() {
216 return charitable()->endpoints()->is_page( 'donation_cancellation' );
217 }
218
219 /**
220 * Returns the URL for the campaign donation page.
221 *
222 * This is functionally equivalent to using charitable_get_permalink( 'campaign_widget' ).
223 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
224 *
225 * @since 1.2.0
226 *
227 * @param string $url Deprecated argument.
228 * @param array $args Mixed arguments.
229 * @return string
230 */
231 function charitable_get_campaign_widget_page_permalink( $url = null, $args = array() ) {
232 return charitable()->endpoints()->get_page_url( 'campaign_widget', $args );
233 }
234
235 /**
236 * Checks whether the current request is for the donation receipt page.
237 *
238 * This is functionally equivalent to using charitable_is_page( 'campaign_widget' ).
239 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
240 *
241 * @since 1.0.0
242 *
243 * @return boolean
244 */
245 function charitable_is_campaign_widget_page() {
246 return charitable()->endpoints()->is_page( 'campaign_widget' );
247 }
248
249 /**
250 * Returns the URL for the forgot password page.
251 *
252 * This is functionally equivalent to using charitable_get_permalink( 'forgot_password' ).
253 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
254 *
255 * @since 1.4.0
256 *
257 * @param string $url Deprecated argument.
258 * @param array $args Mixed arguments.
259 * @return string
260 */
261 function charitable_get_forgot_password_page_permalink( $url = null, $args = array() ) {
262 return charitable()->endpoints()->get_page_url( 'forgot_password', $args );
263 }
264
265 /**
266 * Checks whether the current request is for the forgot password page.
267 *
268 * This is functionally equivalent to using charitable_is_page( 'forgot_password' ).
269 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
270 *
271 * @since 1.4.0
272 *
273 * @return boolean
274 */
275 function charitable_is_forgot_password_page() {
276 return charitable()->endpoints()->is_page( 'forgot_password' );
277 }
278
279 /**
280 * Returns the URL for the reset password page.
281 *
282 * This is functionally equivalent to using charitable_get_permalink( 'reset_password' ).
283 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
284 *
285 * @since 1.4.0
286 *
287 * @param string $url Deprecated argument.
288 * @param array $args Mixed arguments.
289 * @return string
290 */
291 function charitable_get_reset_password_page_permalink( $url = null, $args = array() ) {
292 return charitable()->endpoints()->get_page_url( 'reset_password' );
293 }
294
295 /**
296 * Checks whether the current request is for the reset password page.
297 *
298 * This is functionally equivalent to using charitable_is_page( 'reset_password' ).
299 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
300 *
301 * @since 1.4.0
302 *
303 * @return boolean
304 */
305 function charitable_is_reset_password_page() {
306 return charitable()->endpoints()->is_page( 'reset_password' );
307 }
308
309 /**
310 * Returns the URL for the login page.
311 *
312 * This is functionally equivalent to using charitable_get_permalink( 'login' ).
313 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
314 *
315 * @since 1.0.0
316 *
317 * @param string $url Deprecated argument.
318 * @param array $args Mixed arguments.
319 * @return string
320 */
321 function charitable_get_login_page_permalink( $url = null, $args = array() ) {
322 return charitable()->endpoints()->get_page_url( 'login' );
323 }
324
325 /**
326 * Checks whether the current request is for the login page.
327 *
328 * This is functionally equivalent to using charitable_is_page( 'login' ).
329 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
330 *
331 * @since 1.0.0
332 *
333 * @return boolean
334 */
335 function charitable_is_login_page() {
336 return charitable()->endpoints()->is_page( 'login' );
337 }
338
339 /**
340 * Returns the URL for the registration page.
341 *
342 * This is functionally equivalent to using charitable_get_permalink( 'registration' ).
343 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
344 *
345 * @since 1.0.0
346 *
347 * @param string $url Deprecated argument.
348 * @param array $args Mixed arguments.
349 * @return string
350 */
351 function charitable_get_registration_page_permalink( $url = null, $args = array() ) {
352 return charitable()->endpoints()->get_page_url( 'registration' );
353 }
354
355 /**
356 * Checks whether the current request is for the registration page.
357 *
358 * This is functionally equivalent to using charitable_is_page( 'registration' ).
359 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
360 *
361 * @since 1.0.0
362 *
363 * @return boolean
364 */
365 function charitable_is_registration_page() {
366 return charitable()->endpoints()->is_page( 'registration' );
367 }
368
369 /**
370 * Returns the URL for the profile page.
371 *
372 * This is functionally equivalent to using charitable_get_permalink( 'profile' ).
373 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
374 *
375 * @since 1.0.0
376 *
377 * @param string $url Deprecated argument.
378 * @param array $args Mixed arguments.
379 * @return string
380 */
381 function charitable_get_profile_page_permalink( $url = null, $args = array() ) {
382 return charitable()->endpoints()->get_page_url( 'profile' );
383 }
384
385 /**
386 * Checks whether the current request is for the profile page.
387 *
388 * This is functionally equivalent to using charitable_is_page( 'profile' ).
389 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
390 *
391 * @since 1.0.0
392 *
393 * @return boolean
394 */
395 function charitable_is_profile_page() {
396 return charitable()->endpoints()->is_page( 'profile' );
397 }
398
399 /**
400 * Checks whether the current request is for an email preview.
401 *
402 * This is functionally equivalent to using charitable_is_page( 'email_preview' ).
403 * It will produce the same results. We keep both for backwards compatibility (pre 1.5).
404 *
405 * @since 1.0.0
406 *
407 * @return boolean
408 */
409 function charitable_is_email_preview() {
410 return charitable()->endpoints()->is_page( 'email_preview' );
411 }
412