plugin_file = $plugin_file; // Initialize logger and rate limiter. $this->logger = new Logger(); $this->rate_limiter = new Rate_Limiter( $this->logger ); // Initialize configuration and factory. $this->config = new Config( $this->logger ); $this->client_factory = new S3_Client_Factory( $this->config ); // Initialize components with dependency injection. $this->admin_page = new Admin_Page( $this->config, $this->client_factory, $this->logger, $this->rate_limiter, $plugin_file ); $this->media_uploader = new Media_Uploader( $this->config, $this->client_factory, $this->logger ); $this->url_rewriter = new URL_Rewriter( $this->config ); } /** * Get the singleton instance. * * @since 0.3.0 * * @param string $plugin_file Path to the main plugin file. * @return Plugin The singleton instance. */ public static function get_instance( string $plugin_file ): Plugin { if ( null === self::$instance ) { self::$instance = new self( $plugin_file ); } return self::$instance; } /** * Initialize the plugin by registering all hooks. * * @since 0.3.0 * * @return void */ public function init(): void { // Load text domain for translations. add_action( 'plugins_loaded', array( $this, 'load_textdomain' ), 20 ); // Register component hooks. $this->admin_page->register(); $this->media_uploader->register(); $this->url_rewriter->register(); } /** * Load the plugin text domain for translations. * * Registers the plugin's text domain so that translation files in the * /languages directory are loaded on the front end and in the admin. * * @since 0.3.0 * * @return void */ public function load_textdomain(): void { load_plugin_textdomain( 'idrivee2-media-upload', false, dirname( plugin_basename( $this->plugin_file ) ) . '/languages' ); } }