report = $report; $this->consent = $consent; } /** * Registers hooks. */ public function register(): void { add_action( 'admin_notices', array( $this, 'render' ) ); add_action( 'admin_post_' . self::DISMISS_ACTION, array( $this, 'dismiss' ) ); } /** * Fingerprint of the current critical plugins. * * @param array> $rows Critical rows. * @return string */ private static function fingerprint( array $rows ): string { $files = wp_list_pluck( $rows, 'file' ); sort( $files ); return md5( implode( '|', $files ) ); } /** * URL that dismisses a notice. * * @param string $notice "intro" or "critical". * @param string $fingerprint Fingerprint of the critical plugins. * @return string */ private static function dismiss_url( string $notice, string $fingerprint = '' ): string { $url = add_query_arg( array( 'action' => self::DISMISS_ACTION, 'notice' => $notice, 'fingerprint' => $fingerprint, ), admin_url( 'admin-post.php' ) ); return wp_nonce_url( $url, self::DISMISS_ACTION ); } /** * Prints the notices. */ public function render(): void { $screen = get_current_screen(); if ( $screen && 'tools_page_' . Page::SLUG === $screen->id ) { return; } if ( $this->consent->granted() ) { $this->render_critical(); } else { $this->render_intro( $screen ? (string) $screen->id : '' ); } } /** * Note after activation: points to the Brachmelder page, nothing else. * * @param string $screen_id Current screen. */ private function render_intro( string $screen_id ): void { if ( ! in_array( $screen_id, self::INTRO_SCREENS, true ) || ! current_user_can( Consent::CAPABILITY ) || ! get_option( Plugin::INTRO_OPTION ) ) { return; } ?>

 | 

report->critical_rows(); if ( empty( $rows ) ) { return; } $fingerprint = self::fingerprint( $rows ); if ( get_user_meta( get_current_user_id(), ResultStore::DISMISS_META, true ) === $fingerprint ) { return; } $names = implode( ', ', wp_list_pluck( $rows, 'local_name' ) ); ?>


 |