Twenty Fourteen: Bail early from Featured_Content::hide_featured_term() if term objects are unavailable.

fixes #28072.
Built from https://develop.svn.wordpress.org/trunk@28536


git-svn-id: http://core.svn.wordpress.org/trunk@28362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-05-22 09:25:15 +00:00
parent 45d5e5d32f
commit 7de1eac464
1 changed files with 7 additions and 2 deletions

View File

@ -106,7 +106,7 @@ class Featured_Content {
*/
public static function wp_loaded() {
if ( self::get_setting( 'hide-tag' ) ) {
add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 2 );
add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 3 );
add_filter( 'get_the_terms', array( __CLASS__, 'hide_the_featured_term' ), 10, 3 );
}
}
@ -312,7 +312,7 @@ class Featured_Content {
*
* @uses Featured_Content::get_setting()
*/
public static function hide_featured_term( $terms, $taxonomies ) {
public static function hide_featured_term( $terms, $taxonomies, $args ) {
// This filter is only appropriate on the front-end.
if ( is_admin() ) {
@ -329,6 +329,11 @@ class Featured_Content {
return $terms;
}
// Bail if term objects are unavailable.
if ( 'all' != $args['fields'] ) {
return $terms;
}
$settings = self::get_setting();
foreach( $terms as $order => $term ) {
if ( ( $settings['tag-id'] === $term->term_id || $settings['tag-name'] === $term->name ) && 'post_tag' === $term->taxonomy ) {