wppaste
WordPress

Featured_Content

Source
wp-content/themes/twentyfourteen/inc/featured-content.php:13
Twenty Fourteen Featured Content

Description

This module allows you to define a subset of posts to be displayed in the theme's Featured Content area.

For maximum compatibility with different methods of posting users will designate a featured post tag to associate posts with. Since this tag now has special meaning beyond that of a normal tags, users will have the ability to hide it from the front end of their site.

Compatibility

WordPress
core
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 1

$max_postsintpublic static
The maximum number of posts a Featured Content area can contain.

Methods · 16

Source code

class Featured_Content { 	/**	 * The maximum number of posts a Featured Content area can contain.	 *	 * We define a default value here but themes can override	 * this by defining a "max_posts" entry in the second parameter	 * passed in the call to add_theme_support( 'featured-content' ).	 *	 * @see Featured_Content::init()	 *	 * @since Twenty Fourteen 1.0	 *	 * @var int	 */	public static $max_posts = 15; 	/**	 * Instantiates.	 *	 * All custom functionality will be hooked into the "init" action.	 *	 * @since Twenty Fourteen 1.0	 */	public static function setup() {		add_action( 'init', array( __CLASS__, 'init' ), 30 );	} 	/**	 * Conditionally hooks into WordPress.	 *	 * Theme must declare that they support this module by adding	 * add_theme_support( 'featured-content' ); during after_setup_theme.	 *	 * If no theme support is found there is no need to hook into WordPress.	 * We'll just return early instead.	 *	 * @since Twenty Fourteen 1.0	 */	public static function init() {		$theme_support = get_theme_support( 'featured-content' ); 		// Return early if theme does not support Featured Content.		if ( ! $theme_support ) {			return;		} 		/*		 * An array of named arguments must be passed as the second parameter		 * of add_theme_support().		 */		if ( ! isset( $theme_support[0] ) ) {			return;		} 		// Return early if "featured_content_filter" has not been defined.		if ( ! isset( $theme_support[0]['featured_content_filter'] ) ) {			return;		} 		$filter = $theme_support[0]['featured_content_filter']; 		// Theme can override the number of max posts.		if ( isset( $theme_support[0]['max_posts'] ) ) {			self::$max_posts = absint( $theme_support[0]['max_posts'] );		} 		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( 'switch_theme', array( __CLASS__, 'delete_transient' ) );		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' ) );		add_action( 'wp_loaded', array( __CLASS__, 'wp_loaded' ) );	} 	/**	 * Hides "featured" tag from the front end.

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-content/themes/twentyfourteen/inc/featured-content.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.