*/ private const SCHEDULED_HOOKS = array( 'twootwocode_zsf_event_retention_cleanup', 'twootwocode_zsf_quarantine_retention_cleanup', ); /** * Run uninstall cleanup when the admin opted into data removal. */ public static function uninstall(): void { $settings = ( new SettingsRepository() )->get_settings(); self::clear_scheduled_hooks(); if ( empty( $settings['delete_data_on_uninstall'] ) ) { return; } self::delete_known_plugin_options(); } /** * Delete only known plugin-owned options. */ public static function delete_known_plugin_options(): void { if ( ! function_exists( 'delete_option' ) ) { return; } foreach ( self::get_known_option_names() as $option_name ) { delete_option( $option_name ); } } /** * Clear only plugin-owned scheduled hooks. */ public static function clear_scheduled_hooks(): void { if ( ! function_exists( 'wp_clear_scheduled_hook' ) ) { return; } foreach ( self::SCHEDULED_HOOKS as $hook_name ) { wp_clear_scheduled_hook( $hook_name ); } } /** * Get known plugin-owned option names. * * @return array */ public static function get_known_option_names(): array { return array( SettingsRepository::OPTION_NAME, OptionEventStore::OPTION_NAME, ); } }