Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if the hook is present before adding it #160

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions gsitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,17 @@ public function install()
}

/**
* Registers hook(s)
* Check if the hook is present in the system or add it
*
* @return bool
*/
protected function installHook()
{
$hook = new Hook(Hook::getIdByName(self::HOOK_ADD_URLS));
if (Validate::isLoadedObject($hook)) {
return true;
}

$hook = new Hook();
$hook->name = self::HOOK_ADD_URLS;
$hook->title = 'GSitemap Append URLs';
Expand Down Expand Up @@ -151,11 +156,6 @@ public function uninstall()
}
}

$hook = new Hook(Hook::getIdByName(self::HOOK_ADD_URLS));
if (Validate::isLoadedObject($hook)) {
$hook->delete();
}

return parent::uninstall() && $this->removeSitemap();
}

Expand Down