Starting from Plesk 12.0, there is an easy way to add custom buttons related to an extension. Previously, extension developers had to use CLI or XML API calls in post-install and pre-uninstall scripts for creating custom buttons.
To add custom buttons, you need to develop a class derived from pm_Hook_CustomButtons. The class must be placed in the directory plib/hooks/
. You can find the complete list of supported values for 'place' under 'Constants'.
The following example shows how to add several custom buttons:
class Modules_CustomButtons_CustomButtons extends pm_Hook_CustomButtons
{
public static function getButtons()
{
return [[
'place' => self::PLACE_DOMAIN,
'title' => 'Domain Button',
'description' => 'Description for domain button',
'icon' => pm_Context::getBaseUrl() . 'images/icon.png',
'link' => pm_Context::getBaseUrl() . 'index.php/index/index',
], [
'place' => [
self::PLACE_HOSTING_PANEL_NAVIGATION,
self::PLACE_ADMIN_TOOLS_AND_SETTINGS,
self::PLACE_RESELLER_TOOLS_AND_SETTINGS,
],
'title' => 'Multi Place Button',
'description' => 'Description for multi place button',
'link' => 'http://plesk.com/',
'newWindow' => true,
]];
}
}
You can set up custom buttons in the following places:
One button can be set up for multiple places at once. In some places, you can use such optional parameters as icon
and description
. You can specify both local and external hyperlinks.
You can find the sample code in our repository here.