', esc_attr( $extra_class ), esc_url( SWIFTDASH_URL . 'assets/icons.svg' ) . '#sd-i-' . esc_attr( sanitize_key( $name ) ) ); } /** * Allowed tags for wp_kses() when printing icons and status pills. * * @return array[] */ function swiftdash_icon_kses() { return array( 'svg' => array( 'class' => true, 'aria-hidden' => true, 'focusable' => true, ), 'use' => array( 'href' => true ), 'span' => array( 'class' => true ), ); } /** * User menu rows: SwiftWebDev Dashboard screens placed in the user menu, settings last. * * @return array[] Each: label, url, icon. */ function swiftdash_user_menu_items() { $items = array(); $last = array(); foreach ( swiftdash_screens() as $slug => $screen ) { if ( 'user' !== swiftdash_screen_location( $screen ) ) { continue; } $row = array( 'label' => $screen['menu'], 'url' => admin_url( 'admin.php?page=' . $slug ), 'icon' => isset( $screen['icon'] ) ? $screen['icon'] : 'squares-four-fill', ); if ( 'swift-dash-settings' === $slug ) { $last[] = $row; } else { $items[] = $row; } } return array_merge( $items, $last ); } /** * Pending updates as notification rows (real counts from core). * * @return array[] Each: text, url. */ function swiftdash_notifications() { $data = wp_get_update_data(); $rows = array(); $map = array( /* translators: %d: number of plugin updates. */ 'plugins' => array( _n_noop( '%d plugin update available', '%d plugin updates available', 'swiftwebdev-dashboard-analytics' ), 'plugins.php?plugin_status=upgrade' ), /* translators: %d: number of theme updates. */ 'themes' => array( _n_noop( '%d theme update available', '%d theme updates available', 'swiftwebdev-dashboard-analytics' ), 'themes.php' ), /* translators: %d: number of WordPress updates. */ 'wordpress' => array( _n_noop( '%d WordPress update available', '%d WordPress updates available', 'swiftwebdev-dashboard-analytics' ), 'update-core.php' ), /* translators: %d: number of translation updates. */ 'translations' => array( _n_noop( '%d translation update available', '%d translation updates available', 'swiftwebdev-dashboard-analytics' ), 'update-core.php' ), ); foreach ( $map as $key => $row ) { $count = isset( $data['counts'][ $key ] ) ? (int) $data['counts'][ $key ] : 0; if ( $count > 0 ) { $rows[] = array( 'text' => sprintf( translate_nooped_plural( $row[0], $count, 'swiftwebdev-dashboard-analytics' ), $count ), 'url' => admin_url( $row[1] ), ); } } return $rows; } /** * Print the top header. */ function swiftdash_render_header() { $user = wp_get_current_user(); $notes = swiftdash_notifications(); $initials = strtoupper( mb_substr( $user->display_name ? $user->display_name : $user->user_login, 0, 1 ) ); ?>
array( __( 'Speed & Optimize', 'swiftwebdev-dashboard-analytics' ), 'gauge' ), 'swift-dash-links' => array( __( 'Quick Links', 'swiftwebdev-dashboard-analytics' ), 'link-simple' ), ); foreach ( $shortcuts as $slug => $shortcut ) : ?> >
get_names(); $role = $user->roles ? reset( $user->roles ) : ''; return isset( $roles[ $role ] ) ? translate_user_role( $roles[ $role ] ) : ''; } /** * Print the page header (guideline 3.3). * * @param string $title Page title. * @param string $description One sentence. * @param callable $actions Optional: prints the action buttons. */ function swiftdash_render_page_header( $title, $description, $actions = null ) { ?>