is there any supported way to add custom admin pages (or views) from a plugin to the default booty admin theme (next to the "plugin configuration" pages)?
I couldn't found a working solution, and it seems impossible due to the "Sanitize::pathFile" check, which prevents Symbolic links. (So at least it doesn't work by changing the global "$layout" variable using the "beforeAdminLoad" hook.).
My current solution uses a regular expression to inject my own admin page:
Code: Select all
<?php
class MyPlugin extends Plugin{
/*
| HOOK :: ADD PAGE TO ADMIN SIDEBAR
| @since 0.1.0
*/
public function adminSidebar(){
return '<a href="' . HTML_PATH_ADMIN_ROOT . 'my-admin-page">My Admin Page</a>';
}
/*
| HOOK :: BEFORE ADMIN CONTENT
*/
public function adminBodyBegin(){
if(!$this->isMyAdmin){
// The current view isn't my plugin admin page
return false;
}
ob_start();
}
/*
| HOOK :: AFTER ADMIN CONTENT
*/
public function adminBodyEnd(){
if(!$this->isMyAdmin){
// The current view isn't my plugin admin page
return false;
}
$content = ob_get_contents();
ob_end_clean();
// Load my AdminPage
ob_start();
include("system/admin.php");
$add = ob_get_contents();
ob_end_clean();
// Inject Code
$regexp = "#(\<div class=\"col-lg-10 pt-3 pb-1 h-100\"\>)(.*?)(\<\/div\>)#s";
$content = preg_replace($regexp, "$1{$add}$3", $content);
print($content);
}
}
?>
Sincerely,
Sam.