-
Notifications
You must be signed in to change notification settings - Fork 5
Register Admin class
ecorica edited this page Jul 23, 2021
·
1 revision
If you need to load methods only in the back office (add columns in a list view). You can add a class (Main.php) that will be loaded only in the admin.
For a better readability you have to create an Admin folder and add your class inside.
- Create your Main class in the Admin folder
<?php
namespace BEA\PB\Admin;
use BEA\PB\Singleton;
/**
* Basic class for Admin
*
* Class Main
* @package BEA\PB\Admin
*/
class Main {
/**
* Use the trait
*/
use Singleton;
public function init(): void {
}
}
- Instantiate your class in the plugins_loaded method of the root php file.
// Admin
if ( is_admin() ) {
\BEA\PB\Admin\Main::get_instance();
}