Created
December 15, 2015 21:53
-
-
Save klaude/e1e69b9d482d3a9879b5 to your computer and use it in GitHub Desktop.
Revisions
-
klaude created this gist
Dec 15, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ <?php /** * Add Modules Garden's Unban Center module's sidebar menu items without having * to create or modify template files. * * @see http://docs.whmcs.com/Editing_Client_Area_Menus */ add_hook('ClientAreaPage', 1, function ($templateVariables) { // Look for the Unban Center's $hasUnban template variable. If it's not // defined then the Unban Center might might not be loaded. $hasUnban = isset($templateVariables[0]['hasUnban']) ? (bool) $templateVariables[0]['hasUnban'] : false; /** @var \WHMCS\View\Menu\Item $secondarySidebar */ $secondarySidebar = Menu::secondarySidebar(); $myServicesActions = $secondarySidebar->getChild('My Services Actions'); // Don't modify the secondary sidebar if the Unban Center module isn't // loaded, if the secondary sidebar doesn't exist, or if the "My Services // Actions" panel in the secondary sidebar doesn't exist. if (!$hasUnban || is_null($secondarySidebar) || is_null($myServicesActions)) { return []; } // Determine the contents of the "Unban IP Address" menu item. $uri = 'index.php?m=unbanCenter'; if (isset($templateVariables[0]['unbanId'])) { $uri .= "&id={$templateVariables[0]['unbanId']}"; } $label = isset($templateVariables[0]['mglang']) ? $templateVariables[0]['mglang']->_('integrationbtn') : 'Unban Your IP Address'; // Add the "Unban IP Address" menu item to the secondary sidebar's "My // Services Actions" panel. $unbanIpAddress = $myServicesActions->addChild( 'Unban Center', [ 'uri' => $uri, 'icon' => 'fa-unlock', 'label' => $label, ] ); $unbanIpAddress->moveToBack(); // Re-assign the secondary sidebar to the template. return ['secondarySidebar' => $secondarySidebar]; });