register(); } public static function getInstance(): self { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } public function register(): void { add_action('admin_notices', [$this, 'render']); add_action('current_screen', [$this, 'maybe_clear_on_plugin_pages']); add_action('wp_ajax_advmo_dismiss_welcome_notice', [$this, 'dismiss']); } /** * The notice's job is to get the user to the plugin screens; once they * arrive on their own, stop showing it everywhere else. */ public function maybe_clear_on_plugin_pages(): void { if (advmo_is_settings_page() && get_option(self::OPTION_KEY)) { delete_option(self::OPTION_KEY); } } public function render(): void { if (!get_option(self::OPTION_KEY) || !current_user_can('manage_options')) { return; } // The plugin's own screens replace admin notices with their own header UI. if (advmo_is_settings_page()) { return; } $settings_url = admin_url('admin.php?page=advmo'); $overview_url = admin_url('admin.php?page=advmo_media_overview'); $is_configured = advmo_get_cloud_provider_key() !== ''; $options = get_option('advmo_settings', []); $auto_offload = !isset($options['auto_offload_uploads']) || (int) $options['auto_offload_uploads'] === 1; ?>
__('Security check failed.', 'advanced-media-offloader')]); } delete_option(self::OPTION_KEY); wp_send_json_success(); } // Prevent cloning of the instance private function __clone() {} // Prevent unserializing of the instance public function __wakeup() {} }