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