I am trying to get 2 shortcodes (single-include and single-factsheet) on one page. The Problem is, that only the first shortcode is getting executed. The second shortcode on a page simple returns the shortcode string.
This code is within the plugin:
add_filter('the_content', 'initQmediaRechnerSnippet');
function initQmediaRechnerSnippet($content)
{
$pattern = "/\[([^=]*)=?(.*)?\]/";
if (preg_match($pattern, $content, $treffer))
{
$snippetName = $treffer[1];
$snippet = '';
switch ($snippetName) {
case 'kreditkarte':
$snippet = qRechnerInclude(API_CALC_KREDITKARTE, '');
$content = str_replace('[' . $snippetName . ']', $snippet, $content);
break;
case 'single-include':
list($ids, $product) = explode(":", $treffer[2]);
$snippet = qRechnerInclude(str_replace('$PRODUCT$', $product, API_CALC_SINGLEINCLUDE . $ids), '');
$content = str_replace('[' . $snippetName . '=' . $ids . ':' . $product . ']', $snippet, $content);
break;
case 'single-factsheet':
list($ids, $product) = explode(":", $treffer[2]);
$snippet = qRechnerInclude(str_replace('$PRODUCT$', $product, API_CALC_SINGLEFACTSHEET . $ids), '');
$content = str_replace('[' . $snippetName . '=' . $ids . ':' . $product . ']', $snippet, $content);
break;
default:
;
break;
}
}
return $content;
}
How can I get this working? (removing the breaks did not work) Replacing preg_match with preg_match_all stops the execution of all shortcodes.