Ticket #561: 561.2.diff
File 561.2.diff, 3.6 KB (added by , 11 years ago) |
---|
-
wp-content/plugins/wc-post-types/wc-post-types.php
256 256 'posts_per_page' => -1, 257 257 'orderby' => 'date', 258 258 'order' => 'desc', 259 'track' => 'all', 259 260 ), $attr ); 260 261 261 262 $attr['show_avatars'] = $this->str_to_bool( $attr['show_avatars'] ); 262 263 $attr['orderby'] = ( in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ) ? $attr['orderby'] : 'date'; 263 264 $attr['order'] = ( in_array( $attr['order'], array( 'asc', 'desc') ) ) ? $attr['order'] : 'desc'; 264 265 265 $speakers = new WP_Query( array( 266 'post_type' => 'wcb_speaker', 267 'posts_per_page' => intval( $attr['posts_per_page'] ), 268 'orderby' => $attr['orderby'], 269 'order' => $attr['order'], 270 ) ); 266 // Add a 'refresh' parameter to the URL to force the speaker list to refresh 267 if( isset( $_GET['refresh'] ) ) { 268 delete_transient( 'wordcamp_speaker_ids' ); 269 } 271 270 271 // Get saved speaker IDs of transient exists 272 $speaker_ids = get_transient( 'wordcamp_speaker_ids' ); 273 274 if( ! $speaker_ids ) { 275 276 // Fetch all sessions 277 $session_args = array( 278 'post_type' => 'wcb_session', 279 'posts_per_page' => -1, 280 ); 281 282 // Filter by track if specified 283 if( 'all' != $attr['track'] ) { 284 $session_args['tax_query'] = array( 285 array( 286 'taxonomy' => 'wcb_track', 287 'field' => 'slug', 288 'terms' => explode( ',', $attr['track'] ), 289 ), 290 ); 291 } 292 293 $sessions = get_posts( $session_args ); 294 295 // Get array of relevant speaker IDs 296 $speaker_ids = array(); 297 foreach ( $sessions as $session ) { 298 $session_speaker_ids = get_post_meta( $session->ID, '_wcpt_speaker_id' ); 299 $speaker_ids = array_merge( $speaker_ids, $session_speaker_ids ); 300 } 301 302 // Set transient with speaker IDs to prevent long page load times 303 set_transient( 'wordcamp_speaker_ids', $speaker_ids, 3600 ); 304 } 305 306 // Fetch all specified speakers 307 $speaker_args = array( 308 'post_type' => 'wcb_speaker', 309 'posts_per_page' => intval( $attr['posts_per_page'] ), 310 'post__in' => $speaker_ids, 311 'orderby' => $attr['orderby'], 312 'order' => $attr['order'], 313 ); 314 315 $speakers = new WP_Query( $speaker_args ); 316 272 317 if ( ! $speakers->have_posts() ) 273 318 return ''; 274 319 … … 279 324 280 325 <?php while ( $speakers->have_posts() ) : $speakers->the_post(); ?> 281 326 282 <div id="wcorg-speaker-<?php echo sanitize_html_class( $post->post_name ); ?>" class="wcorg-speaker"> 327 <?php 328 // Get list of speaker tracks for div class 329 $tracks = get_post_meta( get_the_ID(), '_wcpt_speaker_tracks', false ); 330 $track_class = ''; 331 foreach( $tracks as $track ) { 332 $track_class .= ' ' . sanitize_html_class( $track ); 333 } 334 ?> 335 336 <div id="wcorg-speaker-<?php echo sanitize_html_class( $post->post_name ); ?>" class="wcorg-speaker<?php echo $track_class; ?>"> 283 337 <h2><?php the_title(); ?></h2> 284 338 <div class="wcorg-speaker-description"> 285 339 <?php echo ( $attr['show_avatars'] ) ? get_avatar( get_post_meta( get_the_ID(), '_wcb_speaker_email', true ), absint( $attr['avatar_size'] ) ) : ''; ?> 286 340 <?php the_content(); ?> 287 341 </div> 288 </div> 342 </div><!-- .wcorg-speaker --> 289 343 290 344 <?php endwhile; ?> 291 345 … … 293 347 <?php 294 348 295 349 wp_reset_postdata(); 296 $content = ob_get_contents(); 297 ob_end_clean();350 351 $content = ob_get_clean(); 298 352 return $content; 299 353 } 300 354