address_rules->normalize( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); if ( null === $requested ) { return; } $redirect_to = $this->query_runner->value( $this->query_runner->prepare( 'SELECT redirect_to FROM ' . $this->tables->links() . ' WHERE url_hash = %s AND outcome = %s' . ' AND redirect_to IS NOT NULL AND redirect_to <> url', md5( $requested ), Outcome::Resolved->value ) ); if ( null === $redirect_to ) { return; } $target_host = $this->address_rules->host_of( $redirect_to ); add_filter( self::ALLOWED_HOSTS_FILTER, fn( array $allowed_hosts ): array => array_merge( $allowed_hosts, array( $target_host ) ) ); wp_safe_redirect( $redirect_to, self::PERMANENT_REDIRECT ); wp_die( '', '', array( 'response' => absint( self::PERMANENT_REDIRECT ) ) ); } }