wpseek.com
A WordPress-centric search engine for devs and theme authors
get_shortcode_tags_in_content › WordPress Function
Since6.3.2
Deprecatedn/a
› get_shortcode_tags_in_content ( $content )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
| Codex: |
Returns a list of registered shortcode names found in the given content.
Example usage: get_shortcode_tags_in_content( '[audio src="file.mp3"][/audio] [foo] [gallery ids="1,2,3"]' ); // array( 'audio', 'gallery' )Related Functions: get_shortcode_atts_regex, get_url_in_content, get_the_content, _filter_do_shortcode_context, get_shortcode_regex
Source
function get_shortcode_tags_in_content( $content ) {
if ( ! str_contains( $content, '[' ) ) {
return array();
}
preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER );
if ( empty( $matches ) ) {
return array();
}
$tags = array();
foreach ( $matches as $shortcode ) {
$tags[] = $shortcode[2];
if ( ! empty( $shortcode[5] ) ) {
$deep_tags = get_shortcode_tags_in_content( $shortcode[5] );
if ( ! empty( $deep_tags ) ) {
$tags = array_merge( $tags, $deep_tags );
}
}
}
return $tags;
}