#adminmenu .toplevel_page_%1$s .wp-menu-image::before{content:"%2$s";font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;font-size:20px;font-weight:400;line-height:1.4}', esc_attr( WPMGR_MENU_SLUG ), esc_attr( $glyph ) ); } /** * The shared landing page. * * Nothing here knows which plugins exist. Every card comes from the * filter, so the page is correct whichever of them registered the menu and * whichever of them have since been deactivated. */ function wpmgr_render_dashboard() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html( 'You do not have permission to view this page.' ) ); } /** * Cards on the shared dashboard, one per installed manager plugin. * * Each entry: * title string Plugin name, already translated by its owner. * status string 'ok' | 'warn' | 'fail' — what the check said. * headline string One short line: the number that matters. * lines array label => value, a handful at most. * url string Where "Open" goes. * colour string The plugin's own colour, as #rrggbb. * * Implementations must not measure anything here. This filter runs on * an admin page load; a card that walks the disk or makes an HTTP * request turns somebody else's dashboard into a slow page, and they * will not know why. * * @param array $cards The cards so far. */ $cards = apply_filters( 'wpmgr_dashboard_cards', array() ); echo '
'; echo '

' . esc_html( apply_filters( 'wpmgr_menu_title', 'Manager' ) ) . '

'; if ( empty( $cards ) ) { echo '

Nothing to report.

'; return; } echo ''; echo '
'; $states = array( 'ok' => 'OK', 'warn' => 'Attention', 'fail' => 'Action needed', ); foreach ( $cards as $card ) { if ( empty( $card['title'] ) ) { continue; } $colour = isset( $card['colour'] ) && preg_match( '/^#[0-9a-f]{6}$/i', $card['colour'] ) ? $card['colour'] : '#50575e'; $status = isset( $card['status'] ) && isset( $states[ $card['status'] ] ) ? $card['status'] : 'ok'; echo '
'; printf( '

%s

%s
', esc_attr( $colour ), esc_html( $card['title'] ), esc_html( $states[ $status ] ) ); echo '
'; if ( ! empty( $card['headline'] ) ) { echo '

' . esc_html( $card['headline'] ) . '

'; } if ( ! empty( $card['lines'] ) && is_array( $card['lines'] ) ) { echo '
'; foreach ( $card['lines'] as $label => $value ) { echo '
' . esc_html( $label ) . '
' . esc_html( $value ) . '
'; } echo '
'; } echo '
'; if ( ! empty( $card['url'] ) ) { printf( '', esc_url( $card['url'] ), esc_html( isset( $card['action'] ) ? $card['action'] : 'Open' ) ); } echo '
'; } echo '
'; } }