diff --git a/load-post.php b/load-post.php index 1f331be..e6e7e6c 100644 --- a/load-post.php +++ b/load-post.php @@ -1,38 +1,72 @@ . -define( 'SITE_NAME', 'My Amazing Website' ); +/* + * This file describes the website core. + * This file is automagically called after the 'load.php' file. + */ -register_css( 'my-style', 'static/my-style.css' ); +// name of the website +define( 'SITE_NAME', 'WikiCAPTCHA' ); -register_js( 'my-script', 'static/my-script.js' ); +// set the default class for the User retrieved from database +define( 'SESSIONUSER_CLASS', 'User' ); + +// register a custom CSS stylesheet +register_css( 'my-style', 'static/my-style.css' ); + +// register a custom JavaScript +register_js( 'my-script', 'static/my-script.js' ); // register an 'user' role with some permissions register_permissions('user', [ - 'say-hello', + 'backend', ] ); -// register an 'admin' role that it's somehow more than an 'user' -inherit_permissions( 'admin', 'user', [ - 'edit-every-hello', +// register an 'analist' role that it's somehow more than an 'user' +inherit_permissions( 'analist', 'user', [ + 'view-dashboard', 'create-monsters', ] ); -// autoload my classes from my /include directory -// I just have to remember to create classes as 'class-Foo.php' -// then when inside the code I will do: -// $a = new Foo(); -// this function will do the magic and will requires it +/** + * register an 'admin' role that can edit everything + */ +inherit_permissions( 'admin', 'analist', [ + 'edit-all-app', +] ); + +// autoload classes and traits from the 'include' directory spl_autoload_register( function( $missing_class_name ) { - // my class should be there + // the class should be there $path = ABSPATH . "/include/class-{$missing_class_name}.php"; - // if it's really mine, require it + // if the class name ends with 'Trait' just autoload it's class + $suffix = substr( $missing_class_name, -5 ); + if( $suffix === 'Trait' ) { + $missing_class_name = substr( $missing_class_name, 0, -5 ); + } + + // eventually load if valid if( file_exists( $path ) ) { require $path; } } ); -// you may also want to load some yours additional functions +// load some additional functions require ABSPATH . '/include/functions.php';