PUM_Helpers::get_shortcodes_from_content( $content )
Contents
Description Description
Source Source
File: classes/Helpers.php
public static function get_shortcodes_from_content( $content ) { $pattern = get_shortcode_regex(); $shortcodes = array(); if ( preg_match_all( '/' . $pattern . '/s', $content, $matches ) ) { foreach ( $matches[0] as $key => $value ) { $shortcodes[ $key ] = array( 'full_text' => $value, 'tag' => $matches[2][ $key ], 'atts' => shortcode_parse_atts( $matches[3][ $key ] ), 'content' => $matches[5][ $key ], ); if ( ! empty( $shortcodes[ $key ]['atts'] ) ) { foreach ( $shortcodes[ $key ]['atts'] as $attr_name => $attr_value ) { // Filter numeric keys as they are valueless/truthy attributes. if ( is_numeric( $attr_name ) ) { $shortcodes[ $key ]['atts'][ $attr_value ] = true; unset( $shortcodes[ $key ]['atts'][ $attr_name ] ); } } } } } return $shortcodes; }
Expand full source code Collapse full source code View on Trac