<?php
/**
 * Compatibility settings and functions for WP.com
 * Kept in separate file easier merging and separation of concerns.
 */

/**
 * Theme Colors (old skool)
 */
if ( ! isset( $themecolors ) ) {
	$themecolors = array(
		'bg' => 'ffffff',
		'text' => '444444',
		'link' => '21759b',
		'border' => 'CCCCCC',
		'url' => '21759b',
	);
}

/**
 * Enqueue our WP.com styles for front-end.
 * Loads after style.css so we can add overrides.
 */
function twentytwelve_wpcom_styles() {
	wp_enqueue_style( 'twentytwelve-wpcom-style', get_template_directory_uri() . '/style-wpcom.css' );
}
add_action( 'wp_enqueue_scripts', 'twentytwelve_wpcom_styles' );

/**
 * Better support for full-width pages and Tiled Galleries.
 *
 * This forces a value of 960 pixels for content_width on full-width pages
 * regardless of what users save in their Custom CSS settings.
 *
 * The Custom CSS with setting will only affect "normal" content containers
 * on posts/pages when a sidebar is present.
 */
function twentytwelve_tiled_contentwidth() {
	if ( is_page_template( 'page-templates/full-width.php' ) || is_attachment() || ! is_active_sidebar( 'sidebar-1' ) )
		remove_filter( 'tiled_gallery_content_width', 'wpcom_content_width' );
}
add_action( 'template_redirect', 'twentytwelve_tiled_contentwidth' );

/**
 * Sets up defaults for wp.com-specific functionality
 */
function twentytwelve_wpcom_setup() {
	add_theme_support( 'video-header' );
}
add_action( 'after_setup_theme', 'twentytwelve_wpcom_setup' );

/**
 * Whether a video header has been set up.
 *
 * @return bool
 */
function twentytwelve_has_video_header() {
	return apply_filters( 'wpcom_has_video_header', false );
}

/**
 * Displays header video
 *
 * @return void
 */
function twentytwelve_video_header() {
	do_action( 'wpcom_video_header' );
}