MC4WP_Dynamic_Content_Tags::replace_tag PHP Method

replace_tag() protected method

protected replace_tag ( $matches ) : string
$matches
return string
    protected function replace_tag($matches)
    {
        $tags = $this->all();
        $tag = $matches[1];
        if (isset($tags[$tag])) {
            $config = $tags[$tag];
            $replacement = '';
            if (isset($config['replacement'])) {
                $replacement = $config['replacement'];
            } elseif (isset($config['callback'])) {
                // parse attributes
                $attributes = array();
                if (isset($matches[2])) {
                    $attribute_string = $matches[2];
                    $attributes = shortcode_parse_atts($attribute_string);
                }
                // call function
                $replacement = call_user_func($config['callback'], $attributes);
            }
            return $this->escape_value($replacement);
        }
        // default to not replacing it
        // @todo always replace with empty string?
        return $matches[0];
    }