PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
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 / class-charitable-donation-cancellation-endpoint.php

class-charitable-donation-cancellation-endpoint.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at includes/endpoints/class-charitable-donation-cancellation-endpoint.php

112 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Donation cancellation endpoint.
4 *
5 * @package Charitable/Classes/Charitable_Donation_Cancellation_Endpoint
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.5.0
10 * @version 1.5.4
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Donation_Cancellation_Endpoint' ) ) :
18
19 /**
20 * Charitable_Donation_Cancellation_Endpoint
21 *
22 * @since 1.5.0
23 */
24 class Charitable_Donation_Cancellation_Endpoint extends Charitable_Endpoint {
25
26 /** Endpoint ID. */
27 const ID = 'donation_cancellation';
28
29 /**
30 * Object instantiation.
31 *
32 * @since 1.5.4
33 */
34 public function __construct() {
35 $this->cacheable = false;
36 }
37
38 /**
39 * Return the endpoint ID.
40 *
41 * @since 1.5.0
42 *
43 * @return string
44 */
45 public static function get_endpoint_id() {
46 return self::ID;
47 }
48
49 /**
50 * Add rewrite rules for the endpoint.
51 *
52 * @since 1.5.0
53 */
54 public function setup_rewrite_rules() {
55 }
56
57 /**
58 * Return the endpoint URL.
59 *
60 * @since 1.5.0
61 *
62 * @global WP_Rewrite $wp_rewrite
63 * @param array $args Mixed args.
64 * @return string
65 */
66 public function get_page_url( $args = array() ) {
67 global $wp_rewrite;
68
69 /* A donation ID must be provided. */
70 if ( ! array_key_exists( 'donation_id', $args ) ) {
71 return $url;
72 }
73
74 /* Grab the first campaign donation. */
75 $campaign_donation = current( charitable_get_donation( $args['donation_id'] )->get_campaign_donations() );
76
77 $donation_page = charitable_get_permalink( 'campaign_donation_page', array(
78 'campaign_id' => $campaign_donation->campaign_id,
79 ) );
80
81 return esc_url_raw(
82 add_query_arg(
83 array(
84 'donation_id' => $args['donation_id'],
85 'cancel' => true,
86 ),
87 $donation_page
88 )
89 );
90 }
91
92 /**
93 * Return whether we are currently viewing the endpoint.
94 *
95 * @since 1.5.0
96 *
97 * @global WP_Query $wp_query
98 * @param array $args Mixed arguments.
99 * @return boolean
100 */
101 public function is_page( $args = array() ) {
102 global $wp_query;
103
104 return charitable_is_page( 'campaign_donation_page' )
105 && array_key_exists( 'donation_id', $wp_query->query_vars )
106 && array_key_exists( 'cancel', $wp_query->query_vars )
107 && $wp_query->query_vars['cancel'];
108 }
109 }
110
111 endif;
112