ID
));
foreach($tracking as $link) {
$linked = DataObject::get_by_id('SiteTree', $link['ChildID']);
$page->{$link['FieldName']} = preg_replace (
"/href *= *([\"']?){$linked->URLSegment}\/?/i",
"href=$1[sitetree_link id={$linked->ID}]",
$page->{$link['FieldName']},
-1,
$replaced
);
if($replaced) {
$page->write();
$links += $replaced;
}
}
$pages++;
}
echo "Rewrote $links link(s) on $pages page(s) to use shortcodes.\n";
}
}