Making WordPress.org

Changeset 483


Ignore:
Timestamp:
03/31/2014 10:42:34 PM (12 years ago)
Author:
iandunn
Message:

Post Types: Add extra CSS classes to schedule shortcode.

props dustyf.
see #355.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    r235 r483  
    505505                                }
    506506
     507                                // Gather relevant data about the session
    507508                                $colspan = 1;
    508509                                $classes = array();
    509510                                $session = get_post( $entry[ $term_id ] );
    510511                                $session_title = apply_filters( 'the_title', $session->post_title );
     512                                $session_tracks = get_the_terms( $session->ID, 'wcb_track' );
    511513                                $session_type = get_post_meta( $session->ID, '_wcpt_session_type', true );
    512514
     
    514516                                        $session_type = 'session';
    515517
     518                                // Fetch speakers associated with this session.
     519                                $speakers = array();
     520                                $speakers_ids = array_map( 'absint', (array) get_post_meta( $session->ID, '_wcpt_speaker_id' ) );
     521                                if ( ! empty( $speakers_ids ) ) {
     522                                        $speakers = get_posts( array(
     523                                                'post_type'      => 'wcb_speaker',
     524                                                'posts_per_page' => -1,
     525                                                'post__in'       => $speakers_ids,
     526                                        ) );
     527                                }
     528
     529                                // Add CSS classes to help with custom styles
     530                                foreach ( $speakers as $speaker ) {
     531                                        $classes[] = 'wcb-speaker-' . $speaker->post_name;
     532                                }
     533
     534                                if ( is_array( $session_tracks ) ) {
     535                                        foreach ( $session_tracks as $session_track ) {
     536                                                $classes[] = 'wcb-track-' . $session_track->slug;
     537                                        }
     538                                }
     539
    516540                                $classes[] = 'wcpt-session-type-' . $session_type;
    517 
     541                                $classes[] = 'wcb-session-' . $session->post_name;
     542
     543                                // Determine the session title
    518544                                if ( 'permalink' == $attr['session_link'] && 'session' == $session_type )
    519545                                        $session_title = sprintf( '<a class="wcpt-session-title" href="%s">%s</a>', esc_url( get_permalink( $session->ID ) ), $session_title );
     
    524550
    525551                                $content = $session_title;
    526 
    527                                 // Fetch speakers associated with this session.
    528                                 $speakers = array();
    529                                 $speakers_ids = array_map( 'absint', (array) get_post_meta( $session->ID, '_wcpt_speaker_id' ) );
    530                                 if ( ! empty( $speakers_ids ) ) {
    531                                         $speakers = get_posts( array(
    532                                                 'post_type' => 'wcb_speaker',
    533                                                 'posts_per_page' => -1,
    534                                                 'post__in' => $speakers_ids,
    535                                         ) );
    536                                 }
    537552
    538553                                $speakers_names = array();
Note: See TracChangeset for help on using the changeset viewer.