Child pages
  • Tutorial - Create a New WHM Interface in PHP
Skip to end of metadata
Go to start of metadata

Introduction

This tutorial uses PHP to create a new WHM interface. The examples below create a new interface that integrates seamlessly with the look and feel of the main WHM interface. 

Important:

This tutorial requires cPanel & WHM version 66 or later. Earlier versions of cPanel & WHM do not include PHP access to the WHM chrome.

Create a new WHM interface


Access the PHP library.

To begin a PHP plugin interface, add the following header:

<?php
 require_once('/usr/local/cpanel/php/WHM.php');
?>

This header accesses WHM's PHP library in the /usr/local/cpanel/php/WHM.php file.

 


 

Retrieve the WHM header.

You can use two different methods to retrieve the WHM header:

Important:

The code examples below only use this method to display the WHM header. 

In cPanel & WHM version 66 and later, to directly display WHM's header, your code should resemble the following example:

<?php
 require_once('/usr/local/cpanel/php/WHM.php');
    WHM::header('Example Plugin Interface',0,0); 
?>

Line 3 passes the following values:

  • The first passed value sets the interface's title.
  • The second passed value sets the skipsupport parameter to 0.
  • The third passed value sets the skipheader parameter to 0.

For more information and additional options, read our Guide to WHM Plugins - Interfaces documentation.

Important:

When you develop WHM interfaces in PHP, you cannot specify values for other header parameters. To modify these parameters, you must use Template Toolkit to develop your interface.

Important:

The code examples below do not use this method to display the WHM header. 

In cPanel & WHM version 70 and later, to retrieve WHM's header as a string, your code should resemble the following example:

<?php
 require_once('/usr/local/cpanel/php/WHM.php');
 $headerString = WHM::getHeaderString("Example Plugin Interface",0,0);
 echo($headerString);
?>

Line 3 passes the following values:

  • The first passed value sets the interface's title.
  • The second passed value sets the skipsupport parameter to 0.
  • The third passed value sets the skipheader parameter to 0.

For more information and additional options, read our Guide to WHM Plugins - Interfaces documentation.

Important:

When you develop WHM interfaces in PHP, you cannot specify values for other header parameters. To modify these parameters, you must use Template Toolkit to develop your interface.

 


 

Add content.

Add the desired interface contents below the header.

<?php
 require_once('/usr/local/cpanel/php/WHM.php');
    WHM::header('Example Plugin Interface',0,0); 
?>
 
// Add content here.

 


 

Add the WHM footer.

You can use two different methods to retrieve the WHM header:

In cPanel & WHM version 66 and later, to directly display WHM's footer, your code should resemble the following example:

<?php
 require_once('/usr/local/cpanel/php/WHM.php');
    WHM::header('Example Plugin Interface',0,0); 
?>

// Add content here.
 
<?php
    WHM::footer(); 
?>

For more information, read our Guide to WHM Plugins - Interfaces documentation.

In cPanel & WHM version 70 and later, to retrieve WHM's footer as a string, your code should resemble the following example:

<?php
 require_once('/usr/local/cpanel/php/WHM.php');
    WHM::header('Example Plugin Interface',0,0); 
?>

// Add content here.
 
<?php
    $footerString = WHM::getFooterString();
    echo($footerString);
?>

For more information, read our Guide to WHM Plugins - Interfaces documentation.