<?php
  if (! defined("\x41\x42\x53\x50\x41\x54\x48")) exit;  function unipixel_get_events_for_platform($platform_id) { global $wpdb; $events_table = $wpdb->prefix . "\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x65\x76\x65\x6E\x74\x73\x5F\x73\x65\x74\x74\x69\x6E\x67\x73";   $query = $wpdb->prepare( "SELECT * FROM %i WHERE platform_id = %d", $events_table, $platform_id );  $events = $wpdb->get_results($query, ARRAY_A); return $events; } function unipixel_get_platform_settings($platform_id) { global $wpdb; $table_name = $wpdb->prefix . "\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x70\x6C\x61\x74\x66\x6F\x72\x6D\x5F\x73\x65\x74\x74\x69\x6E\x67\x73";  $query = $wpdb->prepare( "SELECT * FROM %i WHERE id = %d", $table_name, $platform_id );  $row = $wpdb->get_row($query);  return $row ?: new stdClass();  }  function unipixel_get_event_settings($platform_id, $event_name) { global $wpdb; $table = $wpdb->prefix . "\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x65\x76\x65\x6E\x74\x73\x5F\x73\x65\x74\x74\x69\x6E\x67\x73"; $query = $wpdb->prepare(  "SELECT * FROM %i WHERE platform_id = %d AND event_name = %s LIMIT 1", $table, $platform_id, $event_name );  $row = $wpdb->get_row($query);  return $row ?: new stdClass();  } function unipixel_build_client_result_mock($consentBlocked = false, $params = [], $platformId = 1, $event_name = '') { $code = $consentBlocked ? 1 : 0; $log_payload = unipixel_construct_client_side_send_log($platformId, $event_name, $params); return [ 'response' => [ 'response' => [ 'code' => $code, 'message' => $consentBlocked ? "\x45\x76\x65\x6E\x74\x20\x62\x6C\x6F\x63\x6B\x65\x64\x3A\x20\x43\x6F\x6E\x73\x65\x6E\x74\x20\x6E\x6F\x74\x20\x70\x72\x6F\x76\x69\x64\x65\x64" : "\x43\x6C\x69\x65\x6E\x74\x2D\x73\x69\x64\x65\x20\x6F\x6E\x6C\x79\x20\xE2\x80\x93\x20\x6E\x6F\x20\x73\x65\x72\x76\x65\x72\x20\x72\x65\x73\x70\x6F\x6E\x73\x65", ] ], 'args' => $log_payload ]; } function unipixel_get_help_icon($key) { $help_texts = [ "Meta_Enabled" => [ "title" => "\x54\x75\x72\x6E\x69\x6E\x67\x20\x4F\x6E\x20\x4D\x65\x74\x61\x20\x54\x72\x61\x63\x6B\x69\x6E\x67", "content" => "When set to off, Unipixel won't include Meta Pixel and won't send any events for this platform." ], "Meta_Include" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x53\x65\x74\x74\x69\x6E\x67", "content" => "\x54\x68\x69\x73\x20\x77\x69\x6C\x6C\x20\x61\x64\x64\x20\x4D\x65\x74\x61\x27\x73\x20\x74\x72\x61\x63\x6B\x69\x6E\x67\x20\x70\x69\x78\x65\x6C\x20\x74\x6F\x20\x79\x6F\x75\x72\x20\x73\x69\x74\x65\x2C\x20\x61\x6E\x64\x20\x79\x6F\x75\x20\x6A\x75\x73\x74\x20\x6E\x65\x65\x64\x20\x74\x6F\x20\x61\x64\x64\x20\x50\x69\x78\x65\x6C\x20\x49\x44\x20\x62\x65\x6C\x6F\x77\x2E\x20\x54\x68\x69\x73\x20\x61\x6C\x6C\x6F\x77\x73\x20\x74\x68\x65\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x6F\x66\x20\x73\x74\x61\x6E\x64\x61\x72\x64\x20\x6D\x65\x74\x61\x20\x74\x72\x61\x63\x6B\x69\x6E\x67\x20\x65\x76\x65\x6E\x74\x73\x20\x6C\x69\x6B\x65\x20\x70\x61\x67\x65\x20\x76\x69\x65\x77\x2C\x20\x61\x6E\x64\x20\x61\x6E\x79\x20\x65\x63\x6F\x6D\x6D\x65\x72\x63\x65\x20\x6F\x72\x20\x63\x75\x73\x74\x6F\x6D\x20\x65\x76\x65\x6E\x74\x73\x20\x79\x6F\x75\x20\x68\x61\x76\x65\x20\x73\x65\x74\x75\x70\x20\x62\x65\x6C\x6F\x77\x2E" ], "Meta_Already" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x53\x65\x74\x74\x69\x6E\x67", "content" => "\x49\x66\x20\x79\x6F\x75\x27\x76\x65\x20\x61\x6C\x72\x65\x61\x64\x79\x20\x61\x64\x64\x65\x64\x20\x61\x20\x4D\x65\x74\x61\x20\x50\x69\x78\x65\x6C\x20\x74\x6F\x20\x79\x6F\x75\x72\x20\x73\x69\x74\x65\x2C\x20\x55\x6E\x69\x50\x69\x78\x65\x6C\x20\x63\x61\x6E\x20\x70\x69\x67\x67\x79\x2D\x62\x61\x63\x6B\x20\x6F\x66\x66\x20\x74\x68\x69\x73\x2C\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x61\x64\x64\x69\x74\x6F\x6E\x20\x65\x76\x65\x6E\x74\x73\x20\x79\x6F\x75\x20\x68\x61\x76\x65\x20\x73\x65\x74\x75\x70\x20\x62\x65\x6C\x6F\x77\x2E" ], "Meta_PixelId" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x49\x44", "content" => "Your unique identifier for your Meta Pixel. Found in Meta Events Manager under your Pixel settings.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-meta/' target='_blank'>See the full Meta setup guide</a>" ], "Meta_AccessToken" => [ "title" => "\x41\x63\x63\x65\x73\x73\x20\x54\x6F\x6B\x65\x6E", "content" => "Used for Conversions API / Server side tracking. <br/>
                    1. Go to <b>Business Settings</b> in <b>Facebook Business Manager</b>.<br/>
                    2. Navigate to System Users and click <b>Add System User</b>.<br/>
                    3. Assign Admin permissions and select your <b>Business Account</b>.<br/>
                    4. In the <b>Permissions</b> tab, ensure access to <b>Manage Ads</b>.<br/>
                    5. Click <b>Generate Access Token</b>.<br/>
                    6. Copy and save the token securely.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-meta/' target='_blank'>See the full Meta setup guide</a>" ], "Meta_PageView_ClientSideTurnOn" => [ "title" => "\x50\x61\x67\x65\x56\x69\x65\x77\x20\x43\x6C\x69\x65\x6E\x74\x2D\x73\x69\x64\x65\x20\x65\x76\x65\x6E\x74", "content" => "\x50\x61\x67\x65\x56\x69\x65\x77\x20\x65\x76\x65\x6E\x74\x20\x69\x6E\x66\x6F\x72\x6D\x61\x74\x69\x6F\x6E\x20\x69\x73\x20\x61\x75\x74\x6F\x6D\x61\x74\x69\x63\x61\x6C\x6C\x79\x20\x73\x65\x6E\x74\x20\x76\x69\x61\x20\x61\x20\x63\x6C\x69\x65\x6E\x74\x2D\x73\x69\x64\x65\x20\x63\x61\x6C\x6C\x20\x74\x6F\x20\x4D\x65\x74\x61\x20\x75\x73\x69\x6E\x67\x20\x74\x68\x65\x20\x6E\x61\x74\x69\x76\x65\x20\x74\x72\x61\x63\x6B\x69\x6E\x67\x20\x73\x63\x72\x69\x70\x74\x20\x69\x6E\x63\x6C\x75\x64\x65\x64\x20\x77\x68\x65\x6E\x20\x79\x6F\x75\x20\x65\x6E\x61\x62\x6C\x65\x20\x4D\x65\x74\x61\x2E" ], "Meta_PageView_ServerSideTurnOn" => [ "title" => "\x50\x61\x67\x65\x56\x69\x65\x77\x20\x53\x65\x72\x76\x65\x72\x2D\x73\x69\x64\x65\x20\x65\x76\x65\x6E\x74", "content" => "Optionally on each page load, you can send the PageView event information to facebook via a <b>Server-side</b> call too." ], "TikTok_PageView_ClientSideTurnOn" => [ "title" => "\x54\x69\x6B\x54\x6F\x6B\x20\x50\x61\x67\x65\x56\x69\x65\x77\x20\x43\x6C\x69\x65\x6E\x74\x2D\x73\x69\x64\x65\x20\x65\x76\x65\x6E\x74", "content" => "\x50\x61\x67\x65\x56\x69\x65\x77\x20\x65\x76\x65\x6E\x74\x20\x69\x73\x20\x6E\x6F\x20\x6C\x6F\x6E\x67\x65\x72\x20\x61\x20\x73\x74\x61\x6E\x64\x61\x72\x64\x20\x65\x76\x65\x6E\x74\x20\x61\x74\x20\x54\x69\x6B\x54\x6F\x6B\x2C\x20\x68\x6F\x77\x65\x76\x65\x72\x2C\x20\x79\x6F\x75\x20\x63\x61\x6E\x20\x74\x75\x72\x6E\x20\x69\x74\x20\x6F\x6E\x20\x69\x66\x20\x79\x6F\x75\x20\x77\x61\x6E\x74\x20\x74\x6F\x20\x74\x72\x61\x63\x6B\x20\x69\x74\x20\x61\x73\x20\x61\x20\x63\x75\x73\x74\x6F\x6D\x20\x65\x76\x65\x6D\x74\x2E\x20\x54\x68\x69\x73\x20\x6F\x70\x74\x69\x6F\x6E\x20\x61\x6C\x6C\x6F\x77\x73\x20\x69\x74\x20\x74\x6F\x20\x62\x65\x20\x73\x65\x6E\x74\x20\x76\x69\x61\x20\x61\x20\x63\x6C\x69\x65\x6E\x74\x2D\x73\x69\x64\x65\x20\x63\x61\x6C\x6C\x20\x74\x6F\x20\x75\x73\x69\x6E\x67\x20\x74\x68\x65\x20\x6E\x61\x74\x69\x76\x65\x20\x74\x72\x61\x63\x6B\x69\x6E\x67\x20\x73\x63\x72\x69\x70\x74\x20\x69\x6E\x63\x6C\x75\x64\x65\x64\x20\x77\x68\x65\x6E\x20\x79\x6F\x75\x20\x65\x6E\x61\x62\x6C\x65\x20\x54\x69\x6B\x54\x6F\x6B\x2E" ], "TikTok_PageView_ServerSideTurnOn" => [ "title" => "\x54\x69\x6B\x54\x6F\x6B\x20\x50\x61\x67\x65\x56\x69\x65\x77\x20\x53\x65\x72\x76\x65\x72\x2D\x73\x69\x64\x65\x20\x65\x76\x65\x6E\x74", "content" => "Optionally on each page load, you can send the PageView event (as a custom event) to TikTok via a <b>Server-side</b>, first-party call too." ], "Google_Enabled" => [ "title" => "\x54\x75\x72\x6E\x69\x6E\x67\x20\x4F\x6E\x20\x47\x6F\x6F\x67\x6C\x65\x20\x54\x72\x61\x63\x6B\x69\x6E\x67", "content" => "When set to off, Unipixel sends no events." ], "Google_Include" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x53\x65\x74\x74\x69\x6E\x67", "content" => "\x46\x75\x6C\x6C\x20\x74\x72\x61\x63\x6B\x69\x6E\x67\x3A\x20\x69\x6E\x63\x6C\x75\x64\x65\x73\x20\x74\x68\x65\x20\x47\x6F\x6F\x67\x6C\x65\x20\x67\x74\x61\x67\x20\x73\x63\x72\x69\x70\x74\x20\x77\x68\x69\x63\x68\x20\x73\x65\x6E\x64\x73\x20\x73\x74\x61\x6E\x64\x61\x72\x64\x20\x65\x76\x65\x6E\x74\x73\x2C\x20\x6F\x6E\x6C\x79\x20\x73\x65\x6E\x64\x73\x20\x74\x68\x65\x20\x63\x75\x73\x74\x6F\x6D\x20\x65\x76\x65\x6E\x74\x73\x20\x79\x6F\x75\x20\x68\x61\x76\x65\x20\x61\x64\x64\x65\x64\x20\x68\x65\x72\x65\x2E" ], "Google_Already" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x53\x65\x74\x74\x69\x6E\x67", "content" => "\x41\x73\x73\x75\x6D\x65\x73\x20\x74\x68\x65\x20\x67\x74\x61\x67\x20\x73\x63\x72\x69\x70\x74\x20\x69\x73\x20\x61\x6C\x72\x65\x61\x64\x79\x20\x70\x72\x65\x73\x65\x6E\x74\x2C\x20\x6F\x6E\x6C\x79\x20\x73\x65\x6E\x64\x73\x20\x74\x68\x65\x20\x63\x75\x73\x74\x6F\x6D\x20\x65\x76\x65\x6E\x74\x73\x20\x79\x6F\x75\x20\x68\x61\x76\x65\x20\x61\x64\x64\x65\x64\x20\x68\x65\x72\x65\x2E" ], "Google_Gtm" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x53\x65\x74\x74\x69\x6E\x67", "content" => "This setting assumes the gtag script is already present on your site but included via Google Tag Manager (GTM). In that case we also need the GTM Container ID. Unipixel send the events you have setup in this plugin, and the other events you may have setup in GTM continue to be fired through GTM. 
                <br/><br/>It is important to <a href='https://unipixelhq.com/unipixel-docs/using-unipixel-with-google-tag-manager-gtm/' target='_blank'>read the docs here</a> to setup your GTM tags and triggers correctly.
                <br/><br/><b>Note:</b> if using this option, you need to <b>set GTM's send_page_view setting to 'false'</b> in your Google tag configuration, to void doubling up this event - UniPixel already takes care of the page_view event, including consent checks, and logging. To do this, do the following:
                <br/><br/><b>1.</b> In Google Tag Manager, go to the Tags list and edit your GA4 Configuration Tag.
                <br/><b>2.</b> Edit the tag, and in configuration settings set the send_page_view parameter to 'false', or uncheck the option relating to this to prevent the page_view event running at GTM too when this configuration loads.
                <br/><b>3.</b> Save, then Submit & Publish your container." ], "Google_MeasurementId" => [ "title" => "\x4D\x65\x61\x73\x75\x72\x65\x6D\x65\x6E\x74\x20\x49\x44", "content" => "This ID specifies your unique Google Analytics setup, ensuring data is sent to the correct property. It can be found in Google Analytics > Admin > Data Streams, under 'Measurement ID' (formatted as G-XXXXXXXXXX).<br/><br/><a href='https://unipixelhq.com/unipixel-docs/getting-ready-for-unipixel-what-you-need-from-google/' target='_blank'>See the full Google setup guide</a>" ], "Google_ContainerId" => [ "title" => "\x54\x61\x67\x20\x4D\x61\x6E\x61\x67\x65\x72\x20\x43\x6F\x6E\x74\x61\x69\x6E\x65\x72\x20\x49\x64", "content" => "This ID identifies your specific Google Tag Manager container, which holds all your tracking tags, triggers, and variables. It can be found in Google Tag Manager > Admin > Container Settings, typically formatted as GTM-XXXXXXX. You'll need this in addition to your Measurement ID if your gtag is loaded via Google Tag Manager.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/using-unipixel-with-google-tag-manager-gtm/' target='_blank'>See the GTM setup guide</a>" ], "Google_ApiSecret" => [ "title" => "\x41\x50\x49\x20\x53\x65\x63\x72\x65\x74", "content" => "Used for Google Server side tracking. <br/>
                    1. Go to <b>Google Analytics Admin</b>.<br/>
                    2. Under <b>Data Streams</b>, select your website stream.<br/>
                    3. Scroll down to <b>Measurement Protocol API Secret</b>.<br/>
                    4. Click <b>Create</b>, name it (e.g., 'Server-Side Tracking'), and copy the API Secret.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/getting-ready-for-unipixel-what-you-need-from-google/' target='_blank'>See the full Google setup guide</a>" ], "SendClientSide" => [ "title" => "\x53\x65\x6E\x64\x20\x63\x6C\x69\x65\x6E\x74\x2D\x73\x69\x64\x65", "content" => "This option sends the event through the platform's own tracking script that runs directly in the visitor's browser. Because the data is sent from the user's browser to the platform's domain (e.g., facebook.com or google-analytics.com), it is categorized as <b>Third Party</b> tracking.  
            <br/><br/>
            In contrast, <b>First Party</b> tracking -- like UniPixel's Server-side method -- sends the event from your own website's server to the platform's API. This means the data originates from your domain and can preserve more stable tracking even when browsers limit third-party cookies." ], "SendServerSide" => [ "title" => "\x53\x65\x6E\x64\x20\x73\x65\x72\x76\x65\x72\x2D\x73\x69\x64\x65", "content" => "This option sends the event from your website's server to the platform's API, rather than from the user's browser. Because the data originates from your domain, it is categorized as <b>First Party</b> tracking.
            <br/><br/>
            In contrast, <b>Third Party</b> tracking -- the client-side method -- sends the event from the browser directly to the platform's domain. Server-side can be more resilient to ad blockers and third-party cookie limits, and it can run alongside client-side with deduplication if desired." ], "Google_SendClientSide" => [ "title" => "\x53\x65\x6E\x64\x20\x63\x6C\x69\x65\x6E\x74\x2D\x73\x69\x64\x65", "content" => "This option sends the event through the Google's own tracking script that runs directly in the visitor's browser. Because the data is sent from the user's browser to the platform's domain (e.g., facebook.com or google-analytics.com), it is categorized as <b>Third Party</b> tracking.  
            <br/><br/>
            In contrast, <b>First Party</b> tracking -- like UniPixel's Server-side method -- sends the event from your own website's server to the platform's API. This means the data originates from your domain and can preserve more stable tracking even when browsers limit third-party cookies.
            <br/><br/>
            Note: Google does not deduplicate (except for 'purchase') so this UI restricts you from having both client and server on for most events." ], "Google_SendServerSide" => [ "title" => "\x53\x65\x6E\x64\x20\x73\x65\x72\x76\x65\x72\x2D\x73\x69\x64\x65", "content" => "This option sends the event from your website's server to the platform's API, rather than from the user's browser. Because the data originates from your domain, it is categorized as <b>First Party</b> tracking.
            <br/><br/>
            In contrast, <b>Third Party</b> tracking -- the client-side method -- sends the event from the browser directly to the platform's domain. Server-side can be more resilient to ad blockers and third-party cookie limits.
            <br/><br/>
            Note: Google does not deduplicate (except for 'purchase') so this UI restricts you from having both client and server on for most events." ], "LogServerSideResponse" => [ "title" => "\x4C\x6F\x67\x20\x53\x65\x72\x76\x65\x72\x2D\x73\x69\x64\x65\x20\x52\x65\x73\x70\x6F\x6E\x73\x65", "content" => "When sending events to a platform, for the Server-side event, you have the option of getting a response from the platform. This is useful for confirming that a Server-side version of the event was sent and received. For common events, like page view or product views, you may consider turning response logging off or using it temporarily for testing purposes. When turned off, UniPixel by-passes waiting for any response resulting in no delay in page load performance." ], "TikTok_Enabled" => [ "title" => "\x54\x75\x72\x6E\x69\x6E\x67\x20\x4F\x6E\x20\x54\x69\x6B\x54\x6F\x6B\x20\x54\x72\x61\x63\x6B\x69\x6E\x67", "content" => "\x57\x68\x65\x6E\x20\x65\x6E\x61\x62\x6C\x65\x64\x2C\x20\x55\x6E\x69\x50\x69\x78\x65\x6C\x20\x6C\x6F\x61\x64\x73\x20\x74\x68\x65\x20\x54\x69\x6B\x54\x6F\x6B\x20\x50\x69\x78\x65\x6C\x20\x73\x63\x72\x69\x70\x74\x20\x61\x6E\x64\x20\x74\x72\x61\x63\x6B\x73\x20\x65\x76\x65\x6E\x74\x73\x20\x63\x6F\x6E\x66\x69\x67\x75\x72\x65\x64\x20\x66\x6F\x72\x20\x74\x68\x69\x73\x20\x70\x6C\x61\x74\x66\x6F\x72\x6D\x2E" ], "TikTok_Include" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x53\x65\x74\x74\x69\x6E\x67", "content" => "This includes TikTok's tracking pixel directly from UniPixel. You just need to provide your Pixel ID below." ], "TikTok_Already" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x53\x65\x74\x74\x69\x6E\x67", "content" => "Select this if you already have TikTok's base pixel installed elsewhere on your site. UniPixel will only handle events." ], "TikTok_PixelId" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x49\x44", "content" => "Your unique TikTok Pixel ID, available in your TikTok Ads Manager under Events > Manage > Pixel Settings.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-tiktok/' target='_blank'>See the full TikTok setup guide</a>" ], "TikTok_AccessToken" => [ "title" => "\x41\x63\x63\x65\x73\x73\x20\x54\x6F\x6B\x65\x6E", "content" => "Used for TikTok Events API / Server side tracking.<br/>
                    1. Go to <b>TikTok Ads Manager</b>.<br/>
                    2. Navigate to <b>Events</b> > <b>Manage</b> and select your Pixel.<br/>
                    3. Under <b>Settings</b>, find <b>Events API</b>.<br/>
                    4. Click <b>Generate Access Token</b>.<br/>
                    5. Copy and save the token securely.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-tiktok/' target='_blank'>See the full TikTok setup guide</a>" ], "Pinterest_Enabled" => [ "title" => "\x54\x75\x72\x6E\x69\x6E\x67\x20\x4F\x6E\x20\x50\x69\x6E\x74\x65\x72\x65\x73\x74\x20\x54\x72\x61\x63\x6B\x69\x6E\x67", "content" => "When enabled, UniPixel loads the Pinterest Tag and tracks events configured for this platform.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-pinterest/' target='_blank'>See the full Pinterest setup guide</a>" ], "Pinterest_Include" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x53\x65\x74\x74\x69\x6E\x67", "content" => "This includes Pinterest's tracking tag directly from UniPixel. You just need to provide your Tag ID below." ], "Pinterest_Already" => [ "title" => "\x50\x69\x78\x65\x6C\x20\x53\x65\x74\x74\x69\x6E\x67", "content" => "Select this if you already have the Pinterest Tag installed elsewhere on your site. UniPixel will only handle event sending." ], "Pinterest_TagId" => [ "title" => "\x50\x69\x6E\x74\x65\x72\x65\x73\x74\x20\x54\x61\x67\x20\x49\x44", "content" => "Your unique Pinterest Tag ID. Found in Pinterest Ads Manager under <b>Conversions</b> > <b>Set Up the Pinterest Tag</b>, or in your Tag settings.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-pinterest/' target='_blank'>See the full Pinterest setup guide</a>" ], "Pinterest_AdAccountId" => [ "title" => "\x41\x64\x20\x41\x63\x63\x6F\x75\x6E\x74\x20\x49\x44", "content" => "Your Pinterest Ad Account ID. Found in Pinterest Ads Manager -- visible in the URL or under <b>Ads</b> > <b>Overview</b> in the account dropdown. Required for server-side Conversions API calls.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-pinterest/' target='_blank'>See the full Pinterest setup guide</a>" ], "Pinterest_AccessToken" => [ "title" => "\x43\x6F\x6E\x76\x65\x72\x73\x69\x6F\x6E\x20\x41\x63\x63\x65\x73\x73\x20\x54\x6F\x6B\x65\x6E", "content" => "Used for Pinterest Conversions API / Server-side tracking.<br/>
                    1. Go to <b>Pinterest Ads Manager</b>.<br/>
                    2. Navigate to <b>Conversions</b> and select your Tag.<br/>
                    3. Under <b>Set Up Conversions API</b>, generate an access token.<br/>
                    4. Copy and save the token securely.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-pinterest/' target='_blank'>See the full Pinterest setup guide</a>" ], "Pinterest_PageView_ClientSideTurnOn" => [ "title" => "\x50\x69\x6E\x74\x65\x72\x65\x73\x74\x20\x50\x61\x67\x65\x56\x69\x65\x77\x20\x43\x6C\x69\x65\x6E\x74\x2D\x73\x69\x64\x65", "content" => "\x50\x61\x67\x65\x56\x69\x65\x77\x20\x65\x76\x65\x6E\x74\x20\x69\x6E\x66\x6F\x72\x6D\x61\x74\x69\x6F\x6E\x20\x69\x73\x20\x61\x75\x74\x6F\x6D\x61\x74\x69\x63\x61\x6C\x6C\x79\x20\x73\x65\x6E\x74\x20\x76\x69\x61\x20\x61\x20\x63\x6C\x69\x65\x6E\x74\x2D\x73\x69\x64\x65\x20\x63\x61\x6C\x6C\x20\x74\x6F\x20\x50\x69\x6E\x74\x65\x72\x65\x73\x74\x20\x75\x73\x69\x6E\x67\x20\x74\x68\x65\x20\x74\x72\x61\x63\x6B\x69\x6E\x67\x20\x74\x61\x67\x20\x69\x6E\x63\x6C\x75\x64\x65\x64\x20\x77\x68\x65\x6E\x20\x79\x6F\x75\x20\x65\x6E\x61\x62\x6C\x65\x20\x50\x69\x6E\x74\x65\x72\x65\x73\x74\x2E" ], "Pinterest_PageView_ServerSideTurnOn" => [ "title" => "\x50\x69\x6E\x74\x65\x72\x65\x73\x74\x20\x50\x61\x67\x65\x56\x69\x65\x77\x20\x53\x65\x72\x76\x65\x72\x2D\x73\x69\x64\x65", "content" => "Optionally on each page load, you can send the PageView event to Pinterest via a <b>Server-side</b>, first-party call too." ], "ServerSideGlobalEnabled" => [ "title" => "Enable Server-Side Tracking", "content" => "Turn this on to send events from your server directly to the platform's API, in addition to (or instead of) the browser pixel. Requires an Access Token. When off, only client-side pixel tracking is active -- no server API calls are made for this platform." ], "Microsoft_Enabled" => [ "title" => "\x54\x75\x72\x6E\x69\x6E\x67\x20\x4F\x6E\x20\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\x20\x54\x72\x61\x63\x6B\x69\x6E\x67", "content" => "When enabled, UniPixel loads the Microsoft UET tag and tracks events configured for this platform. When set to off, no Microsoft events are sent.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-microsoft/' target='_blank'>See the full Microsoft setup guide</a>" ], "Microsoft_PixelId" => [ "title" => "\x55\x45\x54\x20\x54\x61\x67\x20\x49\x44", "content" => "Your unique Microsoft UET Tag ID. Found in Microsoft Advertising under <b>Tools</b> > <b>UET tag</b>. It is the numeric ID shown next to your tag name, also visible in the UET code snippet as the value after <b>ti=</b>.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-microsoft/' target='_blank'>See the full Microsoft setup guide</a>" ], "Microsoft_AccessToken" => [ "title" => "\x43\x41\x50\x49\x20\x41\x63\x63\x65\x73\x73\x20\x54\x6F\x6B\x65\x6E", "content" => "Used for Microsoft Conversions API / Server-side tracking.<br/>
                    1. Go to <b>Microsoft Advertising</b>.<br/>
                    2. Navigate to <b>Tools</b> > <b>UET tag</b> and select your tag.<br/>
                    3. Look for the <b>Conversions API</b> section.<br/>
                    4. Generate or copy your access token.<br/>
                    5. Save the token securely -- treat it like a password.<br/><br/>If you do not see the Conversions API option, your account may need to be opted in. Contact your Microsoft Advertising account manager.<br/><br/><a href='https://unipixelhq.com/unipixel-docs/setting-up-unipixel-with-microsoft/' target='_blank'>See the full Microsoft setup guide</a>" ],         "Consent_PopupStyle" => [ "title" => "\x50\x6F\x70\x75\x70\x20\x73\x74\x79\x6C\x65", "content" => "Controls where the consent popup appears on the page. <b>Centred card</b> is the default and most prominent. <b>Bottom/top bars</b> stretch full-width and are less intrusive. <b>Corner cards</b> are the smallest, sitting in the bottom-left or bottom-right and not covering main content." ], "Consent_ForceChoice" => [ "title" => "\x46\x6F\x72\x63\x65\x20\x63\x68\x6F\x69\x63\x65\x20\x28\x64\x69\x6D\x6D\x65\x64\x20\x62\x61\x63\x6B\x64\x72\x6F\x70\x29", "content" => "When ON, a dimmed backdrop is shown behind the popup and the visitor must click a button (Accept / Adjust / Reject) before they can interact with the rest of the page. When OFF, the popup is non-blocking &mdash; visitors can scroll and click around freely while the popup stays visible. <br><br><b>Either way, no tracking events are sent until the visitor makes a choice</b> &mdash; the difference is purely how aggressively the popup demands attention." ], ]; if (!isset($help_texts[$key])) { return "";  } $title = esc_attr($help_texts[$key]["\x74\x69\x74\x6C\x65"]); $content = esc_attr($help_texts[$key]["\x63\x6F\x6E\x74\x65\x6E\x74"]); return '<i class="fa-solid fa-circle-info" data-bs-custom-class="UniPixelPopover" data-bs-toggle="popover" data-bs-placement="right" data-bs-title="' . $title . "\x22\x20\x64\x61\x74\x61\x2D\x62\x73\x2D\x63\x6F\x6E\x74\x65\x6E\x74\x3D\x22" . $content . '"></i>'; } function unipixel_get_popover_allowlist() { return [ 'span' => ['class' => []], 'i' => [ 'class' => [], 'aria-hidden' => [],  'data-bs-toggle' => [], 'data-bs-placement' => [], 'data-bs-title' => [], 'data-bs-content' => [], 'data-bs-trigger' => [],  ], 'svg' => ['class' => [], 'width' => [], 'height' => [], 'viewBox' => [], 'role' => []], 'path' => ['d' => [], 'fill' => []], 'a' => ['href' => [], 'target' => [], 'rel' => [], 'class' => []], 'code' => [], 'small' => ['class' => []], 'br' => [], 'ul' => ['class' => []], 'li' => [], 'strong' => [], ]; }  function unipixel_get_logging_setting($key) { $defaults = array( 'enableLogging_Admin' => true, 'enableLogging_InitiateEvents' => true, 'enableLogging_SendEvents' => true, ); $options = get_option('unipixel_logging_options', $defaults);  if (! is_array($options)) { $options = $defaults; } return isset($options[$key]) ? (bool) $options[$key] : $defaults[$key]; } function unipixel_should_dbstore_event($eventName) { $settings = unipixel_get_dbstore_event_settings();  $wooCommEvents = [ "\x41\x64\x64\x54\x6F\x43\x61\x72\x74", "\x61\x64\x64\x5F\x74\x6F\x5F\x63\x61\x72\x74", "\x49\x6E\x69\x74\x69\x61\x74\x65\x43\x68\x65\x63\x6B\x6F\x75\x74", "\x62\x65\x67\x69\x6E\x5F\x63\x68\x65\x63\x6B\x6F\x75\x74", "\x50\x75\x72\x63\x68\x61\x73\x65", "\x70\x75\x72\x63\x68\x61\x73\x65", "\x56\x69\x65\x77\x43\x6F\x6E\x74\x65\x6E\x74", "\x76\x69\x65\x77\x5F\x69\x74\x65\x6D" ]; $pageViewEvents = [ 'PageView', 'page_view' ];  if (in_array($eventName, $pageViewEvents, true)) { if (!empty($settings["\x64\x62\x73\x74\x6F\x72\x65\x5F\x70\x61\x67\x65\x76\x69\x65\x77\x5F\x65\x76\x65\x6E\x74\x73"])) { return true; } else { return false; } }  if (in_array($eventName, $wooCommEvents, true)) {  if (!empty($settings["\x64\x62\x73\x74\x6F\x72\x65\x5F\x77\x6F\x6F\x63\x6F\x6D\x6D\x65\x72\x63\x65\x5F\x65\x76\x65\x6E\x74\x73"][$eventName])) { return true;  } else { return false;  } }  if (!empty($settings["\x64\x62\x73\x74\x6F\x72\x65\x5F\x63\x75\x73\x74\x6F\x6D\x5F\x65\x76\x65\x6E\x74\x73"])) { return true; } else { return false; } } function unipixel_get_dbstore_event_settings() { $schema = unipixel_get_dbstore_events_schema(); $saved = get_option('unipixel_dbstore_settings', null); if (!is_array($saved)) { update_option('unipixel_dbstore_settings', $schema); return $schema; } return array_replace_recursive($schema, $saved); } function unipixel_metric_log($action, $platform, $detail = array(), $version = '1.0.0') { $listener_url = 'https://buildio.dev/wp-json/unipixelmetrics/v1/log'; $payload = array(  'site_id' => site_url(), 'plugin_version' => UNIPIXEL_VERSION, 'action' => $action, 'platform' => $platform, 'detail' => wp_json_encode($detail), ); $args = array( 'method' => "\x50\x4F\x53\x54", 'headers' => array('Content-Type' => 'application/json'), 'body' => wp_json_encode($payload), 'timeout' => 0.01, 'blocking' => false, ); wp_remote_post($listener_url, $args); }  function unipixel_get_platform_name($platform_id) { switch ($platform_id) { case 1: return "\x4D\x65\x74\x61"; case 2: return "\x50\x69\x6E\x74\x65\x72\x65\x73\x74"; case 3: return "\x54\x69\x6B\x54\x6F\x6B"; case 4: return "\x47\x6F\x6F\x67\x6C\x65"; case 5: return "\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74"; default: return "\x55\x6E\x6B\x6E\x6F\x77\x6E"; } }  function unipixel_get_fbc_value($eventTimeStampMs_in = null) { if (! empty($_COOKIE["\x5F\x66\x62\x63"])) { return sanitize_text_field($_COOKIE["\x5F\x66\x62\x63"]); }  if (! empty($_COOKIE["\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x66\x62\x63\x6C\x69\x64"])) { $raw_fbclid = sanitize_text_field($_COOKIE["\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x66\x62\x63\x6C\x69\x64"]);  $domainIndex = '1'; if (! empty($_COOKIE["\x5F\x66\x62\x63"])) { $parts = explode("\x2E", sanitize_text_field($_COOKIE["\x5F\x66\x62\x63"])); if (count($parts) >= 3 && in_array($parts[1], ["\x30", "\x31", "\x32"], true)) { $domainIndex = $parts[1]; } }  $tsMs = $eventTimeStampMs_in ? (int) $eventTimeStampMs_in : (int) round(microtime(true) * 1000); return "fb.{$domainIndex}.{$tsMs}.{$raw_fbclid}"; }  return ""; }  function unipixel_get_tt_value() {  if (!empty($_GET["\x74\x74\x63\x6C\x69\x64"])) { $ttclid_raw = sanitize_text_field($_GET["\x74\x74\x63\x6C\x69\x64"]); setcookie( "\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x74\x74\x63\x6C\x69\x64", $ttclid_raw, [ 'expires' => time() + (90 * DAY_IN_SECONDS), 'path' => '/', 'secure' => is_ssl(), 'httponly' => false, 'samesite' => "\x4C\x61\x78", ] ); $_COOKIE["\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x74\x74\x63\x6C\x69\x64"] = $ttclid_raw;  }  $ttp_cookie = ''; if (!empty($_COOKIE["\x5F\x74\x74\x70"])) { $ttp_cookie = sanitize_text_field(urldecode($_COOKIE["\x5F\x74\x74\x70"])); } $ttclid_value = ''; if (!empty($_COOKIE["\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x74\x74\x63\x6C\x69\x64"])) { $ttclid_value = sanitize_text_field($_COOKIE["\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x74\x74\x63\x6C\x69\x64"]); } elseif (!empty($_COOKIE["\x74\x74\x63\x6C\x69\x64"])) { $ttclid_value = sanitize_text_field($_COOKIE["\x74\x74\x63\x6C\x69\x64"]); } elseif (!empty($_GET["\x74\x74\x63\x6C\x69\x64"])) { $ttclid_value = sanitize_text_field($_GET["\x74\x74\x63\x6C\x69\x64"]); }  return [ 'ttp_cookie' => $ttp_cookie, 'ttclid' => $ttclid_value, ]; }  function unipixel_get_gclid_value() {  if (! empty($_COOKIE["\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x67\x63\x6C\x69\x64"])) { return sanitize_text_field(wp_unslash($_COOKIE["\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x67\x63\x6C\x69\x64"])); }  if (! empty($_COOKIE["\x5F\x67\x63\x6C\x5F\x61\x77"])) { $parts = explode("\x2E", sanitize_text_field(wp_unslash($_COOKIE["\x5F\x67\x63\x6C\x5F\x61\x77"]))); if (isset($parts[2])) { return $parts[2]; } } return ""; } function unipixel_normalize_ga_client_id($value) { $value = trim((string)$value); if ($value === "") return ""; if (preg_match('/^\d+\.\d+$/', $value)) return $value;  if (preg_match('/^GA\d+\.\d+\.(\d+\.\d+)$/', $value, $m)) return $m[1];  return "";  } function unipixel_get_msclkid_value() { if (! empty($_COOKIE["\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x6D\x73\x63\x6C\x6B\x69\x64"])) { return sanitize_text_field(wp_unslash($_COOKIE["\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x6D\x73\x63\x6C\x6B\x69\x64"])); } return ""; }  function unipixel_get_current_page_url() {  if (did_action('init') && function_exists("\x68\x6F\x6D\x65\x5F\x75\x72\x6C")) {  $path = add_query_arg(null, null); $url = home_url($path); }  else { $scheme = (is_ssl() || (! empty($_SERVER["\x48\x54\x54\x50\x53"]) && $_SERVER["\x48\x54\x54\x50\x53"] !== "\x6F\x66\x66")) ? 'https://' : 'http://'; $host = $_SERVER["\x48\x54\x54\x50\x5F\x48\x4F\x53\x54"] ?? ""; $uri = $_SERVER["\x52\x45\x51\x55\x45\x53\x54\x5F\x55\x52\x49"] ?? ""; $url = $scheme . $host . $uri; } return esc_url_raw(wp_unslash($url)); }  function unipixel_get_ip_address() {  if (! empty($_SERVER["\x48\x54\x54\x50\x5F\x58\x5F\x46\x4F\x52\x57\x41\x52\x44\x45\x44\x5F\x46\x4F\x52"])) { $parts = explode("\x2C", $_SERVER["\x48\x54\x54\x50\x5F\x58\x5F\x46\x4F\x52\x57\x41\x52\x44\x45\x44\x5F\x46\x4F\x52"]); $first = trim($parts[0]); if (filter_var($first, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return $first; } }  $addr = $_SERVER["\x52\x45\x4D\x4F\x54\x45\x5F\x41\x44\x44\x52"] ?? ""; if (filter_var($addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return $addr; }  if (filter_var($addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { return $addr; } return null; }  function unipixel_get_product_categories($product) {  if ($product instanceof WC_Product_Variation) { $product_id = $product->get_parent_id(); } else { $product_id = $product->get_id(); }  $cats = wp_get_post_terms( $product_id, "\x70\x72\x6F\x64\x75\x63\x74\x5F\x63\x61\x74", ['fields' => "\x6E\x61\x6D\x65\x73"] );  return array_map("\x73\x61\x6E\x69\x74\x69\x7A\x65\x5F\x74\x65\x78\x74\x5F\x66\x69\x65\x6C\x64", (array) $cats); } function unipixel_get_product_variant($product) { if (! $product instanceof WC_Product_Variation) { return ""; }   $attributes = $product->get_attributes(); if (empty($attributes) || ! is_array($attributes)) { return ""; }  $parts = []; foreach ($attributes as $value) { $value = trim($value); if ($value !== "") { $parts[] = sanitize_text_field($value); } } return implode(' / ', $parts); }  function unipixel_denyCrawlerBots(): bool { $userAgent = $_SERVER["\x48\x54\x54\x50\x5F\x55\x53\x45\x52\x5F\x41\x47\x45\x4E\x54"] ?? "";  if ($userAgent === "") { return true; }  $patterns = '/
        bot|
        crawl|
        spider|
        slurp|
        facebookexternalhit|
        pinterest|
        monitor|
        uptime|
        headless|
        feedfetcher|
        googlewebpreview|
        discordbot|
        embedly|
        crawler|
        wget|
        curl|
        python-requests|
        dataminr|
        preview|
        validator
    /ix';  return (bool) preg_match($patterns, $userAgent); } function unipixel_construct_client_side_send_log($platformId, $event_name, $params) { $log_payload = [ 'event_name' => $event_name, ];  $add_if_present = function (&$arr, $key, $value) { if (isset($value) && $value !== "" && $value !== [] && $value !== null) { $arr[$key] = $value; } }; $get_event_value = function ($params) { if (isset($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x76\x61\x6C\x75\x65"])) { return (float)$params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x76\x61\x6C\x75\x65"]; } if (isset($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x69\x63\x65"])) { return (float)$params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x69\x63\x65"]; } return 0.0; }; switch ((int)$platformId) {    case 1: $add_if_present($log_payload, "\x65\x76\x65\x6E\x74\x5F\x69\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x65\x76\x65\x6E\x74\x49\x64"] ?? ""); $add_if_present($log_payload, "\x63\x75\x72\x72\x65\x6E\x63\x79", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x63\x75\x72\x72\x65\x6E\x63\x79"] ?? ""); $add_if_present($log_payload, "\x76\x61\x6C\x75\x65", $get_event_value($params)); $add_if_present($log_payload, "\x63\x6F\x6E\x74\x65\x6E\x74\x5F\x69\x64\x73", [(string)($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x6F\x64\x75\x63\x74\x49\x64"] ?? "")]); $add_if_present($log_payload, "\x63\x6F\x6E\x74\x65\x6E\x74\x5F\x74\x79\x70\x65", "\x70\x72\x6F\x64\x75\x63\x74"); $add_if_present($log_payload, "\x63\x6C\x69\x65\x6E\x74\x5F\x69\x70", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x63\x6C\x69\x65\x6E\x74\x49\x70"] ?? ""); $add_if_present($log_payload, "\x75\x73\x65\x72\x5F\x61\x67\x65\x6E\x74", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x75\x73\x65\x72\x41\x67\x65\x6E\x74"] ?? ""); $add_if_present($log_payload, "\x66\x62\x70", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x66\x62\x70\x43\x6F\x6F\x6B\x69\x65"] ?? ""); $add_if_present($log_payload, "\x66\x62\x63", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x66\x62\x63\x43\x6F\x6F\x6B\x69\x65"] ?? ""); $add_if_present($log_payload, "\x65\x6D\x61\x69\x6C\x5F\x68\x61\x73\x68\x65\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x45\x6D\x61\x69\x6C"] ?? ""); $add_if_present($log_payload, "\x70\x68\x6F\x6E\x65\x5F\x68\x61\x73\x68\x65\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x50\x68\x6F\x6E\x65"] ?? ""); break;    case 4: $add_if_present($log_payload, "\x65\x76\x65\x6E\x74\x5F\x69\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x65\x76\x65\x6E\x74\x49\x64"] ?? ""); $add_if_present($log_payload, "\x63\x75\x72\x72\x65\x6E\x63\x79", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x63\x75\x72\x72\x65\x6E\x63\x79"] ?? ""); $add_if_present($log_payload, "\x76\x61\x6C\x75\x65", $get_event_value($params)); $add_if_present($log_payload, "\x63\x6C\x69\x65\x6E\x74\x5F\x69\x64", $params["\x63\x6C\x69\x65\x6E\x74\x5F\x69\x64"] ?? ""); $add_if_present($log_payload, "\x75\x73\x65\x72\x5F\x61\x67\x65\x6E\x74", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x75\x73\x65\x72\x41\x67\x65\x6E\x74"] ?? ""); $add_if_present($log_payload, "\x67\x63\x6C\x69\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x67\x63\x6C\x69\x64"] ?? ""); if (!empty($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6C\x69\x6E\x65\x49\x74\x65\x6D\x73"]) && is_array($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6C\x69\x6E\x65\x49\x74\x65\x6D\x73"])) { $items = []; foreach ($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6C\x69\x6E\x65\x49\x74\x65\x6D\x73"] as $li) { $items[] = [ 'item_id' => $li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x69\x74\x65\x6D\x49\x64"] ?? "", 'item_name' => $li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x69\x74\x65\x6D\x4E\x61\x6D\x65"] ?? "", 'quantity' => (int)($li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x71\x75\x61\x6E\x74\x69\x74\x79"] ?? 1), 'price' => (float)($li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x69\x63\x65"] ?? 0), ]; } $add_if_present($log_payload, "\x69\x74\x65\x6D\x73", $items); } elseif (!empty($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x6F\x64\x75\x63\x74\x49\x64"])) { $log_payload["\x69\x74\x65\x6D\x73"] = [[ 'item_id' => $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x6F\x64\x75\x63\x74\x49\x64"], 'item_name' => $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x69\x74\x65\x6D\x4E\x61\x6D\x65"] ?? "", 'price' => (float)($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x69\x63\x65"] ?? 0), ]]; } break;    case 3: $add_if_present($log_payload, "\x65\x76\x65\x6E\x74\x5F\x69\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x65\x76\x65\x6E\x74\x49\x64"] ?? ""); $add_if_present($log_payload, "\x63\x75\x72\x72\x65\x6E\x63\x79", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x63\x75\x72\x72\x65\x6E\x63\x79"] ?? ""); $add_if_present($log_payload, "\x76\x61\x6C\x75\x65", $get_event_value($params)); $add_if_present($log_payload, "\x69\x70", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x63\x6C\x69\x65\x6E\x74\x49\x70"] ?? ""); $add_if_present($log_payload, "\x75\x73\x65\x72\x5F\x61\x67\x65\x6E\x74", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x75\x73\x65\x72\x41\x67\x65\x6E\x74"] ?? ""); $add_if_present($log_payload, "\x74\x74\x63\x6C\x69\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x74\x74\x63\x6C\x69\x64"] ?? ($params["\x74\x74\x63\x6C\x69\x64"] ?? "")); $add_if_present($log_payload, "\x74\x74\x70", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x74\x74\x70"] ?? ($params["\x74\x74\x70"] ?? "")); $add_if_present($log_payload, "\x65\x6D\x61\x69\x6C\x5F\x68\x61\x73\x68\x65\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x45\x6D\x61\x69\x6C"] ?? ""); $add_if_present($log_payload, "\x70\x68\x6F\x6E\x65\x5F\x68\x61\x73\x68\x65\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x50\x68\x6F\x6E\x65"] ?? ""); if (!empty($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6C\x69\x6E\x65\x49\x74\x65\x6D\x73"]) && is_array($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6C\x69\x6E\x65\x49\x74\x65\x6D\x73"])) { $contents = []; foreach ($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6C\x69\x6E\x65\x49\x74\x65\x6D\x73"] as $li) { $contents[] = [ 'content_id' => (string)($li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x69\x74\x65\x6D\x49\x64"] ?? ""), 'content_name' => $li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x69\x74\x65\x6D\x4E\x61\x6D\x65"] ?? "", 'content_type' => "\x70\x72\x6F\x64\x75\x63\x74", 'quantity' => (int)($li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x71\x75\x61\x6E\x74\x69\x74\x79"] ?? 1), 'price' => (float)($li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x69\x63\x65"] ?? 0), ]; } $add_if_present($log_payload, "\x63\x6F\x6E\x74\x65\x6E\x74\x73", $contents); } elseif (!empty($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x6F\x64\x75\x63\x74\x49\x64"])) { $log_payload["\x63\x6F\x6E\x74\x65\x6E\x74\x73"] = [[ 'content_id' => (string)$params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x6F\x64\x75\x63\x74\x49\x64"], 'content_name' => $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x69\x74\x65\x6D\x4E\x61\x6D\x65"] ?? "", 'content_type' => "\x70\x72\x6F\x64\x75\x63\x74", 'quantity' => (int)($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x71\x75\x61\x6E\x74\x69\x74\x79"] ?? 1), 'price' => (float)($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x69\x63\x65"] ?? 0), ]]; } break;    case 2: $add_if_present($log_payload, "\x65\x76\x65\x6E\x74\x5F\x69\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x65\x76\x65\x6E\x74\x49\x64"] ?? ""); $add_if_present($log_payload, "\x63\x75\x72\x72\x65\x6E\x63\x79", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x63\x75\x72\x72\x65\x6E\x63\x79"] ?? ""); $add_if_present($log_payload, "\x76\x61\x6C\x75\x65", $get_event_value($params)); break;    case 5: $add_if_present($log_payload, "\x65\x76\x65\x6E\x74\x5F\x69\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x65\x76\x65\x6E\x74\x49\x64"] ?? ""); $add_if_present($log_payload, "\x63\x75\x72\x72\x65\x6E\x63\x79", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x63\x75\x72\x72\x65\x6E\x63\x79"] ?? ""); $add_if_present($log_payload, "\x76\x61\x6C\x75\x65", $get_event_value($params)); $add_if_present($log_payload, "\x63\x6C\x69\x65\x6E\x74\x5F\x69\x70", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x63\x6C\x69\x65\x6E\x74\x49\x70"] ?? ""); $add_if_present($log_payload, "\x75\x73\x65\x72\x5F\x61\x67\x65\x6E\x74", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x75\x73\x65\x72\x41\x67\x65\x6E\x74"] ?? ""); $add_if_present($log_payload, "\x6D\x73\x63\x6C\x6B\x69\x64", $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6D\x73\x63\x6C\x6B\x69\x64"] ?? ""); if (!empty($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6C\x69\x6E\x65\x49\x74\x65\x6D\x73"]) && is_array($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6C\x69\x6E\x65\x49\x74\x65\x6D\x73"])) { $items = []; foreach ($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x6C\x69\x6E\x65\x49\x74\x65\x6D\x73"] as $li) { $items[] = [ 'item_id' => $li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x69\x74\x65\x6D\x49\x64"] ?? "", 'item_name' => $li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x69\x74\x65\x6D\x4E\x61\x6D\x65"] ?? "", 'quantity' => (int)($li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x71\x75\x61\x6E\x74\x69\x74\x79"] ?? 1), 'price' => (float)($li["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x69\x63\x65"] ?? 0), ]; } $add_if_present($log_payload, "\x69\x74\x65\x6D\x73", $items); } elseif (!empty($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x6F\x64\x75\x63\x74\x49\x64"])) { $log_payload["\x69\x74\x65\x6D\x73"] = [[ 'item_id' => $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x6F\x64\x75\x63\x74\x49\x64"], 'item_name' => $params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x69\x74\x65\x6D\x4E\x61\x6D\x65"] ?? "", 'price' => (float)($params["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x70\x72\x69\x63\x65"] ?? 0), ]]; } break;    default: $log_payload = $params; } return $log_payload; } function unipixel_get_user_identifier_for_transient(): string { if (is_user_logged_in()) return (string) get_current_user_id(); $ip = $_SERVER["\x52\x45\x4D\x4F\x54\x45\x5F\x41\x44\x44\x52"] ?? ""; $ua = $_SERVER["\x48\x54\x54\x50\x5F\x55\x53\x45\x52\x5F\x41\x47\x45\x4E\x54"] ?? ""; return md5($ip . $ua); }  function unipixel_normalize_phone_for_hashing($rawPhone, $billingCountry = '', $fallbackCountry = '') { if (empty($rawPhone)) { return ""; }  $cleanPhone = preg_replace('/[^0-9]/', "", $rawPhone);  if (preg_match('/^[1-9][0-9]{8,14}$/', $cleanPhone)) { return $cleanPhone; }  $country = strtoupper($billingCountry ?: $fallbackCountry ?: "\x55\x53");  static $prefixes = [ 'US' => "\x31", 'CA' => "\x31", 'MX' => "\x35\x32", 'BR' => "\x35\x35", 'AR' => "\x35\x34", 'CL' => "\x35\x36", 'CO' => "\x35\x37", 'PE' => "\x35\x31", 'VE' => "\x35\x38", 'GB' => "\x34\x34", 'IE' => "\x33\x35\x33", 'FR' => "\x33\x33", 'DE' => "\x34\x39", 'IT' => "\x33\x39", 'ES' => "\x33\x34", 'PT' => "\x33\x35\x31", 'NL' => "\x33\x31", 'BE' => "\x33\x32", 'CH' => "\x34\x31", 'AT' => "\x34\x33", 'DK' => "\x34\x35", 'SE' => "\x34\x36", 'NO' => "\x34\x37", 'FI' => "\x33\x35\x38", 'PL' => "\x34\x38", 'CZ' => "\x34\x32\x30", 'SK' => "\x34\x32\x31", 'HU' => "\x33\x36", 'RO' => "\x34\x30", 'BG' => "\x33\x35\x39", 'GR' => "\x33\x30", 'TR' => "\x39\x30", 'RU' => "\x37", 'UA' => "\x33\x38\x30", 'BY' => "\x33\x37\x35", 'RS' => "\x33\x38\x31", 'HR' => "\x33\x38\x35", 'SI' => "\x33\x38\x36", 'BA' => "\x33\x38\x37", 'MK' => "\x33\x38\x39", 'MD' => "\x33\x37\x33", 'EE' => "\x33\x37\x32", 'LV' => "\x33\x37\x31", 'LT' => "\x33\x37\x30", 'IS' => "\x33\x35\x34", 'AU' => "\x36\x31", 'NZ' => "\x36\x34", 'SG' => "\x36\x35", 'MY' => "\x36\x30", 'TH' => "\x36\x36", 'VN' => "\x38\x34", 'PH' => "\x36\x33", 'ID' => "\x36\x32", 'KH' => "\x38\x35\x35", 'MM' => "\x39\x35", 'IN' => "\x39\x31", 'PK' => "\x39\x32", 'BD' => "\x38\x38\x30", 'LK' => "\x39\x34", 'NP' => "\x39\x37\x37", 'HK' => "\x38\x35\x32", 'TW' => "\x38\x38\x36", 'JP' => "\x38\x31", 'KR' => "\x38\x32", 'CN' => "\x38\x36", 'SA' => "\x39\x36\x36", 'AE' => "\x39\x37\x31", 'IL' => "\x39\x37\x32", 'IR' => "\x39\x38", 'JO' => "\x39\x36\x32", 'KW' => "\x39\x36\x35", 'QA' => "\x39\x37\x34", 'OM' => "\x39\x36\x38", 'BH' => "\x39\x37\x33", 'EG' => "\x32\x30", 'ZA' => "\x32\x37", 'NG' => "\x32\x33\x34", 'KE' => "\x32\x35\x34", 'TZ' => "\x32\x35\x35", 'UG' => "\x32\x35\x36", 'GH' => "\x32\x33\x33", 'DZ' => "\x32\x31\x33", 'MA' => "\x32\x31\x32", 'TN' => "\x32\x31\x36", 'RU' => "\x37", 'KZ' => "\x37", 'UZ' => "\x39\x39\x38", 'TM' => "\x39\x39\x33", 'KG' => "\x39\x39\x36", 'TJ' => "\x39\x39\x32", 'AZ' => "\x39\x39\x34", 'AM' => "\x33\x37\x34", 'GE' => "\x39\x39\x35", 'KR' => "\x38\x32", 'JP' => "\x38\x31", 'CN' => "\x38\x36", 'HK' => "\x38\x35\x32", 'MO' => "\x38\x35\x33", 'TW' => "\x38\x38\x36", 'ID' => "\x36\x32", 'MY' => "\x36\x30", 'SG' => "\x36\x35", 'TH' => "\x36\x36", 'VN' => "\x38\x34", 'PH' => "\x36\x33", 'KH' => "\x38\x35\x35", 'LA' => "\x38\x35\x36", 'AF' => "\x39\x33", 'AE' => "\x39\x37\x31", 'QA' => "\x39\x37\x34", 'OM' => "\x39\x36\x38", 'KW' => "\x39\x36\x35", 'BH' => "\x39\x37\x33", 'IQ' => "\x39\x36\x34", 'SY' => "\x39\x36\x33", 'YE' => "\x39\x36\x37", 'IR' => "\x39\x38", 'IL' => "\x39\x37\x32", 'JO' => "\x39\x36\x32", 'PS' => "\x39\x37\x30", 'LB' => "\x39\x36\x31", 'SA' => "\x39\x36\x36", 'ET' => "\x32\x35\x31", 'SD' => "\x32\x34\x39", 'DZ' => "\x32\x31\x33", 'MA' => "\x32\x31\x32", 'TN' => "\x32\x31\x36", 'LY' => "\x32\x31\x38", 'AO' => "\x32\x34\x34", 'NA' => "\x32\x36\x34", 'ZW' => "\x32\x36\x33", 'ZM' => "\x32\x36\x30", 'MW' => "\x32\x36\x35", 'MZ' => "\x32\x35\x38", 'BW' => "\x32\x36\x37", 'LS' => "\x32\x36\x36", 'SZ' => "\x32\x36\x38", 'RW' => "\x32\x35\x30", 'BI' => "\x32\x35\x37", 'UG' => "\x32\x35\x36", 'KE' => "\x32\x35\x34", 'NG' => "\x32\x33\x34", 'GH' => "\x32\x33\x33", 'SN' => "\x32\x32\x31", 'ML' => "\x32\x32\x33", 'BF' => "\x32\x32\x36", 'CI' => "\x32\x32\x35", 'NE' => "\x32\x32\x37", 'TD' => "\x32\x33\x35", 'CM' => "\x32\x33\x37", 'GA' => "\x32\x34\x31", 'CG' => "\x32\x34\x32", 'CD' => "\x32\x34\x33",  'PR' => "\x31", 'VI' => "\x31", 'JM' => "\x31", 'TT' => "\x31", 'BB' => "\x31", 'DO' => "\x31", 'HT' => "\x35\x30\x39", 'CU' => "\x35\x33",  'PG' => "\x36\x37\x35", 'FJ' => "\x36\x37\x39", 'WS' => "\x36\x38\x35", 'TO' => "\x36\x37\x36", 'SB' => "\x36\x37\x37", 'VU' => "\x36\x37\x38", 'NC' => "\x36\x38\x37", 'PF' => "\x36\x38\x39",  'LI' => "\x34\x32\x33", 'LU' => "\x33\x35\x32", 'MC' => "\x33\x37\x37", 'AD' => "\x33\x37\x36", 'SM' => "\x33\x37\x38", 'VA' => "\x33\x37\x39", 'GI' => "\x33\x35\x30", 'MT' => "\x33\x35\x36", 'CY' => "\x33\x35\x37", 'AL' => "\x33\x35\x35", 'ME' => "\x33\x38\x32",  'DEFAULT' => "\x31" ]; $prefix = $prefixes[$country] ?? $prefixes["\x44\x45\x46\x41\x55\x4C\x54"];  if (preg_match('/^0[0-9]{8,9}$/', $cleanPhone)) { $cleanPhone = $prefix . substr($cleanPhone, 1); } elseif (!preg_match('/^[1-9]/', $cleanPhone)) {  $cleanPhone = ltrim($cleanPhone, "\x30"); $cleanPhone = $prefix . $cleanPhone; } return $cleanPhone; }  function unipixel_get_advanced_matching_data($order = null) { $enabled = get_option('unipixel_advanced_matching_enabled', true); if (!$enabled) { return []; } $email = ''; $phone = ''; $fn = ''; $ln = ''; $ct = ''; $st = ''; $zp = ''; $country = '';  if ($order instanceof WC_Order) { $email = $order->get_billing_email(); $phone = $order->get_billing_phone(); $fn = $order->get_billing_first_name(); $ln = $order->get_billing_last_name(); $ct = $order->get_billing_city(); $st = $order->get_billing_state(); $zp = $order->get_billing_postcode(); $country = $order->get_billing_country(); }  if (is_user_logged_in()) { $user = wp_get_current_user(); $uid = $user->ID; if (empty($email)) $email = $user->user_email; if (empty($phone)) $phone = get_user_meta($uid, "\x62\x69\x6C\x6C\x69\x6E\x67\x5F\x70\x68\x6F\x6E\x65", true); if (empty($fn)) $fn = get_user_meta($uid, "\x62\x69\x6C\x6C\x69\x6E\x67\x5F\x66\x69\x72\x73\x74\x5F\x6E\x61\x6D\x65", true) ?: $user->first_name; if (empty($ln)) $ln = get_user_meta($uid, "\x62\x69\x6C\x6C\x69\x6E\x67\x5F\x6C\x61\x73\x74\x5F\x6E\x61\x6D\x65", true) ?: $user->last_name; if (empty($ct)) $ct = get_user_meta($uid, "\x62\x69\x6C\x6C\x69\x6E\x67\x5F\x63\x69\x74\x79", true); if (empty($st)) $st = get_user_meta($uid, "\x62\x69\x6C\x6C\x69\x6E\x67\x5F\x73\x74\x61\x74\x65", true); if (empty($zp)) $zp = get_user_meta($uid, "\x62\x69\x6C\x6C\x69\x6E\x67\x5F\x70\x6F\x73\x74\x63\x6F\x64\x65", true); if (empty($country)) $country = get_user_meta($uid, "\x62\x69\x6C\x6C\x69\x6E\x67\x5F\x63\x6F\x75\x6E\x74\x72\x79", true); }  if (empty($email) && empty($phone) && empty($fn)) { return []; } $result = [];  if (!empty($email)) { $result["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x45\x6D\x61\x69\x6C"] = hash("\x73\x68\x61\x32\x35\x36", strtolower(trim($email))); }  if (!empty($phone)) { $storeBase = ''; if (function_exists("\x77\x63\x5F\x67\x65\x74\x5F\x62\x61\x73\x65\x5F\x6C\x6F\x63\x61\x74\x69\x6F\x6E")) { $storeBase = wc_get_base_location()["\x63\x6F\x75\x6E\x74\x72\x79"] ?? ""; } $normalized = unipixel_normalize_phone_for_hashing($phone, $country, $storeBase); if ($normalized) { $result["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x50\x68\x6F\x6E\x65"] = hash("\x73\x68\x61\x32\x35\x36", $normalized); } }  if (!empty($fn)) $result["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x46\x6E"] = hash("\x73\x68\x61\x32\x35\x36", strtolower(trim($fn))); if (!empty($ln)) $result["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x4C\x6E"] = hash("\x73\x68\x61\x32\x35\x36", strtolower(trim($ln))); if (!empty($ct)) $result["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x43\x74"] = hash("\x73\x68\x61\x32\x35\x36", strtolower(trim($ct))); if (!empty($st)) $result["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x53\x74"] = hash("\x73\x68\x61\x32\x35\x36", strtolower(trim($st))); if (!empty($zp)) $result["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x5A\x70"] = hash("\x73\x68\x61\x32\x35\x36", strtolower(trim($zp))); if (!empty($country)) $result["\x70\x6C\x63\x65\x68\x6C\x64\x72\x5F\x68\x61\x73\x68\x65\x64\x43\x6F\x75\x6E\x74\x72\x79"] = hash("\x73\x68\x61\x32\x35\x36", strtolower(trim($country))); return $result; }  function unipixel_url_pattern_match($pattern, $url) { if (!is_string($pattern) || !is_string($url)) return false; $pattern = trim($pattern); if ($pattern === "") return false; $parts = wp_parse_url($url); $url_path = isset($parts["\x70\x61\x74\x68"]) ? $parts["\x70\x61\x74\x68"] : '/'; $url_query = isset($parts["\x71\x75\x65\x72\x79"]) ? $parts["\x71\x75\x65\x72\x79"] : ""; if (strpos($pattern, "\x3F") === false) { $target = $url_path; } else { $target = $url_path . ($url_query !== "" ? "\x3F" . $url_query : ""); } $target = unipixel_strip_trailing_slash_from_path($target); $pattern = unipixel_strip_trailing_slash_from_path($pattern); $target_lc = strtolower($target); $pattern_lc = strtolower($pattern); $regex = '#^' . str_replace('\*', "\x2E\x2A", preg_quote($pattern_lc, "\x23")) . "\x24\x23"; return (bool) preg_match($regex, $target_lc); } function unipixel_strip_trailing_slash_from_path($s) { $qpos = strpos($s, "\x3F"); if ($qpos === false) { $stripped = rtrim($s, '/'); return $stripped === "" ? '/' : $stripped; } $path = substr($s, 0, $qpos); $rest = substr($s, $qpos); $path_stripped = rtrim($path, '/'); if ($path_stripped === "") $path_stripped = '/'; return $path_stripped . $rest; } 