| @@ 86-104 (lines=19) @@ | ||
| 83 | * |
|
| 84 | * @return string $content Replaced post content. |
|
| 85 | */ |
|
| 86 | function jetpack_preg_replace_outside_tags( $pattern, $replacement, $content, $search = null ) { |
|
| 87 | if ( ! function_exists( 'wp_html_split' ) ) { |
|
| 88 | return $content; |
|
| 89 | } |
|
| 90 | ||
| 91 | if ( $search && false === strpos( $content, $search ) ) { |
|
| 92 | return $content; |
|
| 93 | } |
|
| 94 | ||
| 95 | $textarr = wp_html_split( $content ); |
|
| 96 | unset( $content ); |
|
| 97 | foreach ( $textarr as &$element ) { |
|
| 98 | if ( '' === $element || '<' === $element{0} ) { |
|
| 99 | continue; |
|
| 100 | } |
|
| 101 | $element = preg_replace( $pattern, $replacement, $element ); |
|
| 102 | } |
|
| 103 | ||
| 104 | return join( $textarr ); |
|
| 105 | } |
|
| 106 | ||
| 107 | /** |
|
| @@ 118-136 (lines=19) @@ | ||
| 115 | * |
|
| 116 | * @return string $content Replaced post content. |
|
| 117 | */ |
|
| 118 | function jetpack_preg_replace_callback_outside_tags( $pattern, $callback, $content, $search = null ) { |
|
| 119 | if ( ! function_exists( 'wp_html_split' ) ) { |
|
| 120 | return $content; |
|
| 121 | } |
|
| 122 | ||
| 123 | if ( $search && false === strpos( $content, $search ) ) { |
|
| 124 | return $content; |
|
| 125 | } |
|
| 126 | ||
| 127 | $textarr = wp_html_split( $content ); |
|
| 128 | unset( $content ); |
|
| 129 | foreach ( $textarr as &$element ) { |
|
| 130 | if ( '' === $element || '<' === $element{0} ) { |
|
| 131 | continue; |
|
| 132 | } |
|
| 133 | $element = preg_replace_callback( $pattern, $callback, $element ); |
|
| 134 | } |
|
| 135 | ||
| 136 | return join( $textarr ); |
|
| 137 | } |
|
| 138 | ||
| 139 | if ( ! function_exists( 'jetpack_shortcode_get_wpvideo_id' ) ) { |
|