card_open() etc. * * @package Admbud */ if ( ! defined( 'ABSPATH' ) ) { exit; } // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variables scoped to this included template file. use Admbud\Colours; /** * Ensure a colour option value is valid for type="color" inputs. * Returns the saved value if non-empty, otherwise the fallback. * Prevents browser warnings about empty values on . */ function admbud_colour_val( string $option, string $fallback = '#000000' ): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- admbud_ is the plugin prefix. $val = get_option( $option, '' ); return ( $val !== '' && preg_match( '/^#[0-9a-fA-F]{6}$/', $val ) ) ? $val : $fallback; } /** @var \Admbud\Settings $settings */ $primary = esc_attr( admbud_get_option( 'admbud_colours_primary', Colours::DEFAULT_PRIMARY ) ); $secondary = esc_attr( admbud_get_option( 'admbud_colours_secondary', Colours::DEFAULT_SECONDARY ) ); $menu_text = esc_attr( admbud_get_option( 'admbud_colours_menu_text', Colours::DEFAULT_MENU_TEXT ) ); $menu_bg = esc_attr( admbud_get_option( 'admbud_colours_menu_bg', Colours::DEFAULT_MENU_BG ) ); $text_hint_primary = Colours::suggest_text_colour( admbud_get_option( 'admbud_colours_primary', Colours::DEFAULT_PRIMARY ) ); $text_hint_menu_bg = Colours::suggest_text_colour( admbud_get_option( 'admbud_colours_menu_bg', Colours::DEFAULT_MENU_BG ) ); $contrast_menu = Colours::contrast_ratio( admbud_get_option( 'admbud_colours_menu_text', Colours::DEFAULT_MENU_TEXT ), admbud_get_option( 'admbud_colours_menu_bg', Colours::DEFAULT_MENU_BG ) ); $contrast_ok = $contrast_menu >= 4.5; $sidebar_gradient = admbud_get_option( 'admbud_colours_sidebar_gradient', '0' ) === '1'; $menu_item_sep = admbud_get_option( 'admbud_colours_menu_item_sep', '1' ) === '1'; $grad_dir = admbud_get_option( 'admbud_colours_sidebar_grad_dir', Colours::DEFAULT_SIDEBAR_GRAD_DIR ); $grad_from = esc_attr( admbud_get_option( 'admbud_colours_sidebar_grad_from', Colours::DEFAULT_SIDEBAR_GRAD_FROM ) ); $grad_to = esc_attr( admbud_get_option( 'admbud_colours_sidebar_grad_to', Colours::DEFAULT_SIDEBAR_GRAD_TO ) ); $grad_hidden = $sidebar_gradient ? '' : 'ab-hidden'; $directions = [ 'to top left' => '↖', 'to top' => '↑', 'to top right' => '↗', 'to left' => '←', 'to right' => '→', 'to bottom left' => '↙', 'to bottom' => '↓', 'to bottom right' => '↘', ]; $grid_order = [ 'to top left', 'to top', 'to top right', 'to left', null, 'to right', 'to bottom left', 'to bottom', 'to bottom right', ]; $effective_menu_text = admbud_get_option( 'admbud_colours_menu_text', Colours::DEFAULT_MENU_TEXT ); $effective_active_text = admbud_get_option( 'admbud_colours_active_text', Colours::DEFAULT_ACTIVE_TEXT ); $submenu_text_val = admbud_get_option( 'admbud_colours_submenu_text', '' ) ?: $effective_menu_text; $hover_text_val = admbud_get_option( 'admbud_colours_hover_text', '' ) ?: $effective_menu_text; $act_parent_val = admbud_get_option( 'admbud_colours_active_parent_text', '' ) ?: $effective_active_text; $submenu_bg_val = admbud_get_option( 'admbud_colours_submenu_bg', '' ) ?: Colours::DEFAULT_SUBMENU_BG; $submenu_hover_bg_val = admbud_get_option( 'admbud_colours_submenu_hover_bg', '' ) ?: Colours::DEFAULT_SUBMENU_HOVER_BG; $submenu_hover_text_val = admbud_get_option( 'admbud_colours_submenu_hover_text', '' ) ?: Colours::DEFAULT_SUBMENU_HOVER_TEXT; $active_subtab = \Admbud\Settings::get_active_subtab( 'colours', 'presets' ); $active_subtab = in_array( $active_subtab, [ 'presets', 'accent', 'auto-palette', 'menu', 'adminbar', 'content', 'exclusions' ], true ) ? $active_subtab : 'presets'; ?>
>
card_open_svg( '', __( 'Accent Colours', 'admin-buddy' ), __( 'Used for buttons, links, focus rings, and active states throughout the admin.', 'admin-buddy' ) ); ?> card_close(); ?>
card_open_svg( '', __( 'Admin Menu', 'admin-buddy' ), __( 'Sidebar background, text colours, and optional gradient.', 'admin-buddy' ) ); ?> > card_close(); ?>
card_open_svg( '', __( 'Admin Bar', 'admin-buddy' ), __( 'Top admin bar colours. Applies on backend and frontend. Leave any blank to use its noted default.', 'admin-buddy' ) ); ?> card_close(); ?>
card_open_svg( '', __( 'Page', 'admin-buddy' ), __( 'Content area background, headings, body text and links.', 'admin-buddy' ) ); ?> colour_field( 'admbud_colours_body_bg', __( 'Content Background', 'admin-buddy' ), __( 'Main admin content area background. Leave blank for WP default.', 'admin-buddy' ), '#f0f0f1' ); $settings->colour_field( 'admbud_colours_content_heading', __( 'Heading Text', 'admin-buddy' ), __( 'h1–h4 colour in the content area. Leave blank for WP default.', 'admin-buddy' ), '#1d2327' ); $settings->colour_field( 'admbud_colours_content_text', __( 'Body Text', 'admin-buddy' ), __( 'Paragraph and label text. Leave blank for WP default.', 'admin-buddy' ), '#3c434a' ); $settings->colour_field( 'admbud_colours_content_link', __( 'Link Colour', 'admin-buddy' ), __( 'Link colour. Leave blank to use your Primary colour.', 'admin-buddy' ), '#7c3aed' ); $settings->colour_field( 'admbud_colours_content_link_hover', __( 'Link Hover', 'admin-buddy' ), __( 'Link hover colour. Leave blank to use your Secondary colour.', 'admin-buddy' ), '#6d28d9' ); $settings->colour_field( 'admbud_colours_shadow_colour', __( 'Drop Shadow', 'admin-buddy' ), __( 'Shadow colour for flyout panels and dropdowns. Leave blank for default.', 'admin-buddy' ), '#000000' ); ?> card_close(); ?> card_open_svg( '', __( 'Tables', 'admin-buddy' ), __( 'List tables used across Posts, Pages, Plugins, Users and more.', 'admin-buddy' ) ); ?> colour_field( 'admbud_colours_table_header_bg', __( 'Header Background', 'admin-buddy' ), '', '#f4effd' ); $settings->colour_field( 'admbud_colours_table_header_text', __( 'Header Text', 'admin-buddy' ), '', '#1d2327' ); $settings->colour_field( 'admbud_colours_table_header_link', __( 'Header Links', 'admin-buddy' ), __( 'Clickable column headings (Title, Author, Date).', 'admin-buddy' ), '#1d2327' ); $settings->colour_field( 'admbud_colours_table_row_bg', __( 'Row Background', 'admin-buddy' ), '', '#ffffff' ); $settings->colour_field( 'admbud_colours_table_row_text', __( 'Row Text', 'admin-buddy' ), '', '#3c434a' ); $settings->colour_field( 'admbud_colours_table_row_alt_bg', __( 'Alternating Row Background', 'admin-buddy' ), __( 'Auto-derived from row background if left blank.', 'admin-buddy' ), '#f9f7fe' ); $settings->colour_field( 'admbud_colours_table_row_alt_text', __( 'Alternating Row Text', 'admin-buddy' ), '', '#3c434a' ); $settings->colour_field( 'admbud_colours_table_row_hover', __( 'Row Hover', 'admin-buddy' ), '', '#efe7fc' ); $settings->colour_field( 'admbud_colours_table_border', __( 'Cell Border', 'admin-buddy' ), __( 'Outer cell borders.', 'admin-buddy' ), '#decdfa' ); $settings->colour_field( 'admbud_colours_table_row_separator', __( 'Row Separator', 'admin-buddy' ), __( 'Horizontal line between rows.', 'admin-buddy' ), '#ebe1fc' ); $settings->colour_field( 'admbud_colours_table_title_link', __( 'Title Links', 'admin-buddy' ), __( 'Post titles, plugin names, user names.', 'admin-buddy' ), '#7c3aed' ); $settings->colour_field( 'admbud_colours_table_action_link', __( 'Action Links', 'admin-buddy' ), __( 'Edit / Trash / View links under each row.', 'admin-buddy' ), '#7c3aed' ); ?> card_close(); ?> card_open_svg( '', __( 'Forms', 'admin-buddy' ), __( 'Input fields, focus rings and secondary buttons. Scoped to the content area only.', 'admin-buddy' ) ); ?> colour_field( 'admbud_colours_input_bg', __( 'Input Background', 'admin-buddy' ), '', '#ffffff' ); $settings->colour_field( 'admbud_colours_input_border', __( 'Input Border', 'admin-buddy' ), '', '#d1baf8' ); $settings->colour_field( 'admbud_colours_input_focus', __( 'Focus Ring', 'admin-buddy' ), __( 'Border and box-shadow on focused inputs. Leave blank to use Primary.', 'admin-buddy' ), '#2271b1' ); $settings->colour_field( 'admbud_colours_btn_primary_bg', __( 'Primary Button Background', 'admin-buddy' ), __( 'Leave blank to use your Primary colour.', 'admin-buddy' ), '#7c3aed' ); $settings->colour_field( 'admbud_colours_btn_primary_text', __( 'Primary Button Text', 'admin-buddy' ), '', '#ffffff' ); $settings->colour_field( 'admbud_colours_btn_primary_hover', __( 'Primary Button Hover', 'admin-buddy' ), __( 'Leave blank to use your Secondary colour.', 'admin-buddy' ), '#6d28d9' ); $settings->colour_field( 'admbud_colours_btn_secondary_bg', __( 'Secondary Button Background', 'admin-buddy' ), __( 'WP .button-secondary background.', 'admin-buddy' ), '#f7f3fd' ); ?> card_close(); ?> card_open_svg( '', __( 'Cards', 'admin-buddy' ), __( 'Postbox / meta box cards used on the Dashboard and edit screens.', 'admin-buddy' ) ); ?> colour_field( 'admbud_colours_postbox_bg', __( 'Card Background', 'admin-buddy' ), '', '#ffffff' ); $settings->colour_field( 'admbud_colours_postbox_header_bg', __( 'Card Header', 'admin-buddy' ), '', '#f9f7fe' ); $settings->colour_field( 'admbud_colours_postbox_border', __( 'Card Border', 'admin-buddy' ), '', '#decdfa' ); $settings->colour_field( 'admbud_colours_postbox_text', __( 'Card Text', 'admin-buddy' ), __( 'Text colour inside cards. Leave blank to use Body Text.', 'admin-buddy' ), '#3c434a' ); ?> card_close(); ?> card_open_svg( '', __( 'Notices', 'admin-buddy' ), __( 'Admin notice background. Semantic border colours (info/success/warning/error) are preserved.', 'admin-buddy' ) ); ?> colour_field( 'admbud_colours_notice_bg', __( 'Notice Background', 'admin-buddy' ), __( 'Background for all admin notices. Leave blank for WP default white.', 'admin-buddy' ), '#fbf9fe' ); ?> card_close(); ?> card_open_svg( '', __( 'Status Pills', 'admin-buddy' ), __( 'Admin bar indicator pill colours for Maintenance, Coming Soon and Search Blocked states.', 'admin-buddy' ) ); ?> card_close(); ?>
get_colour_presets(); $preset_nonce = wp_create_nonce( 'admbud_apply_preset' ); $settings->card_open_svg( '', __( 'Colour Presets', 'admin-buddy' ), __( 'Apply a ready-made colour scheme instantly. Overwrites your current colour settings.', 'admin-buddy' ) ); ?>
$preset ) : ?>

card_close(); ?>

[ 'label' => string, 'slugs' => string[], 'count' => int ] /** * Extract a plugin prefix from a menu slug. * Splits on both hyphens and underscores to group sub-pages. * e.g. "sureforms_entries" → "sureforms", "acf-field-group" → "acf" */ $get_prefix = static function ( string $slug ): string { // Normalise to lowercase before splitting. $slug = strtolower( $slug ); // strtok splits on ANY character in the delimiter string. return strtok( $slug, '-_' ); }; /** * Check if a slug should be skipped (core, junk, URL, hash-router, or .php file). */ $should_skip = static function ( string $slug ) use ( $core_prefixes, $junk_slugs, $get_prefix ): bool { if ( $slug === '' ) { return true; } // URLs and hash-router paths (e.g. Surerank#/advanced). if ( str_contains( $slug, '://' ) || str_contains( $slug, '.php' ) || str_contains( $slug, '#' ) ) { return true; } // Core prefixes. $slug_lower = strtolower( $slug ); foreach ( $core_prefixes as $cp ) { if ( $slug_lower === $cp || str_starts_with( $slug_lower, $cp ) ) { return true; } } // Junk single-word slugs. $prefix = $get_prefix( $slug ); if ( in_array( $prefix, $junk_slugs, true ) ) { return true; } // Skip very short prefixes (1 char) - too ambiguous. if ( strlen( $prefix ) < 2 ) { return true; } // Skip bare 'wp' slug only - allow wp-reset, wp-mail-smtp etc. if ( $slug_lower === 'wp' ) { return true; } return false; }; // Walk through $menu (top-level) first - these have the best labels. if ( ! empty( $menu ) && is_array( $menu ) ) { foreach ( $menu as $item ) { $slug = strtolower( $item[2] ?? '' ); $label = wp_strip_all_tags( $item[0] ?? '' ); if ( $should_skip( $slug ) || $label === '' ) { continue; } $prefix = $get_prefix( $slug ); if ( ! isset( $detected[ $prefix ] ) ) { $detected[ $prefix ] = [ 'label' => $label, 'slugs' => [], 'count' => 0 ]; } // Top-level label is usually the plugin name - prefer it. $detected[ $prefix ]['label'] = $label; if ( ! in_array( $slug, $detected[ $prefix ]['slugs'], true ) ) { $detected[ $prefix ]['slugs'][] = $slug; } } } // Walk through $submenu to count sub-pages per prefix. if ( ! empty( $submenu ) && is_array( $submenu ) ) { foreach ( $submenu as $parent => $items ) { foreach ( $items as $item ) { $slug = strtolower( $item[2] ?? '' ); if ( $should_skip( $slug ) ) { continue; } $prefix = $get_prefix( $slug ); if ( ! isset( $detected[ $prefix ] ) ) { $label = wp_strip_all_tags( $item[0] ?? '' ); if ( $label === '' ) { continue; } $detected[ $prefix ] = [ 'label' => $label, 'slugs' => [], 'count' => 0, ]; } if ( ! in_array( $slug, $detected[ $prefix ]['slugs'], true ) ) { $detected[ $prefix ]['slugs'][] = $slug; } $detected[ $prefix ]['count']++; } } } ksort( $detected ); ?> card_open_svg( '', __( 'Detected Plugins', 'admin-buddy' ), __( 'Toggle plugins whose admin pages should keep their own styling. Admin Buddy\'s content colours (links, buttons, tables, inputs) will be skipped on their pages. The sidebar and admin bar remain styled.', 'admin-buddy' ) ); ?>
$info ) : $is_excluded = false; foreach ( $excluded_slugs as $ex ) { if ( $prefix === $ex || str_starts_with( $prefix, $ex . '-' ) || str_starts_with( $prefix, $ex . '_' ) ) { $is_excluded = true; break; } if ( str_starts_with( $ex, $prefix . '-' ) || str_starts_with( $ex, $prefix . '_' ) || $ex === $prefix ) { $is_excluded = true; break; } } $page_count = max( 1, count( $info['slugs'] ) ); ?>

card_close(); ?> card_open_svg( '', __( 'Manual Exclusions', 'admin-buddy' ), __( 'For plugins not detected above, add page slugs manually. One entry per line. Prefix matching is supported: "acf" excludes acf-field-group, acf-post-type, etc.', 'admin-buddy' ) ); ?>
card_close(); ?>