Skip to content

Commit

Permalink
Merge branch '7.x/fb-ia-sdk' into 7.x/ads
Browse files Browse the repository at this point in the history
# Conflicts:
#	modules/fb_instant_articles_display/src/DrupalInstantArticleDisplay.php
  • Loading branch information
simonengelhardt committed Apr 12, 2016
2 parents 1e0938d + bd9db44 commit ecc7082
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public static function create($node, $layoutSettings) {
$instantArticle->withHeader($header);

$display = new DrupalInstantArticleDisplay($node, $layoutSettings, $instantArticle);
$display->addAnalyticsFromSettings();
$display->addAdsFromSettings();
return $display;
}
Expand Down Expand Up @@ -553,6 +554,27 @@ private function fieldFormatSocialElement($items, $body) {
}
}

/**
* Add analytics tracking code if configured in settings
*/
private function addAnalyticsFromSettings() {
$analytics_embed_code = variable_get('fb_instant_articles_analytics_embed_code');
if ($analytics_embed_code) {
$document = new \DOMDocument();
$fragment = $document->createDocumentFragment();
$valid_html = @$fragment->appendXML($analytics_embed_code);
if ($valid_html) {
$this->instantArticle
->addChild(
Analytics::create()
->withHTML(
$fragment
)
);
}
}
}

/**
* Add ads if configured in settings
*/
Expand Down

1 comment on commit ecc7082

@simonengelhardt
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merges in upstream changes that originated from #34

Please sign in to comment.