label, in display order. * * @return array */ public static function tabs(): array { $tabs = [ self::PRIMARY => __( 'وضعیت', 'rahkar-toolkit' ), Menu::SLUG . '-logs' => __( 'گزارش‌ها', 'rahkar-toolkit' ), ]; /** * Filters the screens joined by the diagnostics strip. * * A module whose diagnostics screen only exists while it is switched on — * the sign-in monitor is the one that does — adds itself here, so the * strip lists what the site actually has rather than what it might have. * * @param array $tabs Label per menu slug, in display order. */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort -- Inline type assertion for phpstan: a filter may return anything. /** @var mixed $filtered */ $filtered = apply_filters( 'rahkar_wp_diagnostics_tabs', $tabs ); return is_array( $filtered ) ? $filtered : $tabs; } /** * Slugs that should not appear in the menu on their own. * * Everything in the strip except the one that keeps the entry. * * @return list */ public static function hidden(): array { return array_values( array_diff( array_keys( self::tabs() ), [ self::PRIMARY ] ) ); } /** * Print the strip. * * Called by each of the three screens straight after `Ui::pageOpen()`, so * wherever the visitor lands they can see the other two exist. * * @param string $current Slug of the screen drawing it. */ public static function render( string $current ): void { $tabs = self::tabs(); // One tab is not a strip. On a site with the sign-in module switched off // and nothing else contributing, this is two — and below two it is a row // of chrome that says nothing. if ( count( $tabs ) < 2 ) { return; } $items = []; foreach ( $tabs as $slug => $label ) { $items[ $slug ] = [ 'label' => $label, 'href' => admin_url( 'admin.php?page=' . $slug ), ]; } echo wp_kses( Ui::tabs( $items, $current, __( 'بخش‌های وضعیت', 'rahkar-toolkit' ) ), Ui::allowedHtml() ); } }