' . esc_html( number_format_i18n( $open ) ) . ''; } add_menu_page( __( 'Equivora Accessibility', 'equivora' ), $title, 'manage_options', self::MENU, array( __CLASS__, 'statement_page' ), 'dashicons-universal-access-alt', 81 ); add_submenu_page( self::MENU, __( 'Accessibility Statement', 'equivora' ), __( 'Statement', 'equivora' ), 'manage_options', self::MENU, array( __CLASS__, 'statement_page' ) ); add_submenu_page( self::MENU, __( 'Content Check', 'equivora' ), __( 'Content Check', 'equivora' ), 'edit_others_posts', 'equivora-check', array( __CLASS__, 'check_page' ) ); add_submenu_page( self::MENU, __( 'Equivora Settings', 'equivora' ), __( 'Settings', 'equivora' ), 'manage_options', 'equivora-settings', array( __CLASS__, 'settings_page' ) ); } /** * Registers the general settings. */ public static function register_settings() { register_setting( 'equivora', Equivora_Settings::OPTION, array( 'type' => 'array', 'sanitize_callback' => array( 'Equivora_Settings', 'sanitize' ), 'default' => Equivora_Settings::defaults(), ) ); } /** * Whether the current screen belongs to the plugin. * * @return bool */ private static function is_plugin_screen() { $screen = get_current_screen(); return $screen && ( false !== strpos( $screen->id, 'equivora' ) || Equivora_Reports::POST_TYPE === $screen->post_type ); } /** * Loads admin assets on the plugin screens. */ public static function assets() { if ( ! self::is_plugin_screen() ) { return; } wp_enqueue_style( 'equivora-admin', EQUIVORA_URL . 'assets/css/admin.css', array(), EQUIVORA_VERSION ); wp_enqueue_script( 'equivora-admin', EQUIVORA_URL . 'assets/js/admin.js', array( 'wp-api-fetch', 'wp-i18n' ), EQUIVORA_VERSION, true ); wp_set_script_translations( 'equivora-admin', 'equivora' ); } /** * Admin notices on the plugin screens. */ public static function notices() { if ( ! self::is_plugin_screen() ) { return; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only message key set by our own redirect. $message = isset( $_GET['equivora_message'] ) ? sanitize_key( wp_unslash( $_GET['equivora_message'] ) ) : ''; $texts = array( 'saved' => __( 'Accessibility statement saved. The review date was set to today.', 'equivora' ), 'pages' => __( 'Pages created. Your statement and feedback form are live.', 'equivora' ), 'status' => __( 'Report status updated.', 'equivora' ), 'missing' => __( 'Please save your statement first.', 'equivora' ), ); if ( isset( $texts[ $message ] ) ) { printf( '

%s

', esc_html( $texts[ $message ] ) ); } $days = Equivora_Statement::days_since_review(); if ( null !== $days && $days > 365 ) { printf( '

%s

', esc_html( sprintf( /* translators: %d: number of days. */ _n( 'Your accessibility statement was last reviewed %d day ago. Statements should be reviewed at least once a year.', 'Your accessibility statement was last reviewed %d days ago. Statements should be reviewed at least once a year.', $days, 'equivora' ), $days ) ) ); } } /** * Redirects back with a message. * * @param string $url URL. * @param string $message Message key. */ private static function back( $url, $message ) { wp_safe_redirect( add_query_arg( 'equivora_message', $message, $url ) ); exit; } // --------------------------------------------------------------------- // Statement builder. // --------------------------------------------------------------------- /** * Renders a checkbox group. * * @param string $name Field name. * @param array $choices Choices. * @param array $selected Selected keys. */ private static function checkboxes( $name, $choices, $selected ) { echo '
' . esc_html( $name ) . ''; foreach ( $choices as $key => $label ) { printf( '', esc_attr( $name ), esc_attr( $key ), checked( in_array( $key, (array) $selected, true ), true, false ), esc_html( $label ) ); } echo '
'; } /** * Renders the statement builder. */ public static function statement_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $s = Equivora_Statement::all(); $statement_page = (int) $s['statement_page']; $feedback_page = (int) $s['feedback_page']; $limitations = $s['limitations'] ? $s['limitations'] : array(); $limitations[] = array( 'item' => '', 'issue' => '', 'reason' => '', 'alternative' => '', ); ?>

·

$row ) : ?>

'page', 'post_status' => 'publish', 'post_title' => __( 'Accessibility Feedback', 'equivora' ), 'post_content' => '

' . esc_html__( 'Did something on our website not work for you? Tell us and we will fix it or help you another way.', 'equivora' ) . '

' . "\n\n" . '', ) ); } $data['statement_page'] = (int) wp_insert_post( array( 'post_type' => 'page', 'post_status' => 'publish', 'post_title' => __( 'Accessibility Statement', 'equivora' ), 'post_content' => '', ) ); Equivora_Statement::save( $data ); self::back( admin_url( 'admin.php?page=' . self::MENU ), 'pages' ); } // --------------------------------------------------------------------- // Content check. // --------------------------------------------------------------------- /** * Renders the content check page. */ public static function check_page() { if ( ! current_user_can( 'edit_others_posts' ) ) { return; } $summary = Equivora_Checker::summary(); $rules = Equivora_Checker::rules(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only pagination. $paged = isset( $_GET['paged'] ) ? max( 1, absint( $_GET['paged'] ) ) : 1; $list = Equivora_Checker::posts_with_issues( $paged ); ?>

/

ID, '_equivora_issues', true ), 'is_array' ); $labels = array(); foreach ( $issues as $issue ) { $labels[] = isset( $rules[ $issue['code'] ] ) ? $rules[ $issue['code'] ][1] : $issue['code']; } ?>
post_type )->labels->singular_name ); ?> ·
ID, '_equivora_errors', true ) ) ); ?> ID, '_equivora_warnings', true ) ) ); ?>
  • —
1 ) { echo '
'; echo wp_kses_post( paginate_links( array( 'base' => add_query_arg( 'paged', '%#%' ), 'format' => '', 'current' => $paged, 'total' => $pages, ) ) ); echo '
'; } ?>

$columns['cb'], 'title' => __( 'Report', 'equivora' ), 'equivora_status' => __( 'Status', 'equivora' ), 'equivora_technology' => __( 'Assistive technology', 'equivora' ), 'equivora_reporter' => __( 'Reporter', 'equivora' ), 'equivora_received' => __( 'Received', 'equivora' ), ); } /** * Lets the received column sort by date. * * @param array $columns Sortable columns. * @return array */ public static function sortable_columns( $columns ) { $columns['equivora_received'] = array( 'date', true ); return $columns; } /** * Renders a report column. * * @param string $column Column. * @param int $post_id Post ID. */ public static function column( $column, $post_id ) { $report = Equivora_Reports::get( $post_id ); if ( ! $report ) { return; } switch ( $column ) { case 'equivora_status': $statuses = Equivora_Reports::statuses(); echo '' . esc_html( $statuses[ $report['status'] ] ) . ''; break; case 'equivora_technology': $tech = Equivora_Reports::technologies(); echo esc_html( $report['technology'] && isset( $tech[ $report['technology'] ] ) ? $tech[ $report['technology'] ] : '—' ); break; case 'equivora_reporter': echo esc_html( $report['name'] ? $report['name'] : __( 'Anonymous', 'equivora' ) ); if ( $report['email'] ) { echo '
' . esc_html( $report['email'] ) . ''; } break; case 'equivora_received': echo esc_html( get_the_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $post_id ) ); break; } } /** * Quick status links. * * @param string[] $actions Actions. * @param WP_Post $post Post. * @return string[] */ public static function row_actions( $actions, $post ) { if ( Equivora_Reports::POST_TYPE !== $post->post_type || ! current_user_can( 'edit_post', $post->ID ) ) { return $actions; } unset( $actions['inline hide-if-no-js'], $actions['view'] ); $report = Equivora_Reports::get( $post ); foreach ( Equivora_Reports::statuses() as $key => $label ) { if ( $key === $report['status'] ) { continue; } $url = wp_nonce_url( admin_url( 'admin-post.php?action=equivora_report_status&status=' . $key . '&post=' . $post->ID ), 'equivora_status_' . $post->ID ); /* translators: %s: status name. */ $actions[ 'equivora_' . $key ] = '' . esc_html( sprintf( __( 'Mark as %s', 'equivora' ), strtolower( $label ) ) ) . ''; } return $actions; } /** * Handles a quick status link. */ public static function quick_status() { $post_id = isset( $_GET['post'] ) ? absint( $_GET['post'] ) : 0; check_admin_referer( 'equivora_status_' . $post_id ); $status = isset( $_GET['status'] ) ? sanitize_key( wp_unslash( $_GET['status'] ) ) : ''; if ( ! $post_id || Equivora_Reports::POST_TYPE !== get_post_type( $post_id ) || ! current_user_can( 'edit_post', $post_id ) || ! isset( Equivora_Reports::statuses()[ $status ] ) ) { wp_die( esc_html__( 'Sorry, you are not allowed to do that.', 'equivora' ), 403 ); } update_post_meta( $post_id, '_equivora_status', $status ); $referer = wp_get_referer(); self::back( $referer ? $referer : admin_url( 'edit.php?post_type=' . Equivora_Reports::POST_TYPE ), 'status' ); } /** * Reports use the classic editor. * * @param bool $use_block_editor Whether to use the block editor. * @param string $post_type Post type. * @return bool */ public static function classic_editor( $use_block_editor, $post_type ) { return Equivora_Reports::POST_TYPE === $post_type ? false : $use_block_editor; } /** * Adds the report details box. */ public static function meta_boxes() { add_meta_box( 'equivora-report', __( 'Report details', 'equivora' ), array( __CLASS__, 'report_box' ), Equivora_Reports::POST_TYPE, 'side', 'high' ); } /** * Renders the report details box. * * @param WP_Post $post Post. */ public static function report_box( $post ) { $report = Equivora_Reports::get( $post ); $tech = Equivora_Reports::technologies(); wp_nonce_field( 'equivora_report', 'equivora_report_nonce' ); ?>






' . esc_html__( 'Statement', 'equivora' ) . '' ); return $links; } }