<?php
/**
 * Name: Site Identity on Login
 * Description: Replace default WordPress logo with your site icon on login page to create branded login experience matching your site identity and design
 * Category: Admin
 * Icon: -
 * UseCases: [
 *   {
 *     "title": "Brand Recognition",
 *     "description": "Display site logo and tagline on login page so team members quickly identify which client site they're logging into among 20+ sites."
 *   },
 *   {
 *     "title": "Multi-Brand Multisite",
 *     "description": "Each subsite shows its own logo on login, preventing editors from accidentally logging into wrong brand's admin area."
 *   },
 *   {
 *     "title": "Professional First Impression",
 *     "description": "New clients see their brand identity immediately on login page, reinforcing professional, customized website delivery."
 *   }
 * ]
 * WhereToFind: {
 *   "location": "Login Page",
 *   "url": "/wp-login.php",
 *   "instructions": "Logout to see your site icon on the login page",
 *   "newTab": true
 * }
 * Added: 2025-07-02
 * Tags: login, logo, branding, site-icon, customization
 */

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

class SwitchboardSiteIdentityLogin {
    
    public function __construct() {
        add_filter('login_headerurl', [$this, 'login_url']);
        add_filter('login_headertext', [$this, 'login_title']);
        add_action('login_enqueue_scripts', [$this, 'login_logo']);
    }
    
    public function login_url() {
        return home_url();
    }
    
    public function login_title() {
        return get_bloginfo('name');
    }
    
    public function login_logo() {
        $site_icon = get_site_icon_url(84);

        if ($site_icon) {
            echo '<style type="text/css">
                #login h1 a {
                    background-image: url(' . esc_url($site_icon) . ');
                    background-size: contain;
                    width: 84px;
                    height: 84px;
                }
            </style>';
        }
    }

    /**
     * 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 SwitchboardSiteIdentityLogin();
Switchboard_Data_Registry::get_instance()->auto_register($switchboard_instance, __FILE__);
