?CoreError`, e.g. SecretRotator::rotate(). * * @var callable(): ?CoreError */ private $rotate; /** * Constructor. * * @param callable $rotate Rotates the secret; null on success, the error otherwise. * * @phpstan-param callable(): ?CoreError $rotate */ public function __construct( callable $rotate ) { $this->rotate = $rotate; } /** * Registers the handler. */ public function register(): void { add_action( 'admin_post_' . AdminAction::hook_name( self::ACTION ), array( $this, 'handle' ) ); } /** * Handles the button and redirects (never returns). */ public function handle(): void { AdminAction::verify( self::ACTION ); $error = ( $this->rotate )(); Notices::push( null === $error ? Notice::success( self::ROTATED ) : Notice::error( $error ) ); wp_safe_redirect( SettingsPage::url() ); exit; } }