Skip to content

Commit b74398f

Browse files
committed
Properly modify page title to avoid lint error introduced by #633
1 parent 353752e commit b74398f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

includes/WP_Admin.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ final class WP_Admin {
3030
public function __construct() {
3131
\add_action( 'init', array( __CLASS__, 'load_php_textdomain' ) );
3232
\add_action( 'admin_menu', array( __CLASS__, 'register_page' ) );
33+
\add_filter( 'admin_title', array( __CLASS__, 'page_title' ), 10, 1 );
3334
\add_action( 'load-dashboard_page_' . self::$slug, array( __CLASS__, 'initialize' ) );
3435
if ( 'sitegen' === Data::current_flow() ) {
3536
\add_action( 'load-themes.php', array( __CLASS__, 'mark_sitegen_generated_themes' ) );
@@ -70,6 +71,20 @@ public static function register_page() {
7071
);
7172
}
7273

74+
/**
75+
* Set the page title for the Onboarding page.
76+
*
77+
* @param string $admin_title The title of the admin page.
78+
* @return string
79+
*/
80+
public static function page_title( $admin_title ) {
81+
if ( isset( $_GET['page'] ) && \sanitize_text_field( wp_unslash( $_GET['page'] ) ) === self::$slug ) {
82+
$admin_title = \__( 'Onboarding', 'wp-module-onboarding' ) . $admin_title;
83+
}
84+
85+
return $admin_title;
86+
}
87+
7388
/**
7489
* Render DOM element for React SPA mount.
7590
*
@@ -155,12 +170,6 @@ public static function enqueue_block_assets() {
155170
* @return void
156171
*/
157172
public static function initialize() {
158-
global $title;
159-
160-
if ( is_null( $title ) ) {
161-
$title = __( 'Onboarding', 'wp-module-onboarding' );
162-
}
163-
164173
if ( ! empty( $_GET['nfd_plugins'] ) && 'true' === sanitize_text_field( $_GET['nfd_plugins'] ) ) {
165174
PluginService::initialize();
166175
}

0 commit comments

Comments
 (0)