You appear to be a bot. Output may be restricted
Description
Adds data attributes to the PayPal JS SDK <script> tag.
Usage
$string = add_data_attributes( $script_tag, $handle, $src );
Parameters
- $script_tag
- ( string ) required – HTML <script> tag.
- $handle
- ( string ) required – Registered handle.
- $src
- ( string ) required – Script SRC value.
Returns
string
Source
File name: easy-digital-downloads/includes/gateways/paypal/scripts.php
Lines:
1 to 26 of 26
function add_data_attributes( $script_tag, $handle, $src ) { if ( 'sandhills-paypal-js-sdk' !== $handle ) { return $script_tag; } /** * Filters the data attributes to add to the <script> tag. * * @since 2.11 * * @param array $data_attributes */ $data_attributes = apply_filters( 'edd_paypal_js_sdk_data_attributes', array( 'partner-attribution-id' => EDD_PAYPAL_PARTNER_ATTRIBUTION_ID ) ); if ( empty( $data_attributes ) || ! is_array( $data_attributes ) ) { return $script_tag; } $formatted_attributes = array_map( function ( $key, $value ) { return sprintf( 'data-%s="%s"', sanitize_html_class( $key ), esc_attr( $value ) ); }, array_keys( $data_attributes ), $data_attributes ); return str_replace( ' src', ' ' . implode( ' ', $formatted_attributes ) . ' src', $script_tag ); }