Skip to content

Commit

Permalink
Merge pull request #160 from Hlavtox/add-hook-condition
Browse files Browse the repository at this point in the history
Check if the hook is present before adding it
  • Loading branch information
Hlavtox committed Sep 18, 2023
2 parents fbbf7be + af82d38 commit eb8a874
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gsitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,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 @@ -161,11 +166,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

0 comments on commit eb8a874

Please sign in to comment.