'', 'nonce' => wp_create_nonce( 'jb_dismiss_notice' ), ) ); } public static function maybe_handle_dismissal() { if ( ! is_admin() || ! current_user_can( 'manage_options' ) || ! isset( $_GET[ self::$dismissal_key ] ) || ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'jb_dismiss_notice' ) ) { return; } // Dismiss the notice that shows up for major changes. static::dismiss(); wp_safe_redirect( remove_query_arg( array( self::$dismissal_key, 'nonce' ) ) ); } public static function init() { add_action( 'admin_notices', array( static::class, 'maybe_render' ) ); if ( static::is_enabled() ) { static::maybe_handle_dismissal(); } } public static function maybe_render() { // We're not actually using the GET parameter here, it's only used to find out what page we're on. // phpcs:disable WordPress.Security.NonceVerification.Recommended $on_settings_page = is_admin() && isset( $_GET['page'] ) && Admin::MENU_SLUG === $_GET['page']; if ( $on_settings_page || ! current_user_can( 'manage_options' ) ) { return; } if ( static::is_enabled() ) { static::render(); } } public static function render() { ?>