Changeset 26079
- Timestamp:
- 11/10/2013 11:37:36 PM (11 years ago)
- Location:
- trunk/src/wp-content/themes/twentyfourteen
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfourteen/inc/customizer.php
r26045 r26079 21 21 22 22 // Add custom description to Colors and Background sections. 23 $wp_customize->get_section( 'colors' )->description = __( 'Background may only be visible on wide screens.', 'twentyfourteen' );23 $wp_customize->get_section( 'colors' )->description = __( 'Background may only be visible on wide screens.', 'twentyfourteen' ); 24 24 $wp_customize->get_section( 'background_image' )->description = __( 'Background may only be visible on wide screens.', 'twentyfourteen' ); 25 25 -
trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php
r26037 r26079 3 3 * Twenty Fourteen Featured Content 4 4 * 5 * This module allows you to define a subset of posts to be 6 * displayed in thetheme's Featured Content area.5 * This module allows you to define a subset of posts to be displayed in the 6 * theme's Featured Content area. 7 7 * 8 * For maximum compatibility with different methods of posting 9 * users will designate a featured post tag to associate posts 10 * with. Since this tag now has special meaning beyond that of a 11 * normal tags, users will have the ability to hide it from the 12 * front-end of their site. 8 * For maximum compatibility with different methods of posting users will 9 * designate a featured post tag to associate posts with. Since this tag now 10 * has special meaning beyond that of a normal tags, users will have the 11 * ability to hide it from the front-end of their site. 13 12 */ 14 13 class Featured_Content { 15 14 16 15 /** 17 * The maximum number of posts that a Featured Content 18 * area can contain. We define a default value here but 19 * themes can override this by defining a "max_posts" 20 * entry in the second parameter passed in the call to 16 * The maximum number of posts that a Featured Content area can contain. We 17 * define a default value here but themes can override this by defining a 18 * "max_posts" entry in the second parameter passed in the call to 21 19 * add_theme_support( 'featured-content' ). 22 20 * … … 40 38 * add_theme_support( 'featured-content' ); during after_setup_theme. 41 39 * 42 * If no theme support is found there is no need to hook into 43 * W ordPress. We'll just return early instead.40 * If no theme support is found there is no need to hook into WordPress. 41 * We'll just return early instead. 44 42 * 45 43 * @uses Featured_Content::$max_posts … … 53 51 54 52 /* 55 * An array of named arguments must be passed as 56 * the second parameterof add_theme_support().53 * An array of named arguments must be passed as the second parameter 54 * of add_theme_support(). 57 55 */ 58 56 if ( ! isset( $theme_support[0] ) ) … … 76 74 add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) ); 77 75 add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) ); 78 79 // Hide "featured" tag from the front-end. 76 add_action( 'wp_loaded', array( __CLASS__, 'wp_loaded' ) ); 77 } 78 79 /** 80 * Hide "featured" tag from the front-end. 81 * 82 * Has to run on wp_loaded so that the preview filters of the customizer 83 * have a chance to alter the value. 84 */ 85 public static function wp_loaded() { 80 86 if ( self::get_setting( 'hide-tag' ) ) { 81 87 add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 2 ); … … 117 123 */ 118 124 public static function get_featured_post_ids() { 119 $settings = self::get_setting();120 121 // Return false if the user has disabled this feature.122 $tag = $settings['tag-id'];123 if ( empty( $tag ) ) {124 $term = get_term_by( 'name', 'featured', 'post_tag' );125 if ( $term )126 $tag = $term->term_id;127 else128 return self::get_sticky_posts();129 }130 131 125 // Return array of cached results if they exist. 132 126 $featured_ids = get_transient( 'featured_content_ids' ); 133 127 if ( ! empty( $featured_ids ) ) 134 128 return array_map( 'absint', (array) $featured_ids ); 129 130 $settings = self::get_setting(); 131 132 // Return sticky post ids if no tag name is set. 133 $term = get_term_by( 'name', $settings['tag-name'], 'post_tag' ); 134 if ( $term ) 135 $tag = $term->term_id; 136 else 137 return self::get_sticky_posts(); 135 138 136 139 // Query for featured posts. … … 229 232 * @see Featured_Content::validate_settings(). 230 233 * 231 * @param int $tag_id the term_id of the tag that has been deleted.234 * @param int $tag_id The term_id of the tag that has been deleted. 232 235 * @return void 233 236 */ … … 330 333 $wp_customize->add_section( 'featured_content', array( 331 334 'title' => __( 'Featured Content', 'twentyfourteen' ), 335 'description' => __( 'Easily feature all posts with the "featured" tag or a tag of your choice; if no posts match the tag, "sticky" posts will be displayed instead.', 'twentyfourteen' ), 332 336 'priority' => 130, 333 337 'theme_supports' => 'featured-content', … … 336 340 // Add Featured Content settings. 337 341 $wp_customize->add_setting( 'featured-content[tag-name]', array( 338 'default' => 'featured', 339 'type' => 'option', 342 'default' => 'featured', 343 'type' => 'option', 344 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ), 340 345 ) ); 341 346 $wp_customize->add_setting( 'featured-content[hide-tag]', array( 342 'default' => true, 343 'type' => 'option', 344 ) ); 345 $wp_customize->add_setting( 'featured-content[tag-id]', array( 346 'default' => 0, 347 'type' => 'option', 347 'default' => true, 348 'type' => 'option', 349 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ), 348 350 ) ); 349 351 … … 360 362 'priority' => 30, 361 363 ) ); 362 $wp_customize->add_control( new Featured_Content_Customize_Hidden_Control( $wp_customize, 'featured-content[tag-id]', array(363 'section' => 'featured_content',364 'priority' => 999,365 ) ) );366 364 } 367 365 … … 376 374 'ajaxurl' => admin_url( 'admin-ajax.php' ), 377 375 ) ); 378 } 379 376 wp_add_inline_style( 'customize-controls', " 377 .ac_results { 378 z-index: 500000; 379 } 380 " ); 381 } 380 382 381 383 /** … … 401 403 'quantity' => 6, 402 404 'tag-id' => 0, 405 'tag-name' => 'featured', 403 406 ); 404 407 … … 430 433 $output = array(); 431 434 432 if ( isset( $input['tag-id'] ) )433 $output['tag-id'] = absint( $input['tag-id'] );434 435 if ( isset( $input['tag-name'] ) ) {436 if ( empty( $input['tag-name'] ) ) {437 $output['tag-id'] = 0;435 if ( empty( $input['tag-name'] ) ) { 436 $output['tag-id'] = 0; 437 } else { 438 $new_tag = wp_create_tag( $input['tag-name'] ); 439 if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) ) { 440 $output['tag-id'] = $new_tag['term_id']; 438 441 } else { 439 $new_tag = wp_create_tag( $input['tag-name'] ); 440 if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) ) 441 $tag = get_term( $new_tag['term_id'], 'post_tag' ); 442 if ( isset( $tag->term_id ) ) 443 $output['tag-id'] = $tag->term_id; 444 if ( is_int( $new_tag ) ) 445 $output['tag-id'] = $new_tag; 446 $output['tag-name'] = get_term( $output['tag-id'], 'post_tag' )->name; 442 $term = get_term_by( 'name', $input['tag-name'], 'post_tag' ); 443 $output['tag-id'] = $term ? $term->term_id : 0; 447 444 } 445 $output['tag-name'] = $input['tag-name']; 448 446 } 449 447 … … 478 476 } 479 477 480 if ( class_exists( 'WP_Customize_Control' ) ) {481 class Featured_Content_Customize_Hidden_Control extends WP_Customize_Control {482 public function render_content() {483 ?>484 <input type="hidden" <?php $this->link(); ?> value="<?php echo esc_attr( $this->value() ); ?>">485 <?php486 }487 }488 }489 490 478 Featured_Content::setup(); -
trunk/src/wp-content/themes/twentyfourteen/style.css
r26069 r26079 2861 2861 2862 2862 /* Does the same thing as <meta name="viewport" content="width=device-width">, 2863 * but in the future W3C standard way. -ms- prefix is required for IE10+ to 2864 * render responsive styling in Windows 8 "snapped" views; IE10+ does not honor 2863 * but in the future W3C standard way. -ms- prefix is required for IE10+ to 2864 * render responsive styling in Windows 8 "snapped" views; IE10+ does not honor 2865 2865 * the meta tag. See http://core.trac.wordpress.org/ticket/25888. 2866 2866 */
Note: See TracChangeset
for help on using the changeset viewer.