Code Duplication    Length = 23-23 lines in 2 locations

modules/asset-cdn/asset-cdn.php 2 locations

@@ 84-106 (lines=23) @@
81
	 * so they're still served from the CDN
82
	 */
83
84
	function rewrite_script_src( $src, $handle ) {
85
		global $wp_scripts;
86
87
		if ( is_admin() || ! isset( $wp_scripts->registered[$handle] ) ) {
88
			return $src;
89
		}
90
91
		$script = $wp_scripts->registered[$handle];
92
93
		if ( ! $this->should_concat_script( $script ) && $this->should_cdn_script( $script ) ) {
94
			// serve this script from the CDN
95
			$parts = parse_url( $src );
96
			$url = $this->cdn_server . '/js';
97
			$url = add_query_arg( array(
98
				'b' => "{$parts['scheme']}://{$parts['host']}",
99
				'f' => array( $parts['path'] ),
100
				'v' => array( $script->ver )
101
			), $url );
102
			return $url;
103
		}
104
105
		return $src;
106
	}
107
108
	function should_cdn_script( $script ) {
109
		return true;
@@ 112-134 (lines=23) @@
109
		return true;
110
	}
111
112
	function rewrite_style_src( $src, $handle ) {
113
		global $wp_styles;
114
115
		if ( is_admin() || ! isset( $wp_styles->registered[$handle] ) ) {
116
			return $src;
117
		}
118
119
		$style = $wp_styles->registered[$handle];
120
121
		if ( ! $this->should_concat_style( $style ) && $this->should_cdn_style( $style ) ) {
122
			// serve this style from the CDN
123
			$parts = parse_url( $src );
124
			$url = $this->cdn_server . '/js';
125
			$url = add_query_arg( array(
126
				'b' => "{$parts['scheme']}://{$parts['host']}",
127
				'f' => array( $parts['path'] ),
128
				'v' => array( $style->ver )
129
			), $url );
130
			return $url;
131
		}
132
133
		return $src;
134
	}
135
136
	function should_cdn_style( $style ) {
137
		return true;