You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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();
}