Function Reference: geodir_parse_shortcodes

Summary

This function has not been documented yet.

Filters

‘geodir_parse_shortcodes’ [Line: 719]

Source File

geodir_parse_shortcodes() is located in geodirectory-functions/template_functions.php [Line: 683]

Source Code

function geodir_parse_shortcodes( $content, $shortcode, $first = true ) {
    if ( empty( $content ) || empty( $shortcode ) ) {
        return array();
    }
    
    if ( false === strpos( $content, '[' ) ) {
        return array();
    }

    if ( ! has_shortcode( $content, $shortcode ) ) {
        return array();
    }

    $shortcodes = array();
    if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) ) {
        foreach ( $matches as $match ) {
            if ( $shortcode === $match[2] ) {
                $shortcode_attrs = shortcode_parse_atts( $match[3] );
                if ( ! is_array( $shortcode_attrs ) ) {
                    $shortcode_attrs = array();
                }
                $shortcode_attrs['shortcode_tag'] = $shortcode;
                if ( !empty( $match[5] ) ) {
                    $shortcode_attrs['shortcode_content'] = $match[5];
                }
                $shortcodes[] = $shortcode_attrs;
                if ( $first === true ) {
                    break;
                }
            }
        }
        if ( $first === true && !empty( $shortcodes ) ) {
            $shortcodes = $shortcodes[0];
        }
    }

    return apply_filters( 'geodir_parse_shortcodes', $shortcodes, $content, $shortcode, $first );
}