<?php
/**
 * BrowserThemeColor.
 *
 * @package MadeByAura\Prime\Hooks
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime\Hooks;

use MadeByAura\Prime\Helpers\SingletonTrait;

defined( 'ABSPATH' ) || die();

/**
 * BrowserThemeColor.
 */
class BrowserThemeColor {
	use SingletonTrait;

	/**
	 * Constructor.
	 */
	protected function __construct() {
		// Add brand color to browser theme.
		add_action( 'wp_head', [ __CLASS__, 'add_browser_theme_color' ] );
	}

	/**
	 * Add brand color to browser theme.
	 */
	public static function add_browser_theme_color() {
		$color = get_theme_mod( 'aura_browser_theme_color' );

		// Do not proceed if there is no color.
		if ( ! $color ) {
			return;
		}

		?>
		<meta name="msapplication-TileColor" content="<?php echo esc_attr( $color ); ?>">
		<meta name="theme-color" content="<?php echo esc_attr( $color ); ?>">
		<?php
	}
}
