robotstxt-manager/includes/class-robotstxt-manager-plugin.php
2026-08-14 07:55:23 +00:00

92 lines
1.8 KiB
PHP

<?php
/**
* Core plugin class — entry point for the ROBOTSTXT Manager plugin.
*
* @package Robotstxt_Manager
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Robotstxt_Manager_Plugin
*
* Singleton that owns the loader instance and wires up all component hooks.
*/
final class Robotstxt_Manager_Plugin {
/**
* Singleton instance.
*
* @var self|null
*/
private static ?self $instance = null;
/**
* Hook loader.
*
* @var Robotstxt_Manager_Loader
*/
private Robotstxt_Manager_Loader $loader;
/**
* Returns the singleton instance, creating it on the first call.
*
* @return self
*/
public static function get_instance(): self {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor — private to enforce singleton usage.
*/
private function __construct() {
$this->loader = new Robotstxt_Manager_Loader();
$this->define_hooks();
}
/**
* Wires component callbacks into the loader.
*
* @return void
*/
private function define_hooks(): void {
$this->loader->add_action( 'init', $this, 'load_textdomain' );
$admin = new Robotstxt_Manager_Admin();
$settings = new Robotstxt_Manager_Settings();
$installer = new Robotstxt_Manager_Installer();
$admin->register( $this->loader );
$settings->register( $this->loader );
$installer->register( $this->loader );
}
/**
* Loads the plugin text domain for i18n.
*
* @return void
*/
public function load_textdomain(): void {
load_plugin_textdomain(
'robotstxt-manager',
false,
dirname( ROBOTSTXT_MANAGER_BASENAME ) . '/languages'
);
}
/**
* Dispatches all registered hooks to WordPress.
*
* @return void
*/
public function run(): void {
$this->loader->run();
}
}