2013-10-16 00:22:09 -04:00
< ? php
/**
* Twenty Fourteen Featured Content
*
2013-12-03 12:06:11 -05:00
* This module allows you to define a subset of posts to be displayed
* in the theme ' s Featured Content area .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* 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
2016-02-25 07:53:27 -05:00
* will have the ability to hide it from the front end of their site .
2013-10-16 00:22:09 -04:00
*/
class Featured_Content {
/**
2013-12-03 12:06:11 -05:00
* 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' ) .
2013-10-16 00:22:09 -04:00
*
* @ see Featured_Content :: init ()
2013-12-03 12:06:11 -05:00
*
* @ since Twenty Fourteen 1.0
*
* @ var int
2013-10-16 00:22:09 -04:00
*/
public static $max_posts = 15 ;
/**
2013-12-03 12:06:11 -05:00
* Instantiate .
2013-10-16 00:22:09 -04:00
*
* All custom functionality will be hooked into the " init " action .
2013-12-03 12:06:11 -05:00
*
* @ since Twenty Fourteen 1.0
2013-10-16 00:22:09 -04:00
*/
public static function setup () {
2013-10-16 14:29:09 -04:00
add_action ( 'init' , array ( __CLASS__ , 'init' ), 30 );
2013-10-16 00:22:09 -04:00
}
/**
2013-12-03 12:06:11 -05:00
* Conditionally hook into WordPress .
2013-10-16 00:22:09 -04:00
*
* Theme must declare that they support this module by adding
* add_theme_support ( 'featured-content' ); during after_setup_theme .
*
2013-11-10 18:38:10 -05:00
* If no theme support is found there is no need to hook into WordPress .
* We ' ll just return early instead .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
2013-10-16 00:22:09 -04:00
*/
public static function init () {
$theme_support = get_theme_support ( 'featured-content' );
// Return early if theme does not support Featured Content.
2013-11-18 18:11:10 -05:00
if ( ! $theme_support ) {
2013-10-16 00:22:09 -04:00
return ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
/*
2013-11-10 18:38:10 -05:00
* An array of named arguments must be passed as the second parameter
* of add_theme_support () .
2013-10-16 00:22:09 -04:00
*/
2013-11-18 18:11:10 -05:00
if ( ! isset ( $theme_support [ 0 ] ) ) {
2013-10-16 00:22:09 -04:00
return ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
// Return early if "featured_content_filter" has not been defined.
2013-11-18 18:11:10 -05:00
if ( ! isset ( $theme_support [ 0 ][ 'featured_content_filter' ] ) ) {
2013-10-16 00:22:09 -04:00
return ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
$filter = $theme_support [ 0 ][ 'featured_content_filter' ];
// Theme can override the number of max posts.
2013-11-18 18:11:10 -05:00
if ( isset ( $theme_support [ 0 ][ 'max_posts' ] ) ) {
2013-10-16 00:22:09 -04:00
self :: $max_posts = absint ( $theme_support [ 0 ][ 'max_posts' ] );
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
2017-11-30 18:11:00 -05:00
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' ) );
2013-11-10 18:38:10 -05:00
}
2013-10-16 00:22:09 -04:00
2013-11-10 18:38:10 -05:00
/**
2016-02-25 07:53:27 -05:00
* Hide " featured " tag from the front end .
2013-11-10 18:38:10 -05:00
*
2014-10-15 13:21:19 -04:00
* Has to run on wp_loaded so that the preview filters of the Customizer
2013-11-10 18:38:10 -05:00
* have a chance to alter the value .
2013-12-03 12:06:11 -05:00
*
* @ since Twenty Fourteen 1.0
2013-11-10 18:38:10 -05:00
*/
public static function wp_loaded () {
2013-10-16 00:22:09 -04:00
if ( self :: get_setting ( 'hide-tag' ) ) {
2017-11-30 18:11:00 -05:00
add_filter ( 'get_terms' , array ( __CLASS__ , 'hide_featured_term' ), 10 , 3 );
2013-10-16 00:22:09 -04:00
add_filter ( 'get_the_terms' , array ( __CLASS__ , 'hide_the_featured_term' ), 10 , 3 );
}
}
/**
2013-12-03 12:06:11 -05:00
* Get featured posts .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* @ return array Array of featured posts .
2013-10-16 00:22:09 -04:00
*/
public static function get_featured_posts () {
$post_ids = self :: get_featured_post_ids ();
// No need to query if there is are no featured posts.
2013-11-18 18:11:10 -05:00
if ( empty ( $post_ids ) ) {
2013-10-16 00:22:09 -04:00
return array ();
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
2017-11-30 18:11:00 -05:00
$featured_posts = get_posts (
array (
'include' => $post_ids ,
'posts_per_page' => count ( $post_ids ),
)
);
2013-10-16 00:22:09 -04:00
return $featured_posts ;
}
/**
* Get featured post IDs
*
* This function will return the an array containing the
* post IDs of all featured posts .
*
* Sets the " featured_content_ids " transient .
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
*
* @ return array Array of post IDs .
2013-10-16 00:22:09 -04:00
*/
public static function get_featured_post_ids () {
2014-07-15 02:44:15 -04:00
// Get array of cached results if they exist.
2013-10-16 00:22:09 -04:00
$featured_ids = get_transient ( 'featured_content_ids' );
2013-11-10 18:38:10 -05:00
2014-07-15 02:44:15 -04:00
if ( false === $featured_ids ) {
$settings = self :: get_setting ();
$term = get_term_by ( 'name' , $settings [ 'tag-name' ], 'post_tag' );
if ( $term ) {
// Query for featured posts.
2017-11-30 18:11:00 -05:00
$featured_ids = get_posts (
array (
'fields' => 'ids' ,
'numberposts' => self :: $max_posts ,
'suppress_filters' => false ,
'tax_query' => array (
array (
'field' => 'term_id' ,
'taxonomy' => 'post_tag' ,
'terms' => $term -> term_id ,
),
2014-07-15 02:44:15 -04:00
),
2017-11-30 18:11:00 -05:00
)
);
2014-07-15 02:44:15 -04:00
}
// Get sticky posts if no Featured Content exists.
if ( ! $featured_ids ) {
$featured_ids = self :: get_sticky_posts ();
}
set_transient ( 'featured_content_ids' , $featured_ids );
2013-11-18 18:11:10 -05:00
}
2013-11-10 18:38:10 -05:00
2014-07-15 02:44:15 -04:00
// Ensure correct format before return.
return array_map ( 'absint' , $featured_ids );
2013-10-16 00:22:09 -04:00
}
2013-11-07 15:25:09 -05:00
/**
2013-12-03 12:06:11 -05:00
* Return an array with IDs of posts maked as sticky .
*
* @ since Twenty Fourteen 1.0
2013-11-07 15:25:09 -05:00
*
2013-12-03 12:06:11 -05:00
* @ return array Array of sticky posts .
2013-11-07 15:25:09 -05:00
*/
public static function get_sticky_posts () {
2014-02-07 12:39:13 -05:00
return array_slice ( get_option ( 'sticky_posts' , array () ), 0 , self :: $max_posts );
2013-11-07 15:25:09 -05:00
}
2013-10-16 00:22:09 -04:00
/**
2013-12-03 12:06:11 -05:00
* Delete featured content ids transient .
2013-10-16 00:22:09 -04:00
*
* Hooks in the " save_post " action .
2013-12-03 12:06:11 -05:00
*
2013-10-16 00:22:09 -04:00
* @ see Featured_Content :: validate_settings () .
2013-12-03 12:06:11 -05:00
*
* @ since Twenty Fourteen 1.0
2013-10-16 00:22:09 -04:00
*/
public static function delete_transient () {
delete_transient ( 'featured_content_ids' );
}
/**
2013-12-03 12:06:11 -05:00
* Exclude featured posts from the home page blog query .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* Filter the home page posts , and remove any featured post ID ' s from it .
* Hooked onto the 'pre_get_posts' action , this changes the parameters of
* the query before it gets any posts .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
*
* @ param WP_Query $query WP_Query object .
* @ return WP_Query Possibly - modified WP_Query .
2013-10-16 00:22:09 -04:00
*/
2013-11-18 17:04:09 -05:00
public static function pre_get_posts ( $query ) {
2013-10-16 00:22:09 -04:00
2013-11-18 17:04:09 -05:00
// Bail if not home or not main query.
2013-11-18 18:11:10 -05:00
if ( ! $query -> is_home () || ! $query -> is_main_query () ) {
2013-10-16 00:22:09 -04:00
return ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
// Bail if the blog page is not the front page.
2014-09-07 10:23:17 -04:00
if ( 'posts' !== get_option ( 'show_on_front' ) ) {
2013-10-16 00:22:09 -04:00
return ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
$featured = self :: get_featured_post_ids ();
// Bail if no featured posts.
2013-11-18 18:11:10 -05:00
if ( ! $featured ) {
2013-10-16 00:22:09 -04:00
return ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
// We need to respect post ids already in the blacklist.
$post__not_in = $query -> get ( 'post__not_in' );
if ( ! empty ( $post__not_in ) ) {
$featured = array_merge ( ( array ) $post__not_in , $featured );
$featured = array_unique ( $featured );
}
$query -> set ( 'post__not_in' , $featured );
}
/**
2013-12-03 12:06:11 -05:00
* Reset tag option when the saved tag is deleted .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* It ' s important to mention that the transient needs to be deleted ,
* too . While it may not be obvious by looking at the function alone ,
* the transient is deleted by Featured_Content :: validate_settings () .
2013-10-16 00:22:09 -04:00
*
* Hooks in the " delete_post_tag " action .
2013-12-03 12:06:11 -05:00
*
2013-10-16 00:22:09 -04:00
* @ see Featured_Content :: validate_settings () .
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
*
2013-11-10 18:38:10 -05:00
* @ param int $tag_id The term_id of the tag that has been deleted .
2013-10-16 00:22:09 -04:00
*/
public static function delete_post_tag ( $tag_id ) {
$settings = self :: get_setting ();
2013-11-18 18:11:10 -05:00
if ( empty ( $settings [ 'tag-id' ] ) || $tag_id != $settings [ 'tag-id' ] ) {
2013-10-16 00:22:09 -04:00
return ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
$settings [ 'tag-id' ] = 0 ;
2017-11-30 18:11:00 -05:00
$settings = self :: validate_settings ( $settings );
2013-10-16 00:22:09 -04:00
update_option ( 'featured-content' , $settings );
}
/**
2016-02-25 07:53:27 -05:00
* Hide featured tag from displaying when global terms are queried from the front end .
2013-10-16 00:22:09 -04:00
*
* Hooks into the " get_terms " filter .
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
*
* @ param array $terms List of term objects . This is the return value of get_terms () .
2013-10-16 00:22:09 -04:00
* @ param array $taxonomies An array of taxonomy slugs .
2013-12-03 12:06:11 -05:00
* @ return array A filtered array of terms .
2013-10-16 00:22:09 -04:00
*
* @ uses Featured_Content :: get_setting ()
*/
2014-05-22 05:25:15 -04:00
public static function hide_featured_term ( $terms , $taxonomies , $args ) {
2013-10-16 00:22:09 -04:00
2016-02-25 07:53:27 -05:00
// This filter is only appropriate on the front end.
2013-11-18 18:11:10 -05:00
if ( is_admin () ) {
2013-10-16 00:22:09 -04:00
return $terms ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
// We only want to hide the featured tag.
2013-11-18 18:11:10 -05:00
if ( ! in_array ( 'post_tag' , $taxonomies ) ) {
2013-10-16 00:22:09 -04:00
return $terms ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
// Bail if no terms were returned.
2013-11-18 18:11:10 -05:00
if ( empty ( $terms ) ) {
2013-10-16 00:22:09 -04:00
return $terms ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
2014-05-22 05:25:15 -04:00
// Bail if term objects are unavailable.
if ( 'all' != $args [ 'fields' ] ) {
return $terms ;
}
2014-02-07 12:17:13 -05:00
$settings = self :: get_setting ();
2015-01-20 14:03:23 -05:00
foreach ( $terms as $order => $term ) {
2014-02-07 12:17:13 -05:00
if ( ( $settings [ 'tag-id' ] === $term -> term_id || $settings [ 'tag-name' ] === $term -> name ) && 'post_tag' === $term -> taxonomy ) {
2013-11-07 15:25:09 -05:00
unset ( $terms [ $order ] );
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
}
return $terms ;
}
/**
2013-12-03 12:06:11 -05:00
* Hide featured tag from display when terms associated with a post object
2016-02-25 07:53:27 -05:00
* are queried from the front end .
2013-10-16 00:22:09 -04:00
*
* Hooks into the " get_the_terms " filter .
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
*
* @ param array $terms A list of term objects . This is the return value of get_the_terms () .
* @ param int $id The ID field for the post object that terms are associated with .
2013-10-16 00:22:09 -04:00
* @ param array $taxonomy An array of taxonomy slugs .
2013-12-03 12:06:11 -05:00
* @ return array Filtered array of terms .
2013-10-16 00:22:09 -04:00
*
* @ uses Featured_Content :: get_setting ()
*/
public static function hide_the_featured_term ( $terms , $id , $taxonomy ) {
2016-02-25 07:53:27 -05:00
// This filter is only appropriate on the front end.
2013-11-18 18:11:10 -05:00
if ( is_admin () ) {
2013-10-16 00:22:09 -04:00
return $terms ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
// Make sure we are in the correct taxonomy.
2013-11-18 18:11:10 -05:00
if ( 'post_tag' != $taxonomy ) {
2013-10-16 00:22:09 -04:00
return $terms ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
// No terms? Return early!
2013-11-18 18:11:10 -05:00
if ( empty ( $terms ) ) {
2013-10-16 00:22:09 -04:00
return $terms ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
2014-02-07 12:17:13 -05:00
$settings = self :: get_setting ();
2015-01-20 14:03:23 -05:00
foreach ( $terms as $order => $term ) {
2014-02-07 12:17:13 -05:00
if ( ( $settings [ 'tag-id' ] === $term -> term_id || $settings [ 'tag-name' ] === $term -> name ) && 'post_tag' === $term -> taxonomy ) {
2013-11-07 15:25:09 -05:00
unset ( $terms [ $term -> term_id ] );
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
}
return $terms ;
}
/**
2013-12-03 12:06:11 -05:00
* Register custom setting on the Settings -> Reading screen .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
2013-10-16 00:22:09 -04:00
*/
public static function register_setting () {
2013-11-07 15:25:09 -05:00
register_setting ( 'featured-content' , 'featured-content' , array ( __CLASS__ , 'validate_settings' ) );
2013-10-16 00:22:09 -04:00
}
/**
2013-11-07 15:25:09 -05:00
* Add settings to the Customizer .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
*
2014-10-15 13:21:19 -04:00
* @ param WP_Customize_Manager $wp_customize Customizer object .
2013-10-16 00:22:09 -04:00
*/
2013-11-07 15:25:09 -05:00
public static function customize_register ( $wp_customize ) {
2017-11-30 18:11:00 -05:00
$wp_customize -> add_section (
2018-08-16 21:51:36 -04:00
'featured_content' ,
array (
2017-11-30 18:11:00 -05:00
'title' => __ ( 'Featured Content' , 'twentyfourteen' ),
'description' => sprintf (
2019-07-08 21:10:00 -04:00
/* translators: 1: featured tag editor URL, 2: post editor URL */
2017-11-30 18:11:00 -05:00
__ ( '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' ),
esc_url ( add_query_arg ( 'tag' , _x ( 'featured' , 'featured content default tag slug' , 'twentyfourteen' ), admin_url ( 'edit.php' ) ) ),
admin_url ( 'edit.php?show_sticky=1' )
),
'priority' => 130 ,
'theme_supports' => 'featured-content' ,
)
);
2013-10-16 00:22:09 -04:00
2013-11-07 15:25:09 -05:00
// Add Featured Content settings.
2017-11-30 18:11:00 -05:00
$wp_customize -> add_setting (
2018-08-16 21:51:36 -04:00
'featured-content[tag-name]' ,
array (
2017-11-30 18:11:00 -05:00
'default' => _x ( 'featured' , 'featured content default tag slug' , 'twentyfourteen' ),
'type' => 'option' ,
'sanitize_js_callback' => array ( __CLASS__ , 'delete_transient' ),
)
);
$wp_customize -> add_setting (
2018-08-16 21:51:36 -04:00
'featured-content[hide-tag]' ,
array (
2017-11-30 18:11:00 -05:00
'default' => true ,
'type' => 'option' ,
'sanitize_js_callback' => array ( __CLASS__ , 'delete_transient' ),
)
);
2013-10-16 14:27:09 -04:00
2013-11-07 15:25:09 -05:00
// Add Featured Content controls.
2017-11-30 18:11:00 -05:00
$wp_customize -> add_control (
2018-08-16 21:51:36 -04:00
'featured-content[tag-name]' ,
array (
2017-11-30 18:11:00 -05:00
'label' => __ ( 'Tag Name' , 'twentyfourteen' ),
'section' => 'featured_content' ,
'priority' => 20 ,
)
);
$wp_customize -> add_control (
2018-08-16 21:51:36 -04:00
'featured-content[hide-tag]' ,
array (
2017-11-30 18:11:00 -05:00
'label' => __ ( 'Don’t display tag on front end.' , 'twentyfourteen' ),
'section' => 'featured_content' ,
'type' => 'checkbox' ,
'priority' => 30 ,
)
);
2013-10-16 00:22:09 -04:00
}
2013-11-07 15:25:09 -05:00
/**
* Enqueue the tag suggestion script .
*
* @ since Twenty Fourteen 1.0
*/
public static function enqueue_scripts () {
2019-08-07 21:29:58 -04:00
wp_enqueue_script ( 'featured-content-suggest' , get_template_directory_uri () . '/js/featured-content-admin.js' , array ( 'jquery' , 'suggest' ), '20131205' , true );
2013-11-07 15:25:09 -05:00
}
2013-10-16 00:22:09 -04:00
/**
2013-12-03 12:06:11 -05:00
* Get featured content settings .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* Get all settings recognized by this module . This function
* will return all settings whether or not they have been stored
* in the database yet . This ensures that all keys are available
* at all times .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* In the event that you only require one setting , you may pass
* its name as the first parameter to the function and only that
* value will be returned .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
2013-10-16 00:22:09 -04:00
*
* @ param string $key The key of a recognized setting .
* @ return mixed Array of all settings by default . A single value if passed as first parameter .
*/
public static function get_setting ( $key = 'all' ) {
$saved = ( array ) get_option ( 'featured-content' );
$defaults = array (
'hide-tag' => 1 ,
'tag-id' => 0 ,
2014-02-07 12:47:11 -05:00
'tag-name' => _x ( 'featured' , 'featured content default tag slug' , 'twentyfourteen' ),
2013-10-16 00:22:09 -04:00
);
$options = wp_parse_args ( $saved , $defaults );
$options = array_intersect_key ( $options , $defaults );
2013-11-18 18:11:10 -05:00
if ( 'all' != $key ) {
2013-11-07 15:25:09 -05:00
return isset ( $options [ $key ] ) ? $options [ $key ] : false ;
2013-11-18 18:11:10 -05:00
}
2013-10-16 00:22:09 -04:00
return $options ;
}
/**
2013-12-03 12:06:11 -05:00
* Validate featured content settings .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* Make sure that all user supplied content is in an expected
* format before saving to the database . This function will also
* delete the transient set in Featured_Content :: get_featured_content () .
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* @ since Twenty Fourteen 1.0
2013-10-16 00:22:09 -04:00
*
2013-12-03 12:06:11 -05:00
* @ param array $input Array of settings input .
* @ return array Validated settings output .
2013-10-16 00:22:09 -04:00
*/
public static function validate_settings ( $input ) {
$output = array ();
2013-11-10 18:38:10 -05:00
if ( empty ( $input [ 'tag-name' ] ) ) {
$output [ 'tag-id' ] = 0 ;
} else {
2013-11-19 10:27:11 -05:00
$term = get_term_by ( 'name' , $input [ 'tag-name' ], 'post_tag' );
if ( $term ) {
$output [ 'tag-id' ] = $term -> term_id ;
2013-11-07 15:25:09 -05:00
} else {
2013-11-19 10:27:11 -05:00
$new_tag = wp_create_tag ( $input [ 'tag-name' ] );
if ( ! is_wp_error ( $new_tag ) && isset ( $new_tag [ 'term_id' ] ) ) {
$output [ 'tag-id' ] = $new_tag [ 'term_id' ];
}
2013-11-07 15:25:09 -05:00
}
2013-11-19 10:27:11 -05:00
2013-11-10 18:38:10 -05:00
$output [ 'tag-name' ] = $input [ 'tag-name' ];
2013-10-16 00:22:09 -04:00
}
2013-11-07 15:25:09 -05:00
$output [ 'hide-tag' ] = isset ( $input [ 'hide-tag' ] ) && $input [ 'hide-tag' ] ? 1 : 0 ;
2013-10-16 00:22:09 -04:00
2013-12-03 12:06:11 -05:00
// Delete the featured post ids transient.
2013-10-16 00:22:09 -04:00
self :: delete_transient ();
return $output ;
}
2013-12-03 12:06:11 -05:00
} // Featured_Content
2013-10-16 00:22:09 -04:00
Featured_Content :: setup ();