' . esc_html__( 'This screen could not be displayed because of an unexpected error. Details were written to Help → Diagnostics.', 'siteaudithub' ) . '
403 ) ); } check_admin_referer( 'siteaudithub_enable_checksums' ); $settings = get_option( Settings::OPTION, array() ); $settings = is_array( $settings ) ? $settings : array(); $settings['integrity_wporg_checksums'] = 1; update_option( Settings::OPTION, $settings ); Settings::flush(); wp_safe_redirect( Ui::page_url( 'siteaudithub-integrity', array( 'checksums' => 'on' ) ) ); exit; } /** * Pages: slug => [menu label, page title, view]. * * @return array */ public static function pages() { return array( 'siteaudithub' => array( __( 'Dashboard', 'siteaudithub' ), __( 'Dashboard', 'siteaudithub' ), 'dashboard', 'dashicons-dashboard' ), 'siteaudithub-site-audit' => array( __( 'Site Audit', 'siteaudithub' ), __( 'Website-wide audit', 'siteaudithub' ), 'site-audit', 'dashicons-admin-site-alt3' ), 'siteaudithub-seo' => array( __( 'SEO', 'siteaudithub' ), __( 'SEO audit', 'siteaudithub' ), 'module', 'dashicons-search' ), 'siteaudithub-a11y' => array( __( 'Accessibility', 'siteaudithub' ), __( 'Accessibility audit', 'siteaudithub' ), 'module', 'dashicons-universal-access' ), 'siteaudithub-plugins' => array( __( 'Plugins', 'siteaudithub' ), __( 'Plugin monitor', 'siteaudithub' ), 'plugins', 'dashicons-admin-plugins' ), 'siteaudithub-health' => array( __( 'Health', 'siteaudithub' ), __( 'Technical health', 'siteaudithub' ), 'health', 'dashicons-heart' ), 'siteaudithub-integrity' => array( __( 'Malware & Integrity', 'siteaudithub' ), __( 'Malware & file integrity', 'siteaudithub' ), 'integrity', 'dashicons-shield' ), 'siteaudithub-logins' => array( __( 'Login Activity', 'siteaudithub' ), __( 'Login activity', 'siteaudithub' ), 'logins', 'dashicons-groups' ), 'siteaudithub-reports' => array( __( 'Reports', 'siteaudithub' ), __( 'Reports & history', 'siteaudithub' ), 'reports', 'dashicons-media-spreadsheet' ), 'siteaudithub-settings' => array( __( 'Settings', 'siteaudithub' ), __( 'Settings', 'siteaudithub' ), 'settings', 'dashicons-admin-generic' ), 'siteaudithub-help' => array( __( 'Help', 'siteaudithub' ), __( 'Help & documentation', 'siteaudithub' ), 'help', 'dashicons-editor-help' ), ); } /** * Register menu pages. */ public static function menu() { $cap = Security::capability(); self::$hooks[] = add_menu_page( __( 'SiteAuditHub', 'siteaudithub' ), __( 'SiteAuditHub', 'siteaudithub' ), $cap, 'siteaudithub', array( __CLASS__, 'render' ), Ui::menu_icon(), 80 ); foreach ( self::pages() as $slug => $page ) { self::$hooks[] = add_submenu_page( 'siteaudithub', $page[1] . ' ‹ SiteAuditHub', $page[0], $cap, $slug, array( __CLASS__, 'render' ) ); } } /** * Whether the current screen belongs to the plugin. * * @return bool */ public static function is_plugin_screen() { $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended return isset( self::pages()[ $page ] ); } /** * Body class for scoped styling. * * @param string $classes Classes. * @return string */ public static function body_class( $classes ) { if ( self::is_plugin_screen() ) { $classes .= ' sah-admin'; if ( isset( $_GET['print'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $classes .= ' sah-print-view'; } } return $classes; } /** * Enqueue assets only on plugin screens. * * @param string $hook Hook suffix. */ public static function assets( $hook ) { if ( ! in_array( $hook, self::$hooks, true ) ) { return; } wp_enqueue_style( 'siteaudithub-admin', SITEAUDITHUB_URL . 'assets/css/admin.css', array(), SITEAUDITHUB_VERSION ); if ( 'siteaudithub-settings' === self::filter( 'page' ) && 'login' === self::filter( 'tab' ) ) { wp_enqueue_media(); // Image pickers for the login page design. } wp_enqueue_script( 'siteaudithub-admin', SITEAUDITHUB_URL . 'assets/js/admin.js', array(), SITEAUDITHUB_VERSION, true ); wp_localize_script( 'siteaudithub-admin', 'siteaudithubAdmin', array( 'root' => esc_url_raw( rest_url( Rest::NS ) ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'i18n' => array( 'confirm' => __( 'Confirm', 'siteaudithub' ), 'cancel' => __( 'Keep it', 'siteaudithub' ), 'cancelScan' => __( 'Cancel this scan? Results collected so far are kept, but the scan cannot be resumed.', 'siteaudithub' ), 'deleteScan' => __( 'Delete this scan and all of its results permanently?', 'siteaudithub' ), 'retry' => __( 'Re-check all failed and inaccessible URLs of this audit?', 'siteaudithub' ), 'started' => __( 'Scan started. You can leave this page. It carries on in the background when WP-Cron runs.', 'siteaudithub' ), 'completed' => __( 'Scan completed. Loading results…', 'siteaudithub' ), 'paused' => __( 'Scan paused.', 'siteaudithub' ), 'resumed' => __( 'Scan resumed.', 'siteaudithub' ), 'cancelled' => __( 'Scan cancelled.', 'siteaudithub' ), 'error' => __( 'Request failed:', 'siteaudithub' ), 'networkError' => __( 'Connection problem. Retrying…', 'siteaudithub' ), 'stalled' => __( 'Progress updates stopped after repeated errors. Reload the page to try again.', 'siteaudithub' ), 'ignored' => __( 'Finding ignored. It is hidden from lists and scores from now on.', 'siteaudithub' ), 'unignored' => __( 'Finding restored.', 'siteaudithub' ), 'healthDone' => __( 'Health checks refreshed.', 'siteaudithub' ), 'directoryDone' => __( 'WordPress.org lookup finished.', 'siteaudithub' ), 'directoryMore' => __( 'Partly done. Click again to continue.', 'siteaudithub' ), 'mailAccepted' => __( 'WordPress accepted the test email for delivery to:', 'siteaudithub' ), 'mailRejected' => __( 'wp_mail() reported a failure. Check your mail/SMTP configuration.', 'siteaudithub' ), 'deleted' => __( 'Scan deleted.', 'siteaudithub' ), 'clearLogins' => __( 'Delete all login activity records? This cannot be undone.', 'siteaudithub' ), 'loginsCleared' => __( 'Login activity cleared.', 'siteaudithub' ), 'working' => __( 'Working…', 'siteaudithub' ), /* translators: 1: processed items, 2: total items */ 'processedOf' => __( '%1$s of %2$s items', 'siteaudithub' ), ), ) ); } /** * Plugins screen links. * * @param array $links Links. * @return array */ public static function action_links( $links ) { array_unshift( $links, '' . esc_html__( 'Dashboard', 'siteaudithub' ) . '', '' . esc_html__( 'Settings', 'siteaudithub' ) . '' ); return $links; } /** * Render the current page. */ public static function render() { if ( ! Security::can() ) { wp_die( esc_html__( 'You are not allowed to access this page.', 'siteaudithub' ) ); } $slug = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : 'siteaudithub'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $pages = self::pages(); if ( ! isset( $pages[ $slug ] ) ) { $slug = 'siteaudithub'; } $view = $pages[ $slug ][2]; echo '
' . esc_html__( 'This screen could not be displayed because of an unexpected error. Details were written to Help → Diagnostics.', 'siteaudithub' ) . '