# give/4.17.0/src/DonationForms/Actions/GenerateExternalEmbedScriptUrl.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.17.0. 34 lines.

- Page: https://pluginprobe.com/plugins/give/4.17.0/code/src/DonationForms/Actions/GenerateExternalEmbedScriptUrl.php
- Raw: https://pluginprobe.com/plugins/give/4.17.0/raw/src/DonationForms/Actions/GenerateExternalEmbedScriptUrl.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.17.0/code/src/DonationForms/Actions/GenerateExternalEmbedScriptUrl.php#L10-L20`.

```php
<?php

namespace Give\DonationForms\Actions;

use Give\Framework\Routes\Route;

/**
 * The URL third-party sites load the external embed script from.
 *
 * @since 4.17.0
 */
class GenerateExternalEmbedScriptUrl
{
    /**
     * Path below the router's script base. Snippets pasted on other sites
     * carry this, so it must not change.
     *
     * @since 4.17.0
     */
    public const URI = 'embed/donation-form/script.js';

    /**
     * With a form id the URL names the form (`?form-id=42`), and the script response carries
     * that form's skeleton so the embed can draw it before the form page answers. Without one the
     * script is site-level and the embed shows a spinner until the form page's own skeleton.
     *
     * @since 4.17.0
     */
    public function __invoke(int $formId = 0): string
    {
        return Route::scriptUrl(self::URI, $formId > 0 ? ['form-id' => $formId] : []);
    }
}

```
