# give/4.18.0/src/DonationForms/Actions/GenerateDonationFormPageUrl.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.18.0. 33 lines.

- Page: https://pluginprobe.com/plugins/give/4.18.0/code/src/DonationForms/Actions/GenerateDonationFormPageUrl.php
- Raw: https://pluginprobe.com/plugins/give/4.18.0/raw/src/DonationForms/Actions/GenerateDonationFormPageUrl.php
- Modified: 2026-09-23T17:56:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.18.0/code/src/DonationForms/Actions/GenerateDonationFormPageUrl.php#L10-L20`.

```php
<?php

namespace Give\DonationForms\Actions;

/**
 * The URL of a donation form's own page: the give_forms single, addressed by
 * post type and id so it resolves under every permalink setting. WordPress
 * redirects it to the pretty permalink.
 *
 * Used by the block's new-tab launcher and shipped to the external embed
 * script, which appends the form id itself.
 *
 * @since 4.17.0
 */
class GenerateDonationFormPageUrl
{
    /**
     * @since 4.17.0
     *
     * @param int|null $formId Omit for the base URL without a form id.
     */
    public function __invoke(?int $formId = null): string
    {
        $args = ['post_type' => 'give_forms'];

        if ($formId !== null) {
            $args['p'] = $formId;
        }

        return esc_url_raw(add_query_arg($args, home_url('/')));
    }
}

```
