diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 57ec80e0b71..dce4b158c54 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -29,14 +29,19 @@
*
* @param Website $website Web site object
* @param string $content Content to replace
+ * @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections.
* @return boolean True if OK
*/
-function dolWebsiteReplacementOfLinks($website, $content)
+function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
{
// Replace php code. Note $content may come from database and does not contains body tags.
+ $replacewith='...php...';
+ if ($removephppart) $replacewith='';
+ $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content);
- $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="...php..."', $content);
- $content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', '...php...', $content);
+ $replacewith='...php...';
+ if ($removephppart) $replacewith='';
+ $content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
// Replace relative link / with dolibarr URL
$content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 16d19907883..220a1e9663d 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -2007,9 +2007,9 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
// REPLACEMENT OF LINKS When page called by website editor
$out.=''."\n";