PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.17.0
GiveWP – Donation Plugin and Fundraising Platform v2.17.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
← All changes | src/Controller/Form.php +313 -332 2.31.12.17.0 View file →
@@ -10,19 +10,19 @@
10 10 namespace Give\Controller;
11 11
12 12 use Give\Form\LoadTemplate;
13 13 use Give\Form\Template;
14 -use Give\Helpers\Form\Template as FormTemplateUtils;
15 -use Give\Helpers\Form\Template\Utils\Frontend as FrontendFormTemplateUtils;
16 -use Give\Helpers\Form\Utils as FormUtils;
14 +use Give\Helpers\Frontend\Shortcode as ShortcodeUtils;
17 15 use Give\Helpers\Frontend\ConfirmDonation;
18 -use Give\Helpers\Frontend\Shortcode as ShortcodeUtils;
19 16 use Give\Helpers\Utils;
17 +use Give\Helpers\Form\Utils as FormUtils;
20 18 use Give\Session\SessionDonation\DonationAccessor;
21 19 use Give_Notices;
22 20 use WP_Post;
21 +use Give\Helpers\Form\Template as FormTemplateUtils;
22 +use Give\Helpers\Form\Template\Utils\Frontend as FrontendFormTemplateUtils;
23 23
24 -defined('ABSPATH') || exit;
24 +defined( 'ABSPATH' ) || exit;
25 25
26 26 /**
27 27 * Form class.
28 28 *
@@ -27,384 +27,365 @@
27 27 * Form class.
28 28 *
29 29 * @since 2.7.0
30 30 */
31 -class Form
32 -{
31 +class Form {
33 32
34 - /**
35 - * Initialize
36 - *
37 - * @since 2.7.0
38 - */
39 - public function init()
40 - {
41 - add_action('wp', [$this, 'loadTemplateOnFrontend'], 11, 0);
42 - add_action('admin_init', [$this, 'loadTemplateOnAjaxRequest']);
43 - add_action('init', [$this, 'embedFormRedirectURIHandler'], 1);
44 - add_action('template_redirect', [$this, 'loadReceiptView'], 1);
45 - add_action('give_before_single_form_summary', [$this, 'handleSingleDonationFormPage'], 0);
46 - }
33 + /**
34 + * Initialize
35 + *
36 + * @since 2.7.0
37 + */
38 + public function init() {
39 + add_action( 'wp', [ $this, 'loadTemplateOnFrontend' ], 11, 0 );
40 + add_action( 'admin_init', [ $this, 'loadTemplateOnAjaxRequest' ] );
41 + add_action( 'init', [ $this, 'embedFormRedirectURIHandler' ], 1 );
42 + add_action( 'template_redirect', [ $this, 'loadReceiptView' ], 1 );
43 + add_action( 'give_before_single_form_summary', [ $this, 'handleSingleDonationFormPage' ], 0 );
44 + }
47 45
48 - /**
49 - * Load form template on frontend.
50 - *
51 - * @since 2.7.0
52 - */
53 - public function loadTemplateOnFrontend()
54 - {
55 - if (FormUtils::isProcessingForm()) {
56 - $this->loadTemplate();
46 + /**
47 + * Load form template on frontend.
48 + *
49 + * @since 2.7.0
50 + */
51 + public function loadTemplateOnFrontend() {
52 + if ( FormUtils::isProcessingForm() ) {
53 + $this->loadTemplate();
57 54
58 - add_action('template_redirect', [$this, 'loadDonationFormView'], 1);
59 - }
60 - }
55 + add_action( 'template_redirect', [ $this, 'loadDonationFormView' ], 1 );
56 + }
57 + }
61 58
62 - /**
63 - * Load receipt view.
64 - *
65 - * @since 2.7.0
66 - */
67 - public function loadReceiptView()
68 - {
69 - // Do not handle legacy donation form.
70 - if (FormUtils::isLegacyForm()) {
71 - return;
72 - }
59 + /**
60 + * Load receipt view.
61 + *
62 + * @since 2.7.0
63 + */
64 + public function loadReceiptView() {
65 + // Do not handle legacy donation form.
66 + if ( FormUtils::isLegacyForm() ) {
67 + return;
68 + }
73 69
74 - // Handle success page.
75 - if (FormUtils::isViewingFormReceipt() && ! FormUtils::isLegacyForm()) {
76 - /* @var Template $formTemplate */
77 - $formTemplate = Give()->templates->getTemplate();
70 + // Handle success page.
71 + if ( FormUtils::isViewingFormReceipt() && ! FormUtils::isLegacyForm() ) {
72 + /* @var Template $formTemplate */
73 + $formTemplate = Give()->templates->getTemplate();
78 74
79 - if (FormUtils::inIframe() || ($formTemplate->openSuccessPageInIframe && FormUtils::isProcessingForm())) {
80 - // Set header.
81 - nocache_headers();
82 - header('HTTP/1.1 200 OK');
75 + if ( FormUtils::inIframe() || ( $formTemplate->openSuccessPageInIframe && FormUtils::isProcessingForm() ) ) {
76 + // Set header.
77 + nocache_headers();
78 + header( 'HTTP/1.1 200 OK' );
83 79
84 - // Show donation processing template.
85 - if (ConfirmDonation::isConfirming()) {
86 - $session = new DonationAccessor();
87 - $donationId = $session->getDonationId();
80 + // Show donation processing template.
81 + if ( ConfirmDonation::isConfirming() ) {
82 + $session = new DonationAccessor();
83 + $donationId = $session->getDonationId();
88 84
89 - /**
90 - * Fire the action hook.
91 - *
92 - * If developer wants to verify payment before showing receipt then use `give_handle_donation_confirm` action hook to verify donation.
93 - * Developer can access query parameters return by payment gateway. for example
94 - * $session = new DonationAccessor();
95 - * $session->getByKey( "postDataFor{$paymentGatewayId}" )
96 - *
97 - * @since 2.7.0
98 - *
99 - * @param int $donationId
100 - */
101 - do_action('give_handle_donation_confirmation', $donationId);
85 + /**
86 + * Fire the action hook.
87 + *
88 + * If developer wants to verify payment before showing receipt then use `give_handle_donation_confirm` action hook to verify donation.
89 + * Developer can access query parameters return by payment gateway. for example
90 + * $session = new DonationAccessor();
91 + * $session->getByKey( "postDataFor{$paymentGatewayId}" )
92 + *
93 + * @since 2.7.0
94 + * @param int $donationId
95 + */
96 + do_action( 'give_handle_donation_confirmation', $donationId );
102 97
103 - ConfirmDonation::removePostedDataFromDonationSession();
98 + ConfirmDonation::removePostedDataFromDonationSession();
104 99
105 - // Load payment processing view only if donation is in pending status.
106 - if ('pending' === get_post_status($donationId)) {
107 - include GIVE_PLUGIN_DIR . 'src/Views/Form/defaultFormDonationProcessing.php';
108 - exit();
109 - }
110 - }
100 + // Load payment processing view only if donation is in pending status.
101 + if ( 'pending' === get_post_status( $donationId ) ) {
102 + include GIVE_PLUGIN_DIR . 'src/Views/Form/defaultFormDonationProcessing.php';
103 + exit();
104 + }
105 + }
111 106
112 - // Render receipt with in iframe.
113 - include $formTemplate->getReceiptView();
114 - exit();
115 - }
107 + // Render receipt with in iframe.
108 + include $formTemplate->getReceiptView();
109 + exit();
110 + }
116 111
117 - // Render receipt on success page in iframe.
118 - add_filter('the_content', [$this, 'showReceiptInIframeOnSuccessPage'], 1);
119 - }
120 - }
112 + // Render receipt on success page in iframe.
113 + add_filter( 'the_content', [ $this, 'showReceiptInIframeOnSuccessPage' ], 1 );
114 + }
115 + }
121 116
122 - /**
123 - * Load donation form view.
124 - *
125 - * @since 2.7.0
117 + /**
118 + * Load donation form view.
119 + *
120 + * @since 2.7.0
126 121 * @since 2.16.2 Co-locate $formTemplate with related conditional and usage.
127 - * @global WP_Post $post
128 - */
129 - public function loadDonationFormView()
130 - {
131 - // Handle failed donation error.
132 - if (FormUtils::canShowFailedDonationError()) {
133 - add_action('give_pre_form', [$this, 'setFailedTransactionError']);
134 - }
122 + * @global WP_Post $post
123 + */
124 + public function loadDonationFormView() {
135 125
126 + // Handle failed donation error.
127 + if ( FormUtils::canShowFailedDonationError() ) {
128 + add_action( 'give_pre_form', [ $this, 'setFailedTransactionError' ] );
129 + }
130 +
136 131 // Handle donation form.
137 - if (FormUtils::isViewingForm()) {
132 + if ( FormUtils::isViewingForm() ) {
133 +
138 134 /* @var Template $formTemplate */
139 135 $formTemplate = Give()->templates->getTemplate();
140 136
141 - // Set header.
142 - nocache_headers();
143 - header('HTTP/1.1 200 OK');
137 + // Set header.
138 + nocache_headers();
139 + header( 'HTTP/1.1 200 OK' );
144 140
145 - include $formTemplate->getFormView();
146 - exit();
147 - }
148 - }
141 + include $formTemplate->getFormView();
142 + exit();
143 + }
144 + }
149 145
150 - /**
151 - * Show failed transaction error on donation form.
152 - *
153 - * @since 2.7.0
154 - */
155 - public function setFailedTransactionError()
156 - {
157 - Give_Notices::print_frontend_notice(
158 - Give()->templates->getTemplate(FormTemplateUtils::getActiveID())->getFailedDonationMessage(),
159 - true,
160 - 'error'
161 - );
162 - }
146 + /**
147 + * Show failed transaction error on donation form.
148 + *
149 + * @since 2.7.0
150 + */
151 + public function setFailedTransactionError() {
152 + Give_Notices::print_frontend_notice(
153 + Give()->templates->getTemplate( FormTemplateUtils::getActiveID() )->getFailedDonationMessage(),
154 + true,
155 + 'error'
156 + );
157 + }
163 158
164 - /**
165 - * Handle receipt shortcode on success page
166 - *
167 - * @since 2.7.0
168 - *
169 - * @param string $content
170 - *
171 - * @return string
172 - */
173 - public function showReceiptInIframeOnSuccessPage($content)
174 - {
175 - $receiptShortcode = ShortcodeUtils::getReceiptShortcodeFromConfirmationPage();
176 - $content = str_replace($receiptShortcode, give_form_shortcode([]), $content);
159 + /**
160 + * Handle receipt shortcode on success page
161 + *
162 + * @since 2.7.0
163 + * @param string $content
164 + *
165 + * @return string
166 + */
167 + public function showReceiptInIframeOnSuccessPage( $content ) {
168 + $receiptShortcode = ShortcodeUtils::getReceiptShortcodeFromConfirmationPage();
169 + $content = str_replace( $receiptShortcode, give_form_shortcode( [] ), $content );
177 170
178 - return $content;
179 - }
171 + return $content;
172 + }
180 173
181 - /**
182 - * Load form template
183 - *
184 - * @since 2.7.0
185 - * @return LoadTemplate
186 - */
187 - private function loadTemplate()
188 - {
189 - $templateLoader = new LoadTemplate();
190 - $templateLoader->init();
191 174
192 - return $templateLoader;
193 - }
175 + /**
176 + * Load form template
177 + *
178 + * @return LoadTemplate
179 + * @since 2.7.0
180 + */
181 + private function loadTemplate() {
182 + $templateLoader = new LoadTemplate();
183 + $templateLoader->init();
194 184
195 - /**
196 - * Load form template on ajax request.
197 - *
198 - * @since 2.7.0
199 - */
200 - public function loadTemplateOnAjaxRequest()
201 - {
202 - if (FormUtils::isProcessingGiveActionOnAjax() && ! FormUtils::isLegacyForm()) {
203 - $this->loadTemplate();
204 - }
205 - }
185 + return $templateLoader;
186 + }
206 187
207 - /**
208 - * Handle donor redirect when process donations.
209 - *
210 - * This function handle donor redirect when process donation with offsite checkout and on-site checkout.
211 - * Donor will immediately redirect to success page aka receipt page for on-site payment process. That means success page remain same (as set in admin settings).
212 - * For offsite checkout donor will redirect to embed form parent page. A query parameter will be add to url giveDonationAction=showReceipt to handle further cases.
213 - *
214 - * @since 2.7.0
215 - */
216 - public function embedFormRedirectURIHandler()
217 - {
218 - if (FormUtils::isProcessingForm()) {
219 - add_filter('give_get_success_page_uri', [self::class, 'editSuccessPageURI']);
220 - add_filter('give_get_failed_transaction_uri', [self::class, 'editFailedPageURI']);
221 - add_filter('give_send_back_to_checkout', [$this, 'handlePrePaymentProcessingErrorRedirect']);
222 - add_filter('wp_redirect', [$this, 'handleOffSiteCheckoutRedirect']);
223 - }
224 - }
188 + /**
189 + * Load form template on ajax request.
190 + *
191 + * @since 2.7.0
192 + */
193 + public function loadTemplateOnAjaxRequest() {
194 + if ( FormUtils::isProcessingGiveActionOnAjax() && ! FormUtils::isLegacyForm() ) {
195 + $this->loadTemplate();
196 + }
197 + }
225 198
226 - /**
227 - * Return current page aka embed form parent url as success page.
228 - *
229 - * @since 2.7.0
230 - *
231 - * @param string $url
232 - *
233 - * @return string
234 - */
235 - public static function editSuccessPageURI($url)
236 - {
237 - /* @var Template $template */
238 - $template = Give()->templates->getTemplate();
239 199
240 - return $template->openSuccessPageInIframe ?
241 - FormUtils::createSuccessPageURL(Utils::switchRequestedURL($url, FormUtils::getIframeParentURL())) :
242 - $url;
243 - }
200 + /**
201 + * Handle donor redirect when process donations.
202 + *
203 + * This function handle donor redirect when process donation with offsite checkout and on-site checkout.
204 + * Donor will immediately redirect to success page aka receipt page for on-site payment process. That means success page remain same (as set in admin settings).
205 + * For offsite checkout donor will redirect to embed form parent page. A query parameter will be add to url giveDonationAction=showReceipt to handle further cases.
206 + *
207 + * @since 2.7.0
208 + */
209 + public function embedFormRedirectURIHandler() {
210 + if ( FormUtils::isProcessingForm() ) {
211 + add_filter( 'give_get_success_page_uri', [ self::class, 'editSuccessPageURI' ] );
212 + add_filter( 'give_get_failed_transaction_uri', [ self::class, 'editFailedPageURI' ] );
213 + add_filter( 'give_send_back_to_checkout', [ $this, 'handlePrePaymentProcessingErrorRedirect' ] );
214 + add_filter( 'wp_redirect', [ $this, 'handleOffSiteCheckoutRedirect' ] );
215 + }
216 + }
244 217
245 - /**
246 - * Return current page aka embed form parent url as failed page.
247 - *
248 - * @since 2.7.0
249 - *
250 - * @param string $url
251 - *
252 - * @return string
253 - */
254 - public static function editFailedPageURI($url)
255 - {
256 - /* @var Template $template */
257 - $template = Give()->templates->getTemplate(FormTemplateUtils::getActiveID());
258 218
259 - return $template->openFailedPageInIframe ?
260 - FormUtils::createFailedPageURL(Utils::switchRequestedURL($url, FormUtils::getIframeParentURL())) :
261 - $url;
262 - }
219 + /**
220 + * Return current page aka embed form parent url as success page.
221 + *
222 + * @param string $url
223 + *
224 + * @return string
225 + * @since 2.7.0
226 + */
227 + public static function editSuccessPageURI( $url ) {
228 + /* @var Template $template */
229 + $template = Give()->templates->getTemplate();
263 230
264 - /**
265 - * Handle pre payment processing redirect.
266 - *
267 - * These redirects mainly happen when donation form data is not valid.
268 - *
269 - * @since 2.7.0
270 - * @since 2.9.6 Adds giveDonationFormInIframe query param to url
271 - *
272 - * @param string $redirect
273 - *
274 - * @return string
275 - */
276 - public function handlePrePaymentProcessingErrorRedirect($redirect)
277 - {
278 - $redirect = add_query_arg(
279 - [
280 - 'showDonationProcessingError' => 1,
281 - 'giveDonationFormInIframe' => 1,
282 - ],
283 - $redirect
284 - );
231 + return $template->openSuccessPageInIframe ?
232 + FormUtils::createSuccessPageURL( Utils::switchRequestedURL( $url, FormUtils::getIframeParentURL() ) ) :
233 + $url;
234 + }
285 235
286 - $url = explode('?', esc_url_raw($redirect), 2);
287 - $url[0] = Give()->routeForm->getURL(get_post_field('post_name', absint($_REQUEST['give-form-id'])));
236 + /**
237 + * Return current page aka embed form parent url as failed page.
238 + *
239 + * @param string $url
240 + *
241 + * @return string
242 + * @since 2.7.0
243 + */
244 + public static function editFailedPageURI( $url ) {
245 + /* @var Template $template */
246 + $template = Give()->templates->getTemplate( FormTemplateUtils::getActiveID() );
288 247
289 - return implode('?', $url);
290 - }
248 + return $template->openFailedPageInIframe ?
249 + FormUtils::createFailedPageURL( Utils::switchRequestedURL( $url, FormUtils::getIframeParentURL() ) ) :
250 + $url;
251 + }
291 252
292 - /**
293 - * Handle offsite payment checkout.
294 - *
295 - * In case of offsite checkout, this function will load a intermediate template to redirect embed parent page.
296 - *
297 - * @since 2.7.0
298 - *
299 - * @param string $location
300 - *
301 - * @return mixed
302 - */
303 - public function handleOffSiteCheckoutRedirect($location)
304 - {
305 - /* @var Template $template */
306 - $template = Give()->templates->getTemplate();
307 253
308 - // Exit if redirect is on same website.
309 - if (0 === strpos($location, home_url())) {
310 - if (FormUtils::isIframeParentSuccessPageURL($location)) {
311 - $location = FormUtils::getSuccessPageURL();
312 - $location = Utils::removeDonationAction($location);
254 + /**
255 + * Handle pre payment processing redirect.
256 + *
257 + * These redirects mainly happen when donation form data is not valid.
258 + *
259 + * @since 2.7.0
260 + * @since 2.9.6 Adds giveDonationFormInIframe query param to url
261 + *
262 + * @param string $redirect
263 + *
264 + * @return string
265 + */
266 + public function handlePrePaymentProcessingErrorRedirect( $redirect ) {
267 + $redirect = add_query_arg(
268 + [
269 + 'showDonationProcessingError' => 1,
270 + 'giveDonationFormInIframe' => 1,
271 + ],
272 + $redirect
273 + );
313 274
314 - // Open link in window?
315 - if ( ! $template->openSuccessPageInIframe) {
316 - $this->openLinkInWindow($location);
317 - }
275 + $url = explode( '?', $redirect, 2 );
276 + $url[0] = Give()->routeForm->getURL( get_post_field( 'post_name', absint( $_REQUEST['give-form-id'] ) ) );
318 277
319 - return $location;
320 - }
278 + return implode( '?', $url );
279 + }
321 280
322 - if (FormUtils::isIframeParentFailedPageURL($location)) {
323 - $location = add_query_arg(
324 - ['showFailedDonationError' => 1],
325 - $template->getFailedPageURL(FrontendFormTemplateUtils::getFormId())
326 - );
327 - $location = Utils::removeDonationAction($location);
281 + /**
282 + * Handle offsite payment checkout.
283 + *
284 + * In case of offsite checkout, this function will load a intermediate template to redirect embed parent page.
285 + *
286 + * @since 2.7.0
287 + * @param string $location
288 + *
289 + * @return mixed
290 + */
291 + public function handleOffSiteCheckoutRedirect( $location ) {
292 + /* @var Template $template */
293 + $template = Give()->templates->getTemplate();
328 294
329 - // Open link in window?
330 - if ( ! $template->openFailedPageInIframe) {
331 - $this->openLinkInWindow(FormUtils::getLegacyFailedPageURL());
332 - }
295 + // Exit if redirect is on same website.
296 + if ( 0 === strpos( $location, home_url() ) ) {
297 + if ( FormUtils::isIframeParentSuccessPageURL( $location ) ) {
298 + $location = FormUtils::getSuccessPageURL();
299 + $location = Utils::removeDonationAction( $location );
333 300
334 - return $location;
335 - }
301 + // Open link in window?
302 + if ( ! $template->openSuccessPageInIframe ) {
303 + $this->openLinkInWindow( $location );
304 + }
336 305
337 - // Add comment here.
338 - if (
339 - ( ! $template->openSuccessPageInIframe && 0 === strpos($location, FormUtils::getSuccessPageURL())) ||
340 - ( ! $template->openFailedPageInIframe && 0 === strpos($location, FormUtils::getLegacyFailedPageURL()))
341 - ) {
342 - $this->openLinkInWindow($location);
343 - }
306 + return $location;
307 + }
344 308
345 - return $location;
346 - }
309 + if ( FormUtils::isIframeParentFailedPageURL( $location ) ) {
310 + $location = add_query_arg( [ 'showFailedDonationError' => 1 ], $template->getFailedPageURL( FrontendFormTemplateUtils::getFormId() ) );
311 + $location = Utils::removeDonationAction( $location );
347 312
348 - $this->openLinkInWindow($location);
349 - }
313 + // Open link in window?
314 + if ( ! $template->openFailedPageInIframe ) {
315 + $this->openLinkInWindow( FormUtils::getLegacyFailedPageURL() );
316 + }
350 317
351 - /**
352 - * Handle link opening in window instead of iframe.
353 - *
354 - * @since 2.7.0
355 - *
356 - * @param string $location
357 - */
358 - private function openLinkInWindow($location)
359 - {
360 - include GIVE_PLUGIN_DIR . 'src/Views/Form/defaultRedirectHandlerTemplate.php';
361 - exit();
362 - }
318 + return $location;
319 + }
363 320
364 - /**
365 - * Handle single donation form page.
366 - *
367 - * @since 2.7.0
368 - */
369 - public function handleSingleDonationFormPage()
370 - {
371 - // Exit if current form is legacy
372 - if (FormUtils::isLegacyForm()) {
373 - return;
374 - }
321 + // Add comment here.
322 + if (
323 + ( ! $template->openSuccessPageInIframe && 0 === strpos( $location, FormUtils::getSuccessPageURL() ) ) ||
324 + ( ! $template->openFailedPageInIframe && 0 === strpos( $location, FormUtils::getLegacyFailedPageURL() ) )
325 + ) {
326 + $this->openLinkInWindow( $location );
327 + }
375 328
376 - // Disable sidebar.
377 - add_action('give_get_option_form_sidebar', [$this, 'disableLegacyDonationFormSidebar']);
329 + return $location;
330 + }
378 331
379 - // Remove title.
380 - remove_action('give_single_form_summary', 'give_template_single_title', 5);
332 + $this->openLinkInWindow( $location );
333 + }
381 334
382 - // Remove donation form renderer.
383 - remove_action('give_single_form_summary', 'give_get_donation_form', 10);
384 335
385 - add_action('give_single_form_summary', [$this, 'renderFormOnSingleDonationFormPage'], 10);
386 - }
336 + /**
337 + * Handle link opening in window instead of iframe.
338 + *
339 + * @since 2.7.0
340 + * @param string $location
341 + */
342 + private function openLinkInWindow( $location ) {
343 + include GIVE_PLUGIN_DIR . 'src/Views/Form/defaultRedirectHandlerTemplate.php';
344 + exit();
345 + }
387 346
388 - /**
389 - * Return 'disabled' as donation form sidebar status.
390 - *
391 - * @since 2.7.0
392 - * @return string
393 - */
394 - public function disableLegacyDonationFormSidebar()
395 - {
396 - return 'disabled';
397 - }
347 + /**
348 + * Handle single donation form page.
349 + *
350 + * @since 2.7.0
351 + */
352 + public function handleSingleDonationFormPage() {
353 + // Exit if current form is legacy
354 + if ( FormUtils::isLegacyForm() ) {
355 + return;
356 + }
398 357
399 - /**
400 - * This function handle donation form style for single donation page.
401 - *
402 - * Note: it will render style on basis on selected form template.
403 - *
404 - * @since 2.7.0
405 - */
406 - public function renderFormOnSingleDonationFormPage()
407 - {
408 - echo give_form_shortcode([]);
409 - }
358 + // Disable sidebar.
359 + add_action( 'give_get_option_form_sidebar', [ $this, 'disableLegacyDonationFormSidebar' ] );
360 +
361 + // Remove title.
362 + remove_action( 'give_single_form_summary', 'give_template_single_title', 5 );
363 +
364 + // Remove donation form renderer.
365 + remove_action( 'give_single_form_summary', 'give_get_donation_form', 10 );
366 +
367 + add_action( 'give_single_form_summary', [ $this, 'renderFormOnSingleDonationFormPage' ], 10 );
368 + }
369 +
370 + /**
371 + * Return 'disabled' as donation form sidebar status.
372 + *
373 + * @since 2.7.0
374 + * @return string
375 + */
376 + public function disableLegacyDonationFormSidebar() {
377 + return 'disabled';
378 + }
379 +
380 +
381 + /**
382 + * This function handle donation form style for single donation page.
383 + *
384 + * Note: it will render style on basis on selected form template.
385 + *
386 + * @since 2.7.0
387 + */
388 + public function renderFormOnSingleDonationFormPage() {
389 + echo give_form_shortcode( [] );
390 + }
410 391 }