Jump to content

Adding Links to Shortcut Area


mrTodd

Recommended Posts

Can anyone direct me how to modify this code to add the customers domain name into a link?

For example, ALL my customers have some sort of hosting plan. NOT all have domains with me. Additionally, ALL have a Wordpress website with me that we help maintain for them.

I want to add a link into this shortcut area that will take them directly to their wp-admin page, so https://theirdomainname.com/wp-admin

I found this Social Media code and it works perfectly for what I want, I just need it to only show up if they are logged in AND a way to get their domain name from whmcs. Is there a {$domain-name} variable or some such? How would I format that to achieve {$domain-name}/wp-admin ??

THANK YOU very much for any help or direction you can provide.

Here is the code I found on whmcs to add the links in the shortcuts area:

<?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)
{
    // 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' => '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' => 'https://facebook.com/our-great-company',
        'label' => 'Like us on Facebook!',
        'order' => 1,
        'icon' => 'fa-facebook',
    ));

    // Add a Twitter link to the panel after the Facebook link.
    $socialMediaPanel->addChild('twitter-link', array(
        'uri' => 'https://twitter.com/ourgreatcompany',
        'label' => 'Follow us on Twitter!',
        'order' => 2,
        'icon' => 'fa-twitter',
    ));

    // Add a Google+ link to the panel after the Twitter link.
    $socialMediaPanel->addChild('google-plus-link', array(
        'uri' => 'https://plus.google.com/1234567890123456',
        'label' => 'Add us to your circles!',
        'order' => 3,
        'icon' => 'fa-google-plus',
    ));
});
Link to comment
Share on other sites

16 hours ago, mrTodd said:

For example, ALL my customers have some sort of hosting plan. NOT all have domains with me. Additionally, ALL have a Wordpress website with me that we help maintain for them.

are you looking to add this side to the products detail page, or if not, do any of your clients have more than one hosting/WP product?

Link to comment
Share on other sites

16 hours ago, mrTodd said:

I'd like it to show up in the client area basically in the same spot/area and at same times as the login info for cPanel is visible.

so you could use a tweaked version of the hook I posted in the thread below...

<?php

use WHMCS\View\Menu\Item as MenuItem;

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

$service = Menu::context('service');    
$domain = $service->domain;
$servertype = $service->product->servertype;

# Not cPanel, no links added
   if ($servertype!="cpanel"){
       return;
   }

   if (!is_null($primarySidebar->getChild('Service Details Actions'))) {
            $primarySidebar->getChild('Service Details Actions')
			->addChild('wplink', array(
			'label' => 'Link To WordPress',
			'uri' => 'https://'.$domain.'/wp-admin',
			'order' => 200,
			));
   }
});

hyyMMmd.png

so this hook cheats in two respects - firstly, it doesn't check that the client is logged in, but works on the fact that they can't see this existing sidebar unless they are logged in and viewing the product details page... you could easily add such detection in, it's trivially easy and there are plenty of example hooks that do that here in the forums.

the second is that this link will apply to all cPanel products... if you say that currently they ALL have a WordPress page, then this is fine...at some point in the future, if that is no longer the case, you may need to modify the hook to only show for specific products - again, that's a simple query and you can cross that bridge if/when required.

the two parts that you may want to change is the label "Link To WordPress" - as written, it will show that English string in all languages... if you needed it to use a string in the client's language, then you could use...

'label' => Lang::trans('wplinklabel'),

and then you would need to create relevant Language Overrides for that string for each language you use on your site.

the other change is the value of 'order' - at the moment, it's 200 which should place it at the bottom of the sidebar... if you change that value to 0, it will be at the top; if you change it to 1, it will be after the cPanel link; 6 will put it after the webmail link and so on - feel free to experiment with different values to place it in your preferred location.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated