<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[26037] trunk/src/wp-content/themes/twentyfourteen: Twenty Fourteen: move all controls for managing Featured Content to the Customizer.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/26037">26037</a></dd>
<dt>Author</dt> <dd>lancewillett</dd>
<dt>Date</dt> <dd>2013-11-07 20:24:24 +0000 (Thu, 07 Nov 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Twenty Fourteen: move all controls for managing Featured Content to the Customizer. Also implement smart fallbacks to not using a custom tag with the "featured" tag and sticky posts. Props obenland and celloexpressions, see <a href="http://core.trac.wordpress.org/ticket/25549">#25549</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpcontentthemestwentyfourteenfunctionsphp">trunk/src/wp-content/themes/twentyfourteen/functions.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentyfourteeninccustomizerphp">trunk/src/wp-content/themes/twentyfourteen/inc/customizer.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentyfourteenincfeaturedcontentphp">trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentyfourteenjsfeaturedcontentadminjs">trunk/src/wp-content/themes/twentyfourteen/js/featured-content-admin.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpcontentthemestwentyfourteenfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-content/themes/twentyfourteen/functions.php (26036 => 26037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-content/themes/twentyfourteen/functions.php 2013-11-07 19:04:56 UTC (rev 26036)
+++ trunk/src/wp-content/themes/twentyfourteen/functions.php 2013-11-07 20:24:24 UTC (rev 26037)
</span><span class="lines">@@ -239,7 +239,7 @@
</span><span class="cx"> if ( is_active_sidebar( 'sidebar-3' ) )
</span><span class="cx"> wp_enqueue_script( 'jquery-masonry' );
</span><span class="cx">
</span><del>- if ( 'slider' == get_theme_mod( 'featured_content_layout' ) )
</del><ins>+ if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) )
</ins><span class="cx"> wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131028', true );
</span><span class="cx">
</span><span class="cx"> wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20131102', true );
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentyfourteeninccustomizerphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-content/themes/twentyfourteen/inc/customizer.php (26036 => 26037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-content/themes/twentyfourteen/inc/customizer.php 2013-11-07 19:04:56 UTC (rev 26036)
+++ trunk/src/wp-content/themes/twentyfourteen/inc/customizer.php 2013-11-07 20:24:24 UTC (rev 26037)
</span><span class="lines">@@ -28,23 +28,20 @@
</span><span class="cx"> $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'accent_color', array(
</span><span class="cx"> 'label' => __( 'Accent Color', 'twentyfourteen' ),
</span><span class="cx"> 'section' => 'colors',
</span><del>- 'settings' => 'accent_color',
</del><span class="cx"> ) ) );
</span><span class="cx">
</span><span class="cx"> add_filter( 'theme_mod_accent_mid', 'twentyfourteen_accent_mid' );
</span><span class="cx"> add_filter( 'theme_mod_accent_light', 'twentyfourteen_accent_light' );
</span><span class="cx">
</span><del>- // Add the featured content section.
</del><ins>+ // Add the featured content section in case it's not already there.
</ins><span class="cx"> $wp_customize->add_section( 'featured_content', array(
</span><span class="cx"> 'title' => __( 'Featured Content', 'twentyfourteen' ),
</span><del>- 'priority' => 120,
</del><ins>+ 'priority' => 130,
</ins><span class="cx"> ) );
</span><span class="cx">
</span><span class="cx"> // Add the featured content layout setting and control.
</span><span class="cx"> $wp_customize->add_setting( 'featured_content_layout', array(
</span><del>- 'default' => 'grid',
- 'type' => 'theme_mod',
- 'capability' => 'edit_theme_options',
</del><ins>+ 'default' => 'grid',
</ins><span class="cx"> ) );
</span><span class="cx">
</span><span class="cx"> $wp_customize->add_control( 'featured_content_layout', array(
</span><span class="lines">@@ -52,7 +49,7 @@
</span><span class="cx"> 'section' => 'featured_content',
</span><span class="cx"> 'type' => 'select',
</span><span class="cx"> 'choices' => array(
</span><del>- 'grid' => __( 'Grid', 'twentyfourteen' ),
</del><ins>+ 'grid' => __( 'Grid', 'twentyfourteen' ),
</ins><span class="cx"> 'slider' => __( 'Slider', 'twentyfourteen' ),
</span><span class="cx"> ),
</span><span class="cx"> ) );
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentyfourteenincfeaturedcontentphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php (26036 => 26037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php 2013-11-07 19:04:56 UTC (rev 26036)
+++ trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php 2013-11-07 20:24:24 UTC (rev 26037)
</span><span class="lines">@@ -68,15 +68,17 @@
</span><span class="cx"> if ( isset( $theme_support[0]['max_posts'] ) )
</span><span class="cx"> self::$max_posts = absint( $theme_support[0]['max_posts'] );
</span><span class="cx">
</span><del>- add_filter( $filter, array( __CLASS__, 'get_featured_posts' ) );
- add_action( 'admin_init', array( __CLASS__, 'register_setting' ) );
- add_action( 'save_post', array( __CLASS__, 'delete_transient' ) );
- add_action( 'delete_post_tag', array( __CLASS__, 'delete_post_tag' ) );
- add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
</del><ins>+ add_filter( $filter, array( __CLASS__, 'get_featured_posts' ) );
+ add_action( 'customize_register', array( __CLASS__, 'customize_register' ), 9 );
+ add_action( 'admin_init', array( __CLASS__, 'register_setting' ) );
+ add_action( 'save_post', array( __CLASS__, 'delete_transient' ) );
+ add_action( 'delete_post_tag', array( __CLASS__, 'delete_post_tag' ) );
+ add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
+ add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
</ins><span class="cx">
</span><span class="cx"> // Hide "featured" tag from the front-end.
</span><span class="cx"> if ( self::get_setting( 'hide-tag' ) ) {
</span><del>- add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 2 );
</del><ins>+ add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 2 );
</ins><span class="cx"> add_filter( 'get_the_terms', array( __CLASS__, 'hide_the_featured_term' ), 10, 3 );
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -86,22 +88,18 @@
</span><span class="cx"> *
</span><span class="cx"> * @uses Featured_Content::get_featured_post_ids()
</span><span class="cx"> *
</span><del>- * @return array|bool
</del><ins>+ * @return array
</ins><span class="cx"> */
</span><span class="cx"> public static function get_featured_posts() {
</span><span class="cx"> $post_ids = self::get_featured_post_ids();
</span><span class="cx">
</span><del>- // User has disabled Featured Content.
- if ( false === $post_ids )
- return false;
-
</del><span class="cx"> // No need to query if there is are no featured posts.
</span><span class="cx"> if ( empty( $post_ids ) )
</span><span class="cx"> return array();
</span><span class="cx">
</span><span class="cx"> $featured_posts = get_posts( array(
</span><span class="cx"> 'include' => $post_ids,
</span><del>- 'posts_per_page' => count( $post_ids )
</del><ins>+ 'posts_per_page' => count( $post_ids ),
</ins><span class="cx"> ) );
</span><span class="cx">
</span><span class="cx"> return $featured_posts;
</span><span class="lines">@@ -115,15 +113,20 @@
</span><span class="cx"> *
</span><span class="cx"> * Sets the "featured_content_ids" transient.
</span><span class="cx"> *
</span><del>- * @return array|false Array of post IDs. false if user has disabled this feature.
</del><ins>+ * @return array Array of post IDs
</ins><span class="cx"> */
</span><span class="cx"> public static function get_featured_post_ids() {
</span><span class="cx"> $settings = self::get_setting();
</span><span class="cx">
</span><span class="cx"> // Return false if the user has disabled this feature.
</span><span class="cx"> $tag = $settings['tag-id'];
</span><del>- if ( empty( $tag ) )
- return false;
</del><ins>+ if ( empty( $tag ) ) {
+ $term = get_term_by( 'name', 'featured', 'post_tag' );
+ if ( $term )
+ $tag = $term->term_id;
+ else
+ return self::get_sticky_posts();
+ }
</ins><span class="cx">
</span><span class="cx"> // Return array of cached results if they exist.
</span><span class="cx"> $featured_ids = get_transient( 'featured_content_ids' );
</span><span class="lines">@@ -142,9 +145,9 @@
</span><span class="cx"> ),
</span><span class="cx"> ) );
</span><span class="cx">
</span><del>- // Return empty array if no Featured Content exists.
</del><ins>+ // Return array with sticky posts if no Featured Content exists.
</ins><span class="cx"> if ( ! $featured )
</span><del>- return array();
</del><ins>+ return self::get_sticky_posts();
</ins><span class="cx">
</span><span class="cx"> // Ensure correct format before save/return.
</span><span class="cx"> $featured_ids = wp_list_pluck( (array) $featured, 'ID' );
</span><span class="lines">@@ -156,6 +159,16 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Returns an array with IDs of posts maked as sticky.
+ *
+ * @return array
+ */
+ public static function get_sticky_posts() {
+ $settings = self::get_setting();
+ return array_slice( get_option( 'sticky_posts', array() ), 0, $settings['quantity'] );
+ }
+
+ /**
</ins><span class="cx"> * Delete transient
</span><span class="cx"> *
</span><span class="cx"> * Hooks in the "save_post" action.
</span><span class="lines">@@ -221,12 +234,9 @@
</span><span class="cx"> public static function delete_post_tag( $tag_id ) {
</span><span class="cx"> $settings = self::get_setting();
</span><span class="cx">
</span><del>- if ( empty( $settings['tag-id'] ) )
</del><ins>+ if ( empty( $settings['tag-id'] ) || $tag_id != $settings['tag-id'] )
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- if ( $tag_id != $settings['tag-id'] )
- return;
-
</del><span class="cx"> $settings['tag-id'] = 0;
</span><span class="cx"> $settings = self::validate_settings( $settings );
</span><span class="cx"> update_option( 'featured-content', $settings );
</span><span class="lines">@@ -259,7 +269,7 @@
</span><span class="cx">
</span><span class="cx"> foreach( $terms as $order => $term ) {
</span><span class="cx"> if ( self::get_setting( 'tag-id' ) == $term->term_id && 'post_tag' == $term->taxonomy )
</span><del>- unset( $terms[$order] );
</del><ins>+ unset( $terms[ $order ] );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return $terms;
</span><span class="lines">@@ -284,7 +294,7 @@
</span><span class="cx"> return $terms;
</span><span class="cx">
</span><span class="cx"> // Make sure we are in the correct taxonomy.
</span><del>- if ( ! 'post_tag' == $taxonomy )
</del><ins>+ if ( 'post_tag' != $taxonomy )
</ins><span class="cx"> return $terms;
</span><span class="cx">
</span><span class="cx"> // No terms? Return early!
</span><span class="lines">@@ -293,7 +303,7 @@
</span><span class="cx">
</span><span class="cx"> foreach( $terms as $order => $term ) {
</span><span class="cx"> if ( self::get_setting( 'tag-id' ) == $term->term_id )
</span><del>- unset( $terms[$term->term_id] );
</del><ins>+ unset( $terms[ $term->term_id ] );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return $terms;
</span><span class="lines">@@ -308,46 +318,67 @@
</span><span class="cx"> * @return void
</span><span class="cx"> */
</span><span class="cx"> public static function register_setting() {
</span><del>- add_settings_field( 'featured-content', __( 'Featured content', 'twentyfourteen' ), array( __CLASS__, 'render_form' ), 'reading' );
- register_setting( 'reading', 'featured-content', array( __CLASS__, 'validate_settings' ) );
</del><ins>+ register_setting( 'featured-content', 'featured-content', array( __CLASS__, 'validate_settings' ) );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Render the form fields for Settings -> Reading screen
</del><ins>+ * Add settings to the Customizer.
</ins><span class="cx"> *
</span><del>- * @return void
</del><ins>+ * @param WP_Customize_Manager $wp_customize Theme Customizer object.
</ins><span class="cx"> */
</span><del>- public static function render_form() {
- $settings = self::get_setting();
</del><ins>+ public static function customize_register( $wp_customize ) {
+ $wp_customize->add_section( 'featured_content', array(
+ 'title' => __( 'Featured Content', 'twentyfourteen' ),
+ 'priority' => 130,
+ 'theme_supports' => 'featured-content',
+ ) );
</ins><span class="cx">
</span><del>- $tag_name = '';
- if ( ! empty( $settings['tag-id'] ) ) {
- $tag = get_term( $settings['tag-id'], 'post_tag' );
- if ( ! is_wp_error( $tag ) && isset( $tag->name ) )
- $tag_name = $tag->name;
- }
</del><ins>+ // Add Featured Content settings.
+ $wp_customize->add_setting( 'featured-content[tag-name]', array(
+ 'default' => 'featured',
+ 'type' => 'option',
+ ) );
+ $wp_customize->add_setting( 'featured-content[hide-tag]', array(
+ 'default' => true,
+ 'type' => 'option',
+ ) );
+ $wp_customize->add_setting( 'featured-content[tag-id]', array(
+ 'default' => 0,
+ 'type' => 'option',
+ ) );
</ins><span class="cx">
</span><del>- wp_enqueue_script( 'twentyfourteen-admin', get_template_directory_uri() . '/js/featured-content-admin.js', array( 'jquery', 'suggest' ), '20131016', true );
- ?>
- <div id="featured-content-ui">
- <p>
- <label for="featured-content-tag-name"><?php echo _e( 'Tag name:', 'twentyfourteen' ); ?></label>
- <input type="text" id="featured-content-tag-name" name="featured-content[tag-name]" value="<?php echo esc_attr( $tag_name ); ?>">
- <input type="hidden" id="featured-content-tag-id" name="featured-content[tag-id]" value="<?php echo esc_attr( $settings['tag-id'] ); ?>">
- </p>
- <p>
- <label for="featured-content-quantity"><?php _e( 'Number of posts:', 'twentyfourteen' ); ?></label>
- <input class="small-text" type="number" step="1" min="1" max="<?php echo esc_attr( self::$max_posts ); ?>" id="featured-content-quantity" name="featured-content[quantity]" value="<?php echo esc_attr( $settings['quantity'] ); ?>">
- </p>
- <p>
- <input type="checkbox" id="featured-content-hide-tag" name="featured-content[hide-tag]" <?php checked( $settings['hide-tag'], 1 ); ?>>
- <label for="featured-content-hide-tag"><?php _e( 'Hide tag from displaying in post meta and tag clouds.', 'twentyfourteen' ); ?></label>
- </p>
- </div>
- <?php
</del><ins>+ // Add Featured Content controls.
+ $wp_customize->add_control( 'featured-content[tag-name]', array(
+ 'label' => __( 'Tag name', 'twentyfourteen' ),
+ 'section' => 'featured_content',
+ 'priority' => 20,
+ ) );
+ $wp_customize->add_control( 'featured-content[hide-tag]', array(
+ 'label' => __( 'Hide tag from displaying in post meta and tag clouds.', 'twentyfourteen' ),
+ 'section' => 'featured_content',
+ 'type' => 'checkbox',
+ 'priority' => 30,
+ ) );
+ $wp_customize->add_control( new Featured_Content_Customize_Hidden_Control( $wp_customize, 'featured-content[tag-id]', array(
+ 'section' => 'featured_content',
+ 'priority' => 999,
+ ) ) );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Enqueue the tag suggestion script.
+ *
+ * @since Twenty Fourteen 1.0
+ */
+ public static function enqueue_scripts() {
+ wp_enqueue_script( 'featured-content-suggest', get_template_directory_uri() . '/js/featured-content-admin.js', array( 'jquery', 'suggest' ), '20131022', true );
+ wp_localize_script( 'featured-content-suggest', 'featuredContent', array(
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
+ ) );
+ }
+
+
+ /**
</ins><span class="cx"> * Get settings
</span><span class="cx"> *
</span><span class="cx"> * Get all settings recognized by this module. This function will return
</span><span class="lines">@@ -357,7 +388,7 @@
</span><span class="cx"> * In the event that you only require one setting, you may pass its name
</span><span class="cx"> * as the first parameter to the function and only that value will be returned.
</span><span class="cx"> *
</span><del>- * @uses Featured_Content::self::sanitize_quantity()
</del><ins>+ * @uses Featured_Content::sanitize_quantity()
</ins><span class="cx"> *
</span><span class="cx"> * @param string $key The key of a recognized setting.
</span><span class="cx"> * @return mixed Array of all settings by default. A single value if passed as first parameter.
</span><span class="lines">@@ -375,12 +406,8 @@
</span><span class="cx"> $options = array_intersect_key( $options, $defaults );
</span><span class="cx"> $options['quantity'] = self::sanitize_quantity( $options['quantity'] );
</span><span class="cx">
</span><del>- if ( 'all' != $key ) {
- if ( isset( $options[$key] ) )
- return $options[$key];
- else
- return false;
- }
</del><ins>+ if ( 'all' != $key )
+ return isset( $options[ $key ] ) ? $options[ $key ] : false;
</ins><span class="cx">
</span><span class="cx"> return $options;
</span><span class="cx"> }
</span><span class="lines">@@ -405,20 +432,25 @@
</span><span class="cx"> if ( isset( $input['tag-id'] ) )
</span><span class="cx"> $output['tag-id'] = absint( $input['tag-id'] );
</span><span class="cx">
</span><del>- if ( isset( $input['tag-name'] ) && ! empty( $input['tag-name'] ) ) {
- $new_tag = wp_create_tag( $input['tag-name'] );
- if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) )
- $tag = get_term( $new_tag['term_id'], 'post_tag' );
- if ( isset( $tag->term_id ) )
- $output['tag-id'] = $tag->term_id;
- } else {
- unset( $output['tag-id'] );
</del><ins>+ if ( isset( $input['tag-name'] ) ) {
+ if ( empty( $input['tag-name'] ) ) {
+ $output['tag-id'] = 0;
+ } else {
+ $new_tag = wp_create_tag( $input['tag-name'] );
+ if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) )
+ $tag = get_term( $new_tag['term_id'], 'post_tag' );
+ if ( isset( $tag->term_id ) )
+ $output['tag-id'] = $tag->term_id;
+ if ( is_int( $new_tag ) )
+ $output['tag-id'] = $new_tag;
+ $output['tag-name'] = get_term( $output['tag-id'], 'post_tag' )->name;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if ( isset( $input['quantity'] ) )
</span><span class="cx"> $output['quantity'] = self::sanitize_quantity( $input['quantity'] );
</span><span class="cx">
</span><del>- $output['hide-tag'] = ( isset( $input['hide-tag'] ) ) ? 1 : 0;
</del><ins>+ $output['hide-tag'] = isset( $input['hide-tag'] ) && $input['hide-tag'] ? 1 : 0;
</ins><span class="cx">
</span><span class="cx"> self::delete_transient();
</span><span class="cx">
</span><span class="lines">@@ -445,4 +477,14 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+if ( class_exists( 'WP_Customize_Control' ) ) {
+ class Featured_Content_Customize_Hidden_Control extends WP_Customize_Control {
+ public function render_content() {
+ ?>
+ <input type="hidden" <?php $this->link(); ?> value="<?php echo esc_attr( $this->value() ); ?>">
+ <?php
+ }
+ }
+}
+
</ins><span class="cx"> Featured_Content::setup();
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentyfourteenjsfeaturedcontentadminjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-content/themes/twentyfourteen/js/featured-content-admin.js (26036 => 26037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-content/themes/twentyfourteen/js/featured-content-admin.js 2013-11-07 19:04:56 UTC (rev 26036)
+++ trunk/src/wp-content/themes/twentyfourteen/js/featured-content-admin.js 2013-11-07 20:24:24 UTC (rev 26037)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><del>-jQuery( document ).ready( function( $ ) {
- $( '#featured-content-tag-name' ).suggest( ajaxurl + '?action=ajax-tag-search&tax=post_tag', { delay: 500, minchars: 2 } );
-} );
</del><span class="cx">\ No newline at end of file
</span><ins>+jQuery( function( $ ) {
+ $( '#customize-control-featured-content-tag-name input' ).suggest( featuredContent.ajaxurl + '?action=ajax-tag-search&tax=post_tag', { delay: 500, minchars: 2 } );
+} );
</ins></span></pre>
</div>
</div>
</body>
</html>