Skip to content

Commit 85f8c0b

Browse files
only remove optimized endpoint file if it was created by the plugin
1 parent 439c9f0 commit 85f8c0b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/class-endpoint-installer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ public function install(): bool
8787

8888
$file_name = $this->get_file_name();
8989

90-
// TODO: Verify contents? Or trust 200 OK response?
91-
9290
/* Attempt to put the file into place if it does not exist already */
9391
if (! is_file($file_name)) {
94-
$success = file_put_contents($file_name, $this->get_file_contents());
95-
if (false === $success) {
92+
$created = file_put_contents($file_name, $this->get_file_contents());
93+
if (! $created) {
9694
return false;
9795
}
9896
}
9997

10098
/* Send an HTTP request to the custom endpoint to see if it's working properly */
10199
$works = self::verify();
102100
if (! $works) {
103-
unlink($file_name);
101+
if (isset($created) && $created) {
102+
unlink($file_name);
103+
}
104104
return false;
105105
}
106106

0 commit comments

Comments
 (0)