esc_html( self::organisation( $mailing_list ) ), self::PRIVACY_POLICY => '' === $url ? $label : '' . $label . '', ) ); } /** * The consent as plain text, as GruVer stores it. * * @param MailingList $mailing_list List. */ public static function text( MailingList $mailing_list ): string { $label = __( 'privacy policy', 'gruver-subscribe' ); $url = get_privacy_policy_url(); return strtr( self::template( $mailing_list ), array( self::ORGANISATION => self::organisation( $mailing_list ), self::PRIVACY_POLICY => '' === $url ? $label : $label . ' (' . $url . ')', ) ); } /** * Keyed hash of the plain text, sent along with the form. If the text has changed by the time the form comes * back, the visitor agreed to another text than GruVer would keep as proof, and is asked again. * * @param MailingList $mailing_list List. */ public static function hash( MailingList $mailing_list ): string { return hash_hmac( 'sha256', 'gruver-subscribe-consent|' . $mailing_list->key . '|' . self::text( $mailing_list ), wp_salt( 'nonce' ) ); } /** * Own text of the list or the default. * * @param MailingList $mailing_list List. */ private static function template( MailingList $mailing_list ): string { return '' !== $mailing_list->consent_text ? $mailing_list->consent_text : self::default_template(); } /** * Name of the organisation from the last connection check, otherwise the name of the website. * * @param MailingList $mailing_list List. */ private static function organisation( MailingList $mailing_list ): string { $name = Status::get( $mailing_list->key )['organisation']; return '' !== $name ? $name : html_entity_decode( (string) get_bloginfo( 'name' ), ENT_QUOTES, 'UTF-8' ); } }