souzadavi Posted April 20, 2020 Share Posted April 20, 2020 Hello guys, I would like to developed a new module command button inside of cPanel server module. I attached under here a image to see where I would like to have a new button. I didn't figured out how to create it, please any one know could get it done? I would like only some directions to get it done... thanks 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted April 20, 2020 Share Posted April 20, 2020 (edited) It depends on that you want to do with that button. In fact you can't add in the usual way (cPanel module is not open source) so you'll need to use jQuery in an action hook like follows. <?php add_hook('AdminAreaHeaderOutput', 1, function($vars) { $output .= <<<HTML <script type="text/javascript"> $(document).ready(function(){ $("#modcmdbtns").append(' <button type="button" class="btn btn-danger"><i class="fa fa-shower" aria-hidden="true"></i> Bath Time</button>'); }); </script> HTML; return $output; }); Here's the result: Attachments not working... well... the code adds a red button right after the last button "Change Password" Edited April 21, 2020 by Kian 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted April 21, 2020 Share Posted April 21, 2020 Okay now it's working. Here's the result. 0 Quote Link to comment Share on other sites More sharing options...
souzadavi Posted April 21, 2020 Author Share Posted April 21, 2020 Thanks very much to replied... I would like to set a button to install automatic WordPress site from Softaculous clone process.https://www.softaculous.com/docs/api/api/#clone-an-installed-script The PHP function to create the button action should I call from jquery also? Or there is another better way to do? thanks. 0 Quote Link to comment Share on other sites More sharing options...
souzadavi Posted April 21, 2020 Author Share Posted April 21, 2020 I'using another hook, my script is like that: add_hook('AdminClientServicesTabFields', 1, function($vars) { $id = $vars['id']; $output .= <<<HTML <script src='/assets/js/softaculous_clone.js'></script> <script type="text/javascript"> $(document).ready(function(){ $("#modcmdbtns").append(' <button type="button" class="btn btn-danger" onclick="softaculous_clone($id);" id="btnCloneSoftaculous"><i class="fa fa-wordpress" aria-hidden="true"></i> Clone WP</button>'); }); </script> HTML; echo $output; }); My guess is about the .js file, how could it does to be safe. I`m trying to use customs function, to call the php function, but i'm not sure if is the right way. function softaculous_clone(idService){ var data = { id: idService, modop: "custom", a: "softaculous_clone", } var request = new XMLHttpRequest(); request.open('POST', '/clientarea.php?action=productdetails', true); request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); request.onload = function() { if (request.status >= 200 && request.status < 400) cb(request.responseText); else console.log(1, 'Houve um erro :('); }; request.onerror = function() { console.log(2, 'Houve um erro :('); }; request.send(data); } thanks, any information will be very appreciated. 0 Quote Link to comment Share on other sites More sharing options...
souzadavi Posted April 21, 2020 Author Share Posted April 21, 2020 @Kian I didn't find a way to call a php file safely from ajax. On the button I tried to use the function runModuleCommand but it doesn't find the softaculous function. onclick="runModuleCommand('custom','softaculousclone')"I I think because the function isnt on cpanel server modules. So do you know how can I call a ajax php function from that button "Bath Time" safe? thanks 0 Quote Link to comment Share on other sites More sharing options...
souzadavi Posted April 24, 2020 Author Share Posted April 24, 2020 I get it done with the resource: https://www.softaculous.com/docs/api/api/#import-an-installation-from-remote-server If somebody need the script i can send it, let me know.. PS.: the whmcs oficial ticket support team never help is really bad! 0 Quote Link to comment Share on other sites More sharing options...
Mas-J Posted April 16, 2021 Share Posted April 16, 2021 On 4/25/2020 at 4:46 AM, souzadavi said: I get it done with the resource: https://www.softaculous.com/docs/api/api/#import-an-installation-from-remote-server If somebody need the script i can send it, let me know.. PS.: the whmcs oficial ticket support team never help is really bad! Hi @souzadavi can you share the script ? I need to modify for another function to calling some value from database & show it on products/services page 🙂 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.