jmtech Posted December 4, 2016 Share Posted December 4, 2016 Hi all, I'm planning on using Wordpress for my KB and News articles and as such will be branding my Wordpress site the same as my WHMCS. I am planning on dynamically generating my Wordpress menu based on the WHMCS menu so I only need to update it in one place. The problem I have is enumerating through the list of menu items defined in WHMCS as there appears to be no API for Navigation. Any ideas on the best way to get this info out of WHMCS? Cheers, Jason Link to comment Share on other sites More sharing options...
pablobaldovi Posted December 5, 2016 Share Posted December 5, 2016 Hi Jason, The menu is a object You can use it in any whmcs. Here is de Doc: http://docs.whmcs.com/Editing_Client_Area_Menus try this code inside any add-on echo "<pre>"; var_dump(Menu::primaryNavbar()); echo "</pre>"; its a start Link to comment Share on other sites More sharing options...
jmtech Posted December 5, 2016 Author Share Posted December 5, 2016 Hi Jason, The menu is a object You can use it in any whmcs. Here is de Doc: http://docs.whmcs.com/Editing_Client_Area_Menus try this code inside any add-on echo "<pre>"; var_dump(Menu::primaryNavbar()); echo "</pre>"; its a start Thanks for that - I'm quite familiar with using and customising the menu objects within WHMCS - however, I'm trying to get access to the object from within Wordpress (outside of WHMCS). Some options that I have. - Scrape the HTML from WHMCS. This would involve getting the HTML for the home page and searching for an element ID for the menu container and getting the inner HTML. - Include WHMCS in Wordpress. Given my wordpress install is in the same physical location as WHMCS, I could try and find and include the relevant PHP file/s to include to gain access to the menu objects from within Wordpress. - Create an Addon to expose the Menu. I could create an addon that presents the menu as a public JSON endpoint. - Manually replicate the menu. Given the menu doesn't change very often, I could just manually update it in Wordpress when it changes. - Control the menu from Wordpress. I've done this before - I could include wp_load.php in WHMCS and then dynamically generate the WHMCS menu based on the Wordpress menu. Anyone know what the equivalent of wp-load.php is for WHMCS? Would save me some time trying to figure it out, if it's at all possible. Cheers, Jason Link to comment Share on other sites More sharing options...
pablobaldovi Posted December 6, 2016 Share Posted December 6, 2016 (edited) You can make a kind of "diy api" by creating an addon for whmcs that returns the menu structure in xml or son. That file you would call it from wordpress. Edited December 7, 2016 by pablobaldovi Link to comment Share on other sites More sharing options...
jmtech Posted February 23, 2018 Author Share Posted February 23, 2018 Hi all, Just thought I would update if anyone was interested. I decided to do it the other way round. I have my wordpress site as the main site and I load my Wordpress menu within WHMCS. I have then customised my WHMCS template to match my Wordpress site. Here's how I get my WHMCS menu to match my Wordpress menu. Basically I start by removing all the standard WHMCS menu items. Then I iterate through all the wordpress menu items and add them to WHMCS. // ----- Main Nav Bar ----- add_hook('ClientAreaNavbars', 1, function () { require("../pathToWordpress/wp-load.php"); $wpMenu = wp_get_nav_menu_items('Top Menu'); // Get the current navigation bars. $primaryNavbar = Menu::primaryNavbar(); $secondaryNavbar = Menu::secondaryNavbar(); // Remove unecessary menu items $primaryNavbar->removeChild('Announcements'); $primaryNavbar->removeChild('Knowledgebase'); $primaryNavbar->removeChild('Network Status'); $primaryNavbar->removeChild('Home'); $primaryNavbar->removeChild('Store'); $primaryNavbar->removeChild('Contact Us'); $order = 1; foreach($wpMenu as $item) { $primaryNavbar->addChild($item->title) ->setUri($item->url) ->setOrder($order); $order++; } } Link to comment Share on other sites More sharing options...
Recommended Posts