run(); } /** * Builds the object graph. Constructors are free of side effects. * * @since 1.0.0 */ private function __construct() { $this->settings = new Settings(); $this->capabilities = new Capabilities(); $this->registry = new Module_Registry( $this->settings ); $this->upgrader = new Upgrader(); } /** * Registers hooks, registers and boots the modules. * * @since 1.0.0 * * @return void */ private function run(): void { add_action( 'init', array( $this->settings, 'register' ) ); add_action( 'init', array( $this->upgrader, 'maybe_upgrade' ), 5 ); require_once __DIR__ . '/template-functions.php'; $this->capabilities->hooks(); ( new Rewrite_Rules( $this->settings ) )->hooks(); if ( defined( 'WP_CLI' ) && WP_CLI ) { \WP_CLI::add_command( 'elevenrank', new CLI\Root_Command() ); } $gate = new Output_Gate( $this->settings, new Conflicts() ); $this->registry->register( new Settings_Module( $this->settings, $gate ), true ); $this->registry->register( new Meta_Module( $this->settings, $gate ), true ); $this->registry->register( new Import_Module( $this->settings ), true ); $this->registry->register( new Analysis_Module( $this->settings ) ); $this->registry->register( new Sitemap_Module( $this->settings, $gate ) ); $this->registry->register( new Robots_Module( $this->settings, $gate ) ); $this->registry->register( new Breadcrumbs_Module( $this->settings ) ); $this->registry->register( new Images_Module( $this->settings, $gate ) ); $this->registry->register( new Schema_Module( $this->settings, $gate ) ); $this->registry->register( new Redirects_Module( $this->settings, $gate ) ); $this->registry->register( new Monitor404_Module( $this->settings, $gate ) ); $this->registry->register( new Tools_Module( $this->settings, $gate, $this->registry ), true ); $this->registry->register( new Admin_Module( $gate, $this->registry ), true ); /** * Lets add-ons register their own modules before any module boots. * * @since 1.0.0 * * @param Module_Registry $registry The module registry. */ do_action( 'elevenrank_register_modules', $this->registry ); $this->registry->boot(); /** * Fires once ElevenRank and all active modules are booted. * * @since 1.0.0 */ do_action( 'elevenrank_loaded' ); } }