private function createReplaceCallback($idProvider)
{
$shortcodesInfo = $this->shortcodesInfo;
return function ($m) use($shortcodesInfo, $idProvider) {
// allow [[foo]] syntax for escaping a tag - code adopted from WP function `do_shortcode_tag`
if ($m[1] == '[' && $m[6] == ']') {
return substr($m[0], 1, -1);
}
$shortcodeTag = $m[2];
$shortcodeInfo = $shortcodesInfo->getShortcodeInfo($shortcodeTag);
$attributes = shortcode_parse_atts($m[3]);
foreach ($attributes as $attribute => $value) {
if (isset($shortcodeInfo[$attribute])) {
$ids = explode(',', $value);
$entityName = $shortcodeInfo[$attribute];
$attributes[$attribute] = join(',', array_map(function ($id) use($entityName, $idProvider) {
return $idProvider($entityName, $id);
}, $ids));
}
}
return WordPressMissingFunctions::renderShortcode($shortcodeTag, $attributes);
};
}