Make WordPress Core

Changeset 25808


Ignore:
Timestamp:
10/16/2013 04:21:10 AM (8 years ago)
Author:
lancewillett
Message:

Twenty Fourteen: first pass at implementing Featured Content settings, props obenland. See #25549.

Location:
trunk/src/wp-content/themes/twentyfourteen
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/functions.php

    r25804 r25808  
    103103
    104104    /*
     105     * Add support for featured content.
     106     */
     107    add_theme_support( 'featured-content', array(
     108        'featured_content_filter' => 'twentyfourteen_get_featured_posts',
     109        'max_posts' => 6,
     110    ) );
     111
     112    /*
    105113     * This theme uses its own gallery styles.
    106114     */
     
    127135 *
    128136 * @since Twenty Fourteen 1.0
     137 *
     138 * @return array An array of WP_Post objects.
    129139 */
    130140function twentyfourteen_get_featured_posts() {
    131     return apply_filters( 'twentyfourteen_get_featured_posts', false );
    132 }
    133 
    134 /**
    135  * A helper conditional function that returns a boolean value
    136  * So that we can use a condition like
    137  * if ( twentyfourteen_has_featured_posts( 1 ) )
    138  *
    139  * @since Twenty Fourteen 1.0
    140  */
    141 function twentyfourteen_has_featured_posts( $minimum = 1 ) {
    142     if ( is_paged() )
    143         return false;
    144 
    145         $featured_posts = apply_filters( 'twentyfourteen_get_featured_posts', array() );
    146 
    147     return is_array( $featured_posts ) && count( $featured_posts ) > absint( $minimum );
     141    return apply_filters( 'twentyfourteen_get_featured_posts', array() );
     142}
     143
     144/**
     145 * A helper conditional function that returns a boolean value.
     146 *
     147 * @since Twenty Fourteen 1.0
     148 *
     149 * @return bool Whether there are featured posts.
     150 */
     151function twentyfourteen_has_featured_posts() {
     152    return ! is_paged() && (bool) apply_filters( 'twentyfourteen_get_featured_posts', false );
    148153}
    149154
     
    353358
    354359/**
    355  * Get recent formatted posts that are not featured in FC plugin.
     360 * Get recent formatted posts that are not featured in Featured Content area.
    356361 *
    357362 * @since Twenty Fourteen 1.0
     
    522527// Add Theme Customizer functionality.
    523528require get_template_directory() . '/inc/customizer.php';
     529
     530/*
     531 * Add Featured Content functionality.
     532 *
     533 * To overwrite in a plugin, define your own Featured_Content class on or
     534 * before the 'setup_theme' hook.
     535 */
     536if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] )
     537    require get_template_directory() . '/inc/featured-content.php';
Note: See TracChangeset for help on using the changeset viewer.