New Year Offer - Ends Jan 31 - 20% OFF - Unlock Deal

wsf_footer_script_attributes

Description

The wsf_footer_script_attributes filter hook allows you to add additional script attributes to the WS Form footer script. This can be helpful for adding security-related attributes, such as a Content Security Policy (CSP) nonce, or for including custom data attributes used by other plugins or integrations.

Usage

add_filter( 'wsf_footer_script_attributes', 'my_hook_function', 10, 1 );

Parameters

  1. $attributes String
    An array of key value pair attributes.
    Default value: ['id' => 'ws-form-footer-inline-js', 'type' => 'text/javascript']

Example

// Callback function for the wsf_footer_script_attributes filter hook
function my_hook_function( $attributes ) {

    // Example: Add a CSP nonce for inline script security
    // No need to escape here — WS Form handles attribute escaping internally
    if ( isset( $GLOBALS['csp_nonce'] ) ) {
        $attributes['nonce'] = $GLOBALS['csp_nonce'];
    }

    // Return value
    return $attributes;
}

// Add a callback function for the wsf_footer_script_attributes filter hook
add_filter( 'wsf_footer_script_attributes', 'my_hook_function', 10, 1 );

Source File

This hook can be found in: <plugin root>/public/class-ws-form-public.php