Code Duplication    Length = 5-6 lines in 2 locations

modules/shortcodes/gist.php 1 location

@@ 94-99 (lines=6) @@
91
	}
92
93
	// Not a URL nor an ID? Only keep one of "username/id", "/username/id", "id".
94
	if ( preg_match( '#^/?(([a-z0-9-_]+/)?([a-z0-9]+))$#i', $gist, $matches ) ) {
95
		$gist_info['id'] = $matches[1];
96
97
		// If there is one, strip the GitHub username and only keep the ID.
98
		$gist_info['id'] = preg_replace( '#^.*/(?=[a-z0-9]+)#', '', $gist_info['id'] );
99
	}
100
101
	return $gist_info;
102
}

modules/shortcodes/ted.php 1 location

@@ 37-41 (lines=5) @@
34
	}
35
36
	$url = '';
37
	if ( preg_match( '#^[\d]+$#', $atts['id'], $matches ) ) {
38
		$url = 'http://ted.com/talks/view/id/' . $matches[0];
39
	} elseif ( preg_match( '#^https?://(www\.)?ted\.com/talks/view/id/[0-9]+$#', $atts['id'], $matches ) ) {
40
		$url = $matches[0];
41
	}
42
43
	unset( $atts['id'] );
44