/ and has a module.php that returns its metadata: * * return array( * 'name' => 'Customer Manager', * 'description' => 'What it does, shown on the settings screen.', * 'category' => 'customers', // customers | orders | checkout | reports | marketing * 'class' => 'Bylt_Customer_Manager', * 'file' => 'class-customer-manager.php', * 'requires' => array(), // other module slugs * 'default' => false, // enabled on first install? * ); * * The class file is only loaded when the module is enabled, so a disabled * module adds no hooks, scripts or queries. * * @package BYLTCommerce */ defined( 'ABSPATH' ) || exit; abstract class Bylt_Module { /** @var string */ protected $slug; /** @var array */ protected $meta; public function __construct( $slug, array $meta ) { $this->slug = $slug; $this->meta = $meta; } /** * Register hooks. Called once, only when the module is enabled. */ abstract public function init(); public function slug() { return $this->slug; } public function name() { return $this->meta['name']; } public function dir( $path = '' ) { $base = ! empty( $this->meta['path'] ) ? trailingslashit( $this->meta['path'] ) : BYLT_DIR . 'modules/' . $this->slug . '/'; return $base . ltrim( $path, '/' ); } public function url( $path = '' ) { $base = ! empty( $this->meta['url'] ) ? trailingslashit( $this->meta['url'] ) : BYLT_URL . 'modules/' . $this->slug . '/'; return $base . ltrim( $path, '/' ); } public function is_pro() { return ! empty( $this->meta['pro'] ); } /** * Write to the shared audit log, tagged with this module. */ protected function log( $action, $message, $object_type = '', $object_id = 0 ) { Bylt_Audit_Log::log( $this->slug, $action, $message, $object_type, $object_id ); } }