diff --git wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php
index dd19064..1ffd325 100644
|
|
class WordCamp_Post_Types_Plugin { |
52 | 52 | |
53 | 53 | add_filter( 'body_class', array( $this, 'session_category_slugs_to_body_tag' ) ); |
54 | 54 | |
| 55 | add_filter( 'the_content', array( $this, 'add_session_info_to_session_posts' ) ); |
55 | 56 | add_filter( 'the_content', array( $this, 'add_avatar_to_speaker_posts' ) ); |
56 | | add_filter( 'the_content', array( $this, 'add_speaker_info_to_session_posts' ) ); |
57 | | add_filter( 'the_content', array( $this, 'add_slides_info_to_session_posts' ) ); |
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' ) ); |
60 | 57 | add_filter( 'the_content', array( $this, 'add_session_info_to_speaker_posts' ) ); |
61 | 58 | |
62 | 59 | add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ) ); |
… |
… |
class WordCamp_Post_Types_Plugin { |
1268 | 1265 | } |
1269 | 1266 | |
1270 | 1267 | /** |
1271 | | * Add speaker information to Session posts |
| 1268 | * Add session information to Session posts |
1272 | 1269 | * |
1273 | 1270 | * We don't enable it for sites that were created before it was committed, because some will have already |
1274 | 1271 | * crafted the bio to include this content, so duplicating it would look wrong, but we still allow older |
… |
… |
class WordCamp_Post_Types_Plugin { |
1278 | 1275 | * |
1279 | 1276 | * @return string |
1280 | 1277 | */ |
1281 | | function add_speaker_info_to_session_posts( $content ) { |
| 1278 | function add_session_info_to_session_posts( $content ) { |
1282 | 1279 | global $post; |
1283 | 1280 | $enabled_site_ids = apply_filters( 'wcpt_session_post_speaker_info_enabled_site_ids', array( 364 ) ); // 2014.sf |
1284 | 1281 | |
… |
… |
class WordCamp_Post_Types_Plugin { |
1291 | 1288 | return $content; |
1292 | 1289 | } |
1293 | 1290 | |
| 1291 | // Get the list of speakers |
1294 | 1292 | $speaker_ids = (array) get_post_meta( $post->ID, '_wcpt_speaker_id' ); |
1295 | | |
1296 | | if ( empty ( $speaker_ids ) ) { |
1297 | | return $content; |
1298 | | } |
1299 | | |
1300 | 1293 | $speaker_args = array( |
1301 | 1294 | 'post_type' => 'wcb_speaker', |
1302 | 1295 | 'posts_per_page' => -1, |
… |
… |
class WordCamp_Post_Types_Plugin { |
1307 | 1300 | |
1308 | 1301 | $speakers = new WP_Query( $speaker_args ); |
1309 | 1302 | |
1310 | | if ( ! $speakers->have_posts() ) { |
1311 | | return $content; |
1312 | | } |
1313 | | |
1314 | | $speakers_html = sprintf( |
1315 | | '<h2 class="session-speakers">%s</h2>', |
| 1303 | $speaker_html = sprintf( |
| 1304 | '<li class="session-speakers"><strong>%s', |
1316 | 1305 | _n( |
1317 | 1306 | __( 'Speaker', 'wordcamporg' ), |
1318 | 1307 | __( 'Speakers', 'wordcamporg' ), |
… |
… |
class WordCamp_Post_Types_Plugin { |
1320 | 1309 | ) |
1321 | 1310 | ); |
1322 | 1311 | |
1323 | | $speakers_html .= '<ul id="session-speaker-names">'; |
| 1312 | $speakers_array = array(); |
1324 | 1313 | while ( $speakers->have_posts() ) { |
1325 | 1314 | $speakers->the_post(); |
1326 | | $speakers_html .= sprintf( '<li><a href="%s">%s</a></li>', get_the_permalink(), get_the_title() ); |
| 1315 | $speakers_array[] = sprintf( '<a href="%s">%s</a>', get_the_permalink(), get_the_title() ); |
1327 | 1316 | } |
1328 | | $speakers_html .= '</ul>'; |
1329 | 1317 | |
1330 | 1318 | wp_reset_postdata(); |
1331 | 1319 | |
1332 | | return $content . $speakers_html; |
1333 | | } |
1334 | | |
1335 | | /** |
1336 | | * Add Slides link to Session posts |
1337 | | * |
1338 | | * We don't enable it for sites that were created before it was committed, because some will have already |
1339 | | * crafted the session to include this content, so duplicating it would look wrong, but we still allow older |
1340 | | * sites to opt-in. |
1341 | | * |
1342 | | * @param string $content |
1343 | | * |
1344 | | * @return string |
1345 | | */ |
1346 | | function add_slides_info_to_session_posts( $content ) { |
1347 | | global $post; |
1348 | | $enabled_site_ids = apply_filters( 'wcpt_session_post_slides_info_enabled_site_ids', array( |
1349 | | 206, // testing.wordcamp.org |
1350 | | 648, // 2016.asheville |
1351 | | 651, // 2016.kansascity |
1352 | | 623, // 2016.tampa |
1353 | | ) ); |
1354 | | |
1355 | | if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) { |
1356 | | return $content; |
| 1320 | $speakers_list = join( ', ', $speakers_array ); |
| 1321 | if( $speakers_list ) { |
| 1322 | $speaker_html .= ':</strong> ' . $speakers_list . '</li>'; |
| 1323 | } else { |
| 1324 | $speaker_html = ''; |
1357 | 1325 | } |
1358 | 1326 | |
1359 | | $site_id = get_current_blog_id(); |
1360 | | if ( $site_id <= apply_filters( 'wcpt_session_post_slides_info_min_site_id', 699 ) && ! in_array( $site_id, $enabled_site_ids ) ) { |
1361 | | return $content; |
1362 | | } |
| 1327 | // Get the time and date of the session |
| 1328 | $time = absint( get_post_meta( $post->ID, '_wcpt_session_time', true ) ); |
| 1329 | $time_html = ''; |
| 1330 | if( $time ) { |
| 1331 | $time_format = get_option( 'time_format', 'g:i a' ); |
| 1332 | $date_format = get_option( 'date_format', 'F j, Y' ); |
1363 | 1333 | |
1364 | | $session_slides = get_post_meta( $post->ID, '_wcpt_session_slides', true ); |
| 1334 | $time_string = esc_html( date( $time_format, $time ) ); |
| 1335 | $date_string = esc_html( date( $date_format, $time ) ); |
1365 | 1336 | |
1366 | | if ( empty ( $session_slides ) ) { |
1367 | | return $content; |
| 1337 | $time_html = '<li class="session-time"><strong>' . __( 'Time', 'wordcamporg' ) . ':</strong> ' . $date_string . ' @ ' . $time_string . '</li>'; |
1368 | 1338 | } |
1369 | 1339 | |
1370 | | $session_slides_html = '<div class="session-video">'; |
1371 | | $session_slides_html .= sprintf( __( '<a href="%s" target="_blank">View Session Slides</a>', 'wordcamporg' ), esc_url( $session_slides ) ); |
1372 | | $session_slides_html .= '</div>'; |
1373 | | |
1374 | | return $content . $session_slides_html; |
1375 | | } |
| 1340 | // Get a list of the session tracks |
| 1341 | $tracks = get_the_terms( $post->ID, 'wcb_track' ); |
| 1342 | $tracks_array = array(); |
| 1343 | foreach ( $tracks as $track ) { |
| 1344 | $tracks_array[] = $track->name; |
| 1345 | } |
1376 | 1346 | |
1377 | | /** |
1378 | | * Add Video link to Session posts |
1379 | | * |
1380 | | * We don't enable it for sites that were created before it was committed, because some will have already |
1381 | | * crafted the session to include this content, so duplicating it would look wrong, but we still allow older |
1382 | | * sites to opt-in. |
1383 | | * |
1384 | | * @param string $content |
1385 | | * |
1386 | | * @return string |
1387 | | */ |
1388 | | function add_video_info_to_session_posts( $content ) { |
1389 | | global $post; |
1390 | | $enabled_site_ids = apply_filters( 'wcpt_session_post_video_info_enabled_site_ids', array( |
1391 | | 206, // testing.wordcamp.org |
1392 | | 648, // 2016.asheville |
1393 | | 623, // 2016.tampa |
1394 | | ) ); |
| 1347 | $num_tracks = count ( $tracks_array ); |
| 1348 | $tracks_html = ''; |
| 1349 | if( $num_tracks ) { |
1395 | 1350 | |
1396 | | if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) { |
1397 | | return $content; |
| 1351 | $tracks_html = sprintf( |
| 1352 | '<li class="session-tracks"><strong>%s', |
| 1353 | _n( |
| 1354 | __( 'Track', 'wordcamporg' ), |
| 1355 | __( 'Tracks', 'wordcamporg' ), |
| 1356 | $speakers->post_count |
| 1357 | ) |
| 1358 | ); |
| 1359 | $tracks_list = join( ", ", $tracks_array ); |
| 1360 | $tracks_html .= ':</strong> ' . $tracks_list . '</li>'; |
1398 | 1361 | } |
1399 | 1362 | |
1400 | | $site_id = get_current_blog_id(); |
1401 | | if ( $site_id <= apply_filters( 'wcpt_session_post_video_info_min_site_id', 699 ) && ! in_array( $site_id, $enabled_site_ids ) ) { |
1402 | | return $content; |
| 1363 | // Get the link to the session slides |
| 1364 | $session_slides = get_post_meta( $post->ID, '_wcpt_session_slides', true ); |
| 1365 | $slides_html = ''; |
| 1366 | if ( $session_slides ) { |
| 1367 | $slides_html = sprintf( __( '<li class="session-slides"><a href="%s" target="_blank">View Session Slides</a></li>', 'wordcamporg' ), esc_url( $session_slides ) ); |
1403 | 1368 | } |
1404 | 1369 | |
| 1370 | // Get the link to the session video |
1405 | 1371 | $session_video = get_post_meta( $post->ID, '_wcpt_session_video', true ); |
1406 | | |
1407 | | if ( empty ( $session_video ) ) { |
1408 | | return $content; |
1409 | | } |
1410 | | |
1411 | | $session_video_html = '<div class="session-video">'; |
1412 | | $session_video_html .= sprintf( __( '<a href="%s" target="_blank">View Session Video</a>', 'wordcamporg' ), esc_url( $session_video ) ); |
1413 | | $session_video_html .= '</div>'; |
1414 | | |
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; |
| 1372 | $video_html = ''; |
| 1373 | if( $session_video ) { |
| 1374 | $video_html = sprintf( __( '<li class="session-video"><a href="%s" target="_blank">View Session Video</a></li>', 'wordcamporg' ), esc_url( $session_video ) ); |
1430 | 1375 | } |
1431 | 1376 | |
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>', |
| 1377 | // Get the list of session categories |
| 1378 | $categories_list = get_the_term_list( $post->ID, 'wcb_session_category', '', _x( ', ', 'Used between list items, there is a space after the comma.', 'wordcamporg' ) ); |
| 1379 | $categories_html = ''; |
| 1380 | if ( $categories_list ) { |
| 1381 | $categories_html = sprintf( |
| 1382 | '<li class="session-categories"><span class="screen-reader-text">%1$s </span>%2$s</span>', |
1438 | 1383 | _x( 'Categories', 'Used before session category names.', 'wordcamporg' ), |
1439 | | $session_categories_list |
| 1384 | $categories_list |
1440 | 1385 | ); |
1441 | 1386 | } |
1442 | 1387 | |
1443 | | return $content . $session_categories_html; |
| 1388 | // Generate meta list for display |
| 1389 | $meta_html = ''; |
| 1390 | if( $speaker_html || $time_html || $tracks_html || $slides_html || $video_html || $categories_html ) { |
| 1391 | $meta_html = '<ul class="session-info">'; |
| 1392 | $meta_html .= $speaker_html . $time_html . $tracks_html . $slides_html . $video_html . $categories_html; |
| 1393 | $meta_html .= '</ul>'; |
| 1394 | } |
| 1395 | |
| 1396 | return $content . $meta_html; |
1444 | 1397 | } |
1445 | 1398 | |
| 1399 | |
1446 | 1400 | /** |
1447 | 1401 | * Add the sessions's category slugs to the body tag. |
1448 | 1402 | * |