2013-07-29 00:55:10 +02:00
< ? php
/**
2013-10-12 00:02:11 +02:00
* Twenty Fourteen Theme Customizer support
2013-07-29 00:55:10 +02:00
*
* @ package WordPress
* @ subpackage Twenty_Fourteen
2013-10-12 00:02:11 +02:00
* @ since Twenty Fourteen 1.0
2013-07-29 00:55:10 +02:00
*/
/**
2013-10-15 20:01:09 +02:00
* Implement Theme Customizer additions and adjustments .
2013-07-29 00:55:10 +02:00
*
2013-10-12 00:02:11 +02:00
* @ since Twenty Fourteen 1.0
*
2013-07-29 00:55:10 +02:00
* @ param WP_Customize_Manager $wp_customize Theme Customizer object .
*/
function twentyfourteen_customize_register ( $wp_customize ) {
2013-10-15 20:01:09 +02:00
// Add postMessage support for site title and description.
2013-12-03 19:27:10 +01:00
$wp_customize -> get_setting ( 'blogname' ) -> transport = 'postMessage' ;
$wp_customize -> get_setting ( 'blogdescription' ) -> transport = 'postMessage' ;
$wp_customize -> get_setting ( 'header_textcolor' ) -> transport = 'postMessage' ;
// Rename the label to "Display Site Title & Tagline" in order to make this option extra clear.
$wp_customize -> add_control ( 'display_header_text' , array (
'settings' => 'header_textcolor' ,
'label' => __ ( 'Display Site Title & Tagline' , 'twentyfourteen' ),
'section' => 'title_tagline' ,
'type' => 'checkbox' ,
) );
// Rename the label to "Site Title Color" because this only effects the site title in this theme.
$wp_customize -> add_control ( new WP_Customize_Color_Control ( $wp_customize , 'header_textcolor' , array (
'label' => __ ( 'Site Title Color' , 'twentyfourteen' ),
'section' => 'colors' ,
) ) );
2013-10-16 01:24:10 +02:00
2013-11-07 21:37:08 +01:00
// Add custom description to Colors and Background sections.
2013-11-14 05:57:10 +01:00
$wp_customize -> get_section ( 'colors' ) -> description = __ ( 'Background may only be visible on wide screens.' , 'twentyfourteen' );
$wp_customize -> get_section ( 'background_image' ) -> description = __ ( 'Background may only be visible on wide screens.' , 'twentyfourteen' );
2013-11-07 21:28:11 +01:00
2013-11-07 21:25:09 +01:00
// Add the featured content section in case it's not already there.
2013-10-30 15:39:10 +01:00
$wp_customize -> add_section ( 'featured_content' , array (
2013-11-08 02:09:10 +01:00
'title' => __ ( 'Featured Content' , 'twentyfourteen' ),
2013-11-24 17:57:10 +01:00
'description' => sprintf ( __ ( 'Use a <a href="%1$s"> tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.' , 'twentyfourteen' ), admin_url ( '/edit.php?tag=featured' ), admin_url ( '/edit.php?show_sticky=1' ) ),
2013-11-08 02:09:10 +01:00
'priority' => 130 ,
2013-10-30 15:39:10 +01:00
) );
// Add the featured content layout setting and control.
$wp_customize -> add_setting ( 'featured_content_layout' , array (
2013-11-07 21:25:09 +01:00
'default' => 'grid' ,
2013-10-30 15:39:10 +01:00
) );
$wp_customize -> add_control ( 'featured_content_layout' , array (
'label' => __ ( 'Layout' , 'twentyfourteen' ),
'section' => 'featured_content' ,
'type' => 'select' ,
'choices' => array (
2013-11-07 21:25:09 +01:00
'grid' => __ ( 'Grid' , 'twentyfourteen' ),
2013-10-30 15:39:10 +01:00
'slider' => __ ( 'Slider' , 'twentyfourteen' ),
),
) );
2013-07-29 00:55:10 +02:00
}
add_action ( 'customize_register' , 'twentyfourteen_customize_register' );
/**
2013-10-12 00:02:11 +02:00
* Bind JS handlers to make Theme Customizer preview reload changes asynchronously .
*
* @ since Twenty Fourteen 1.0
2013-07-29 00:55:10 +02:00
*/
function twentyfourteen_customize_preview_js () {
2013-12-03 19:27:10 +01:00
wp_enqueue_script ( 'twentyfourteen_customizer' , get_template_directory_uri () . '/js/customizer.js' , array ( 'customize-preview' ), '20131130' , true );
2013-07-29 00:55:10 +02:00
}
2013-08-15 05:13:29 +02:00
add_action ( 'customize_preview_init' , 'twentyfourteen_customize_preview_js' );
2013-09-13 00:06:09 +02:00
2013-11-14 05:53:09 +01:00
/**
2013-12-03 18:06:11 +01:00
* Add contextual help to the Themes and Post edit screens .
2013-11-14 05:53:09 +01:00
*
* @ since Twenty Fourteen 1.0
*
* @ return void
*/
function twentyfourteen_contextual_help () {
2013-12-03 18:01:10 +01:00
if ( 'admin_head-edit.php' === current_filter () && 'post' !== $GLOBALS [ 'typenow' ] ) {
return ;
}
2013-11-14 05:53:09 +01:00
get_current_screen () -> add_help_tab ( array (
'id' => 'twentyfourteen' ,
'title' => __ ( 'Twenty Fourteen' , 'twentyfourteen' ),
'content' =>
'<ul>' .
2013-12-04 20:53:18 +01:00
'<li>' . sprintf ( __ ( 'The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled by the <a href="%1$s">featured</a> tag; you can change the tag and layout in <a href="%2$s">Appearance → Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.' , 'twentyfourteen' ), admin_url ( '/edit.php?tag=featured' ), admin_url ( 'customize.php' ), admin_url ( '/edit.php?show_sticky=1' ) ) . '</li>' .
2013-11-15 03:43:10 +01:00
'<li>' . sprintf ( __ ( 'Enhance your site design by using <a href="%s">Featured Images</a> for posts you’d like to stand out (also known as post thumbnails). This allows you to associate an image with your post without inserting it. Twenty Fourteen uses featured images for posts and pages—above the title—and in the Featured Content area on the home page.' , 'twentyfourteen' ), 'http://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail' ) . '</li>' .
2013-12-04 20:53:18 +01:00
'<li>' . sprintf ( __ ( 'For an in-depth tutorial, and more tips and tricks, visit the <a href="%s">Twenty Fourteen documentation</a>.' , 'twentyfourteen' ), 'http://codex.wordpress.org/Twenty_Fourteen' ) . '</li>' .
2013-11-14 05:53:09 +01:00
'</ul>' ,
) );
}
add_action ( 'admin_head-themes.php' , 'twentyfourteen_contextual_help' );
add_action ( 'admin_head-edit.php' , 'twentyfourteen_contextual_help' );