mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-27 11:38:01 +01:00
4d6ec7fa96
Built from https://develop.svn.wordpress.org/trunk@26573 git-svn-id: http://core.svn.wordpress.org/trunk@26464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
99 lines
4.5 KiB
PHP
99 lines
4.5 KiB
PHP
<?php
|
|
/**
|
|
* Twenty Fourteen Theme Customizer support
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Twenty_Fourteen
|
|
* @since Twenty Fourteen 1.0
|
|
*/
|
|
|
|
/**
|
|
* Implement Theme Customizer additions and adjustments.
|
|
*
|
|
* @since Twenty Fourteen 1.0
|
|
*
|
|
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
|
*/
|
|
function twentyfourteen_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';
|
|
$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',
|
|
) ) );
|
|
|
|
// Add custom description to Colors and Background sections.
|
|
$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' );
|
|
|
|
// Add the featured content section in case it's not already there.
|
|
$wp_customize->add_section( 'featured_content', array(
|
|
'title' => __( 'Featured Content', 'twentyfourteen' ),
|
|
'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' ) ),
|
|
'priority' => 130,
|
|
) );
|
|
|
|
// Add the featured content layout setting and control.
|
|
$wp_customize->add_setting( 'featured_content_layout', array(
|
|
'default' => 'grid',
|
|
) );
|
|
|
|
$wp_customize->add_control( 'featured_content_layout', array(
|
|
'label' => __( 'Layout', 'twentyfourteen' ),
|
|
'section' => 'featured_content',
|
|
'type' => 'select',
|
|
'choices' => array(
|
|
'grid' => __( 'Grid', 'twentyfourteen' ),
|
|
'slider' => __( 'Slider', 'twentyfourteen' ),
|
|
),
|
|
) );
|
|
}
|
|
add_action( 'customize_register', 'twentyfourteen_customize_register' );
|
|
|
|
/**
|
|
* Bind JS handlers to make Theme Customizer preview reload changes asynchronously.
|
|
*
|
|
* @since Twenty Fourteen 1.0
|
|
*/
|
|
function twentyfourteen_customize_preview_js() {
|
|
wp_enqueue_script( 'twentyfourteen_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20131130', true );
|
|
}
|
|
add_action( 'customize_preview_init', 'twentyfourteen_customize_preview_js' );
|
|
|
|
/**
|
|
* Add contextual help to the Themes and Post edit screens.
|
|
*
|
|
* @since Twenty Fourteen 1.0
|
|
*
|
|
* @return void
|
|
*/
|
|
function twentyfourteen_contextual_help() {
|
|
if ( 'admin_head-edit.php' === current_filter() && 'post' !== $GLOBALS['typenow'] ) {
|
|
return;
|
|
}
|
|
|
|
get_current_screen()->add_help_tab( array(
|
|
'id' => 'twentyfourteen',
|
|
'title' => __( 'Twenty Fourteen', 'twentyfourteen' ),
|
|
'content' =>
|
|
'<ul>' .
|
|
'<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" tag</a>; 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>' .
|
|
'<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>' .
|
|
'</ul>',
|
|
) );
|
|
}
|
|
add_action( 'admin_head-themes.php', 'twentyfourteen_contextual_help' );
|
|
add_action( 'admin_head-edit.php', 'twentyfourteen_contextual_help' );
|