diff --git wp-includes/shortcodes.php wp-includes/shortcodes.php
index 1919af4..3152d94 100644
|
|
function shortcode_exists( $tag ) { |
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | | * Whether the passed content contains the specified shortcode |
| 144 | * Whether the passed content contains any or specified shortcode |
145 | 145 | * |
146 | 146 | * @since 3.6.0 |
147 | 147 | * |
148 | 148 | * @global array $shortcode_tags |
149 | 149 | * |
150 | 150 | * @param string $content Content to search for shortcodes. |
151 | | * @param string $tag Shortcode tag to check. |
| 151 | * @param string $tag Optional. Shortcode tag to check. |
152 | 152 | * @return bool Whether the passed content contains the given shortcode. |
153 | 153 | */ |
154 | | function has_shortcode( $content, $tag ) { |
| 154 | function has_shortcode( $content, $tag = '' ) { |
155 | 155 | if ( false === strpos( $content, '[' ) ) { |
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | |
159 | | if ( shortcode_exists( $tag ) ) { |
160 | | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
161 | | if ( empty( $matches ) ) |
162 | | return false; |
163 | | |
164 | | foreach ( $matches as $shortcode ) { |
165 | | if ( $tag === $shortcode[2] ) { |
166 | | return true; |
167 | | } elseif ( ! empty( $shortcode[5] ) && has_shortcode( $shortcode[5], $tag ) ) { |
168 | | return true; |
169 | | } |
| 159 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 160 | if ( empty( $matches ) ) |
| 161 | return false; |
| 162 | |
| 163 | if ( empty( $tag ) ) { |
| 164 | return true; |
| 165 | } |
| 166 | |
| 167 | foreach ( $matches as $shortcode ) { |
| 168 | if ( $tag === $shortcode[2] ) { |
| 169 | return true; |
| 170 | } elseif ( ! empty( $shortcode[5] ) && has_shortcode( $shortcode[5], $tag ) ) { |
| 171 | return true; |
170 | 172 | } |
171 | 173 | } |
| 174 | |
172 | 175 | return false; |
173 | 176 | } |
174 | 177 | |