PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 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 All 257 releases
give / src / DonationForms / Actions / GenerateDonationFormPageUrl.php

GenerateDonationFormPageUrl.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at src/DonationForms/Actions/GenerateDonationFormPageUrl.php

33 lines 805 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationForms\Actions;
4
5 /**
6 * The URL of a donation form's own page: the give_forms single, addressed by
7 * post type and id so it resolves under every permalink setting. WordPress
8 * redirects it to the pretty permalink.
9 *
10 * Used by the block's new-tab launcher and shipped to the external embed
11 * script, which appends the form id itself.
12 *
13 * @since 4.17.0
14 */
15 class GenerateDonationFormPageUrl
16 {
17 /**
18 * @since 4.17.0
19 *
20 * @param int|null $formId Omit for the base URL without a form id.
21 */
22 public function __invoke(?int $formId = null): string
23 {
24 $args = ['post_type' => 'give_forms'];
25
26 if ($formId !== null) {
27 $args['p'] = $formId;
28 }
29
30 return esc_url_raw(add_query_arg($args, home_url('/')));
31 }
32 }
33