$data ) { if ( isset( $data[2] ) && Plugin::PAGE_REDIRECTS === $data[2] ) { // Rewriting our own row's display label in the global // `$menu` is the documented WP way to override the // auto-derived top-level title (default is the first // submenu page's name). This is the only touch we make. // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $menu[ $position ][0] = Plugin::name(); return; } } } /** * Append a "New" badge to the Add-ons submenu label. * * TEMP: highlights the freshly expanded add-on catalogue. Remove this * method (and its `admin_menu` / `admin_head` hooks in {@see init()}, * plus {@see badge_addons_style()}) in a future release once the * catalogue is no longer "new". * * Appends to the displayed label only — the registered page/menu * titles stay clean — mirroring how {@see rename_top_level()} edits * the menu globals, and how WP core injects its own count bubbles. * * @since 4.0.0 * * @return void */ public function badge_addons(): void { global $submenu; if ( empty( $submenu[ Plugin::PAGE_REDIRECTS ] ) || ! is_array( $submenu[ Plugin::PAGE_REDIRECTS ] ) ) { return; } $badge = ' ' . esc_html__( 'New', '404-to-301' ) . ''; foreach ( $submenu[ Plugin::PAGE_REDIRECTS ] as $index => $item ) { if ( isset( $item[2] ) && Plugin::PAGE_ADDONS === $item[2] ) { // Append once — guard against a re-run leaving two badges. if ( false === strpos( (string) $item[0], 'd404-menu-badge' ) ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $submenu[ Plugin::PAGE_REDIRECTS ][ $index ][0] = $item[0] . $badge; } return; } } } /** * Inline CSS for the Add-ons "New" badge. * * Emitted on `admin_head` (every screen) because the submenu is * visible site-wide, whereas the plugin's stylesheet only enqueues on * its own pages. TEMP — remove alongside {@see badge_addons()}. * * @since 4.0.0 * * @return void */ public function badge_addons_style(): void { ?>