Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向活动自定义菜单项WHMCS添加类_Php_Menu_Hook_Whmcs - Fatal编程技术网

Php 向活动自定义菜单项WHMCS添加类

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-&

我正在为WHMC使用PayPal计费网关,并在钩子文件中使用以下内容将菜单项添加到ClientAreaPrimaryNavbar和ClientAreaSecondary侧边栏:

<?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');
        }

    }

});