-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Studio1902\PeakTools\Updates; | ||
|
||
use Illuminate\Support\Str; | ||
use Illuminate\Support\Facades\File; | ||
use Statamic\UpdateScripts\UpdateScript; | ||
|
||
class UpdateHoneypotField extends UpdateScript | ||
{ | ||
public function shouldUpdate($newVersion, $oldVersion) | ||
{ | ||
return $this->isUpdatingTo('4.4.2'); | ||
} | ||
|
||
public function update() | ||
{ | ||
$view = base_path("resources/views/page_builder/_form.antlers.html"); | ||
|
||
if (File::exists($view)) { | ||
$contents = Str::of(File::get($view)) | ||
->replace('name="{{ honeypot }}"', 'name="{{ honeypot }}" x-model="form.{{ honeypot }}"'); | ||
|
||
File::put($view, $contents); | ||
|
||
$this->console()->info('Added `x-model="form.{{ honeypot }}"` to the honeypot input field in `/views/page_builder/_form.antlers.html`. Update this manually for any other form files you may have.'); | ||
} else { | ||
$this->console()->info('add `x-model="form.{{ honeypot }}"` to the honeypot field in all your form partials.'); | ||
} | ||
} | ||
} |