Skip to content

Commit

Permalink
Properly modify page title to avoid lint error introduced by #633
Browse files Browse the repository at this point in the history
  • Loading branch information
wpalani committed Nov 11, 2024
1 parent 353752e commit b74398f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions includes/WP_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final class WP_Admin {
public function __construct() {
\add_action( 'init', array( __CLASS__, 'load_php_textdomain' ) );
\add_action( 'admin_menu', array( __CLASS__, 'register_page' ) );
\add_filter( 'admin_title', array( __CLASS__, 'page_title' ), 10, 1 );
\add_action( 'load-dashboard_page_' . self::$slug, array( __CLASS__, 'initialize' ) );
if ( 'sitegen' === Data::current_flow() ) {
\add_action( 'load-themes.php', array( __CLASS__, 'mark_sitegen_generated_themes' ) );
Expand Down Expand Up @@ -70,6 +71,20 @@ public static function register_page() {
);
}

/**
* Set the page title for the Onboarding page.
*
* @param string $admin_title The title of the admin page.
* @return string
*/
public static function page_title( $admin_title ) {
if ( isset( $_GET['page'] ) && \sanitize_text_field( wp_unslash( $_GET['page'] ) ) === self::$slug ) {
$admin_title = \__( 'Onboarding', 'wp-module-onboarding' ) . $admin_title;
}

return $admin_title;
}

/**
* Render DOM element for React SPA mount.
*
Expand Down Expand Up @@ -155,12 +170,6 @@ public static function enqueue_block_assets() {
* @return void
*/
public static function initialize() {
global $title;

if ( is_null( $title ) ) {
$title = __( 'Onboarding', 'wp-module-onboarding' );
}

if ( ! empty( $_GET['nfd_plugins'] ) && 'true' === sanitize_text_field( $_GET['nfd_plugins'] ) ) {
PluginService::initialize();
}
Expand Down

0 comments on commit b74398f

Please sign in to comment.