|
@@ 78-96 (lines=19) @@
|
| 75 |
|
* @param String $search |
| 76 |
|
* @return String $content |
| 77 |
|
*/ |
| 78 |
|
function jetpack_preg_replace_outside_tags( $pattern, $replacement, $content, $search = null ) { |
| 79 |
|
if( ! function_exists( 'wp_html_split' ) ) { |
| 80 |
|
return $content; |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
if ( $search && false === strpos( $content, $search ) ) { |
| 84 |
|
return $content; |
| 85 |
|
} |
| 86 |
|
|
| 87 |
|
$textarr = wp_html_split( $content ); |
| 88 |
|
unset( $content ); |
| 89 |
|
foreach( $textarr as &$element ) { |
| 90 |
|
if ( '' === $element || '<' === $element{0} ) |
| 91 |
|
continue; |
| 92 |
|
$element = preg_replace( $pattern, $replacement, $element ); |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
return join( $textarr ); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
/** |
| 99 |
|
* Runs preg_replace_callback so that replacements don't happen within open tags. |
|
@@ 108-126 (lines=19) @@
|
| 105 |
|
* @param String $search |
| 106 |
|
* @return String $content |
| 107 |
|
*/ |
| 108 |
|
function jetpack_preg_replace_callback_outside_tags( $pattern, $callback, $content, $search = null ) { |
| 109 |
|
if( ! function_exists( 'wp_html_split' ) ) { |
| 110 |
|
return $content; |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
if ( $search && false === strpos( $content, $search ) ) { |
| 114 |
|
return $content; |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
$textarr = wp_html_split( $content ); |
| 118 |
|
unset( $content ); |
| 119 |
|
foreach( $textarr as &$element ) { |
| 120 |
|
if ( '' === $element || '<' === $element{0} ) |
| 121 |
|
continue; |
| 122 |
|
$element = preg_replace_callback( $pattern, $callback, $element ); |
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
return join( $textarr ); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
if ( ! function_exists( 'jetpack_shortcode_get_wpvideo_id' ) ) { |
| 129 |
|
function jetpack_shortcode_get_wpvideo_id( $atts ) { |