Editing WHMCS Menu and Sidebar Social Link

 We can add or edit the WHMCS menu.

Here is some examples explained:

1) Remove Affiliates menu

/includes/hooks/

Create a new file (example: removeAffiliatesMenu.php)

Add the below content in the file

<?php
#removing Affiliates menu from primaryNavbar
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    if (!is_null($primaryNavbar->getChild('Affiliates'))) {
        $primaryNavbar->removeChild('Affiliates');
    }
});

 

2) Add a new menu link to primary navbar (header menu left-side)

/includes/hooks/

Create a new file (example: addExampleSiteLink.php)

Add the below content in the file

<?php
// Add a new menu link on primary navbar
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{

    if($primaryNavbar->count() > 0)
    {
        $primaryNavbar->addChild('ExampleSite')
            // Set menu-position (optional)
            #->setOrder(100)
            ->setUri('http://example.com')
            ->setAttribute("target", '_blank');
    }


});

 

3) Add a new menu link to secondary navbar (header menu right-side)

/includes/hooks/

Create a new file (example: addExampleSiteLink.php)

Add the below content in the file

<?php
// Add a new menu link on secondary navbar
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{

    if($secondaryNavbar->count() > 0)
    {
        $secondaryNavbar->addChild('ExampleSite')
            // Set menu-position (optional)
            #->setOrder(100)
            ->setUri('http://example.com')
            ->setAttribute("target", '_blank');
    }


});


4) Menu item name change

/lang/english.php

Line 256,262,406,746,1312,1635,1648,2143,2159

 

5)  Add a Credit Balance box in client area

/includes/hooks/

Create a new file (example: clientCreditBalance.php)

Add the below content in the file

<?php

use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;

add_hook( 'ClientAreaPrimarySidebar', 1, function ( MenuItem $primarySidebar ) {

    $client = Menu::context( "client" );

    if ( $_SERVER['SCRIPT_NAME'] !== '/clientarea.php' || intval( $client->id ) === 0 ) {
        return;
    }

    $primarySidebar->addChild( 'Client-Balance', array(
        'label' => "My Credit Balance",
        'uri'   => '#',
        'order' => '1',
        'icon'  => 'fa-solid fa-sack-dollar'
    ) );

    $getCurrency = Capsule::table( 'tblcurrencies' )->where( 'id', $client->currency )->get();

    $balancePanel = $primarySidebar->getChild( 'Client-Balance' );

    $balancePanel->moveToBack();
    $balancePanel->setOrder( 0 );

    $balancePanel->addChild( 'balance-amount', array(
        'uri'   => 'clientarea.php?action=addfunds',
        'label' => '<h4 style="text-align:center;">' . $getCurrency['0']->prefix . $client->credit . ' ' . $getCurrency['0']->suffix . '</h4>',
        'order' => 1
    ) );

    $balancePanel->setFooterHtml(
        '<a href="clientarea.php?action=addfunds" class="btn btn-success btn-sm btn-block">
            <i class="fa fa-plus"></i> Add Funds
        </a>'
    );

} );

 

6) Add a social media panel in client area

/includes/hooks/

Create a new file (example: socialMediaPanel.php)

Add the below content in the file

<?php
 
use WHMCS\View\Menu\Item as MenuItem;
 
// Add social media links to the end of all secondary sidebars.
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)

{

    $client = Menu::context( "client" );
    if ( $_SERVER['SCRIPT_NAME'] !== '/clientarea.php' || intval( $client->id ) === 0 ) {
        return;
    }

// Add a panel to the end of the secondary sidebar for social media links.
    // Declare it with the name "social-media" so we can easily retrieve it
    // later.
    $secondarySidebar->addChild('social-media', array(
        'label' => 'Social Media',
        'uri' => '#',
        'icon' => 'fas fa-thumbs-up',
    ));
 
    // Retrieve the panel we just created.
    $socialMediaPanel = $secondarySidebar->getChild('social-media');
 
    // Move the panel to the end of the sorting order so it's always displayed
    // as the last panel in the sidebar.
    $socialMediaPanel->moveToBack();
 
    // Add a Facebook link to the panel.
    $socialMediaPanel->addChild('facebook-link', array(
        'uri' => 'http://facebook.com/wholesaleservers',
        'label' => 'Like us on Facebook !',
        'order' => 1,
        'icon' => 'fab fa-facebook-f fa-fw',
    ));
 
    // Add a YouTube link to the panel after the Facebook link.
    $socialMediaPanel->addChild('youtube-link', array(
        'uri' => 'http://youtube.com/@wholesaleservers',
        'label' => 'Subscribe us on YouTube !',
        'order' => 2,
        'icon' => 'fab fa-youtube fa-fw',
    ));
});

 

7)  Add some links to footer

/templates/six/footer.tpl

Create some knowledgebase articles for legal terms, privacy, etc.

And replace Footer Copyright

<p><span>{lang key="copyrightFooterNotice" year=$date_year company=$companyname}</span><span>&nbsp;</span><span><a href="{$WEB_ROOT}/">Home</a></span><span>|</span><span><a href="{$WEB_ROOT}/knowledgebase.php?action=displayarticle&id=1">Privacy Policy</a></span><span>|</span><span><a href="{$WEB_ROOT}/knowledgebase.php?action=displayarticle&id=2">Payment & Refund Policy</a></span><span>|</span><span><a href="{$WEB_ROOT}/knowledgebase.php?action=displayarticle&id=3">Acceptable Use Policy</a></span><span>|</span><span><a href="{$WEB_ROOT}/knowledgebase.php?action=displayarticle&id=4">Terms of Service</a></span></p>


Done !

Post a Comment