Custom SEO (#154)

* Enable Pro plan - WIP

* no pricing page if have no paid plans

* Set pricing ids in env

* views & submissions FREE for all

* extra param for env

* form password FREE for all

* Custom Code is PRO feature

* Replace codeinput prism with codemirror

* Better form Cleaning message

* Added risky user email spam protection

* fix form cleaning

* Custom SEO

* fix custom seo formcleaner

* remvoe fix condition
This commit is contained in:
formsdev
2023-08-30 15:13:11 +05:30
committed by GitHub
parent fb79a5bf3e
commit 01a01a8c72
13 changed files with 174 additions and 13 deletions

View File

@@ -23,6 +23,9 @@ class FormCleaner
private array $data;
// For remove keys those have empty value
private array $customKeys = ['seo_meta'];
private array $formDefaults = [
'notifies' => false,
'no_branding' => false,
@@ -32,6 +35,7 @@ class FormCleaner
'discord_webhook_url' => null,
'editable_submissions' => false,
'custom_code' => null,
'seo_meta' => []
];
private array $fieldDefaults = [
@@ -49,6 +53,7 @@ class FormCleaner
'discord_webhook_url' => "Discord webhook disabled.",
'editable_submissions' => 'Users will not be able to edit their submissions.',
'custom_code' => 'Custom code was disabled',
'seo_meta' => 'Custom code was disabled',
// For fields
'file_upload' => "Link field is not a file upload.",
@@ -202,6 +207,9 @@ class FormCleaner
// Get value from form
$formVal = Arr::get($data, $key);
// Transform customkeys values
$formVal = $this->cleanCustomKeys($key, $formVal);
// Transform boolean values
$formVal = (($formVal === 0 || $formVal === "0") ? false : $formVal);
$formVal = (($formVal === 1 || $formVal === "1") ? true : $formVal);
@@ -242,4 +250,20 @@ class FormCleaner
}*/
}
// Remove keys those have empty value
private function cleanCustomKeys($key, $formVal)
{
if (in_array($key, $this->customKeys) && $formVal !== null) {
$newVal = [];
foreach ($formVal as $k => $val) {
if ($val) {
$newVal[$k] = $val;
}
}
return $newVal;
}
return $formVal;
}
}