<?php
/**
 * Name: Wider Admin Menu
 * Description: Increase admin menu width for better readability of long menu item names and improve navigation especially when using plugins with lengthy menu labels
 * Category: Admin
 * Icon: -
 * UseCases: [
 *   {
 *     "title": "Long Menu Item Names",
 *     "description": "Increase menu width for sites with descriptive custom post types like 'Customer Testimonials' or 'Product Categories' that get truncated."
 *   },
 *   {
 *     "title": "Ultra-Wide Monitors",
 *     "description": "Utilize extra screen space on 27-inch+ monitors by expanding admin menu without sacrificing content area width."
 *   },
 *   {
 *     "title": "Accessibility for Readability",
 *     "description": "Widen menu for users who increased font size for accessibility, preventing text overflow and menu item wrapping."
 *   }
 * ]
 * Added: 2025-08-15
 * Tags: admin-menu, width, ui, layout, sidebar
 * WhereToFind: {
 *   "location": "Admin Sidebar Menu",
 *   "url": "",
 *   "instructions": "When enabled, admin sidebar menu automatically expands to 200px width for better readability of long menu item names.",
 *   "newTab": false
 * }
 */

// Prevent direct access
if (!defined('ABSPATH')) exit;

class SwitchboardWiderAdminMenu {
    
    public function __construct() {
        add_action('admin_head', [$this, 'add_custom_css']);
    }
    
    public function add_custom_css() {
        ?>
        <style>
            /* Widen admin menu and adjust content area */
            #adminmenuback,
            #adminmenuwrap,
            #adminmenu,
            #adminmenu .wp-submenu {
                width: 220px;
            }

            #wpcontent,
            #wpfooter {
                margin-left: 220px;
            }

            /* Fix submenu positioning for wider menu */
            #adminmenu .wp-submenu {
                left: 220px;
            }

            #adminmenu .wp-not-current-submenu .wp-submenu,
            .folded #adminmenu .wp-has-current-submenu .wp-submenu {
                min-width: 220px;
            }

            /* Responsive adjustment for tablets and mobile */
            @media screen and (max-width: 960px) {
                #adminmenuback,
                #adminmenuwrap,
                #adminmenu,
                #adminmenu .wp-submenu {
                    width: 160px;
                }

                #adminmenu .wp-submenu {
                    left: 160px;
                }

                #adminmenu .wp-not-current-submenu .wp-submenu,
                .folded #adminmenu .wp-has-current-submenu .wp-submenu {
                    min-width: 160px;
                }
            }
        </style>
        <?php
    }

    /**
     * Register data locations for cleanup system
     *
     * @return array
     */
    public function register_data_locations() {
        return [
            'options' => [],
            'option_patterns' => [],
            'tables' => [],
            'post_meta' => [],
            'user_meta' => [],
        ];
    }
}

$switchboard_instance = new SwitchboardWiderAdminMenu();
Switchboard_Data_Registry::get_instance()->auto_register($switchboard_instance, __FILE__);
