Code Duplication    Length = 16-22 lines in 2 locations

modules/shortcodes/youtube.php 1 location

@@ 124-139 (lines=16) @@
121
 * @param string $url
122
 * @return string The normalized URL
123
 */
124
if ( ! function_exists( 'youtube_sanitize_url' ) ) :
125
function youtube_sanitize_url( $url ) {
126
	$url = trim( $url, ' "' );
127
	$url = trim( $url );
128
	$url = str_replace( array( 'youtu.be/', '/v/', '#!v=', '&', '&', 'playlist' ), array( 'youtu.be/?v=', '/?v=', '?v=', '&', '&', 'videoseries' ), $url );
129
130
	// Replace any extra question marks with ampersands - the result of a URL like "http://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US" being passed in.
131
	$query_string_start = strpos( $url, "?" );
132
133
	if ( false !== $query_string_start ) {
134
		$url = substr( $url, 0, $query_string_start + 1 ) . str_replace( "?", "&", substr( $url, $query_string_start + 1 ) );
135
	}
136
137
	return $url;
138
}
139
endif;
140
141
/*
142
 * url can be:

functions.compat.php 1 location

@@ 45-66 (lines=22) @@
42
	return $id;
43
}
44
45
if ( !function_exists( 'youtube_sanitize_url' ) ) :
46
/**
47
* Normalizes a YouTube URL to include a v= parameter and a query string free of encoded ampersands.
48
*
49
* @param string $url
50
* @return string The normalized URL
51
*/
52
function youtube_sanitize_url( $url ) {
53
	$url = trim( $url, ' "' );
54
	$url = trim( $url );
55
	$url = str_replace( array( 'youtu.be/', '/v/', '#!v=', '&', '&', 'playlist' ), array( 'youtu.be/?v=', '/?v=', '?v=', '&', '&', 'videoseries' ), $url );
56
57
	// Replace any extra question marks with ampersands - the result of a URL like "http://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US" being passed in.
58
	$query_string_start = strpos( $url, "?" );
59
60
	if ( false !== $query_string_start ) {
61
		$url = substr( $url, 0, $query_string_start + 1 ) . str_replace( "?", "&", substr( $url, $query_string_start + 1 ) );
62
	}
63
64
	return $url;
65
}
66
endif;
67
68
/**
69
 * Merge in three string helper functions from WPCOM.