From c02eabdedeb07f3f0ee4db8bb059881256029a68 Mon Sep 17 00:00:00 2001 From: Micah Wood Date: Thu, 4 May 2023 11:11:10 -0400 Subject: [PATCH] Add PayPal SDK Attribution --- bootstrap.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bootstrap.php b/bootstrap.php index 171729e0..739fd4f8 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -53,5 +53,22 @@ function ( $parsed_args, $url ) { 10, 2 ); + + add_filter( + 'script_loader_tag', + function ( $tag, $handle, $source ) { + if ( stripos( $source, 'paypal.com/sdk' ) !== false ) { + $replacement = ' data-partner-attribution-id="Yith_PCP"'; + if ( stripos( $tag, 'partner-attribution-id' ) === false ) { + $tag = str_replace( ' src=', $replacement . ' src=', $tag ); + } else if ( stripos( $tag, 'NEWFOLD' ) || stripos( $tag, 'YITH' ) ) { + $tag = preg_replace( '/ data-partner-attribution-id="(.*?)"/', $replacement, $tag ); + } + } + return $tag; + }, + 25, + 3 + ); }