Skip to content

Commit

Permalink
Move noscript tag to body element (#68)
Browse files Browse the repository at this point in the history
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: #35

Pull Request resolved: #68

Differential Revision: D68706167

Pulled By: vahidkay-meta

fbshipit-source-id: a4211c11aa757ba4fbd8509699147ae5be9ce292
  • Loading branch information
joran29 authored and facebook-github-bot committed Jan 27, 2025
1 parent 00df37e commit 69388b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion __tests__/core/FacebookWordpressPixelInjectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
);

Expand Down
10 changes: 8 additions & 2 deletions core/class-aamfieldsextractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion core/class-facebookwordpresspixelinjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 69388b3

Please sign in to comment.