Ticket #26093: 26093.3.patch
File 26093.3.patch, 2.6 KB (added by , 11 years ago) |
---|
-
wp-content/themes/twentyfourteen/inc/featured-content.php
46 46 $theme_support = get_theme_support( 'featured-content' ); 47 47 48 48 // Return early if theme does not support Featured Content. 49 if ( ! $theme_support ) 49 if ( ! $theme_support ){ 50 50 return; 51 } 51 52 52 53 /* 53 54 * An array of named arguments must be passed as the second parameter 54 55 * of add_theme_support(). 55 56 */ 56 if ( ! isset( $theme_support[0] ) ) 57 if ( ! isset( $theme_support[0] ) ){ 57 58 return; 59 } 58 60 59 61 // Return early if "featured_content_filter" has not been defined. 60 if ( ! isset( $theme_support[0]['featured_content_filter'] ) ) 62 if ( ! isset( $theme_support[0]['featured_content_filter'] ) ){ 61 63 return; 64 } 62 65 63 66 $filter = $theme_support[0]['featured_content_filter']; 64 67 … … 100 103 $post_ids = self::get_featured_post_ids(); 101 104 102 105 // No need to query if there is are no featured posts. 103 if ( empty( $post_ids ) ) 106 if ( empty( $post_ids ) ){ 104 107 return array(); 108 } 105 109 106 110 $featured_posts = get_posts( array( 107 111 'include' => $post_ids, … … 124 128 public static function get_featured_post_ids() { 125 129 // Return array of cached results if they exist. 126 130 $featured_ids = get_transient( 'featured_content_ids' ); 127 if ( ! empty( $featured_ids ) ) 131 if ( ! empty( $featured_ids ) ){ 128 132 return array_map( 'absint', (array) $featured_ids ); 133 } 129 134 130 135 $settings = self::get_setting(); 131 136 … … 149 154 ) ); 150 155 151 156 // Return array with sticky posts if no Featured Content exists. 152 if ( ! $featured ) 157 if ( ! $featured ){ 153 158 return self::get_sticky_posts(); 159 } 154 160 155 161 // Ensure correct format before save/return. 156 162 $featured_ids = wp_list_pluck( (array) $featured, 'ID' ); … … 195 201 public static function pre_get_posts( $query ) { 196 202 197 203 // Bail if not home or not main query. 198 if ( ! $query->is_home() || ! $query->is_main_query() ) 204 if ( ! $query->is_home() || ! $query->is_main_query() ){ 199 205 return; 206 } 200 207 201 208 $page_on_front = get_option( 'page_on_front' ); 202 209 203 210 // Bail if the blog page is not the front page. 204 if ( ! empty( $page_on_front ) ) 211 if ( ! empty( $page_on_front ) ){ 205 212 return; 213 } 206 214 207 215 $featured = self::get_featured_post_ids(); 208 216 209 217 // Bail if no featured posts. 210 if ( ! $featured ) 218 if ( ! $featured ){ 211 219 return; 220 } 212 221 213 222 // We need to respect post ids already in the blacklist. 214 223 $post__not_in = $query->get( 'post__not_in' );