Changeset 6764 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php
- Timestamp:
- 02/26/2018 06:38:19 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
r6624 r6764 115 115 */ 116 116 function render_order_sponsor_levels() { 117 if ( ! isset( $_REQUEST['updated'] ) ) 117 if ( ! isset( $_REQUEST['updated'] ) ) { 118 118 $_REQUEST['updated'] = false; 119 } 119 120 120 121 $levels = $this->get_sponsor_levels(); … … 134 135 </div> 135 136 <ul class="sponsor-order"> 136 <?php foreach ( $levels as $term ): ?>137 <?php foreach ( $levels as $term ) : ?> 137 138 <li class="level"> 138 139 <input type="hidden" class="level-id" name="wcb_sponsor_level_order[]" value="<?php echo esc_attr( $term->term_id ); ?>" /> … … 169 170 */ 170 171 function get_sponsor_levels() { 171 $option 172 $term_objects 173 $terms 174 $ordered_terms 172 $option = get_option( 'wcb_sponsor_level_order' ); 173 $term_objects = get_terms( 'wcb_sponsor_level', array( 'get' => 'all' ) ); 174 $terms = array(); 175 $ordered_terms = array(); 175 176 176 177 foreach ( $term_objects as $term ) { … … 178 179 } 179 180 180 if ( empty( $option ) ) 181 if ( empty( $option ) ) { 181 182 $option = array(); 183 } 182 184 183 185 foreach ( $option as $term_id ) { … … 197 199 */ 198 200 function admin_pre_get_posts( $query ) { 199 if ( ! is_admin() || ! $query->is_main_query() ) 201 if ( ! is_admin() || ! $query->is_main_query() ) { 200 202 return; 203 } 201 204 202 205 $current_screen = get_current_screen(); … … 228 231 ), 229 232 'modal' => array( 230 'allowedTypes' => array( 'image', 'application/pdf' ) 233 'allowedTypes' => array( 'image', 'application/pdf' ), 231 234 ), 232 235 ) … … 349 352 // Get the speaker IDs for all the sessions in the requested tracks 350 353 $session_speaker_ids = get_post_meta( $session->ID, '_wcpt_speaker_id' ); 351 $speaker_ids = array_merge( $speaker_ids, $session_speaker_ids );354 $speaker_ids = array_merge( $speaker_ids, $session_speaker_ids ); 352 355 353 356 // Map speaker IDs to their corresponding tracks 354 357 $session_terms = wp_get_object_terms( $session->ID, 'wcb_track' ); 355 358 foreach ( $session_speaker_ids as $speaker_id ) { 356 if ( isset 359 if ( isset( $speakers_tracks[ $speaker_id ] ) ) { 357 360 $speakers_tracks[ $speaker_id ] = array_merge( $speakers_tracks[ $speaker_id ], wp_list_pluck( $session_terms, 'slug' ) ); 358 361 } else { … … 392 395 $speakers = new WP_Query( $speaker_args ); 393 396 394 if ( ! $speakers->have_posts() ) 397 if ( ! $speakers->have_posts() ) { 395 398 return ''; 399 } 396 400 397 401 // Render the HTML for the shortcode … … 401 405 <div class="wcorg-speakers"> 402 406 403 <?php while ( $speakers->have_posts() ) : $speakers->the_post(); ?> 404 405 <?php 406 $speaker_classes = array( 'wcorg-speaker', 'wcorg-speaker-' . sanitize_html_class( $post->post_name ) ); 407 408 if ( isset( $speakers_tracks[ get_the_ID() ] ) ) { 409 foreach ( $speakers_tracks[ get_the_ID() ] as $track ) { 410 $speaker_classes[] = sanitize_html_class( 'wcorg-track-' . $track ); 411 } 407 <?php while ( $speakers->have_posts() ) : 408 $speakers->the_post(); 409 410 $speaker_classes = array( 'wcorg-speaker', 'wcorg-speaker-' . sanitize_html_class( $post->post_name ) ); 411 412 if ( isset( $speakers_tracks[ get_the_ID() ] ) ) { 413 foreach ( $speakers_tracks[ get_the_ID() ] as $track ) { 414 $speaker_classes[] = sanitize_html_class( 'wcorg-track-' . $track ); 412 415 } 416 } 417 413 418 ?> 414 419 … … 417 422 <h2> 418 423 <?php if ( 'permalink' === $attr['speaker_link'] ) : ?> 424 419 425 <a href="<?php the_permalink(); ?>"> 420 426 <?php the_title(); ?> 421 427 </a> 428 422 429 <?php else : ?> 430 423 431 <?php the_title(); ?> 432 424 433 <?php endif; ?> 425 434 </h2> 435 426 436 <div class="wcorg-speaker-description"> 427 437 <?php echo ( $attr['show_avatars'] ) ? get_avatar( get_post_meta( get_the_ID(), '_wcb_speaker_email', true ), absint( $attr['avatar_size'] ) ) : ''; ?> 428 438 <?php the_content(); ?> 429 439 </div> 430 </div> <!-- .wcorg-speaker -->440 </div> 431 441 432 442 <?php endwhile; ?> 433 443 434 </div> <!-- .wcorg-speakers -->444 </div> 435 445 436 446 <?php … … 454 464 455 465 $attr['show_avatars'] = $this->str_to_bool( $attr['show_avatars'] ); 456 $attr['orderby'] = strtolower( $attr['orderby'] );457 $attr['orderby'] = ( in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ) ? $attr['orderby'] : 'date';458 $attr['order'] = strtolower( $attr['order'] );459 $attr['order'] = ( in_array( $attr['order'], array( 'asc', 'desc' ), true ) ) ? $attr['order'] : 'desc';466 $attr['orderby'] = strtolower( $attr['orderby'] ); 467 $attr['orderby'] = ( in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ) ? $attr['orderby'] : 'date'; 468 $attr['order'] = strtolower( $attr['order'] ); 469 $attr['order'] = ( in_array( $attr['order'], array( 'asc', 'desc' ), true ) ) ? $attr['order'] : 'desc'; 460 470 461 471 $query_args = array( … … 478 488 $organizers = new WP_Query( $query_args ); 479 489 480 if ( ! $organizers->have_posts() ) 490 if ( ! $organizers->have_posts() ) { 481 491 return ''; 492 } 482 493 483 494 ob_start(); … … 485 496 <div class="wcorg-organizers"> 486 497 487 <?php while ( $organizers->have_posts() ) : $organizers->the_post(); ?> 498 <?php while ( $organizers->have_posts() ) : 499 $organizers->the_post(); ?> 488 500 489 501 <div class="wcorg-organizer"> … … 580 592 $session_type = get_post_meta( $session->ID, '_wcpt_session_type', true ); 581 593 582 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) 594 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) { 583 595 $session_type = 'session'; 596 } 584 597 585 598 // Fetch speakers associated with this session. 586 $speakers = array();599 $speakers = array(); 587 600 $speakers_ids = array_map( 'absint', (array) get_post_meta( $session->ID, '_wcpt_speaker_id' ) ); 601 588 602 if ( ! empty( $speakers_ids ) ) { 589 603 $speakers = get_posts( array( … … 633 647 $speaker_name = apply_filters( 'the_title', $speaker->post_title ); 634 648 635 if ( 'anchor' == $attr['speaker_link'] ) // speakers/#wcorg-speaker-slug 649 if ( 'anchor' == $attr['speaker_link'] ) { 650 // speakers/#wcorg-speaker-slug 636 651 $speaker_permalink = $this->get_wcpt_anchor_permalink( $speaker->ID ); 637 elseif ( 'wporg' == $attr['speaker_link'] ) // profiles.wordpress.org/user 652 } elseif ( 'wporg' == $attr['speaker_link'] ) { 653 // profiles.wordpress.org/user 638 654 $speaker_permalink = $this->get_speaker_wporg_permalink( $speaker->ID ); 639 elseif ( 'permalink' == $attr['speaker_link'] ) // year.city.wordcamp.org/speakers/slug 655 } elseif ( 'permalink' == $attr['speaker_link'] ) { 656 // year.city.wordcamp.org/speakers/slug 640 657 $speaker_permalink = get_permalink( $speaker->ID ); 641 642 if ( ! empty( $speaker_permalink ) ) 658 } 659 660 if ( ! empty( $speaker_permalink ) ) { 643 661 $speaker_name = sprintf( '<a href="%s">%s</a>', esc_url( $speaker_permalink ), esc_html( $speaker_name ) ); 662 } 644 663 645 664 $speakers_names[] = $speaker_name; … … 647 666 648 667 // Add speakers names to the output string. 649 if ( count( $speakers_names ) ) 668 if ( count( $speakers_names ) ) { 650 669 $content .= sprintf( ' <span class="wcpt-session-speakers">%s</span>', implode( ', ', $speakers_names ) ); 670 } 651 671 652 672 // End of cell-content. … … 658 678 if ( $key != key( array_slice( $columns, -1, 1, true ) ) ) { 659 679 while ( $pair = each( $columns_clone ) ) { 660 if ( $pair['key'] == $key ) 680 if ( $pair['key'] == $key ) { 661 681 continue; 682 } 662 683 663 684 if ( ! empty( $entry[ $pair['value'] ] ) && $entry[ $pair['value'] ] == $session->ID ) { … … 769 790 function get_speaker_wporg_permalink( $speaker_id ) { 770 791 $post = get_post( $speaker_id ); 771 if ( $post->post_type != 'wcb_speaker' || $post->post_status != 'publish' ) 792 if ( $post->post_type != 'wcb_speaker' || $post->post_status != 'publish' ) { 772 793 return; 794 } 773 795 774 796 $wporg_user_id = get_post_meta( $speaker_id, '_wcpt_user_id', true ); 775 if ( ! $wporg_user_id ) 797 if ( ! $wporg_user_id ) { 776 798 return; 799 } 777 800 778 801 $user = get_user_by( 'id', $wporg_user_id ); 779 if ( ! $user ) 802 if ( ! $user ) { 780 803 return; 804 } 781 805 782 806 $permalink = sprintf( 'http://profiles.wordpress.org/%s', strtolower( $user->user_nicename ) ); … … 804 828 } 805 829 806 switch ( $anchor_target->post_type ) {830 switch ( $anchor_target->post_type ) { 807 831 case 'wcb_speaker': 808 832 $permalink = has_shortcode( $post->post_content, 'speakers' ) ? get_permalink( $post->id ) : $this->get_wcpt_permalink( 'speakers' ); … … 910 934 // Convert bools to real booleans. 911 935 $bools = array( 'show_meta', 'show_avatars' ); 912 foreach ( $bools as $key ) 936 foreach ( $bools as $key ) { 913 937 $attr[ $key ] = $this->str_to_bool( $attr[ $key ] ); 938 } 914 939 915 940 // Clean up other attributes. … … 920 945 $attr['avatar_size'] = absint( $attr['avatar_size'] ); 921 946 922 if ( ! in_array( $attr['speaker_link'], array( 'anchor', 'wporg', 'permalink', 'none' ) ) ) 947 if ( ! in_array( $attr['speaker_link'], array( 'anchor', 'wporg', 'permalink', 'none' ) ) ) { 923 948 $attr['speaker_link'] = 'anchor'; // todo this is inconsistent with the values passed to shortcode_atts, and probably not needed if the default above is changed to 'anchor' 949 } 924 950 925 951 $attr['orderby'] = ( in_array( $attr['orderby'], array( 'date', 'title', 'rand', 'session_time' ) ) ) ? $attr['orderby'] : 'date'; … … 955 981 'compare' => 'NOT EXISTS', 956 982 ), 957 ) 983 ), 958 984 ), 959 985 ); … … 988 1014 $sessions = new WP_Query( $args ); 989 1015 990 if ( ! $sessions->have_posts() ) 1016 if ( ! $sessions->have_posts() ) { 991 1017 return; 1018 } 992 1019 993 1020 ob_start(); … … 995 1022 996 1023 <div class="wcorg-sessions"> 997 998 <?php while ( $sessions->have_posts() ) : $sessions->the_post(); ?> 999 1000 <?php 1001 // Things to be output, or not. 1002 $session_meta = ''; 1003 $speakers_avatars = ''; 1004 $links = array(); 1005 1006 // Fetch speakers associated with this session. 1007 $speakers = array(); 1008 $speakers_ids = array_map( 'absint', (array) get_post_meta( get_the_ID(), '_wcpt_speaker_id' ) ); 1009 if ( ! empty( $speakers_ids ) ) { 1010 $speakers = get_posts( array( 1011 'post_type' => 'wcb_speaker', 1012 'posts_per_page' => -1, 1013 'post__in' => $speakers_ids, 1014 ) ); 1024 <?php while ( $sessions->have_posts() ) : 1025 $sessions->the_post(); 1026 1027 // Things to be output, or not. 1028 $session_meta = ''; 1029 $speakers_avatars = ''; 1030 $links = array(); 1031 1032 // Fetch speakers associated with this session. 1033 $speakers = array(); 1034 $speakers_ids = array_map( 'absint', (array) get_post_meta( get_the_ID(), '_wcpt_speaker_id' ) ); 1035 1036 if ( ! empty( $speakers_ids ) ) { 1037 $speakers = get_posts( array( 1038 'post_type' => 'wcb_speaker', 1039 'posts_per_page' => -1, 1040 'post__in' => $speakers_ids, 1041 ) ); 1042 } 1043 1044 // Should we add avatars? 1045 if ( $attr['show_avatars'] ) { 1046 foreach ( $speakers as $speaker ) { 1047 $speakers_avatars .= get_avatar( get_post_meta( $speaker->ID, '_wcb_speaker_email', true ), absint( $attr['avatar_size'] ) ); 1015 1048 } 1016 1017 // Should we add avatars? 1018 if ( $attr['show_avatars'] ) { 1019 foreach ( $speakers as $speaker ) { 1020 $speakers_avatars .= get_avatar( get_post_meta( $speaker->ID, '_wcb_speaker_email', true ), absint( $attr['avatar_size'] ) ); 1049 } 1050 1051 // Should we output meta? 1052 if ( $attr['show_meta'] ) { 1053 $speaker_permalink = ''; 1054 $speakers_names = array(); 1055 $tracks_names = array(); 1056 1057 foreach ( $speakers as $speaker ) { 1058 $speaker_name = apply_filters( 'the_title', $speaker->post_title ); 1059 1060 if ( 'anchor' == $attr['speaker_link'] ) { 1061 // speakers/#wcorg-speaker-slug 1062 $speaker_permalink = $this->get_wcpt_anchor_permalink( $speaker->ID ); 1063 } elseif ( 'wporg' == $attr['speaker_link'] ) { 1064 // profiles.wordpress.org/user 1065 $speaker_permalink = $this->get_speaker_wporg_permalink( $speaker->ID ); 1066 } elseif ( 'permalink' == $attr['speaker_link'] ) { 1067 // year.city.wordcamp.org/speakers/slug 1068 $speaker_permalink = get_permalink( $speaker->ID ); 1069 } 1070 1071 if ( ! empty( $speaker_permalink ) ) { 1072 $speaker_name = sprintf( '<a href="%s">%s</a>', esc_url( $speaker_permalink ), esc_html( $speaker_name ) ); 1073 } 1074 1075 $speakers_names[] = $speaker_name; 1076 } 1077 1078 $tracks = get_the_terms( get_the_ID(), 'wcb_track' ); 1079 1080 if ( is_array( $tracks ) ) { 1081 foreach ( $tracks as $track ) { 1082 $tracks_names[] = apply_filters( 'the_title', $track->name ); 1021 1083 } 1022 1084 } 1023 1085 1024 // Should we output meta? 1025 if ( $attr['show_meta'] ) { 1026 $speaker_permalink = ''; 1027 $speakers_names = array(); 1028 $tracks_names = array(); 1029 1030 foreach ( $speakers as $speaker ) { 1031 $speaker_name = apply_filters( 'the_title', $speaker->post_title ); 1032 1033 if ( 'anchor' == $attr['speaker_link'] ) // speakers/#wcorg-speaker-slug 1034 $speaker_permalink = $this->get_wcpt_anchor_permalink( $speaker->ID ); 1035 elseif ( 'wporg' == $attr['speaker_link'] ) // profiles.wordpress.org/user 1036 $speaker_permalink = $this->get_speaker_wporg_permalink( $speaker->ID ); 1037 elseif ( 'permalink' == $attr['speaker_link'] ) // year.city.wordcamp.org/speakers/slug 1038 $speaker_permalink = get_permalink( $speaker->ID ); 1039 1040 if ( ! empty( $speaker_permalink ) ) 1041 $speaker_name = sprintf( '<a href="%s">%s</a>', esc_url( $speaker_permalink ), esc_html( $speaker_name ) ); 1042 1043 $speakers_names[] = $speaker_name; 1044 } 1045 1046 $tracks = get_the_terms( get_the_ID(), 'wcb_track' ); 1047 if ( is_array( $tracks ) ) 1048 foreach ( $tracks as $track ) 1049 $tracks_names[] = apply_filters( 'the_title', $track->name ); 1050 1051 // Add speakers and tracks to session meta. 1052 if ( ! empty( $speakers_names ) && ! empty( $tracks_names ) ) 1053 $session_meta .= sprintf( __( 'Presented by %1$s in %2$s.', 'wordcamporg' ), implode( ', ', $speakers_names ), implode( ', ', $tracks_names ) ); 1054 elseif ( ! empty( $speakers_names ) ) 1055 $session_meta .= sprintf( __( 'Presented by %s.', 'wordcamporg' ), implode( ', ', $speakers_names ) ); 1056 elseif ( ! empty( $tracks_names ) ) 1057 $session_meta .= sprintf( __( 'Presented in %s.', 'wordcamporg' ), implode( ', ', $tracks_names ) ); 1058 1059 if ( ! empty( $session_meta ) ) 1060 $session_meta = sprintf( '<p class="wcpt-session-meta">%s</p>', $session_meta ); 1086 // Add speakers and tracks to session meta. 1087 if ( ! empty( $speakers_names ) && ! empty( $tracks_names ) ) { 1088 $session_meta .= sprintf( __( 'Presented by %1$s in %2$s.', 'wordcamporg' ), implode( ', ', $speakers_names ), implode( ', ', $tracks_names ) ); 1089 } elseif ( ! empty( $speakers_names ) ) { 1090 $session_meta .= sprintf( __( 'Presented by %s.', 'wordcamporg' ), implode( ', ', $speakers_names ) ); 1091 } elseif ( ! empty( $tracks_names ) ) { 1092 $session_meta .= sprintf( __( 'Presented in %s.', 'wordcamporg' ), implode( ', ', $tracks_names ) ); 1061 1093 } 1062 1094 1063 // Gather data for list of links 1064 if ( $url = get_post_meta( $post->ID, '_wcpt_session_slides', true ) ) { 1065 $links['slides'] = array( 1066 'url' => $url, 1067 'label' => __( 'Slides', 'wordcamporg' ), 1068 ); 1095 if ( ! empty( $session_meta ) ) { 1096 $session_meta = sprintf( '<p class="wcpt-session-meta">%s</p>', $session_meta ); 1069 1097 } 1070 1071 if ( $url = get_post_meta( $post->ID, '_wcpt_session_video', true ) ) { 1072 $links['video'] = array( 1073 'url' => $url, 1074 'label' => __( 'Video', 'wordcamporg' ), 1075 ); 1076 } 1098 } 1099 1100 // Gather data for list of links 1101 if ( $url = get_post_meta( $post->ID, '_wcpt_session_slides', true ) ) { 1102 $links['slides'] = array( 1103 'url' => $url, 1104 'label' => __( 'Slides', 'wordcamporg' ), 1105 ); 1106 } 1107 1108 if ( $url = get_post_meta( $post->ID, '_wcpt_session_video', true ) ) { 1109 $links['video'] = array( 1110 'url' => $url, 1111 'label' => __( 'Video', 'wordcamporg' ), 1112 ); 1113 } 1077 1114 1078 1115 ?> 1079 1116 1080 1117 <div id="wcorg-session-<?php the_ID(); ?>" class="wcorg-session" > 1081 <h2><?php the_title(); ?></h2> 1118 <h2> 1119 <?php the_title(); ?> 1120 </h2> 1121 1082 1122 <div class="wcorg-session-description"> 1083 1123 <?php the_post_thumbnail(); ?> … … 1088 1128 <?php if ( $links ) : ?> 1089 1129 <ul class="wcorg-session-links"> 1090 <?php foreach ( $links as $link ) : ?>1130 <?php foreach ( $links as $link ) : ?> 1091 1131 <li> 1092 1132 <a href="<?php echo esc_url( $link['url'] ); ?>"> … … 1101 1141 1102 1142 <?php endwhile; ?> 1103 1104 1143 </div><!-- .wcorg-sessions --> 1105 1144 … … 1126 1165 1127 1166 $attr['link'] = strtolower( $attr['link'] ); 1128 $terms = $this->get_sponsor_levels();1167 $terms = $this->get_sponsor_levels(); 1129 1168 1130 1169 ob_start(); … … 1132 1171 1133 1172 <div class="wcorg-sponsors"> 1134 <?php foreach ( $terms as $term ) : ?> 1135 <?php 1173 <?php foreach ( $terms as $term ) : 1136 1174 $sponsors = new WP_Query( array( 1137 1175 'post_type' => 'wcb_sponsor', … … 1142 1180 ) ); 1143 1181 1144 if ( ! $sponsors->have_posts() ) 1182 if ( ! $sponsors->have_posts() ) { 1145 1183 continue; 1146 ?> 1147 1148 <div class="wcorg-sponsor-level-<?php echo sanitize_html_class( $term->slug ); ?>"> 1149 <h2><?php echo esc_html( $term->name ); ?></h2> 1150 1151 <?php while ( $sponsors->have_posts() ) : $sponsors->the_post(); ?> 1152 <?php $website = get_post_meta( get_the_ID(), '_wcpt_sponsor_website', true ); ?> 1153 1154 <div id="wcorg-sponsor-<?php the_ID(); ?>" class="wcorg-sponsor"> 1155 <?php if ( 'visible' === $attr['title'] ) : ?> 1156 <?php if ( 'website' === $attr['link'] && $website ) : ?> 1157 <h3><a href="<?php echo esc_attr( esc_url( $website ) ); ?>"><?php the_title(); ?></a></h3> 1158 <?php elseif ( 'post' === $attr['link'] ) : ?> 1159 <h3><a href="<?php echo esc_attr( esc_url( get_permalink() ) ); ?>"><?php the_title(); ?></a></h3> 1160 <?php else : ?> 1161 <h3><?php the_title(); ?></h3> 1162 <?php endif; ?> 1163 <?php endif; ?> 1164 1165 <div class="wcorg-sponsor-description"> 1166 <?php if ( 'website' == $attr['link'] && $website ) : ?> 1167 <a href="<?php echo esc_attr( esc_url( $website ) ); ?>"> 1168 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x', array( 'alt' => get_the_title() ) ); ?> 1169 </a> 1170 <?php elseif ( 'post' == $attr['link'] ) : ?> 1171 <a href="<?php echo esc_attr( esc_url( get_permalink() ) ); ?>"> 1172 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x', array( 'alt' => get_the_title() ) ); ?> 1173 </a> 1174 <?php else : ?> 1175 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x', array( 'alt' => get_the_title() ) ); ?> 1176 <?php endif; ?> 1177 1178 <?php if ( 'full' === $attr['content'] ) : ?> 1179 <?php the_content(); ?> 1180 <?php elseif ( 'excerpt' === $attr['content'] ) : ?> 1181 <?php echo wpautop( 1182 wp_trim_words( 1183 get_the_content(), 1184 absint( $attr['excerpt_length'] ), 1185 apply_filters( 'excerpt_more', ' ' . '…' ) 1186 ) 1187 ); ?> 1188 <?php endif; ?> 1189 </div> 1190 </div><!-- #sponsor --> 1191 <?php endwhile; ?> 1192 1193 </div><!-- .wcorg-sponsor-level --> 1194 1195 <?php endforeach; ?> 1184 } 1185 1186 ?> 1187 1188 <div class="wcorg-sponsor-level-<?php echo sanitize_html_class( $term->slug ); ?>"> 1189 <h2><?php echo esc_html( $term->name ); ?></h2> 1190 1191 <?php while ( $sponsors->have_posts() ) : 1192 $sponsors->the_post(); 1193 $website = get_post_meta( get_the_ID(), '_wcpt_sponsor_website', true ); 1194 ?> 1195 1196 <div id="wcorg-sponsor-<?php the_ID(); ?>" class="wcorg-sponsor"> 1197 <?php if ( 'visible' === $attr['title'] ) : ?> 1198 <?php if ( 'website' === $attr['link'] && $website ) : ?> 1199 <h3> 1200 <a href="<?php echo esc_attr( esc_url( $website ) ); ?>"> 1201 <?php the_title(); ?> 1202 </a> 1203 </h3> 1204 <?php elseif ( 'post' === $attr['link'] ) : ?> 1205 <h3> 1206 <a href="<?php echo esc_attr( esc_url( get_permalink() ) ); ?>"> 1207 <?php the_title(); ?> 1208 </a> 1209 </h3> 1210 <?php else : ?> 1211 <h3> 1212 <?php the_title(); ?> 1213 </h3> 1214 <?php endif; ?> 1215 <?php endif; ?> 1216 1217 <div class="wcorg-sponsor-description"> 1218 <?php if ( 'website' == $attr['link'] && $website ) : ?> 1219 <a href="<?php echo esc_attr( esc_url( $website ) ); ?>"> 1220 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x', array( 'alt' => get_the_title() ) ); ?> 1221 </a> 1222 <?php elseif ( 'post' == $attr['link'] ) : ?> 1223 <a href="<?php echo esc_attr( esc_url( get_permalink() ) ); ?>"> 1224 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x', array( 'alt' => get_the_title() ) ); ?> 1225 </a> 1226 <?php else : ?> 1227 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x', array( 'alt' => get_the_title() ) ); ?> 1228 <?php endif; ?> 1229 1230 <?php if ( 'full' === $attr['content'] ) : ?> 1231 <?php the_content(); ?> 1232 <?php elseif ( 'excerpt' === $attr['content'] ) : ?> 1233 <?php echo wpautop( 1234 wp_trim_words( 1235 get_the_content(), 1236 absint( $attr['excerpt_length'] ), 1237 apply_filters( 'excerpt_more', ' ' . '…' ) 1238 ) 1239 ); ?> 1240 <?php endif; ?> 1241 </div> 1242 </div><!-- #sponsor --> 1243 <?php endwhile; ?> 1244 </div><!-- .wcorg-sponsor-level --> 1245 <?php endforeach; ?> 1196 1246 </div><!-- .wcorg-sponsors --> 1247 1197 1248 <?php 1198 1249 … … 1273 1324 $speaker_ids = (array) get_post_meta( $post->ID, '_wcpt_speaker_id' ); 1274 1325 1275 if ( empty 1326 if ( empty( $speaker_ids ) ) { 1276 1327 return $content; 1277 1328 } … … 1325 1376 function add_slides_info_to_session_posts( $content ) { 1326 1377 global $post; 1378 1327 1379 $enabled_site_ids = apply_filters( 'wcpt_session_post_slides_info_enabled_site_ids', array( 1328 1380 206, // testing.wordcamp.org … … 1337 1389 1338 1390 $site_id = get_current_blog_id(); 1391 1339 1392 if ( $site_id <= apply_filters( 'wcpt_session_post_slides_info_min_site_id', 699 ) && ! in_array( $site_id, $enabled_site_ids ) ) { 1340 1393 return $content; … … 1343 1396 $session_slides = get_post_meta( $post->ID, '_wcpt_session_slides', true ); 1344 1397 1345 if ( empty 1398 if ( empty( $session_slides ) ) { 1346 1399 return $content; 1347 1400 } … … 1367 1420 function add_video_info_to_session_posts( $content ) { 1368 1421 global $post; 1422 1369 1423 $enabled_site_ids = apply_filters( 'wcpt_session_post_video_info_enabled_site_ids', array( 1370 1424 206, // testing.wordcamp.org … … 1378 1432 1379 1433 $site_id = get_current_blog_id(); 1434 1380 1435 if ( $site_id <= apply_filters( 'wcpt_session_post_video_info_min_site_id', 699 ) && ! in_array( $site_id, $enabled_site_ids ) ) { 1381 1436 return $content; … … 1384 1439 $session_video = get_post_meta( $post->ID, '_wcpt_session_video', true ); 1385 1440 1386 if ( empty 1441 if ( empty( $session_video ) ) { 1387 1442 return $content; 1388 1443 } … … 1528 1583 $wporg_user = get_user_by( 'id', $user_id ); 1529 1584 1530 if ( $wporg_user ) 1585 if ( $wporg_user ) { 1531 1586 $wporg_username = $wporg_user->user_nicename; 1587 } 1532 1588 ?> 1533 1589 … … 1557 1613 $wporg_user = get_user_by( 'id', $user_id ); 1558 1614 1559 if ( $wporg_user ) 1615 if ( $wporg_user ) { 1560 1616 $wporg_username = $wporg_user->user_nicename; 1617 } 1561 1618 ?> 1562 1619 … … 1576 1633 function metabox_speakers_list() { 1577 1634 global $post; 1635 1578 1636 $speakers = get_post_meta( $post->ID, '_wcb_session_speakers', true ); 1637 1579 1638 wp_enqueue_script( 'jquery-ui-autocomplete' ); 1580 1639 … … 1587 1646 1588 1647 // We'll use these in js. 1589 foreach ( $speakers_objects as $speaker_object ) 1648 foreach ( $speakers_objects as $speaker_object ) { 1590 1649 $speakers_names[] = $speaker_object->post_title; 1650 } 1651 1591 1652 $speakers_names_first = array_pop( $speakers_names ); 1653 1592 1654 ?> 1593 1655 1594 1656 <?php wp_nonce_field( 'edit-speakers-list', 'wcpt-meta-speakers-list-nonce' ); ?> 1657 1595 1658 <!--<input type="text" class="text" id="wcpt-speakers-list" name="wcpt-speakers-list" value="<?php echo esc_attr( $speakers ); ?>" />--> 1596 <textarea class="large-text" placeholder="Start typing a name" id="wcpt-speakers-list" name="wcpt-speakers-list"><?php echo esc_textarea( $speakers ); ?></textarea> 1597 <p class="description"><?php _e( 'A speaker entry must exist first. Separate multiple speakers with commas.', 'wordcamporg' ); ?></p> 1659 <textarea class="large-text" placeholder="Start typing a name" id="wcpt-speakers-list" name="wcpt-speakers-list"><?php 1660 echo esc_textarea( $speakers ); 1661 ?></textarea> 1662 1663 <p class="description"> 1664 <?php _e( 'A speaker entry must exist first. Separate multiple speakers with commas.', 'wordcamporg' ); ?> 1665 </p> 1598 1666 1599 1667 <script> 1600 jQuery(document).ready( function($) { 1601 var availableSpeakers = [ <?php 1602 foreach ( $speakers_names as $name ) { printf( "'%s', ", esc_js( $name ) ); } 1603 printf( "'%s'", esc_js( $speakers_names_first ) ); // avoid the trailing comma 1604 ?> ]; 1605 function split( val ) { 1606 return val.split( /,\s*/ ); 1607 } 1608 function extractLast( term ) { 1609 return split( term ).pop(); 1610 } 1611 $( '#wcpt-speakers-list' ) 1612 .bind( 'keydown', function( event ) { 1668 jQuery( document ).ready( function ( $ ) { 1669 var availableSpeakers = [ 1670 <?php 1671 1672 foreach ( $speakers_names as $name ) { 1673 printf( "'%s', ", esc_js( $name ) ); 1674 } 1675 1676 printf( "'%s'", esc_js( $speakers_names_first ) ); // avoid the trailing comma 1677 1678 ?> 1679 ]; 1680 1681 function split( val ) { 1682 return val.split( /,\s*/ ); 1683 } 1684 1685 function extractLast( term ) { 1686 return split( term ).pop(); 1687 } 1688 1689 $( '#wcpt-speakers-list' ).bind( 'keydown', function ( event ) { 1613 1690 if ( event.keyCode == $.ui.keyCode.TAB && 1614 1691 $( this ).data( 'autocomplete' ).menu.active ) { 1615 1692 event.preventDefault(); 1616 1693 } 1617 }) 1618 .autocomplete({ 1694 } ).autocomplete( { 1619 1695 minLength: 0, 1620 source: function( request, response ) { 1696 1697 source: function ( request, response ) { 1621 1698 response( $.ui.autocomplete.filter( 1622 availableSpeakers, extractLast( request.term ) ) ) 1699 availableSpeakers, extractLast( request.term ) ) ); 1623 1700 }, 1624 focus: function() { 1701 1702 focus: function () { 1625 1703 return false; 1626 1704 }, 1627 select: function( event, ui ) { 1705 1706 select: function ( event, ui ) { 1628 1707 var terms = split( this.value ); 1629 1708 terms.pop(); … … 1631 1710 terms.push( '' ); 1632 1711 this.value = terms.join( ', ' ); 1633 $( this).focus();1712 $( this ).focus(); 1634 1713 return false; 1635 1714 }, 1636 open: function() { $(this).addClass('open'); }, 1637 close: function() { $(this).removeClass('open'); } 1638 }); 1639 }); 1715 1716 open: function () { 1717 $( this ).addClass( 'open' ); 1718 }, 1719 1720 close: function () { 1721 $( this ).removeClass( 'open' ); 1722 } 1723 } ); 1724 } ); 1640 1725 </script> 1641 1726 … … 1664 1749 <select name="wcpt-session-hour" aria-label="<?php _e( 'Session Start Hour', 'wordcamporg' ); ?>"> 1665 1750 <?php for ( $i = 1; $i <= 12; $i++ ) : ?> 1666 <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, $session_hours ) ?>>1751 <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, $session_hours ); ?>> 1667 1752 <?php echo esc_html( $i ); ?> 1668 1753 </option> … … 1672 1757 <select name="wcpt-session-minutes" aria-label="<?php _e( 'Session Start Minutes', 'wordcamporg' ); ?>"> 1673 1758 <?php for ( $i = '00'; (int) $i <= 55; $i = sprintf( '%02d', (int) $i + 5 ) ) : ?> 1674 <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, $session_minutes ) ?>>1759 <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, $session_minutes ); ?>> 1675 1760 <?php echo esc_html( $i ); ?> 1676 1761 </option> … … 1679 1764 1680 1765 <select name="wcpt-session-meridiem" aria-label="<?php _e( 'Session Meridiem', 'wordcamporg' ); ?>"> 1681 <option value="am" <?php selected( 'am', $session_meridiem ) ?>>am</option>1682 <option value="pm" <?php selected( 'pm', $session_meridiem ) ?>>pm</option>1766 <option value="am" <?php selected( 'am', $session_meridiem ); ?>>am</option> 1767 <option value="pm" <?php selected( 'pm', $session_meridiem ); ?>>pm</option> 1683 1768 </select> 1684 1769 </p> … … 1711 1796 */ 1712 1797 function metabox_sponsor_info( $sponsor ) { 1713 $company_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_company_name',true );1714 $website = get_post_meta( $sponsor->ID, '_wcpt_sponsor_website',true );1715 $first_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_first_name',true );1716 $last_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_last_name',true );1717 $email_address = get_post_meta( $sponsor->ID, '_wcpt_sponsor_email_address',true );1718 $phone_number = get_post_meta( $sponsor->ID, '_wcpt_sponsor_phone_number',true );1719 $vat_number = get_post_meta( $sponsor->ID, '_wcpt_sponsor_vat_number',true );1720 $twitter_handle = get_post_meta( $sponsor->ID, '_wcpt_sponsor_twitter_handle',true );1721 1722 $street_address1 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address1', 1723 $street_address2 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address2', 1724 $city = get_post_meta( $sponsor->ID, '_wcpt_sponsor_city', 1725 $state = get_post_meta( $sponsor->ID, '_wcpt_sponsor_state', 1726 $zip_code = get_post_meta( $sponsor->ID, '_wcpt_sponsor_zip_code', 1727 $country = get_post_meta( $sponsor->ID, '_wcpt_sponsor_country', 1798 $company_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_company_name', true ); 1799 $website = get_post_meta( $sponsor->ID, '_wcpt_sponsor_website', true ); 1800 $first_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_first_name', true ); 1801 $last_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_last_name', true ); 1802 $email_address = get_post_meta( $sponsor->ID, '_wcpt_sponsor_email_address', true ); 1803 $phone_number = get_post_meta( $sponsor->ID, '_wcpt_sponsor_phone_number', true ); 1804 $vat_number = get_post_meta( $sponsor->ID, '_wcpt_sponsor_vat_number', true ); 1805 $twitter_handle = get_post_meta( $sponsor->ID, '_wcpt_sponsor_twitter_handle', true ); 1806 1807 $street_address1 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address1', true ); 1808 $street_address2 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address2', true ); 1809 $city = get_post_meta( $sponsor->ID, '_wcpt_sponsor_city', true ); 1810 $state = get_post_meta( $sponsor->ID, '_wcpt_sponsor_state', true ); 1811 $zip_code = get_post_meta( $sponsor->ID, '_wcpt_sponsor_zip_code', true ); 1812 $country = get_post_meta( $sponsor->ID, '_wcpt_sponsor_country', true ); 1728 1813 1729 1814 if ( $state === $this->get_sponsor_info_state_default_value() ) { … … 1811 1896 */ 1812 1897 function save_post_speaker( $post_id, $post ) { 1813 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_speaker' || ! current_user_can( 'edit_post', $post_id ) ) 1898 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_speaker' || ! current_user_can( 'edit_post', $post_id ) ) { 1814 1899 return; 1900 } 1815 1901 1816 1902 if ( isset( $_POST['wcpt-meta-speaker-info'] ) && wp_verify_nonce( $_POST['wcpt-meta-speaker-info'], 'edit-speaker-info' ) ) { … … 1819 1905 $wporg_user = wcorg_get_user_by_canonical_names( $wporg_username ); 1820 1906 1821 if ( empty( $email ) ) 1907 if ( empty( $email ) ) { 1822 1908 delete_post_meta( $post_id, '_wcb_speaker_email' ); 1823 elseif ( $email && is_email( $email ) )1909 } elseif ( $email && is_email( $email ) ) { 1824 1910 update_post_meta( $post_id, '_wcb_speaker_email', $email ); 1825 1826 if ( ! $wporg_user ) 1911 } 1912 1913 if ( ! $wporg_user ) { 1827 1914 delete_post_meta( $post_id, '_wcpt_user_id' ); 1828 else1915 } else { 1829 1916 update_post_meta( $post_id, '_wcpt_user_id', $wporg_user->ID ); 1917 } 1830 1918 } 1831 1919 } … … 1835 1923 */ 1836 1924 function save_post_organizer( $post_id, $post ) { 1837 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_organizer' || ! current_user_can( 'edit_post', $post_id ) ) 1925 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_organizer' || ! current_user_can( 'edit_post', $post_id ) ) { 1838 1926 return; 1927 } 1839 1928 1840 1929 if ( isset( $_POST['wcpt-meta-organizer-info'] ) && wp_verify_nonce( $_POST['wcpt-meta-organizer-info'], 'edit-organizer-info' ) ) { 1841 1930 $wporg_username = sanitize_text_field( $_POST['wcpt-wporg-username'] ); 1842 $wporg_user = wcorg_get_user_by_canonical_names( $wporg_username );1843 1844 if ( ! $wporg_user ) 1931 $wporg_user = wcorg_get_user_by_canonical_names( $wporg_username ); 1932 1933 if ( ! $wporg_user ) { 1845 1934 delete_post_meta( $post_id, '_wcpt_user_id' ); 1846 else1935 } else { 1847 1936 update_post_meta( $post_id, '_wcpt_user_id', $wporg_user->ID ); 1937 } 1848 1938 } 1849 1939 } … … 1853 1943 */ 1854 1944 function save_post_session( $post_id, $post ) { 1855 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_session' ) 1945 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_session' ) { 1856 1946 return; 1947 } 1857 1948 1858 1949 if ( isset( $_POST['wcpt-meta-speakers-list-nonce'] ) && wp_verify_nonce( $_POST['wcpt-meta-speakers-list-nonce'], 'edit-speakers-list' ) && current_user_can( 'edit_post', $post_id ) ) { … … 1876 1967 // Update session type 1877 1968 $session_type = sanitize_text_field( $_POST['wcpt-session-type'] ); 1878 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) 1969 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) { 1879 1970 $session_type = 'session'; 1971 } 1880 1972 1881 1973 update_post_meta( $post_id, '_wcpt_session_type', $session_type ); … … 1895 1987 $speakers_list = explode( ',', $speakers_list ); 1896 1988 1897 if ( ! is_array( $speakers_list ) ) 1989 if ( ! is_array( $speakers_list ) ) { 1898 1990 $speakers_list = array(); 1991 } 1899 1992 1900 1993 $speaker_ids = array(); … … 1902 1995 1903 1996 foreach ( $speakers as $speaker_name ) { 1904 if ( empty( $speaker_name ) ) 1997 if ( empty( $speaker_name ) ) { 1905 1998 continue; 1999 } 1906 2000 1907 2001 /* … … 1915 2009 */ 1916 2010 $speaker = get_page_by_title( $speaker_name, OBJECT, 'wcb_speaker' ); 1917 if ( $speaker ) 2011 if ( $speaker ) { 1918 2012 $speaker_ids[] = $speaker->ID; 2013 } 1919 2014 } 1920 2015 … … 1922 2017 $speaker_ids = array_unique( $speaker_ids ); 1923 2018 delete_post_meta( $post_id, '_wcpt_speaker_id' ); 1924 foreach ( $speaker_ids as $speaker_id ) 2019 foreach ( $speaker_ids as $speaker_id ) { 1925 2020 add_post_meta( $post_id, '_wcpt_speaker_id', $speaker_id ); 2021 } 1926 2022 1927 2023 // Set the speaker as the author of the session post, so the single … … 1929 2025 foreach ( $speaker_ids as $speaker_post ) { 1930 2026 $wporg_user_id = get_post_meta( $speaker_post, '_wcpt_user_id', true ); 1931 $user = get_user_by( 'id', $wporg_user_id );2027 $user = get_user_by( 'id', $wporg_user_id ); 1932 2028 1933 2029 if ( $user ) { 1934 remove_action( 'save_post', array( $this, 'save_post_session' ), 10 , 2 );// avoid infinite recursion2030 remove_action( 'save_post', array( $this, 'save_post_session' ), 10 ); // avoid infinite recursion 1935 2031 wp_update_post( array( 1936 2032 'ID' => $post_id, 1937 'post_author' => $user->ID 2033 'post_author' => $user->ID, 1938 2034 ) ); 1939 2035 add_action( 'save_post', array( $this, 'save_post_session' ), 10, 2 ); … … 1966 2062 } 1967 2063 1968 $values['website'] = esc_url_raw( filter_input( INPUT_POST, '_wcpt_sponsor_website' ) ); 1969 // TODO: maybe only allows links to home page, depending on outcome of http://make.wordpress.org/community/2013/12/31/irs-rules-for-corporate-sponsorship-of-wordcamp/ 1970 2064 $values['website'] = esc_url_raw( filter_input( INPUT_POST, '_wcpt_sponsor_website' ) ); 2065 // TODO: maybe only allows links to home page, depending on outcome of http://make.wordpress.org/community/2013/12/31/irs-rules-for-corporate-sponsorship-of-wordcamp/ 1971 2066 $values['first_name'] = ucfirst( $values['first_name'] ); 1972 $values['last_name' ] = ucfirst( $values['last_name' ] ); 1973 1974 $values['agreement'] = filter_input( INPUT_POST, '_wcpt_sponsor_agreement', FILTER_SANITIZE_NUMBER_INT ); 1975 1976 foreach( $values as $id => $value ) { 2067 $values['last_name'] = ucfirst( $values['last_name'] ); 2068 $values['agreement'] = filter_input( INPUT_POST, '_wcpt_sponsor_agreement', FILTER_SANITIZE_NUMBER_INT ); 2069 2070 foreach ( $values as $id => $value ) { 1977 2071 $meta_key = '_wcpt_sponsor_' . $id; 1978 2072 … … 1992 2086 // Speaker post type labels. 1993 2087 $labels = array( 1994 'name' => __( 'Speakers','wordcamporg' ),1995 'singular_name' => __( 'Speaker','wordcamporg' ),1996 'add_new' => __( 'Add New','wordcamporg' ),1997 'add_new_item' => __( 'Create New Speaker','wordcamporg' ),1998 'edit' => __( 'Edit','wordcamporg' ),1999 'edit_item' => __( 'Edit Speaker','wordcamporg' ),2000 'new_item' => __( 'New Speaker','wordcamporg' ),2001 'view' => __( 'View Speaker','wordcamporg' ),2002 'view_item' => __( 'View Speaker','wordcamporg' ),2003 'search_items' => __( 'Search Speakers','wordcamporg' ),2004 'not_found' => __( 'No speakers found','wordcamporg' ),2005 'not_found_in_trash' 2006 'parent_item_colon' => __( 'Parent Speaker:','wordcamporg' ),2088 'name' => __( 'Speakers', 'wordcamporg' ), 2089 'singular_name' => __( 'Speaker', 'wordcamporg' ), 2090 'add_new' => __( 'Add New', 'wordcamporg' ), 2091 'add_new_item' => __( 'Create New Speaker', 'wordcamporg' ), 2092 'edit' => __( 'Edit', 'wordcamporg' ), 2093 'edit_item' => __( 'Edit Speaker', 'wordcamporg' ), 2094 'new_item' => __( 'New Speaker', 'wordcamporg' ), 2095 'view' => __( 'View Speaker', 'wordcamporg' ), 2096 'view_item' => __( 'View Speaker', 'wordcamporg' ), 2097 'search_items' => __( 'Search Speakers', 'wordcamporg' ), 2098 'not_found' => __( 'No speakers found', 'wordcamporg' ), 2099 'not_found_in_trash' => __( 'No speakers found in Trash', 'wordcamporg' ), 2100 'parent_item_colon' => __( 'Parent Speaker:', 'wordcamporg' ), 2007 2101 ); 2008 2102 2009 2103 // Register speaker post type. 2010 register_post_type( 'wcb_speaker', array( 2011 'labels' => $labels, 2012 'rewrite' => array( 'slug' => 'speaker', 'with_front' => true ), 2013 'supports' => array( 'title', 'editor', 'author', 'revisions', 'comments', 'custom-fields' ), 2014 'menu_position' => 20, 2015 'public' => true, 2016 'show_ui' => true, 2017 'can_export' => true, 2018 'capability_type' => 'post', 2019 'hierarchical' => false, 2020 'query_var' => true, 2021 'menu_icon' => 'dashicons-megaphone', 2022 'show_in_rest' => true, 2023 'rest_base' => 'speakers', 2024 ) ); 2104 register_post_type( 2105 'wcb_speaker', 2106 array( 2107 'labels' => $labels, 2108 'rewrite' => array( 'slug' => 'speaker', 'with_front' => true, ), 2109 'supports' => array( 'title', 'editor', 'author', 'revisions', 'comments', 'custom-fields' ), 2110 'menu_position' => 20, 2111 'public' => true, 2112 'show_ui' => true, 2113 'can_export' => true, 2114 'capability_type' => 'post', 2115 'hierarchical' => false, 2116 'query_var' => true, 2117 'menu_icon' => 'dashicons-megaphone', 2118 'show_in_rest' => true, 2119 'rest_base' => 'speakers', 2120 ) 2121 ); 2025 2122 2026 2123 // Session post type labels. 2027 2124 $labels = array( 2028 'name' => __( 'Sessions','wordcamporg' ),2029 'singular_name' => __( 'Session','wordcamporg' ),2030 'add_new' => __( 'Add New','wordcamporg' ),2031 'add_new_item' => __( 'Create New Session','wordcamporg' ),2032 'edit' => __( 'Edit','wordcamporg' ),2033 'edit_item' => __( 'Edit Session','wordcamporg' ),2034 'new_item' => __( 'New Session','wordcamporg' ),2035 'view' => __( 'View Session','wordcamporg' ),2036 'view_item' => __( 'View Session','wordcamporg' ),2037 'search_items' => __( 'Search Sessions','wordcamporg' ),2038 'not_found' => __( 'No sessions found','wordcamporg' ),2039 'not_found_in_trash' 2040 'parent_item_colon' => __( 'Parent Session:','wordcamporg' ),2125 'name' => __( 'Sessions', 'wordcamporg' ), 2126 'singular_name' => __( 'Session', 'wordcamporg' ), 2127 'add_new' => __( 'Add New', 'wordcamporg' ), 2128 'add_new_item' => __( 'Create New Session', 'wordcamporg' ), 2129 'edit' => __( 'Edit', 'wordcamporg' ), 2130 'edit_item' => __( 'Edit Session', 'wordcamporg' ), 2131 'new_item' => __( 'New Session', 'wordcamporg' ), 2132 'view' => __( 'View Session', 'wordcamporg' ), 2133 'view_item' => __( 'View Session', 'wordcamporg' ), 2134 'search_items' => __( 'Search Sessions', 'wordcamporg' ), 2135 'not_found' => __( 'No sessions found', 'wordcamporg' ), 2136 'not_found_in_trash' => __( 'No sessions found in Trash', 'wordcamporg' ), 2137 'parent_item_colon' => __( 'Parent Session:', 'wordcamporg' ), 2041 2138 ); 2042 2139 2043 2140 // Register session post type. 2044 register_post_type( 'wcb_session', array( 2045 'labels' => $labels, 2046 'rewrite' => array( 'slug' => 'session', 'with_front' => false ), 2047 'supports' => array( 'title', 'editor', 'author', 'revisions', 'thumbnail', 'custom-fields' ), 2048 'menu_position' => 21, 2049 'public' => true, 2050 'show_ui' => true, 2051 'can_export' => true, 2052 'capability_type' => 'post', 2053 'hierarchical' => false, 2054 'query_var' => true, 2055 'menu_icon' => 'dashicons-schedule', 2056 'show_in_rest' => true, 2057 'rest_base' => 'sessions', 2058 ) ); 2141 register_post_type( 2142 'wcb_session', 2143 array( 2144 'labels' => $labels, 2145 'rewrite' => array( 'slug' => 'session', 'with_front' => false, ), 2146 'supports' => array( 'title', 'editor', 'author', 'revisions', 'thumbnail', 'custom-fields' ), 2147 'menu_position' => 21, 2148 'public' => true, 2149 'show_ui' => true, 2150 'can_export' => true, 2151 'capability_type' => 'post', 2152 'hierarchical' => false, 2153 'query_var' => true, 2154 'menu_icon' => 'dashicons-schedule', 2155 'show_in_rest' => true, 2156 'rest_base' => 'sessions', 2157 ) 2158 ); 2059 2159 2060 2160 // Sponsor post type labels. 2061 2161 $labels = array( 2062 'name' => __( 'Sponsors','wordcamporg' ),2063 'singular_name' => __( 'Sponsor','wordcamporg' ),2064 'add_new' => __( 'Add New','wordcamporg' ),2065 'add_new_item' => __( 'Create New Sponsor','wordcamporg' ),2066 'edit' => __( 'Edit','wordcamporg' ),2067 'edit_item' => __( 'Edit Sponsor','wordcamporg' ),2068 'new_item' => __( 'New Sponsor','wordcamporg' ),2069 'view' => __( 'View Sponsor','wordcamporg' ),2070 'view_item' => __( 'View Sponsor','wordcamporg' ),2071 'search_items' => __( 'Search Sponsors','wordcamporg' ),2072 'not_found' => __( 'No sponsors found','wordcamporg' ),2073 'not_found_in_trash' 2074 'parent_item_colon' => __( 'Parent Sponsor:','wordcamporg' ),2162 'name' => __( 'Sponsors', 'wordcamporg' ), 2163 'singular_name' => __( 'Sponsor', 'wordcamporg' ), 2164 'add_new' => __( 'Add New', 'wordcamporg' ), 2165 'add_new_item' => __( 'Create New Sponsor', 'wordcamporg' ), 2166 'edit' => __( 'Edit', 'wordcamporg' ), 2167 'edit_item' => __( 'Edit Sponsor', 'wordcamporg' ), 2168 'new_item' => __( 'New Sponsor', 'wordcamporg' ), 2169 'view' => __( 'View Sponsor', 'wordcamporg' ), 2170 'view_item' => __( 'View Sponsor', 'wordcamporg' ), 2171 'search_items' => __( 'Search Sponsors', 'wordcamporg' ), 2172 'not_found' => __( 'No sponsors found', 'wordcamporg' ), 2173 'not_found_in_trash' => __( 'No sponsors found in Trash', 'wordcamporg' ), 2174 'parent_item_colon' => __( 'Parent Sponsor:', 'wordcamporg' ), 2075 2175 ); 2076 2176 2077 2177 // Register sponsor post type. 2078 register_post_type( 'wcb_sponsor', array( 2079 'labels' => $labels, 2080 'rewrite' => array( 'slug' => 'sponsor', 'with_front' => false ), 2081 'supports' => array( 'title', 'editor', 'revisions', 'thumbnail', 'custom-fields' ), 2082 'menu_position' => 21, 2083 'public' => true, 2084 'show_ui' => true, 2085 'can_export' => true, 2086 'capability_type' => 'post', 2087 'hierarchical' => false, 2088 'query_var' => true, 2089 'menu_icon' => 'dashicons-heart', 2090 'show_in_rest' => true, 2091 'rest_base' => 'sponsors', 2092 ) ); 2178 register_post_type( 2179 'wcb_sponsor', 2180 array( 2181 'labels' => $labels, 2182 'rewrite' => array( 'slug' => 'sponsor', 'with_front' => false, ), 2183 'supports' => array( 'title', 'editor', 'revisions', 'thumbnail', 'custom-fields' ), 2184 'menu_position' => 21, 2185 'public' => true, 2186 'show_ui' => true, 2187 'can_export' => true, 2188 'capability_type' => 'post', 2189 'hierarchical' => false, 2190 'query_var' => true, 2191 'menu_icon' => 'dashicons-heart', 2192 'show_in_rest' => true, 2193 'rest_base' => 'sponsors', 2194 ) 2195 ); 2093 2196 2094 2197 // Organizer post type labels. 2095 2198 $labels = array( 2096 'name' => __( 'Organizers','wordcamporg' ),2097 'singular_name' => __( 'Organizer','wordcamporg' ),2098 'add_new' => __( 'Add New','wordcamporg' ),2099 'add_new_item' => __( 'Create New Organizer','wordcamporg' ),2100 'edit' => __( 'Edit','wordcamporg' ),2101 'edit_item' => __( 'Edit Organizer','wordcamporg' ),2102 'new_item' => __( 'New Organizer','wordcamporg' ),2103 'view' => __( 'View Organizer','wordcamporg' ),2104 'view_item' => __( 'View Organizer','wordcamporg' ),2105 'search_items' => __( 'Search Organizers','wordcamporg' ),2106 'not_found' => __( 'No organizers found','wordcamporg' ),2107 'not_found_in_trash' 2108 'parent_item_colon' => __( 'Parent Organizer:','wordcamporg' ),2199 'name' => __( 'Organizers', 'wordcamporg' ), 2200 'singular_name' => __( 'Organizer', 'wordcamporg' ), 2201 'add_new' => __( 'Add New', 'wordcamporg' ), 2202 'add_new_item' => __( 'Create New Organizer', 'wordcamporg' ), 2203 'edit' => __( 'Edit', 'wordcamporg' ), 2204 'edit_item' => __( 'Edit Organizer', 'wordcamporg' ), 2205 'new_item' => __( 'New Organizer', 'wordcamporg' ), 2206 'view' => __( 'View Organizer', 'wordcamporg' ), 2207 'view_item' => __( 'View Organizer', 'wordcamporg' ), 2208 'search_items' => __( 'Search Organizers', 'wordcamporg' ), 2209 'not_found' => __( 'No organizers found', 'wordcamporg' ), 2210 'not_found_in_trash' => __( 'No organizers found in Trash', 'wordcamporg' ), 2211 'parent_item_colon' => __( 'Parent Organizer:', 'wordcamporg' ), 2109 2212 ); 2110 2213 2111 2214 // Register organizer post type. 2112 register_post_type( 'wcb_organizer', array( 2113 'labels' => $labels, 2114 'rewrite' => array( 'slug' => 'organizer', 'with_front' => false ), 2115 'supports' => array( 'title', 'editor', 'revisions' ), 2116 'menu_position' => 22, 2117 'public' => false, 2118 // todo public or publicly_queryable = true, so consistent with others? at the very least set show_in_json = true 2119 'show_ui' => true, 2120 'can_export' => true, 2121 'capability_type' => 'post', 2122 'hierarchical' => false, 2123 'query_var' => true, 2124 'menu_icon' => 'dashicons-groups', 2125 ) ); 2215 register_post_type( 2216 'wcb_organizer', 2217 array( 2218 'labels' => $labels, 2219 'rewrite' => array( 'slug' => 'organizer', 'with_front' => false, ), 2220 'supports' => array( 'title', 'editor', 'revisions' ), 2221 'menu_position' => 22, 2222 'public' => false, 2223 // todo public or publicly_queryable = true, so consistent with others? at the very least set show_in_json = true 2224 'show_ui' => true, 2225 'can_export' => true, 2226 'capability_type' => 'post', 2227 'hierarchical' => false, 2228 'query_var' => true, 2229 'menu_icon' => 'dashicons-groups', 2230 ) 2231 ); 2126 2232 } 2127 2233 … … 2132 2238 // Labels for tracks. 2133 2239 $labels = array( 2134 'name' => __( 'Tracks','wordcamporg' ),2135 'singular_name' => __( 'Track','wordcamporg' ),2136 'search_items' => __( 'Search Tracks','wordcamporg' ),2137 'popular_items' => __( 'Popular Tracks','wordcamporg' ),2138 'all_items' => __( 'All Tracks','wordcamporg' ),2139 'edit_item' => __( 'Edit Track','wordcamporg' ),2140 'update_item' => __( 'Update Track','wordcamporg' ),2141 'add_new_item' => __( 'Add Track','wordcamporg' ),2142 'new_item_name' => __( 'New Track','wordcamporg' ),2240 'name' => __( 'Tracks', 'wordcamporg' ), 2241 'singular_name' => __( 'Track', 'wordcamporg' ), 2242 'search_items' => __( 'Search Tracks', 'wordcamporg' ), 2243 'popular_items' => __( 'Popular Tracks', 'wordcamporg' ), 2244 'all_items' => __( 'All Tracks', 'wordcamporg' ), 2245 'edit_item' => __( 'Edit Track', 'wordcamporg' ), 2246 'update_item' => __( 'Update Track', 'wordcamporg' ), 2247 'add_new_item' => __( 'Add Track', 'wordcamporg' ), 2248 'new_item_name' => __( 'New Track', 'wordcamporg' ), 2143 2249 ); 2144 2250 2145 2251 // Register the Tracks taxonomy. 2146 register_taxonomy( 'wcb_track', 'wcb_session', array( 2147 'labels' => $labels, 2148 'rewrite' => array( 'slug' => 'track' ), 2149 'query_var' => 'track', 2150 'hierarchical' => true, 2151 'public' => true, 2152 'show_ui' => true, 2153 'show_in_rest' => true, 2154 'rest_base' => 'session_track', 2155 ) ); 2252 register_taxonomy( 2253 'wcb_track', 2254 'wcb_session', 2255 array( 2256 'labels' => $labels, 2257 'rewrite' => array( 'slug' => 'track' ), 2258 'query_var' => 'track', 2259 'hierarchical' => true, 2260 'public' => true, 2261 'show_ui' => true, 2262 'show_in_rest' => true, 2263 'rest_base' => 'session_track', 2264 ) 2265 ); 2156 2266 2157 2267 // Labels for categories. 2158 2268 $labels = array( 2159 'name' => __( 'Categories','wordcamporg' ),2160 'singular_name' => __( 'Category','wordcamporg' ),2161 'search_items' => __( 'Search Categories','wordcamporg' ),2162 'popular_items' => __( 'Popular Categories','wordcamporg' ),2163 'all_items' => __( 'All Categories','wordcamporg' ),2164 'edit_item' => __( 'Edit Category','wordcamporg' ),2165 'update_item' => __( 'Update Category','wordcamporg' ),2166 'add_new_item' => __( 'Add Category','wordcamporg' ),2167 'new_item_name' => __( 'New Category','wordcamporg' ),2269 'name' => __( 'Categories', 'wordcamporg' ), 2270 'singular_name' => __( 'Category', 'wordcamporg' ), 2271 'search_items' => __( 'Search Categories', 'wordcamporg' ), 2272 'popular_items' => __( 'Popular Categories', 'wordcamporg' ), 2273 'all_items' => __( 'All Categories', 'wordcamporg' ), 2274 'edit_item' => __( 'Edit Category', 'wordcamporg' ), 2275 'update_item' => __( 'Update Category', 'wordcamporg' ), 2276 'add_new_item' => __( 'Add Category', 'wordcamporg' ), 2277 'new_item_name' => __( 'New Category', 'wordcamporg' ), 2168 2278 ); 2169 2279 2170 2280 // Register the Categories taxonomy. 2171 register_taxonomy( 'wcb_session_category', 'wcb_session', array( 2172 'labels' => $labels, 2173 'rewrite' => array( 'slug' => 'session-category' ), 2174 'query_var' => 'session_category', 2175 'hierarchical' => true, 2176 'public' => true, 2177 'show_ui' => true, 2178 'show_in_rest' => true, 2179 'rest_base' => 'session_category', 2180 ) ); 2281 register_taxonomy( 2282 'wcb_session_category', 2283 'wcb_session', 2284 array( 2285 'labels' => $labels, 2286 'rewrite' => array( 'slug' => 'session-category' ), 2287 'query_var' => 'session_category', 2288 'hierarchical' => true, 2289 'public' => true, 2290 'show_ui' => true, 2291 'show_in_rest' => true, 2292 'rest_base' => 'session_category', 2293 ) 2294 ); 2181 2295 2182 2296 // Labels for sponsor levels. 2183 2297 $labels = array( 2184 'name' => __( 'Sponsor Levels','wordcamporg' ),2185 'singular_name' => __( 'Sponsor Level','wordcamporg' ),2186 'search_items' => __( 'Search Sponsor Levels','wordcamporg' ),2187 'popular_items' 2188 'all_items' => __( 'All Sponsor Levels','wordcamporg' ),2189 'edit_item' => __( 'Edit Sponsor Level','wordcamporg' ),2190 'update_item' => __( 'Update Sponsor Level','wordcamporg' ),2191 'add_new_item' => __( 'Add Sponsor Level','wordcamporg' ),2192 'new_item_name' => __( 'New Sponsor Level','wordcamporg' ),2298 'name' => __( 'Sponsor Levels', 'wordcamporg' ), 2299 'singular_name' => __( 'Sponsor Level', 'wordcamporg' ), 2300 'search_items' => __( 'Search Sponsor Levels', 'wordcamporg' ), 2301 'popular_items' => __( 'Popular Sponsor Levels', 'wordcamporg' ), 2302 'all_items' => __( 'All Sponsor Levels', 'wordcamporg' ), 2303 'edit_item' => __( 'Edit Sponsor Level', 'wordcamporg' ), 2304 'update_item' => __( 'Update Sponsor Level', 'wordcamporg' ), 2305 'add_new_item' => __( 'Add Sponsor Level', 'wordcamporg' ), 2306 'new_item_name' => __( 'New Sponsor Level', 'wordcamporg' ), 2193 2307 ); 2194 2308 2195 2309 // Register sponsor level taxonomy 2196 register_taxonomy( 'wcb_sponsor_level', 'wcb_sponsor', array( 2197 'labels' => $labels, 2198 'rewrite' => array( 'slug' => 'sponsor_level' ), 2199 'query_var' => 'sponsor_level', 2200 'hierarchical' => true, 2201 'public' => true, 2202 'show_ui' => true, 2203 'show_in_rest' => true, 2204 'rest_base' => 'sponsor_level', 2205 ) ); 2310 register_taxonomy( 2311 'wcb_sponsor_level', 2312 'wcb_sponsor', 2313 array( 2314 'labels' => $labels, 2315 'rewrite' => array( 'slug' => 'sponsor_level' ), 2316 'query_var' => 'sponsor_level', 2317 'hierarchical' => true, 2318 'public' => true, 2319 'show_ui' => true, 2320 'show_in_rest' => true, 2321 'rest_base' => 'sponsor_level', 2322 ) 2323 ); 2206 2324 2207 2325 // Labels for organizer teams. … … 2282 2400 $original_columns = $columns; 2283 2401 2284 $columns =array_slice( $original_columns, 0, 1, true );2402 $columns = array_slice( $original_columns, 0, 1, true ); 2285 2403 $columns += array( 'wcb_speaker_avatar' => __( 'Avatar', 'wordcamporg' ) ); 2286 2404 $columns += array_slice( $original_columns, 1, 1, true ); … … 2295 2413 case 'manage_wcb_session_posts_columns': 2296 2414 $columns = array_slice( $columns, 0, 2, true ) + array( 'wcb_session_speakers' => __( 'Speakers', 'wordcamporg' ) ) + array_slice( $columns, 2, null, true ); 2297 $columns = array_slice( $columns, 0, 1, true ) + array( 'wcb_session_time' => __( 'Time', 'wordcamporg' ) )+ array_slice( $columns, 1, null, true );2415 $columns = array_slice( $columns, 0, 1, true ) + array( 'wcb_session_time' => __( 'Time', 'wordcamporg' ) ) + array_slice( $columns, 1, null, true ); 2298 2416 break; 2299 2417 default: … … 2335 2453 2336 2454 case 'wcb_session_speakers': 2337 $speakers = array();2455 $speakers = array(); 2338 2456 $speakers_ids = array_map( 'absint', (array) get_post_meta( $post_id, '_wcpt_speaker_id' ) ); 2457 2339 2458 if ( ! empty( $speakers_ids ) ) { 2340 2459 $speakers = get_posts( array( 2341 'post_type' => 'wcb_speaker',2460 'post_type' => 'wcb_speaker', 2342 2461 'posts_per_page' => -1, 2343 'post__in' => $speakers_ids,2462 'post__in' => $speakers_ids, 2344 2463 ) ); 2345 2464 } 2346 2465 2347 2466 $output = array(); 2467 2348 2468 foreach ( $speakers as $speaker ) { 2349 2469 $output[] = sprintf( '<a href="%s">%s</a>', esc_url( get_edit_post_link( $speaker->ID ) ), esc_html( apply_filters( 'the_title', $speaker->post_title ) ) ); 2350 2470 } 2471 2351 2472 echo implode( ', ', $output ); 2352 2473 … … 2369 2490 $current_filter = current_filter(); 2370 2491 2371 if ( 'manage_edit-wcb_session_sortable_columns' == $current_filter ) 2492 if ( 'manage_edit-wcb_session_sortable_columns' == $current_filter ) { 2372 2493 $sortable['wcb_session_time'] = '_wcpt_session_time'; 2494 } 2373 2495 2374 2496 return $sortable; … … 2381 2503 $post = get_post(); 2382 2504 2383 if ( 'wcb_session' != $post->post_type ) 2505 if ( 'wcb_session' != $post->post_type ) { 2384 2506 return $states; 2507 } 2385 2508 2386 2509 $session_type = get_post_meta( $post->ID, '_wcpt_session_type', true ); 2387 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) 2510 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) { 2388 2511 $session_type = 'session'; 2389 2390 if ( 'session' == $session_type ) 2512 } 2513 2514 if ( 'session' == $session_type ) { 2391 2515 $states['wcpt-session-type'] = __( 'Session', 'wordcamporg' ); 2392 elseif ( 'custom' == $session_type )2516 } elseif ( 'custom' == $session_type ) { 2393 2517 $states['wcpt-session-type'] = __( 'Custom', 'wordcamporg' ); 2518 } 2394 2519 2395 2520 return $states; … … 2459 2584 public function default_comment_ping_status( $status ) { 2460 2585 $screen = get_current_screen(); 2461 if ( ! empty( $screen->post_type ) && $screen->post_type == 'wcb_speaker' ) 2586 if ( ! empty( $screen->post_type ) && $screen->post_type == 'wcb_speaker' ) { 2462 2587 $status = 'closed'; 2588 } 2463 2589 2464 2590 return $status; … … 2467 2593 2468 2594 // Load the plugin class. 2469 $GLOBALS['wcpt_plugin'] = new WordCamp_Post_Types_Plugin ;2595 $GLOBALS['wcpt_plugin'] = new WordCamp_Post_Types_Plugin();
Note: See TracChangeset
for help on using the changeset viewer.