Php 向活动自定义菜单项WHMCS添加类
我正在为WHMC使用PayPal计费网关,并在钩子文件中使用以下内容将菜单项添加到ClientAreaPrimaryNavbar和ClientAreaSecondary侧边栏:Php 向活动自定义菜单项WHMCS添加类,php,menu,hook,whmcs,Php,Menu,Hook,Whmcs,我正在为WHMC使用PayPal计费网关,并在钩子文件中使用以下内容将菜单项添加到ClientAreaPrimaryNavbar和ClientAreaSecondary侧边栏: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar-&
<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) {
if (!is_null($primaryNavbar->getChild('Billing'))) {
$primaryNavbar->getChild('Billing')->addChild('Manage PayPal Billing', array(
'label' => 'Manage PayPal Billing',
'uri' => 'paypalbilling.php',
'order' => '30'
));
}
});
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
if (!is_null($secondarySidebar->getChild('Billing'))) {
$secondarySidebar->getChild('Billing')->addChild('Manage PayPal Billing', array(
'label' => 'Manage PayPal Billing',
'uri' => 'paypalbilling.php',
'order' => '30'
));
}
});
我已经找到了如何使用当前页面将类添加到子菜单,但仍然无法将类添加到主ClientAreaPrimaryNavbar
账单菜单
我尝试了$primaryNavbar->getChild('Billing')->setClass('active')代码>但它似乎不起作用
以下是用于检查当前页面并使用“活动”类设置新菜单项的代码:
我已经找到了如何使用当前页面将类添加到子菜单,但仍然无法将类添加到主ClientAreaPrimaryNavbar
账单菜单
我尝试了$primaryNavbar->getChild('Billing')->setClass('active')代码>但它似乎不起作用
以下是用于检查当前页面并使用“活动”类设置新菜单项的代码:
<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) {
$filename = basename($_SERVER['REQUEST_URI'], ".php");
$parseFile = explode('.', $filename);
if (!is_null($primaryNavbar->getChild('Billing'))) {
$primaryNavbar->getChild('Billing')->addChild('Manage PayPal Billing', array(
'label' => 'Manage PayPal Billing',
'uri' => 'paypalbilling.php',
'order' => '30'
));
if ($parseFile['0']=='paypalbilling'){
$primaryNavbar->getChild('Billing')->setClass('active'); // THIS LINE DOES NOT WORK
$primaryNavbar->getChild('Billing')->getChild('Manage PayPal Billing')->setClass('active');
}
}
});
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
$filename = basename($_SERVER['REQUEST_URI'], ".php");
$parseFile = explode('.', $filename);
if (!is_null($secondarySidebar->getChild('Billing'))) {
$secondarySidebar->getChild('Billing')->addChild('Manage PayPal Billing', array(
'label' => 'Manage PayPal Billing',
'uri' => 'paypalbilling.php',
'order' => '30'
));
if ($parseFile['0']=='paypalbilling'){
$secondarySidebar->getChild('Billing')->getChild('Manage PayPal Billing')->setClass('active');
}
}
});