← All changes
|
includes/endpoints/class-charitable-donation-processing-endpoint.php
+37
-18
1.6.8
→
1.8.13
View file →
| @@ -2,16 +2,18 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Donation processing endpoint. |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Classes/Charitable_Donation_Processing_Endpoint |
| 6 | - * @author Eric Daams | |
| 7 | - * @copyright Copyright (c) 2019, Studio 164a | |
| 6 | + * @author David Bisset | |
| 7 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @since 1.5.0 |
| 10 | - * @version 1.5.9 | |
| 10 | + * @version 1.6.55 | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 14 | 16 | |
| 15 | 17 | if ( ! class_exists( 'Charitable_Donation_Processing_Endpoint' ) ) : |
| 16 | 18 | |
| 17 | 19 | /** |
| @@ -20,9 +22,9 @@ | ||
| 20 | 22 | * @since 1.5.0 |
| 21 | 23 | */ |
| 22 | 24 | class Charitable_Donation_Processing_Endpoint extends Charitable_Endpoint { |
| 23 | 25 | |
| 24 | - /* @var string */ | |
| 26 | + /** Endpoint ID. */ | |
| 25 | 27 | const ID = 'donation_processing'; |
| 26 | 28 | |
| 27 | 29 | /** |
| 28 | 30 | * Object instantiation. |
| @@ -37,9 +39,9 @@ | ||
| 37 | 39 | * Return the endpoint ID. |
| 38 | 40 | * |
| 39 | 41 | * @since 1.5.0 |
| 40 | 42 | * |
| 41 | - * @return string | |
| 43 | + * @return string | |
| 42 | 44 | */ |
| 43 | 45 | public static function get_endpoint_id() { |
| 44 | 46 | return self::ID; |
| 45 | 47 | } |
| @@ -70,12 +72,17 @@ | ||
| 70 | 72 | |
| 71 | 73 | if ( $wp_rewrite->using_permalinks() ) { |
| 72 | 74 | $url = sprintf( '%s/donation-processing/%d', untrailingslashit( home_url() ), $donation_id ); |
| 73 | 75 | } else { |
| 74 | - $url = esc_url_raw( add_query_arg( array( | |
| 75 | - 'donation_processing' => 1, | |
| 76 | - 'donation_id' => $donation_id, | |
| 77 | - ), home_url() ) ); | |
| 76 | + $url = esc_url_raw( | |
| 77 | + add_query_arg( | |
| 78 | + array( | |
| 79 | + 'donation_processing' => 1, | |
| 80 | + 'donation_id' => $donation_id, | |
| 81 | + ), | |
| 82 | + home_url() | |
| 83 | + ) | |
| 84 | + ); | |
| 78 | 85 | } |
| 79 | 86 | |
| 80 | 87 | return $url; |
| 81 | 88 | } |
| @@ -97,22 +104,34 @@ | ||
| 97 | 104 | && array_key_exists( 'donation_id', $wp_query->query_vars ); |
| 98 | 105 | } |
| 99 | 106 | |
| 100 | 107 | /** |
| 108 | + * Prepare the template for the endpoint. | |
| 109 | + * | |
| 110 | + * @since 1.6.55 | |
| 111 | + * | |
| 112 | + * @return void | |
| 113 | + */ | |
| 114 | + public function setup_template() { | |
| 115 | + new Charitable_Ghost_Page( | |
| 116 | + 'donation-processing-page', | |
| 117 | + array( | |
| 118 | + 'title' => __( 'Thank you for your donation', 'charitable' ), | |
| 119 | + 'content' => sprintf( '<p>%s</p>', __( 'You will shortly be redirected to the payment gateway to complete your donation.', 'charitable' ) ), | |
| 120 | + ) | |
| 121 | + ); | |
| 122 | + } | |
| 123 | + | |
| 124 | + /** | |
| 101 | 125 | * Return the template to display for this endpoint. |
| 102 | 126 | * |
| 103 | 127 | * @since 1.5.0 |
| 104 | 128 | * |
| 105 | 129 | * @param string $template The default template. |
| 106 | - * @return string | |
| 130 | + * @return array | |
| 107 | 131 | */ |
| 108 | 132 | public function get_template( $template ) { |
| 109 | - new Charitable_Ghost_Page( 'donation-processing-page', array( | |
| 110 | - 'title' => __( 'Thank you for your donation', 'charitable' ), | |
| 111 | - 'content' => sprintf( '<p>%s</p>', __( 'You will shortly be redirected to the payment gateway to complete your donation.', 'charitable' ) ), | |
| 112 | - ) ); | |
| 113 | - | |
| 114 | - return array( 'donation-processing-page.php', 'page.php', 'index.php' ); | |
| 133 | + return array( 'donation-processing-page.php', 'page.php', 'singular.php', 'index.php' ); | |
| 115 | 134 | } |
| 116 | 135 | |
| 117 | 136 | /** |
| 118 | 137 | * Get the content to display for the endpoint. |
| @@ -136,9 +155,9 @@ | ||
| 136 | 155 | * Return the body class to add for the endpoint. |
| 137 | 156 | * |
| 138 | 157 | * @since 1.5.0 |
| 139 | 158 | * |
| 140 | - * @return string | |
| 159 | + * @return string | |
| 141 | 160 | */ |
| 142 | 161 | public function get_body_class() { |
| 143 | 162 | return 'campaign-donation-processing'; |
| 144 | 163 | } |