0 === strpos( (string) get_locale(), 'nb' ) || 0 === strpos( (string) get_locale(), 'nn' ) ? 'nb' : 'en', 'org' => get_bloginfo( 'name' ), 'website' => home_url( '/' ), 'email' => get_bloginfo( 'admin_email' ), 'phone' => '', 'response_days' => 10, 'standard' => AriAccess_Settings::get( 'checker', 'standard' ), 'status' => 'partial', 'known_issues' => '', 'alternatives' => '', 'method' => 'self', 'review_date' => gmdate( 'Y-m-d' ), 'uustatus_url' => '', 'footer_link' => false, 'page_id' => 0, ); } /** * Saved data merged over defaults. * * @return array */ public static function get() { $saved = get_option( self::OPTION, array() ); return array_merge( self::defaults(), is_array( $saved ) ? $saved : array() ); } /** * Sanitise and save. * * @param array $in Raw input. * @return array Saved data. */ public static function save( $in ) { $cur = self::get(); $out = array( 'language' => in_array( $in['language'] ?? '', array( 'en', 'nb' ), true ) ? $in['language'] : 'en', 'org' => sanitize_text_field( $in['org'] ?? '' ), 'website' => esc_url_raw( $in['website'] ?? '' ), 'email' => sanitize_email( $in['email'] ?? '' ), 'phone' => sanitize_text_field( $in['phone'] ?? '' ), 'response_days' => max( 1, min( 90, (int) ( $in['response_days'] ?? 10 ) ) ), 'standard' => array_key_exists( $in['standard'] ?? '', AriAccess_Rules::standards() ) ? $in['standard'] : 'no-private', 'status' => in_array( $in['status'] ?? '', array( 'full', 'partial', 'none' ), true ) ? $in['status'] : 'partial', 'known_issues' => sanitize_textarea_field( $in['known_issues'] ?? '' ), 'alternatives' => sanitize_textarea_field( $in['alternatives'] ?? '' ), 'method' => in_array( $in['method'] ?? '', array( 'self', 'external', 'mixed' ), true ) ? $in['method'] : 'self', 'review_date' => preg_match( '/^\d{4}-\d{2}-\d{2}$/', $in['review_date'] ?? '' ) ? $in['review_date'] : gmdate( 'Y-m-d' ), 'uustatus_url' => esc_url_raw( $in['uustatus_url'] ?? '' ), 'footer_link' => ! empty( $in['footer_link'] ), 'page_id' => (int) $cur['page_id'], ); update_option( self::OPTION, $out ); return $out; } /** * Public statement address: explicit setting, then uustatus, then the generated page. * * @return string */ public static function public_url() { $explicit = (string) AriAccess_Settings::get( 'toolbar', 'statement_url' ); if ( '' !== $explicit ) { return $explicit; } $s = self::get(); if ( '' !== $s['uustatus_url'] ) { return $s['uustatus_url']; } if ( $s['page_id'] && 'publish' === get_post_status( $s['page_id'] ) ) { return (string) get_permalink( $s['page_id'] ); } return ''; } /** * Contact address for accessibility feedback (only once a statement exists). * * @return string */ public static function contact_email() { $s = get_option( self::OPTION, array() ); return is_array( $s ) && ! empty( $s['email'] ) && ! empty( $s['page_id'] ) ? (string) $s['email'] : ''; } /** * Small footer link to the statement. */ public static function footer_link() { $s = self::get(); $url = self::public_url(); if ( ! $s['footer_link'] || '' === $url ) { return; } $label = 'nb' === $s['language'] ? 'Tilgjengelighetserklæring' : __( 'Accessibility statement', 'ariaccess' ); printf( '
', esc_url( $url ), esc_html( $label ) ); } /** * Build the statement as block markup. * * @param array $s Statement data. * @return array [ title, content ] */ public static function build( $s ) { $nb = 'nb' === $s['language']; $org = '' !== $s['org'] ? $s['org'] : get_bloginfo( 'name' ); $site = '' !== $s['website'] ? $s['website'] : home_url( '/' ); $date = date_i18n( $nb ? 'j. F Y' : get_option( 'date_format' ), strtotime( $s['review_date'] ) ); $criteria = count( AriAccess_Rules::criteria( $s['standard'] ) ); $standard_text = array( 'no-private' => $nb ? sprintf( 'forskrift om universell utforming av informasjons- og kommunikasjonsteknologiske (IKT)-løsninger, som krever %d suksesskriterier i WCAG 2.0 på nivå A og AA', $criteria ) : sprintf( 'the Norwegian regulation on universal design of ICT, which requires %d WCAG 2.0 success criteria at level A and AA', $criteria ), 'no-public' => $nb ? sprintf( 'forskrift om universell utforming av IKT-løsninger for offentlige virksomheter, som krever %d suksesskriterier i WCAG 2.1 på nivå A og AA', $criteria ) : sprintf( 'the Norwegian regulation on universal design of ICT for public bodies, which requires %d WCAG 2.1 success criteria at level A and AA', $criteria ), 'wcag21aa' => $nb ? 'WCAG 2.1 nivå AA (EN 301 549)' : 'WCAG 2.1 level AA (EN 301 549)', 'wcag22aa' => $nb ? 'WCAG 2.2 nivå AA' : 'WCAG 2.2 level AA', ); $status_text = array( 'full' => $nb ? 'Nettstedet oppfyller kravene.' : 'This website fully conforms to the standard.', 'partial' => $nb ? 'Nettstedet oppfyller kravene delvis. Det betyr at noen deler ikke er universelt utformet ennå. Disse er listet opp nedenfor.' : 'This website partially conforms to the standard. Some parts are not yet accessible; they are listed below.', 'none' => $nb ? 'Nettstedet oppfyller ikke kravene ennå. Vi arbeider med å rette feilene som er listet opp nedenfor.' : 'This website does not yet conform to the standard. We are working on the problems listed below.', ); $method_text = array( 'self' => $nb ? 'Vi har vurdert nettstedet selv, med automatiske tester og manuell kontroll.' : 'We assessed the website ourselves, using automated tests and manual checks.', 'external' => $nb ? 'Nettstedet er vurdert av en ekstern fagperson.' : 'The website was assessed by an external accessibility specialist.', 'mixed' => $nb ? 'Vi har vurdert nettstedet selv og fått hjelp av en ekstern fagperson.' : 'We assessed the website ourselves with help from an external accessibility specialist.', ); $p = function ( $text ) { return "\n" . $text . "
\n\n\n"; }; $h = function ( $text ) { return "\n