From 69388b3f6289970a95f42a2e162bd7ab124983ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jovana=20Ran=C4=91elovi=C4=87?= <jovana@stuntcoders.com>
Date: Mon, 27 Jan 2025 05:17:11 -0800
Subject: [PATCH] Move noscript tag to body element (#68)

Summary:
This changeset updates the placement of the `noscript` pixel tag so that it is added within the `body` tag to keep the code valid HTML.

Originally started in this PR: https://github.com/facebookincubator/Facebook-Pixel-for-Wordpress/pull/35

Pull Request resolved: https://github.com/facebookincubator/Facebook-Pixel-for-Wordpress/pull/68

Differential Revision: D68706167

Pulled By: vahidkay-meta

fbshipit-source-id: a4211c11aa757ba4fbd8509699147ae5be9ce292
---
 __tests__/core/FacebookWordpressPixelInjectionTest.php |  2 +-
 core/class-aamfieldsextractor.php                      | 10 ++++++++--
 core/class-facebookwordpresspixelinjection.php         |  2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/__tests__/core/FacebookWordpressPixelInjectionTest.php b/__tests__/core/FacebookWordpressPixelInjectionTest.php
index 8e19e91b..8710d660 100644
--- a/__tests__/core/FacebookWordpressPixelInjectionTest.php
+++ b/__tests__/core/FacebookWordpressPixelInjectionTest.php
@@ -79,7 +79,7 @@ public function testPixelInjection() {
       array( $injection_obj, 'inject_pixel_code' )
     );
     \WP_Mock::expectActionAdded(
-      'wp_head',
+      'wp_body_open',
       array( $injection_obj, 'inject_pixel_noscript_code' )
     );
 
diff --git a/core/class-aamfieldsextractor.php b/core/class-aamfieldsextractor.php
index a36cb02a..97166980 100644
--- a/core/class-aamfieldsextractor.php
+++ b/core/class-aamfieldsextractor.php
@@ -66,8 +66,14 @@ public static function get_normalized_user_data( $user_data_array ) {
     if (
         isset( $user_data_array[ AAMSettingsFields::DATE_OF_BIRTH ] )
         ) {
-        $unix_timestamp =
-        strtotime( $user_data_array[ AAMSettingsFields::DATE_OF_BIRTH ] );
+
+        $date_time      = \DateTime::createFromFormat(
+            'Y-m-d',
+            $user_data_array[ AAMSettingsFields::DATE_OF_BIRTH ],
+            new \DateTimeZone( 'GMT' )
+        );
+        $unix_timestamp = $date_time ? $date_time->getTimestamp() : false;
+
         if ( ! $unix_timestamp ) {
             unset( $user_data_array[ AAMSettingsFields::DATE_OF_BIRTH ] );
         } else {
diff --git a/core/class-facebookwordpresspixelinjection.php b/core/class-facebookwordpresspixelinjection.php
index 85a35d90..fcc2f936 100644
--- a/core/class-facebookwordpresspixelinjection.php
+++ b/core/class-facebookwordpresspixelinjection.php
@@ -64,7 +64,7 @@ public function inject() {
                 array( $this, 'inject_pixel_code' )
             );
             add_action(
-                'wp_head',
+                'wp_body_open',
                 array( $this, 'inject_pixel_noscript_code' )
             );
             foreach (