Code Duplication    Length = 18-27 lines in 2 locations

modules/latex.php 1 location

@@ 24-50 (lines=27) @@
21
 * $latex [a, b]$              ->  [latex][a, b][/latex]
22
 */
23
24
function latex_markup( $content ) {
25
	$textarr = wp_html_split( $content );
26
	
27
	$regex = '%
28
		\$latex(?:=\s*|\s+)
29
		((?:
30
			[^$]+ # Not a dollar
31
		|
32
			(?<=(?<!\\\\)\\\\)\$ # Dollar preceded by exactly one slash
33
		)+)
34
		(?<!\\\\)\$ # Dollar preceded by zero slashes
35
	%ix';
36
	
37
	foreach ( $textarr as &$element ) {
38
		if ( '' == $element || '<' === $element[0] ) {
39
			continue;
40
		}
41
42
		if ( false === stripos( $element, '$latex' ) ) {
43
			continue;
44
		}
45
46
		$element = preg_replace_callback( $regex, 'latex_src', $element );
47
	}
48
49
	return implode( '', $textarr );
50
}
51
52
function latex_src( $matches ) {
53
	$latex = $matches[1];

modules/shortcodes/spotify.php 1 location

@@ 65-82 (lines=18) @@
62
 *
63
 * @return string
64
 */
65
function jetpack_spotify_embed_ids( $content ) {
66
	$textarr = wp_html_split( $content );
67
68
	foreach ( $textarr as &$element ) {
69
		if ( '' === $element || '<' === $element[0] ) {
70
			continue;
71
		}
72
73
		// If this element does not contain a Spotify embed, continue.
74
		if ( false === strpos( $element, 'spotify:' ) ) {
75
			continue;
76
		}
77
78
		$element = preg_replace_callback( '|^\s*(spotify:[^\s"]+:[^\s"]+)\s*$|im', 'jetpack_spotify_embed_ids_callback', $element );
79
	}
80
81
	return implode( '', $textarr );
82
}
83
add_filter( 'the_content', 'jetpack_spotify_embed_ids', 7 );
84
85
/**