Changeset 6227 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php
- Timestamp:
- 12/03/2017 10:25:24 PM (7 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
r6213 r6227 51 51 add_shortcode( 'schedule', array( $this, 'shortcode_schedule' ) ); 52 52 53 add_filter( 'body_class', array( $this, 'session_category_slugs_to_body_tag' ) ); 54 53 55 add_filter( 'the_content', array( $this, 'add_avatar_to_speaker_posts' ) ); 54 56 add_filter( 'the_content', array( $this, 'add_speaker_info_to_session_posts' ) ); 55 57 add_filter( 'the_content', array( $this, 'add_slides_info_to_session_posts' ) ); 56 58 add_filter( 'the_content', array( $this, 'add_video_info_to_session_posts' ) ); 59 add_filter( 'the_content', array( $this, 'add_session_categories_to_session_posts' ) ); 57 60 add_filter( 'the_content', array( $this, 'add_session_info_to_speaker_posts' ) ); 58 61 … … 1411 1414 1412 1415 return $content . $session_video_html; 1416 } 1417 1418 /** 1419 * Append a session's categories to its post content. 1420 * 1421 * @param string $content 1422 * 1423 * @return string 1424 */ 1425 function add_session_categories_to_session_posts( $content ) { 1426 global $post; 1427 1428 if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) { 1429 return $content; 1430 } 1431 1432 $session_categories_html = ''; 1433 1434 $session_categories_list = get_the_term_list( $post->ID, 'wcb_session_category', '', _x( ', ', 'Used between list items, there is a space after the comma.', 'wordcamporg' ) ); 1435 if ( $session_categories_list ) { 1436 $session_categories_html = sprintf( 1437 '<span class="session-categories-links"><span class="screen-reader-text">%1$s </span>%2$s</span>', 1438 _x( 'Categories', 'Used before session category names.', 'wordcamporg' ), 1439 $session_categories_list 1440 ); 1441 } 1442 1443 return $content . $session_categories_html; 1444 } 1445 1446 /** 1447 * Add the sessions's category slugs to the body tag. 1448 * 1449 * @param array $body_classes 1450 * 1451 * @return array 1452 */ 1453 function session_category_slugs_to_body_tag( $body_classes ) { 1454 if ( 'wcb_session' === get_post_type() ) { 1455 $session_categories = get_the_terms( get_post(), 'wcb_session_category' ); 1456 1457 if ( is_array( $session_categories ) ) { 1458 foreach ( $session_categories as $session_category ) { 1459 $body_classes[] = 'wcb_session_category-' . $session_category->slug; 1460 } 1461 } 1462 } 1463 1464 return $body_classes; 1413 1465 } 1414 1466 … … 2147 2199 register_taxonomy( 'wcb_session_category', 'wcb_session', array( 2148 2200 'labels' => $labels, 2149 'rewrite' => array( 'slug' => 'session _category' ),2201 'rewrite' => array( 'slug' => 'session-category' ), 2150 2202 'query_var' => 'session_category', 2151 2203 'hierarchical' => true,
Note: See TracChangeset
for help on using the changeset viewer.