From ef248a1b1b33ce9a2f15a5ab56ba717a82af9f5a Mon Sep 17 00:00:00 2001
From: Derek Springer
Date: Thu, 24 Oct 2019 15:06:42 -0700
Subject: [PATCH] WordAds: Update Head Loader (#13795)
---
modules/wordads/wordads.php | 52 ++++++++++++++++++++++++++-----------
1 file changed, 37 insertions(+), 15 deletions(-)
diff --git a/modules/wordads/wordads.php b/modules/wordads/wordads.php
index 02d85f798d05a..3fc03fb103507 100644
--- a/modules/wordads/wordads.php
+++ b/modules/wordads/wordads.php
@@ -197,6 +197,7 @@ public static function is_infinite_scroll() {
* @since 4.5.0
*/
private function insert_adcode() {
+ add_filter( 'wp_resource_hints', array( $this, 'resource_hints' ), 10, 2 );
add_action( 'wp_head', array( $this, 'insert_head_meta' ), 20 );
add_action( 'wp_head', array( $this, 'insert_head_iponweb' ), 30 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -264,6 +265,35 @@ function enqueue_scripts() {
);
}
+ /**
+ * Add the IPW resource hints
+ *
+ * @since 7.9
+ */
+ public function resource_hints( $hints, $relation_type ) {
+ if ( 'dns-prefetch' === $relation_type ) {
+ $hints[] = '//s.pubmine.com';
+ $hints[] = '//x.bidswitch.net';
+ $hints[] = '//static.criteo.net';
+ $hints[] = '//ib.adnxs.com';
+ $hints[] = '//aax.amazon-adsystem.com';
+ $hints[] = '//bidder.criteo.com';
+ $hints[] = '//cas.criteo.com';
+ $hints[] = '//gum.criteo.com';
+ $hints[] = '//ads.pubmatic.com';
+ $hints[] = '//gads.pubmatic.com';
+ $hints[] = '//tpc.googlesyndication.com';
+ $hints[] = '//ad.doubleclick.net';
+ $hints[] = '//googleads.g.doubleclick.net';
+ $hints[] = '//www.googletagservices.com';
+ $hints[] = '//cdn.switchadhub.com';
+ $hints[] = '//delivery.g.switchadhub.com';
+ $hints[] = '//delivery.swid.switchadhub.com';
+ }
+
+ return $hints;
+ }
+
/**
* IPONWEB metadata used by the various scripts
*
@@ -300,21 +330,13 @@ function insert_head_iponweb() {
}
$data_tags = ( $this->params->cloudflare ) ? ' data-cfasync="false"' : '';
echo <<
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
HTML;
}