Changeset 779
- Timestamp:
- 08/11/2014 07:10:43 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php
r758 r779 250 250 global $post; 251 251 252 // Prepare the shortcode arguments 252 253 $attr = shortcode_atts( array( 253 254 'show_avatars' => true, … … 256 257 'orderby' => 'date', 257 258 'order' => 'desc', 259 'track' => 'all', 258 260 ), $attr ); 259 261 … … 262 264 $attr['order'] = ( in_array( $attr['order'], array( 'asc', 'desc') ) ) ? $attr['order'] : 'desc'; 263 265 264 $speakers = new WP_Query( array( 266 /* 267 * Only allow 2014.capetown to use the new track attribute 268 * @todo Remove this and update docs after stakeholder review 269 */ 270 if ( ! in_array( get_current_blog_id(), apply_filters( 'wcpt_filter_speakers_by_track_allowed_sites', array( 423 ) ) ) ) { 271 $attr['track'] = 'all'; 272 } 273 274 // Fetch all the relevant sessions 275 $session_args = array( 276 'post_type' => 'wcb_session', 277 'posts_per_page' => -1, 278 ); 279 280 if ( 'all' != $attr['track'] ) { 281 $session_args['tax_query'] = array( 282 array( 283 'taxonomy' => 'wcb_track', 284 'field' => 'slug', 285 'terms' => explode( ',', $attr['track'] ), 286 ), 287 ); 288 } 289 290 $sessions = get_posts( $session_args ); 291 292 // Parse the sessions 293 $speaker_ids = $speakers_tracks = array(); 294 foreach ( $sessions as $session ) { 295 // Get the speaker IDs for all the sessions in the requested tracks 296 $session_speaker_ids = get_post_meta( $session->ID, '_wcpt_speaker_id' ); 297 $speaker_ids = array_merge( $speaker_ids, $session_speaker_ids ); 298 299 // Map speaker IDs to their corresponding tracks 300 $session_terms = wp_get_object_terms( $session->ID, 'wcb_track' ); 301 foreach ( $session_speaker_ids as $speaker_id ) { 302 if ( isset ( $speakers_tracks[ $speaker_id ] ) ) { 303 $speakers_tracks[ $speaker_id ] = array_merge( $speakers_tracks[ $speaker_id ], wp_list_pluck( $session_terms, 'slug' ) ); 304 } else { 305 $speakers_tracks[ $speaker_id ] = wp_list_pluck( $session_terms, 'slug' ); 306 } 307 } 308 } 309 310 // Remove duplicate entries 311 $speaker_ids = array_unique( $speaker_ids ); 312 foreach ( $speakers_tracks as $speaker_id => $tracks ) { 313 $speakers_tracks[ $speaker_id ] = array_unique( $tracks ); 314 } 315 316 // Fetch all specified speakers 317 $speaker_args = array( 265 318 'post_type' => 'wcb_speaker', 266 319 'posts_per_page' => intval( $attr['posts_per_page'] ), 320 'post__in' => $speaker_ids, 267 321 'orderby' => $attr['orderby'], 268 322 'order' => $attr['order'], 269 ) ); 323 ); 324 325 $speakers = new WP_Query( $speaker_args ); 270 326 271 327 if ( ! $speakers->have_posts() ) 272 328 return ''; 273 329 330 // Render the HTML for the shortcode 274 331 ob_start(); 275 332 ?> … … 279 336 <?php while ( $speakers->have_posts() ) : $speakers->the_post(); ?> 280 337 281 <div id="wcorg-speaker-<?php echo sanitize_html_class( $post->post_name ); ?>" class="wcorg-speaker"> 338 <?php 339 $speaker_classes = array( 'wcorg-speaker', 'wcorg-speaker-' . sanitize_html_class( $post->post_name ) ); 340 foreach ( $speakers_tracks[ get_the_ID() ] as $track ) { 341 $speaker_classes[] = sanitize_html_class( 'wcorg-track-' . $track ); 342 } 343 ?> 344 345 <!-- Organizers note: The id attribute is deprecated and only remains for backwards compatibility, please use the corresponding class to target individual speakers --> 346 <div id="wcorg-speaker-<?php echo sanitize_html_class( $post->post_name ); ?>" class="<?php echo implode( ' ', $speaker_classes ); ?>"> 282 347 <h2><?php the_title(); ?></h2> 283 348 <div class="wcorg-speaker-description"> … … 285 350 <?php the_content(); ?> 286 351 </div> 287 </div> 352 </div><!-- .wcorg-speaker --> 288 353 289 354 <?php endwhile; ?> 290 355 291 356 </div><!-- .wcorg-speakers --> 357 292 358 <?php 293 359 294 360 wp_reset_postdata(); 295 $content = ob_get_contents(); 296 ob_end_clean(); 297 return $content; 361 return ob_get_clean(); 298 362 } 299 363
Note: See TracChangeset
for help on using the changeset viewer.