<?php
/**
 * PHG Coming Soon — theme setup.
 *
 * @package phg-coming-soon
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Enqueue the stylesheet.
 */
function phg_enqueue_assets() {
	wp_enqueue_style(
		'phg-coming-soon',
		get_stylesheet_uri(),
		array(),
		wp_get_theme()->get( 'Version' )
	);
}
add_action( 'wp_enqueue_scripts', 'phg_enqueue_assets' );

/**
 * Basic theme supports. Title tag lets WP handle <title> for us.
 */
function phg_theme_setup() {
	add_theme_support( 'title-tag' );
	add_theme_support( 'html5', array( 'style', 'script' ) );
}
add_action( 'after_setup_theme', 'phg_theme_setup' );

/**
 * Trim the emoji/embed cruft — nothing on this page needs it.
 */
function phg_trim_head() {
	remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
	remove_action( 'wp_print_styles', 'print_emoji_styles' );
	remove_action( 'wp_head', 'wp_generator' );
	remove_action( 'wp_head', 'rsd_link' );
	remove_action( 'wp_head', 'wlwmanifest_link' );
}
add_action( 'init', 'phg_trim_head' );

/**
 * The site isn't launched yet — ask search engines to hold off indexing
 * until there's something to index.
 */
function phg_noindex() {
	echo '<meta name="robots" content="noindex, nofollow">' . "\n";
}
add_action( 'wp_head', 'phg_noindex', 1 );
