From 1d0387c38c25f40894225061712fe8c2ed41e74c Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 2 Dec 2024 12:07:51 +0800 Subject: [PATCH] Remove JS `convertStoreSubscriberIDInCookie` function --- resources/frontend/js/convertkit.js | 73 +---------------------------- 1 file changed, 2 insertions(+), 71 deletions(-) diff --git a/resources/frontend/js/convertkit.js b/resources/frontend/js/convertkit.js index 58c71475..42f62072 100644 --- a/resources/frontend/js/convertkit.js +++ b/resources/frontend/js/convertkit.js @@ -7,72 +7,6 @@ * @author ConvertKit */ -/** - * Gets the subscriber ID for the given email address, storing - * it in the `ck_subscriber_id` cookie if it exists. - * - * Typically called when the user completes a ConvertKit Form - * that has either "Auto-confirm new subscribers" or - * "Send subscriber to thank you page" enabled (both scenarios - * include a ck_subscriber_id). - * - * @since 1.9.6 - * - * @param int id Subscriber ID - */ -function convertStoreSubscriberIDInCookie( subscriber_id ) { - - if ( convertkit.debug ) { - console.log( 'convertStoreSubscriberIDInCookie' ); - console.log( subscriber_id ); - } - - fetch( - convertkit.ajaxurl, - { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - body: new URLSearchParams( - { - action: 'convertkit_store_subscriber_id_in_cookie', - convertkit_nonce: convertkit.nonce, - subscriber_id: subscriber_id - } - ) - } - ) - .then( - function ( response ) { - if ( convertkit.debug ) { - console.log( response ); - } - - return response.json(); - } - ) - .then( - function ( result ) { - if ( convertkit.debug ) { - console.log( result ); - } - - convertKitRemoveSubscriberIDFromURL( window.location.href ); - } - ) - .catch( - function ( error ) { - if ( convertkit.debug ) { - console.error( error ); - } - - convertKitRemoveSubscriberIDFromURL( window.location.href ); - } - ); - -} - /** * Gets the subscriber ID for the given email address, storing * it in the `ck_subscriber_id` cookie if it exists. @@ -217,11 +151,8 @@ document.addEventListener( 'DOMContentLoaded', function () { - if ( convertkit.subscriber_id > 0 ) { - // If the user can be detected as a ConvertKit Subscriber (i.e. their Subscriber ID is in a cookie or the URL), - // update the cookie now. - convertStoreSubscriberIDInCookie( convertkit.subscriber_id ); - } + // Removes `ck_subscriber_id` from the URI. + convertKitRemoveSubscriberIDFromURL( window.location.href ); // Store subscriber ID as a cookie from the email address used when a ConvertKit Form is submitted. document.addEventListener(