This article is about creating custom made pages within a Plugin, to increase or personalize the page. A Public Page is known for its multiuse functionality.
Adding to Plugin Constructor
The public page is defined in the plugin constructor and afterwards as a function within the specific plugin.
public function __construct()
{
$this->slug = "test_plugin";
$this->id = "test_plugin";
$this->title = "Test Plugin with Public Page";
$this->image = "https://gcdn.ippeurope.com/wp-content/uploads/IPPeurope-logo-dark.png";
$this->setFields();
$plugin_fields = $this->getFields();
$this->public_pages = [
"page_one",
"page_two"
];
}
protected function pages_page_one($REQ)
When adding a public page, the underlaying function is started with pages_ to define we are initializing the pages functionality, followed by the page slug. In our Example Constructor there are two public pages defined as page_one and page_two.
$REQ
The Request parameter ($REQ) contains all available parameters from the POST or GET that initialized the visit for the page.
The REQ have been validated for invaliding requests before it is being served.
The URL for a public page
The URL for a public page is defined with two parameters. Pages and Page.
Pages define the Plugin of Question.
Page define the public page and function of the Request
https://MerchantPortal/?pages=test_plugin&page=page_one
Use of Theme header and Footer in Public Pages
Public Pages are as standard served without the Theme Frames enabled, due to why you will need manually to enable these.
Within the function you need to add:
protected function pages_page_one($REQ) {
require_once(THEME."/partner/head.php");
require_once(THEME."/partner/foot.php");
echo head();
echo "My Custom Page";
echo foot();
}