<?php
/**
 * Alovernat Theme Customizer support
 *
 * 
 * @subpackage Alovernat
 * @since Alovernat 1.0
 */

/**
 * Implement Theme Customizer additions and adjustments.
 *
 * @since Alovernat 1.0
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function alovernat_customize_register( $wp_customize ) {

	// Add postMessage support for site title and description.
	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';


	// Rename the label to "Display Site Title & Tagline" in order to make this option extra clear.
	$wp_customize->get_control( 'display_header_text' )->label = __( 'Display Site Title &amp; Tagline', 'alovernat' );


}
add_action( 'customize_register', 'alovernat_customize_register' );


/**
 * Bind JS handlers to make Theme Customizer preview reload changes asynchronously.
 *
 * @since Alovernat 1.0
 */
function alovernat_customize_preview_js() {
	wp_enqueue_script( 'alovernat_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20141027', true );
}
add_action( 'customize_preview_init', 'alovernat_customize_preview_js' );

/**
 * Add contextual help to the Themes and Post edit screens.
 *
 * @since Alovernat 1.0
 */
function alovernat_contextual_help() {
	if ( 'admin_head-edit.php' === current_filter() && 'post' !== $GLOBALS['typenow'] ) {
		return;
	}

	get_current_screen()->add_help_tab( array(
		'id'      => 'alovernat',
		'title'   => __( 'Alovernat', 'alovernat' ),
		'content' =>
			'<ul>' .
				'<li>' . sprintf( __( 'The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled by a <a href="%1$s">tag</a>; you can change the tag and layout in <a href="%2$s">Appearance &rarr; Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.', 'alovernat' ), esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'alovernat' ), admin_url( 'edit.php' ) ) ), admin_url( 'customize.php' ), admin_url( 'edit.php?show_sticky=1' ) ) . '</li>' .
				'<li>' . sprintf( __( 'Enhance your site design by using <a href="%s">Featured Images</a> for posts you&rsquo;d like to stand out (also known as post thumbnails). This allows you to associate an image with your post without inserting it. Alovernat uses featured images for posts and pages&mdash;above the title&mdash;and in the Featured Content area on the home page.', 'alovernat' ), 'http://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail' ) . '</li>' .
				
			'</ul>',
	) );
}
add_action( 'admin_head-themes.php', 'alovernat_contextual_help' );
add_action( 'admin_head-edit.php',   'alovernat_contextual_help' );
