Completed
Push — add/related-posts-customize ( 4a306a...1c5144 )
by
unknown
43:30 queued 35:07
created

WordAds_Amazon   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B insert_head_amazon() 0 29 2
1
<?php
2
3
/**
4
 * Amazon network class
5
 *
6
 * @since 4.5.0
7
 */
8
class WordAds_Amazon {
9
10
	/**
11
	 * Instantiate
12
	 *
13
	 * @since 4.5.0
14
	 */
15
	function __construct() {
16
		add_action( 'wp_head', array( $this, 'insert_head_amazon' ), 25 );
17
	}
18
19
	function insert_head_amazon() {
20
		$data_tags = ( WordAds_Params::is_cloudflare() ) ? ' data-cfasync="false"' : '';
21
		echo <<<HTML
22
		<script$data_tags type="text/javascript" src="//c.amazon-adsystem.com/aax2/amzn_ads.js"></script>
23
		<script$data_tags type="text/javascript">
24
			try {
25
				amznads.getAds("3033");
26
			} catch(e) { /* ignore */ }
27
		</script>
28
		<script$data_tags type="text/javascript">
29
			var a9_p = amznads.getKeys();
30
			if ("undefined" != typeof a9_p && "" != a9_p && null !== a9_p && "[object Array]" === Object.prototype.toString.call(a9_p)) {
31
				var a = "",
32
					b = 0,
33
					c = a9_p.length,
34
					d, e;
35
				a9_p.sort();
36
				for (d = 0; d < c; d+=1) {
37
					a9_p[d - b] = a9_p[d - b].replace(/a1x6p/, "a160x600p");
38
					e = a9_p[d - b].split("p");
39
					e[0] == a && (a9_p.splice(d - b, 1), b++);
40
					a = e[0];
41
				}
42
				_ipw_custom.amznPay = a9_p;
43
			}
44
			document.close();
45
		</script>
46
HTML;
47
	}
48
}
49
50
global $wordads_amazon;
51
$wordads_amazon = new WordAds_Amazon();
52