Ticket #2711: 2711.meta.3.diff
File 2711.meta.3.diff, 78.9 KB (added by , 7 years ago) |
---|
-
wordcamp.org/public_html/wp-content/plugins/wc-post-types/views/sponsors/metabox-sponsor-info.php
diff --git wordcamp.org/public_html/wp-content/plugins/wc-post-types/views/sponsors/metabox-sponsor-info.php wordcamp.org/public_html/wp-content/plugins/wc-post-types/views/sponsors/metabox-sponsor-info.php index 9bbd174a..e6934331 100644
141 141 </ul> 142 142 143 143 <ul class="wcpt-form"> 144 <li> 145 <label for="_wcpt_sponsor_country"> 146 <?php _e( 'Country:', 'wordcamporg' ) ?> 147 </label> 148 149 <?php // todo add selected attribute to select and change first option value to empty string ?> 150 <select id="_wcpt_sponsor_country" name="_wcpt_sponsor_country"> 151 <option value="null" <?php selected( $country, 'null' ); ?>> 152 <?php _e( '-- Select a Country --', 'wordcamporg' ); ?> 153 </option> 154 155 <?php foreach ( $available_countries as $available_country ) : ?> 156 <option value="<?php echo esc_attr( $available_country ); ?>" <?php selected( $available_country, $country ); ?>> 157 <?php echo esc_html( $available_country ); ?> 158 </option> 159 <?php endforeach; ?> 160 </select> 161 162 <?php $this->render_form_field_required_indicator(); ?> 163 </li> 164 144 165 <li class="wcpt-form-header"> 145 166 <?php _e( 'Address', 'wordcamporg' ); ?> 146 167 </li> … … 204 225 id="_wcpt_sponsor_state" 205 226 name="_wcpt_sponsor_state" 206 227 value="<?php echo esc_attr( $state ); ?>" 207 required208 228 /> 209 229 210 <?php $this->render_form_field_required_indicator(); ?> 230 <span class="description"> 231 <?php esc_html_e( 'Only necessary if you want this to be shown on your invoice', 'wordcamporg' ); ?> 232 </span> 211 233 </li> 212 234 213 235 <li> … … 227 249 228 250 <?php $this->render_form_field_required_indicator(); ?> 229 251 </li> 230 231 <li>232 <label for="_wcpt_sponsor_country">233 <?php _e( 'Country:', 'wordcamporg' ) ?>234 </label>235 236 <?php // todo add selected attribute to select and change first option value to empty string ?>237 <select id="_wcpt_sponsor_country" name="_wcpt_sponsor_country">238 <option value="null" <?php selected( $country, 'null' ); ?>>239 <?php _e( '-- Select a Country --', 'wordcamporg' ); ?>240 </option>241 242 <?php foreach ( $available_countries as $available_country ) : ?>243 <option value="<?php echo esc_attr( $available_country ); ?>" <?php selected( $available_country, $country ); ?>>244 <?php echo esc_html( $available_country ); ?>245 </option>246 <?php endforeach; ?>247 </select>248 249 <?php $this->render_form_field_required_indicator(); ?>250 </li>251 252 </ul> 252 253 253 254 <span class="wcpt-form-required"> -
wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php
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 43f3413e..2f26492c 100644
class WordCamp_Post_Types_Plugin { 29 29 30 30 add_action( 'save_post', array( $this, 'save_post_speaker' ), 10, 2 ); 31 31 add_action( 'save_post', array( $this, 'save_post_session' ), 10, 2 ); 32 add_action( 'save_post', array( $this, 'save_post_organizer' ), 10, 2 );33 add_action( 'save_post', array( $this, 'save_post_sponsor' ), 10, 2 );32 add_action( 'save_post', array( $this, 'save_post_organizer' ), 10, 2 ); 33 add_action( 'save_post', array( $this, 'save_post_sponsor' ), 10, 2 ); 34 34 35 35 add_filter( 'manage_wcb_speaker_posts_columns', array( $this, 'manage_post_types_columns' ) ); 36 36 add_filter( 'manage_wcb_session_posts_columns', array( $this, 'manage_post_types_columns' ) ); … … class WordCamp_Post_Types_Plugin { 110 110 * Renders the Order Sponsor Levels admin page. 111 111 */ 112 112 function render_order_sponsor_levels() { 113 if ( ! isset( $_REQUEST['updated'] ) ) 113 if ( ! isset( $_REQUEST['updated'] ) ) { 114 114 $_REQUEST['updated'] = false; 115 } 115 116 116 117 $levels = $this->get_sponsor_levels(); 117 118 ?> … … class WordCamp_Post_Types_Plugin { 129 130 <?php _e( 'Change the order of sponsor levels are displayed in the sponsors page template.', 'wordcamporg' ); ?> 130 131 </div> 131 132 <ul class="sponsor-order"> 132 <?php foreach( $levels as $term ): ?>133 <li class="level">134 <input type="hidden" class="level-id" name="wcb_sponsor_level_order[]" value="<?php echo esc_attr( $term->term_id ); ?>"/>135 <?php echo esc_html( $term->name ); ?>136 </li>137 <?php endforeach; ?>133 <?php foreach ( $levels as $term ): ?> 134 <li class="level"> 135 <input type="hidden" class="level-id" name="wcb_sponsor_level_order[]" value="<?php echo esc_attr( $term->term_id ); ?>"/> 136 <?php echo esc_html( $term->name ); ?> 137 </li> 138 <?php endforeach; ?> 138 139 </ul> 139 140 <p class="submit"> 140 <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'wordcamporg' ); ?>" 141 <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'wordcamporg' ); ?>"/> 141 142 </p> 142 143 </form> 143 144 </div> … … class WordCamp_Post_Types_Plugin { 164 165 * Returns the sponsor level terms in set order. 165 166 */ 166 167 function get_sponsor_levels() { 167 $option 168 $term_objects 169 $terms 170 $ordered_terms 168 $option = get_option( 'wcb_sponsor_level_order' ); 169 $term_objects = get_terms( 'wcb_sponsor_level', array( 'get' => 'all' ) ); 170 $terms = array(); 171 $ordered_terms = array(); 171 172 172 173 foreach ( $term_objects as $term ) { 173 174 $terms[ $term->term_id ] = $term; 174 175 } 175 176 176 if ( empty( $option ) ) 177 if ( empty( $option ) ) { 177 178 $option = array(); 179 } 178 180 179 181 foreach ( $option as $term_id ) { 180 182 if ( isset( $terms[ $term_id ] ) ) { … … class WordCamp_Post_Types_Plugin { 192 194 * @param WP_Query $query 193 195 */ 194 196 function admin_pre_get_posts( $query ) { 195 if ( ! is_admin() || ! $query->is_main_query() ) 197 if ( ! is_admin() || ! $query->is_main_query() ) { 196 198 return; 199 } 197 200 198 201 $current_screen = get_current_screen(); 199 202 … … class WordCamp_Post_Types_Plugin { 228 231 <script type="text/javascript"> 229 232 jQuery( document ).ready( function( $ ) { 230 233 $( '#wcpt-session-date' ).datepicker( { 231 dateFormat :'yy-mm-dd',232 changeMonth : true,233 changeYear :true234 dateFormat : 'yy-mm-dd', 235 changeMonth : true, 236 changeYear : true 234 237 } ); 235 238 } ); 236 239 </script> … … class WordCamp_Post_Types_Plugin { 289 292 } 290 293 291 294 $attr['show_avatars'] = $this->str_to_bool( $attr['show_avatars'] ); 292 $attr['orderby'] = in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ? $attr['orderby']: 'date';293 $attr['order'] = in_array( $attr['order'], array( 'asc', 'desc' ) ) ? $attr['order']: 'desc';294 $attr['speaker_link'] = in_array( $attr['speaker_link'], array( 'permalink' 295 $attr['track'] 296 $attr['groups'] 295 $attr['orderby'] = in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ? $attr['orderby'] : 'date'; 296 $attr['order'] = in_array( $attr['order'], array( 'asc', 'desc' ) ) ? $attr['order'] : 'desc'; 297 $attr['speaker_link'] = in_array( $attr['speaker_link'], array( 'permalink' ) ) ? $attr['speaker_link'] : ''; 298 $attr['track'] = array_filter( explode( ',', $attr['track'] ) ); 299 $attr['groups'] = array_filter( explode( ',', $attr['groups'] ) ); 297 300 298 301 // Fetch all the relevant sessions 299 302 $session_args = array( … … class WordCamp_Post_Types_Plugin { 361 364 362 365 $speakers = new WP_Query( $speaker_args ); 363 366 364 if ( ! $speakers->have_posts() ) 367 if ( ! $speakers->have_posts() ) { 365 368 return ''; 369 } 366 370 367 371 // Render the HTML for the shortcode 368 372 ob_start(); … … class WordCamp_Post_Types_Plugin { 373 377 <?php while ( $speakers->have_posts() ) : $speakers->the_post(); ?> 374 378 375 379 <?php 376 380 $speaker_classes = array( 'wcorg-speaker', 'wcorg-speaker-' . sanitize_html_class( $post->post_name ) ); 377 381 378 if ( isset( $speakers_tracks[ get_the_ID() ] ) ) { 379 foreach ( $speakers_tracks[ get_the_ID() ] as $track ) { 380 $speaker_classes[] = sanitize_html_class( 'wcorg-track-' . $track ); 381 } 382 if ( isset( $speakers_tracks[ get_the_ID() ] ) ) { 383 foreach ( $speakers_tracks[ get_the_ID() ] as $track ) { 384 $speaker_classes[] = sanitize_html_class( 'wcorg-track-' . $track ); 382 385 } 386 } 383 387 ?> 384 388 385 389 <!-- Organizers note: The id attribute is deprecated and only remains for backwards compatibility, please use the corresponding class to target individual speakers --> … … class WordCamp_Post_Types_Plugin { 406 410 <?php 407 411 408 412 wp_reset_postdata(); 413 409 414 return ob_get_clean(); 410 415 } 411 416 … … class WordCamp_Post_Types_Plugin { 426 431 $attr['orderby'] = ( in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ) ? $attr['orderby'] : 'date'; 427 432 428 433 $query_args = array( 429 'post_type' => 'wcb_organizer',434 'post_type' => 'wcb_organizer', 430 435 'posts_per_page' => intval( $attr['posts_per_page'] ), 431 'orderby' => $attr['orderby'],436 'orderby' => $attr['orderby'], 432 437 ); 433 438 434 439 if ( ! empty( $attr['teams'] ) ) { … … class WordCamp_Post_Types_Plugin { 443 448 444 449 $organizers = new WP_Query( $query_args ); 445 450 446 if ( ! $organizers->have_posts() ) 451 if ( ! $organizers->have_posts() ) { 447 452 return ''; 453 } 448 454 449 455 ob_start(); 450 456 ?> … … class WordCamp_Post_Types_Plugin { 468 474 wp_reset_postdata(); 469 475 $content = ob_get_contents(); 470 476 ob_end_clean(); 477 471 478 return $content; 472 479 } 473 480 … … class WordCamp_Post_Types_Plugin { 491 498 $attr[ $key_for_case_sensitive_value ] = strtolower( $attr[ $key_for_case_sensitive_value ] ); 492 499 } 493 500 494 if ( ! in_array( $attr['speaker_link'], array( 'anchor', 'wporg', 'permalink', 'none' ) ) ) 501 if ( ! in_array( $attr['speaker_link'], array( 'anchor', 'wporg', 'permalink', 'none' ) ) ) { 495 502 $attr['speaker_link'] = 'anchor'; 503 } 496 504 497 if ( ! in_array( $attr['session_link'], array( 'permalink', 'anchor', 'none' ) ) ) 505 if ( ! in_array( $attr['session_link'], array( 'permalink', 'anchor', 'none' ) ) ) { 498 506 $attr['session_link'] = 'permalink'; 507 } 499 508 500 509 $columns = array(); 501 510 $tracks = array(); … … class WordCamp_Post_Types_Plugin { 504 513 'post_type' => 'wcb_session', 505 514 'posts_per_page' => -1, 506 515 'meta_query' => array( 507 'relation' 516 'relation' => 'AND', 508 517 array( 509 518 'key' => '_wcpt_session_time', 510 519 'compare' => 'EXISTS', … … class WordCamp_Post_Types_Plugin { 520 529 $terms = array_map( 'trim', explode( ',', $attr['tracks'] ) ); 521 530 foreach ( $terms as $term_slug ) { 522 531 $term = get_term_by( 'slug', $term_slug, 'wcb_track' ); 523 if ( $term ) 532 if ( $term ) { 524 533 $tracks[ $term->term_id ] = $term; 534 } 525 535 } 526 536 527 537 // If tracks were provided, restrict the lookup in WP_Query. … … class WordCamp_Post_Types_Plugin { 536 546 537 547 if ( $attr['date'] && strtotime( $attr['date'] ) ) { 538 548 $query_args['meta_query'][] = array( 539 'key' => '_wcpt_session_time',540 'value' => array(549 'key' => '_wcpt_session_time', 550 'value' => array( 541 551 strtotime( $attr['date'] ), 542 552 strtotime( $attr['date'] . ' +1 day' ), 543 553 ), … … class WordCamp_Post_Types_Plugin { 548 558 549 559 // Use tracks to form the columns. 550 560 if ( $tracks ) { 551 foreach ( $tracks as $track ) 561 foreach ( $tracks as $track ) { 552 562 $columns[ $track->term_id ] = $track->term_id; 563 } 553 564 } else { 554 $columns[ 0] = 0;565 $columns[0] = 0; 555 566 } 556 567 557 568 unset( $tracks ); … … class WordCamp_Post_Types_Plugin { 566 577 $time = absint( get_post_meta( $session->ID, '_wcpt_session_time', true ) ); 567 578 $tracks = get_the_terms( $session->ID, 'wcb_track' ); 568 579 569 if ( ! isset( $sessions[ $time ] ) ) 580 if ( ! isset( $sessions[ $time ] ) ) { 570 581 $sessions[ $time ] = array(); 582 } 571 583 572 584 if ( empty( $tracks ) ) { 573 $sessions[ $time ][ 0] = $session->ID;585 $sessions[ $time ][0] = $session->ID; 574 586 } else { 575 foreach ( $tracks as $track ) 587 foreach ( $tracks as $track ) { 576 588 $sessions[ $time ][ $track->term_id ] = $session->ID; 589 } 577 590 } 578 591 } 579 592 … … class WordCamp_Post_Types_Plugin { 584 597 if ( 'all' == $attr['tracks'] ) { 585 598 $used_terms = array(); 586 599 587 foreach ( $sessions as $time => $entry ) 588 if ( is_array( $entry ) ) 589 foreach ( $entry as $term_id => $session_id ) 600 foreach ( $sessions as $time => $entry ) { 601 if ( is_array( $entry ) ) { 602 foreach ( $entry as $term_id => $session_id ) { 590 603 $used_terms[ $term_id ] = $term_id; 604 } 605 } 606 } 591 607 592 608 $columns = array_intersect( $columns, $used_terms ); 593 609 unset( $used_terms ); … … class WordCamp_Post_Types_Plugin { 641 657 } 642 658 643 659 // Gather relevant data about the session 644 $colspan 645 $classes 646 $session 647 $session_title 648 $session_tracks 660 $colspan = 1; 661 $classes = array(); 662 $session = get_post( $entry[ $term_id ] ); 663 $session_title = apply_filters( 'the_title', $session->post_title ); 664 $session_tracks = get_the_terms( $session->ID, 'wcb_track' ); 649 665 $session_track_titles = is_array( $session_tracks ) ? implode( ', ', wp_list_pluck( $session_tracks, 'name' ) ) : ''; 650 $session_type 666 $session_type = get_post_meta( $session->ID, '_wcpt_session_type', true ); 651 667 652 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) 668 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) { 653 669 $session_type = 'session'; 670 } 654 671 655 672 // Fetch speakers associated with this session. 656 673 $speakers = array(); … … class WordCamp_Post_Types_Plugin { 678 695 $classes[] = 'wcb-session-' . $session->post_name; 679 696 680 697 // Determine the session title 681 if ( 'permalink' == $attr['session_link'] && 'session' == $session_type ) 698 if ( 'permalink' == $attr['session_link'] && 'session' == $session_type ) { 682 699 $session_title_html = sprintf( '<a class="wcpt-session-title" href="%s">%s</a>', esc_url( get_permalink( $session->ID ) ), $session_title ); 683 elseif ( 'anchor' == $attr['session_link'] && 'session' == $session_type )700 } elseif ( 'anchor' == $attr['session_link'] && 'session' == $session_type ) { 684 701 $session_title_html = sprintf( '<a class="wcpt-session-title" href="%s">%s</a>', esc_url( $this->get_wcpt_anchor_permalink( $session->ID ) ), $session_title ); 685 else702 } else { 686 703 $session_title_html = sprintf( '<span class="wcpt-session-title">%s</span>', $session_title ); 704 } 687 705 688 706 $content = $session_title_html; 689 707 … … class WordCamp_Post_Types_Plugin { 692 710 $speaker_name = apply_filters( 'the_title', $speaker->post_title ); 693 711 694 712 if ( 'anchor' == $attr['speaker_link'] ) // speakers/#wcorg-speaker-slug 713 { 695 714 $speaker_permalink = $this->get_wcpt_anchor_permalink( $speaker->ID ); 696 elseif ( 'wporg' == $attr['speaker_link'] ) // profiles.wordpress.org/user 715 } elseif ( 'wporg' == $attr['speaker_link'] ) // profiles.wordpress.org/user 716 { 697 717 $speaker_permalink = $this->get_speaker_wporg_permalink( $speaker->ID ); 698 elseif ( 'permalink' == $attr['speaker_link'] ) // year.city.wordcamp.org/speakers/slug 718 } elseif ( 'permalink' == $attr['speaker_link'] ) // year.city.wordcamp.org/speakers/slug 719 { 699 720 $speaker_permalink = get_permalink( $speaker->ID ); 721 } 700 722 701 if ( ! empty( $speaker_permalink ) ) 723 if ( ! empty( $speaker_permalink ) ) { 702 724 $speaker_name = sprintf( '<a href="%s">%s</a>', esc_url( $speaker_permalink ), esc_html( $speaker_name ) ); 725 } 703 726 704 727 $speakers_names[] = $speaker_name; 705 728 } 706 729 707 730 // Add speakers names to the output string. 708 if ( count( $speakers_names ) ) 731 if ( count( $speakers_names ) ) { 709 732 $content .= sprintf( ' <span class="wcpt-session-speakers">%s</span>', implode( ', ', $speakers_names ) ); 733 } 710 734 711 735 $columns_clone = $columns; 712 736 713 737 // If the next element in the table is the same as the current one, use colspan 714 738 if ( $key != key( array_slice( $columns, -1, 1, true ) ) ) { 715 739 while ( $pair = each( $columns_clone ) ) { 716 if ( $pair['key'] == $key ) 740 if ( $pair['key'] == $key ) { 717 741 continue; 742 } 718 743 719 744 if ( ! empty( $entry[ $pair['value'] ] ) && $entry[ $pair['value'] ] == $session->ID ) { 720 745 $colspan++; … … class WordCamp_Post_Types_Plugin { 728 753 $columns_html .= sprintf( '<td colspan="%d" class="%s" data-track-title="%s">%s</td>', $colspan, esc_attr( implode( ' ', $classes ) ), $session_track_titles, $content ); 729 754 } 730 755 731 $global_session 756 $global_session = $colspan == count( $columns ) ? ' global-session' : ''; 732 757 $global_session_slug = $global_session ? ' ' . sanitize_html_class( sanitize_title_with_dashes( $session->post_title ) ) : ''; 733 758 734 759 $html .= sprintf( '<tr class="%s">', sanitize_html_class( 'wcpt-time-' . date( $time_format, $time ) ) . $global_session . $global_session_slug ); … … class WordCamp_Post_Types_Plugin { 739 764 740 765 $html .= '</tbody>'; 741 766 $html .= '</table>'; 767 742 768 return $html; 743 769 } 744 770 … … class WordCamp_Post_Types_Plugin { 749 775 */ 750 776 function get_speaker_wporg_permalink( $speaker_id ) { 751 777 $post = get_post( $speaker_id ); 752 if ( $post->post_type != 'wcb_speaker' || $post->post_status != 'publish' ) 778 if ( $post->post_type != 'wcb_speaker' || $post->post_status != 'publish' ) { 753 779 return; 780 } 754 781 755 782 $wporg_user_id = get_post_meta( $speaker_id, '_wcpt_user_id', true ); 756 if ( ! $wporg_user_id ) 783 if ( ! $wporg_user_id ) { 757 784 return; 785 } 758 786 759 787 $user = get_user_by( 'id', $wporg_user_id ); 760 if ( ! $user ) 788 if ( ! $user ) { 761 789 return; 790 } 762 791 763 792 $permalink = sprintf( 'http://profiles.wordpress.org/%s', strtolower( $user->user_nicename ) ); 793 764 794 return esc_url_raw( $permalink ); 765 795 } 766 796 … … class WordCamp_Post_Types_Plugin { 784 814 return ''; 785 815 } 786 816 787 switch ( $anchor_target->post_type ) {817 switch ( $anchor_target->post_type ) { 788 818 case 'wcb_speaker': 789 819 $permalink = has_shortcode( $post->post_content, 'speakers' ) ? get_permalink( $post->id ) : $this->get_wcpt_permalink( 'speakers' ); 790 820 $anchor_id = $anchor_target->post_name; … … class WordCamp_Post_Types_Plugin { 890 920 891 921 // Convert bools to real booleans. 892 922 $bools = array( 'show_meta', 'show_avatars' ); 893 foreach ( $bools as $key ) 923 foreach ( $bools as $key ) { 894 924 $attr[ $key ] = $this->str_to_bool( $attr[ $key ] ); 925 } 895 926 896 927 // Clean up other attributes. 897 928 foreach ( array( 'track', 'speaker_link', 'orderby', 'order' ) as $key_for_case_sensitive_value ) { … … class WordCamp_Post_Types_Plugin { 900 931 901 932 $attr['avatar_size'] = absint( $attr['avatar_size'] ); 902 933 903 if ( ! in_array( $attr['speaker_link'], array( 'anchor', 'wporg', 'permalink', 'none' ) ) ) 904 $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' 934 if ( ! in_array( $attr['speaker_link'], array( 'anchor', 'wporg', 'permalink', 'none' ) ) ) { 935 $attr['speaker_link'] = 'anchor'; 936 } // todo this is inconsistent with the values passed to shortcode_atts, and probably not needed if the default above is changed to 'anchor' 905 937 906 938 $attr['orderby'] = ( in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ) ? $attr['orderby'] : 'date'; 907 939 … … class WordCamp_Post_Types_Plugin { 918 950 919 951 // Only ones marked "session" or where the meta key does 920 952 // not exist, for backwards compatibility. 921 'meta_query' => array(953 'meta_query' => array( 922 954 'relation' => 'AND', 923 955 924 956 array( … … class WordCamp_Post_Types_Plugin { 935 967 'value' => '', 936 968 'compare' => 'NOT EXISTS', 937 969 ), 938 ) 970 ), 939 971 ), 940 972 ); 941 973 … … class WordCamp_Post_Types_Plugin { 962 994 // Fetch sessions. 963 995 $sessions = new WP_Query( $args ); 964 996 965 if ( ! $sessions->have_posts() ) 997 if ( ! $sessions->have_posts() ) { 966 998 return; 999 } 967 1000 968 1001 ob_start(); 969 1002 ?> … … class WordCamp_Post_Types_Plugin { 973 1006 <?php while ( $sessions->have_posts() ) : $sessions->the_post(); ?> 974 1007 975 1008 <?php 976 // Things to be output, or not. 977 $session_meta = ''; 978 $speakers_avatars = ''; 979 $links = array(); 980 981 // Fetch speakers associated with this session. 982 $speakers = array(); 983 $speakers_ids = array_map( 'absint', (array) get_post_meta( get_the_ID(), '_wcpt_speaker_id' ) ); 984 if ( ! empty( $speakers_ids ) ) { 985 $speakers = get_posts( array( 986 'post_type' => 'wcb_speaker', 987 'posts_per_page' => -1, 988 'post__in' => $speakers_ids, 989 ) ); 990 } 1009 // Things to be output, or not. 1010 $session_meta = ''; 1011 $speakers_avatars = ''; 1012 $links = array(); 991 1013 992 // Should we add avatars? 993 if ( $attr['show_avatars'] ) { 994 foreach ( $speakers as $speaker ) { 995 $speakers_avatars .= get_avatar( get_post_meta( $speaker->ID, '_wcb_speaker_email', true ), absint( $attr['avatar_size'] ) ); 996 } 997 } 1014 // Fetch speakers associated with this session. 1015 $speakers = array(); 1016 $speakers_ids = array_map( 'absint', (array) get_post_meta( get_the_ID(), '_wcpt_speaker_id' ) ); 1017 if ( ! empty( $speakers_ids ) ) { 1018 $speakers = get_posts( array( 1019 'post_type' => 'wcb_speaker', 1020 'posts_per_page' => -1, 1021 'post__in' => $speakers_ids, 1022 ) ); 1023 } 998 1024 999 // Should we output meta? 1000 if ( $attr['show_meta'] ) { 1001 $speaker_permalink = ''; 1002 $speakers_names = array(); 1003 $tracks_names = array(); 1025 // Should we add avatars? 1026 if ( $attr['show_avatars'] ) { 1027 foreach ( $speakers as $speaker ) { 1028 $speakers_avatars .= get_avatar( get_post_meta( $speaker->ID, '_wcb_speaker_email', true ), absint( $attr['avatar_size'] ) ); 1029 } 1030 } 1004 1031 1005 foreach ( $speakers as $speaker ) { 1006 $speaker_name = apply_filters( 'the_title', $speaker->post_title ); 1032 // Should we output meta? 1033 if ( $attr['show_meta'] ) { 1034 $speaker_permalink = ''; 1035 $speakers_names = array(); 1036 $tracks_names = array(); 1037 1038 foreach ( $speakers as $speaker ) { 1039 $speaker_name = apply_filters( 'the_title', $speaker->post_title ); 1040 1041 if ( 'anchor' == $attr['speaker_link'] ) // speakers/#wcorg-speaker-slug 1042 { 1043 $speaker_permalink = $this->get_wcpt_anchor_permalink( $speaker->ID ); 1044 } elseif ( 'wporg' == $attr['speaker_link'] ) // profiles.wordpress.org/user 1045 { 1046 $speaker_permalink = $this->get_speaker_wporg_permalink( $speaker->ID ); 1047 } elseif ( 'permalink' == $attr['speaker_link'] ) // year.city.wordcamp.org/speakers/slug 1048 { 1049 $speaker_permalink = get_permalink( $speaker->ID ); 1050 } 1007 1051 1008 if ( 'anchor' == $attr['speaker_link'] ) // speakers/#wcorg-speaker-slug 1009 $speaker_permalink = $this->get_wcpt_anchor_permalink( $speaker->ID ); 1010 elseif ( 'wporg' == $attr['speaker_link'] ) // profiles.wordpress.org/user 1011 $speaker_permalink = $this->get_speaker_wporg_permalink( $speaker->ID ); 1012 elseif ( 'permalink' == $attr['speaker_link'] ) // year.city.wordcamp.org/speakers/slug 1013 $speaker_permalink = get_permalink( $speaker->ID ); 1052 if ( ! empty( $speaker_permalink ) ) { 1053 $speaker_name = sprintf( '<a href="%s">%s</a>', esc_url( $speaker_permalink ), esc_html( $speaker_name ) ); 1054 } 1014 1055 1015 if ( ! empty( $speaker_permalink ) )1016 $speaker_name = sprintf( '<a href="%s">%s</a>', esc_url( $speaker_permalink ), esc_html( $speaker_name ) );1056 $speakers_names[] = $speaker_name; 1057 } 1017 1058 1018 $speakers_names[] = $speaker_name; 1059 $tracks = get_the_terms( get_the_ID(), 'wcb_track' ); 1060 if ( is_array( $tracks ) ) { 1061 foreach ( $tracks as $track ) { 1062 $tracks_names[] = apply_filters( 'the_title', $track->name ); 1019 1063 } 1020 1021 $tracks = get_the_terms( get_the_ID(), 'wcb_track' );1022 if ( is_array( $tracks ) )1023 foreach ( $tracks as $track )1024 $tracks_names[] = apply_filters( 'the_title', $track->name );1025 1026 // Add speakers and tracks to session meta.1027 if ( ! empty( $speakers_names ) && ! empty( $tracks_names ) )1028 $session_meta .= sprintf( __( 'Presented by %1$s in %2$s.', 'wordcamporg' ), implode( ', ', $speakers_names ), implode( ', ', $tracks_names ) );1029 elseif ( ! empty( $speakers_names ) )1030 $session_meta .= sprintf( __( 'Presented by %s.', 'wordcamporg' ), implode( ', ', $speakers_names ) );1031 elseif ( ! empty( $tracks_names ) )1032 $session_meta .= sprintf( __( 'Presented in %s.', 'wordcamporg' ), implode( ', ', $tracks_names ) );1033 1034 if ( ! empty( $session_meta ) )1035 $session_meta = sprintf( '<p class="wcpt-session-meta">%s</p>', $session_meta );1036 1064 } 1037 1065 1038 // Gather data for list of links 1039 if ( $url = get_post_meta( $post->ID, '_wcpt_session_slides', true ) ) { 1040 $links['slides'] = array( 1041 'url' => $url, 1042 'label' => __( 'Slides', 'wordcamporg' ), 1043 ); 1066 // Add speakers and tracks to session meta. 1067 if ( ! empty( $speakers_names ) && ! empty( $tracks_names ) ) { 1068 $session_meta .= sprintf( __( 'Presented by %1$s in %2$s.', 'wordcamporg' ), implode( ', ', $speakers_names ), implode( ', ', $tracks_names ) ); 1069 } elseif ( ! empty( $speakers_names ) ) { 1070 $session_meta .= sprintf( __( 'Presented by %s.', 'wordcamporg' ), implode( ', ', $speakers_names ) ); 1071 } elseif ( ! empty( $tracks_names ) ) { 1072 $session_meta .= sprintf( __( 'Presented in %s.', 'wordcamporg' ), implode( ', ', $tracks_names ) ); 1044 1073 } 1045 1074 1046 if ( $url = get_post_meta( $post->ID, '_wcpt_session_video', true ) ) { 1047 $links['video'] = array( 1048 'url' => $url, 1049 'label' => __( 'Video', 'wordcamporg' ), 1050 ); 1075 if ( ! empty( $session_meta ) ) { 1076 $session_meta = sprintf( '<p class="wcpt-session-meta">%s</p>', $session_meta ); 1051 1077 } 1078 } 1079 1080 // Gather data for list of links 1081 if ( $url = get_post_meta( $post->ID, '_wcpt_session_slides', true ) ) { 1082 $links['slides'] = array( 1083 'url' => $url, 1084 'label' => __( 'Slides', 'wordcamporg' ), 1085 ); 1086 } 1087 1088 if ( $url = get_post_meta( $post->ID, '_wcpt_session_video', true ) ) { 1089 $links['video'] = array( 1090 'url' => $url, 1091 'label' => __( 'Video', 'wordcamporg' ), 1092 ); 1093 } 1052 1094 1053 1095 ?> 1054 1096 1055 <div id="wcorg-session-<?php the_ID(); ?>" class="wcorg-session" 1097 <div id="wcorg-session-<?php the_ID(); ?>" class="wcorg-session"> 1056 1098 <h2><?php the_title(); ?></h2> 1057 1099 <div class="wcorg-session-description"> 1058 1100 <?php the_post_thumbnail(); ?> … … class WordCamp_Post_Types_Plugin { 1062 1104 1063 1105 <?php if ( $links ) : ?> 1064 1106 <ul class="wcorg-session-links"> 1065 <?php foreach ( $links as $link ) : ?>1107 <?php foreach ( $links as $link ) : ?> 1066 1108 <li> 1067 1109 <a href="<?php echo esc_url( $link['url'] ); ?>"> 1068 1110 <?php echo esc_html( $link['label'] ); ?> … … class WordCamp_Post_Types_Plugin { 1083 1125 wp_reset_postdata(); 1084 1126 $content = ob_get_contents(); 1085 1127 ob_end_clean(); 1128 1086 1129 return $content; 1087 1130 } 1088 1131 … … class WordCamp_Post_Types_Plugin { 1093 1136 global $post; 1094 1137 1095 1138 $attr = shortcode_atts( array( 1096 'link' => 'none' 1139 'link' => 'none', 1097 1140 ), $attr ); 1098 1141 1099 1142 $attr['link'] = strtolower( $attr['link'] ); … … class WordCamp_Post_Types_Plugin { 1103 1146 ?> 1104 1147 1105 1148 <div class="wcorg-sponsors"> 1106 <?php foreach ( $terms as $term ) : ?>1107 <?php1149 <?php foreach ( $terms as $term ) : ?> 1150 <?php 1108 1151 $sponsors = new WP_Query( array( 1109 1152 'post_type' => 'wcb_sponsor', 1110 1153 'order' => 'ASC', … … class WordCamp_Post_Types_Plugin { 1113 1156 'term' => $term->slug, 1114 1157 ) ); 1115 1158 1116 if ( ! $sponsors->have_posts() ) 1159 if ( ! $sponsors->have_posts() ) { 1117 1160 continue; 1118 ?> 1161 } 1162 ?> 1119 1163 1120 <div class="wcorg-sponsor-level-<?php echo sanitize_html_class( $term->slug ); ?>">1121 <h2><?php echo esc_html( $term->name ); ?></h2>1164 <div class="wcorg-sponsor-level-<?php echo sanitize_html_class( $term->slug ); ?>"> 1165 <h2><?php echo esc_html( $term->name ); ?></h2> 1122 1166 1123 <?php while ( $sponsors->have_posts() ) : $sponsors->the_post(); ?>1124 <?php $website = get_post_meta( get_the_ID(), '_wcpt_sponsor_website', true ); ?>1167 <?php while ( $sponsors->have_posts() ) : $sponsors->the_post(); ?> 1168 <?php $website = get_post_meta( get_the_ID(), '_wcpt_sponsor_website', true ); ?> 1125 1169 1126 <div id="wcorg-sponsor-<?php the_ID(); ?>" class="wcorg-sponsor">1127 <?php if ( 'website' == $attr['link'] && $website ) : ?>1128 <h3><a href="<?php echo esc_attr( esc_url( $website ) ); ?>"><?php the_title(); ?></a></h3>1129 <?php else : ?>1130 <h3><?php the_title(); ?></h3>1131 <?php endif; ?>1170 <div id="wcorg-sponsor-<?php the_ID(); ?>" class="wcorg-sponsor"> 1171 <?php if ( 'website' == $attr['link'] && $website ) : ?> 1172 <h3><a href="<?php echo esc_attr( esc_url( $website ) ); ?>"><?php the_title(); ?></a></h3> 1173 <?php else : ?> 1174 <h3><?php the_title(); ?></h3> 1175 <?php endif; ?> 1132 1176 1133 <div class="wcorg-sponsor-description">1134 <?php if ( 'website' == $attr['link'] && $website ) : ?>1135 <a href="<?php echo esc_attr( esc_url( $website ) ); ?>">1136 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x' ); ?>1137 </a>1138 <?php else : ?>1139 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x' ); ?>1140 <?php endif; ?>1177 <div class="wcorg-sponsor-description"> 1178 <?php if ( 'website' == $attr['link'] && $website ) : ?> 1179 <a href="<?php echo esc_attr( esc_url( $website ) ); ?>"> 1180 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x' ); ?> 1181 </a> 1182 <?php else : ?> 1183 <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x' ); ?> 1184 <?php endif; ?> 1141 1185 1142 <?php the_content(); ?>1143 </div>1144 </div><!-- #sponsor -->1145 <?php endwhile; ?>1186 <?php the_content(); ?> 1187 </div> 1188 </div><!-- #sponsor --> 1189 <?php endwhile; ?> 1146 1190 1147 </div><!-- .wcorg-sponsor-level -->1191 </div><!-- .wcorg-sponsor-level --> 1148 1192 1149 <?php endforeach; ?>1193 <?php endforeach; ?> 1150 1194 </div><!-- .wcorg-sponsors --> 1151 1195 <?php 1152 1196 1153 1197 wp_reset_postdata(); 1154 1198 $content = ob_get_contents(); 1155 1199 ob_end_clean(); 1200 1156 1201 return $content; 1157 1202 } 1158 1203 … … class WordCamp_Post_Types_Plugin { 1187 1232 global $post; 1188 1233 $enabled_site_ids = apply_filters( 'wcpt_speaker_post_avatar_enabled_site_ids', array( 364 ) ); // 2014.sf 1189 1234 1190 if ( ! $this->is_single_cpt_post( 'wcb_speaker' ) ) {1235 if ( ! $this->is_single_cpt_post( 'wcb_speaker' ) ) { 1191 1236 return $content; 1192 1237 } 1193 1238 … … class WordCamp_Post_Types_Plugin { 1197 1242 } 1198 1243 1199 1244 $avatar = get_avatar( get_post_meta( $post->ID, '_wcb_speaker_email', true ) ); 1245 1200 1246 return '<div class="speaker-avatar">' . $avatar . '</div>' . $content; 1201 1247 } 1202 1248 … … class WordCamp_Post_Types_Plugin { 1215 1261 global $post; 1216 1262 $enabled_site_ids = apply_filters( 'wcpt_session_post_speaker_info_enabled_site_ids', array( 364 ) ); // 2014.sf 1217 1263 1218 if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) {1264 if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) { 1219 1265 return $content; 1220 1266 } 1221 1267 … … class WordCamp_Post_Types_Plugin { 1300 1346 return $content; 1301 1347 } 1302 1348 1303 $session_slides_html 1349 $session_slides_html = '<div class="session-video">'; 1304 1350 $session_slides_html .= sprintf( __( '<a href="%s" target="_blank">View Session Slides</a>', 'wordcamporg' ), esc_url( $session_slides ) ); 1305 1351 $session_slides_html .= '</div>'; 1306 1352 … … class WordCamp_Post_Types_Plugin { 1341 1387 return $content; 1342 1388 } 1343 1389 1344 $session_video_html 1390 $session_video_html = '<div class="session-video">'; 1345 1391 $session_video_html .= sprintf( __( '<a href="%s" target="_blank">View Session Video</a>', 'wordcamporg' ), esc_url( $session_video ) ); 1346 1392 $session_video_html .= '</div>'; 1347 1393 … … class WordCamp_Post_Types_Plugin { 1363 1409 global $post; 1364 1410 $enabled_site_ids = apply_filters( 'wcpt_speaker_post_session_info_enabled_site_ids', array( 364 ) ); // 2014.sf 1365 1411 1366 if ( ! $this->is_single_cpt_post( 'wcb_speaker' ) ) {1412 if ( ! $this->is_single_cpt_post( 'wcb_speaker' ) ) { 1367 1413 return $content; 1368 1414 } 1369 1415 … … class WordCamp_Post_Types_Plugin { 1412 1458 * Fired during add_meta_boxes, adds extra meta boxes to our custom post types. 1413 1459 */ 1414 1460 function add_meta_boxes() { 1415 add_meta_box( 'speaker-info', __( 'Speaker Info', 'wordcamporg' ), array( $this, 'metabox_speaker_info' ), 'wcb_speaker','side' );1416 add_meta_box( 'organizer-info', __( 'Organizer Info', 'wordcamporg' 1417 add_meta_box( 'speakers-list', __( 'Speakers', 'wordcamporg' ), array( $this, 'metabox_speakers_list' ), 'wcb_session','side' );1418 add_meta_box( 'session-info', __( 'Session Info', 'wordcamporg' ), array( $this, 'metabox_session_info' ), 'wcb_session','normal' );1419 add_meta_box( 'sponsor-info', __( 'Sponsor Info', 'wordcamporg' ), array( $this, 'metabox_sponsor_info' ), 'wcb_sponsor','normal' );1420 add_meta_box( 'invoice-sponsor', __( 'Invoice Sponsor', 'wordcamporg' ), array( $this, 'metabox_invoice_sponsor' ), 'wcb_sponsor', 'side' 1461 add_meta_box( 'speaker-info', __( 'Speaker Info', 'wordcamporg' ), array( $this, 'metabox_speaker_info' ), 'wcb_speaker', 'side' ); 1462 add_meta_box( 'organizer-info', __( 'Organizer Info', 'wordcamporg' ), array( $this, 'metabox_organizer_info' ), 'wcb_organizer', 'side' ); 1463 add_meta_box( 'speakers-list', __( 'Speakers', 'wordcamporg' ), array( $this, 'metabox_speakers_list' ), 'wcb_session', 'side' ); 1464 add_meta_box( 'session-info', __( 'Session Info', 'wordcamporg' ), array( $this, 'metabox_session_info' ), 'wcb_session', 'normal' ); 1465 add_meta_box( 'sponsor-info', __( 'Sponsor Info', 'wordcamporg' ), array( $this, 'metabox_sponsor_info' ), 'wcb_sponsor', 'normal' ); 1466 add_meta_box( 'invoice-sponsor', __( 'Invoice Sponsor', 'wordcamporg' ), array( $this, 'metabox_invoice_sponsor' ), 'wcb_sponsor', 'side' ); 1421 1467 } 1422 1468 1423 1469 /** … … class WordCamp_Post_Types_Plugin { 1428 1474 $email = get_post_meta( $post->ID, '_wcb_speaker_email', true ); 1429 1475 1430 1476 $wporg_username = ''; 1431 $user_id 1432 $wporg_user 1477 $user_id = get_post_meta( $post->ID, '_wcpt_user_id', true ); 1478 $wporg_user = get_user_by( 'id', $user_id ); 1433 1479 1434 if ( $wporg_user ) 1480 if ( $wporg_user ) { 1435 1481 $wporg_username = $wporg_user->user_nicename; 1482 } 1436 1483 ?> 1437 1484 1438 1485 <?php wp_nonce_field( 'edit-speaker-info', 'wcpt-meta-speaker-info' ); ?> 1439 1486 1440 1487 <p> 1441 1488 <label for="wcpt-gravatar-email"><?php _e( 'Gravatar Email:', 'wordcamporg' ); ?></label> 1442 <input type="text" class="widefat" id="wcpt-gravatar-email" name="wcpt-gravatar-email" value="<?php echo esc_attr( $email ); ?>" 1489 <input type="text" class="widefat" id="wcpt-gravatar-email" name="wcpt-gravatar-email" value="<?php echo esc_attr( $email ); ?>"/> 1443 1490 </p> 1444 1491 1445 1492 <p> 1446 1493 <label for="wcpt-wporg-username"><?php _e( 'WordPress.org Username:', 'wordcamporg' ); ?></label> 1447 <input type="text" class="widefat" id="wcpt-wporg-username" name="wcpt-wporg-username" value="<?php echo esc_attr( $wporg_username ); ?>" 1494 <input type="text" class="widefat" id="wcpt-wporg-username" name="wcpt-wporg-username" value="<?php echo esc_attr( $wporg_username ); ?>"/> 1448 1495 </p> 1449 1496 1450 1497 <?php … … class WordCamp_Post_Types_Plugin { 1457 1504 global $post; 1458 1505 1459 1506 $wporg_username = ''; 1460 $user_id 1461 $wporg_user 1507 $user_id = get_post_meta( $post->ID, '_wcpt_user_id', true ); 1508 $wporg_user = get_user_by( 'id', $user_id ); 1462 1509 1463 if ( $wporg_user ) 1510 if ( $wporg_user ) { 1464 1511 $wporg_username = $wporg_user->user_nicename; 1512 } 1465 1513 ?> 1466 1514 1467 1515 <?php wp_nonce_field( 'edit-organizer-info', 'wcpt-meta-organizer-info' ); ?> 1468 1516 1469 1517 <p> 1470 1518 <label for="wcpt-wporg-username"><?php _e( 'WordPress.org Username:', 'wordcamporg' ); ?></label> 1471 <input type="text" class="widefat" id="wcpt-wporg-username" name="wcpt-wporg-username" value="<?php echo esc_attr( $wporg_username ); ?>" 1519 <input type="text" class="widefat" id="wcpt-wporg-username" name="wcpt-wporg-username" value="<?php echo esc_attr( $wporg_username ); ?>"/> 1472 1520 </p> 1473 1521 1474 1522 <?php … … class WordCamp_Post_Types_Plugin { 1482 1530 $speakers = get_post_meta( $post->ID, '_wcb_session_speakers', true ); 1483 1531 wp_enqueue_script( 'jquery-ui-autocomplete' ); 1484 1532 1485 $speakers_names 1533 $speakers_names = array(); 1486 1534 $speakers_objects = get_posts( array( 1487 1535 'post_type' => 'wcb_speaker', 1488 1536 'post_status' => 'publish', … … class WordCamp_Post_Types_Plugin { 1490 1538 ) ); 1491 1539 1492 1540 // We'll use these in js. 1493 foreach ( $speakers_objects as $speaker_object ) 1541 foreach ( $speakers_objects as $speaker_object ) { 1494 1542 $speakers_names[] = $speaker_object->post_title; 1543 } 1495 1544 $speakers_names_first = array_pop( $speakers_names ); 1496 1545 ?> 1497 1546 … … class WordCamp_Post_Types_Plugin { 1501 1550 <p class="description"><?php _e( 'A speaker entry must exist first. Separate multiple speakers with commas.', 'wordcamporg' ); ?></p> 1502 1551 1503 1552 <script> 1504 jQuery(document).ready( function($) { 1505 var availableSpeakers = [ <?php 1506 foreach ( $speakers_names as $name ) { printf( "'%s', ", esc_js( $name ) ); } 1507 printf( "'%s'", esc_js( $speakers_names_first ) ); // avoid the trailing comma 1508 ?> ]; 1509 function split( val ) { 1510 return val.split( /,\s*/ ); 1511 } 1512 function extractLast( term ) { 1513 return split( term ).pop(); 1514 } 1515 $( '#wcpt-speakers-list' ) 1516 .bind( 'keydown', function( event ) { 1517 if ( event.keyCode == $.ui.keyCode.TAB && 1518 $( this ).data( 'autocomplete' ).menu.active ) { 1519 event.preventDefault(); 1553 jQuery( document ).ready( function( $ ) { 1554 var availableSpeakers = [ <?php 1555 foreach ( $speakers_names as $name ) { 1556 printf( "'%s', ", esc_js( $name ) ); 1520 1557 } 1521 }) 1522 .autocomplete({ 1523 minLength: 0, 1524 source: function( request, response ) { 1525 response( $.ui.autocomplete.filter( 1526 availableSpeakers, extractLast( request.term ) ) ) 1527 }, 1528 focus: function() { 1529 return false; 1530 }, 1531 select: function( event, ui ) { 1532 var terms = split( this.value ); 1533 terms.pop(); 1534 terms.push( ui.item.value ); 1535 terms.push( '' ); 1536 this.value = terms.join( ', ' ); 1537 $(this).focus(); 1538 return false; 1539 }, 1540 open: function() { $(this).addClass('open'); }, 1541 close: function() { $(this).removeClass('open'); } 1542 }); 1543 }); 1558 printf( "'%s'", esc_js( $speakers_names_first ) ); // avoid the trailing comma 1559 ?> ]; 1560 1561 function split( val ) { 1562 return val.split( /,\s*/ ); 1563 } 1564 1565 function extractLast( term ) { 1566 return split( term ).pop(); 1567 } 1568 1569 $( '#wcpt-speakers-list' ) 1570 .bind( 'keydown', function( event ) { 1571 if ( event.keyCode == $.ui.keyCode.TAB && 1572 $( this ).data( 'autocomplete' ).menu.active ) { 1573 event.preventDefault(); 1574 } 1575 } ) 1576 .autocomplete( { 1577 minLength : 0, 1578 source : function( request, response ) { 1579 response( $.ui.autocomplete.filter( 1580 availableSpeakers, extractLast( request.term ) ) ) 1581 }, 1582 focus : function() { 1583 return false; 1584 }, 1585 select : function( event, ui ) { 1586 var terms = split( this.value ); 1587 terms.pop(); 1588 terms.push( ui.item.value ); 1589 terms.push( '' ); 1590 this.value = terms.join( ', ' ); 1591 $( this ).focus(); 1592 return false; 1593 }, 1594 open : function() { $( this ).addClass( 'open' ); }, 1595 close : function() { $( this ).removeClass( 'open' ); } 1596 } ); 1597 } ); 1544 1598 </script> 1545 1599 1546 1600 <?php 1547 1601 } 1548 1602 1549 1603 function metabox_session_info() { 1550 $post 1551 $session_time 1552 $session_date 1553 $session_hours = ( $session_time ) ? date( 'g', $session_time ): date( 'g' );1554 $session_minutes = ( $session_time ) ? date( 'i', $session_time ): '00';1555 $session_meridiem = ( $session_time ) ? date( 'a', $session_time ) 1556 $session_type 1557 $session_slides 1558 $session_video = get_post_meta( $post->ID, '_wcpt_session_video',true );1604 $post = get_post(); 1605 $session_time = absint( get_post_meta( $post->ID, '_wcpt_session_time', true ) ); 1606 $session_date = ( $session_time ) ? date( 'Y-m-d', $session_time ) : date( 'Y-m-d' ); 1607 $session_hours = ( $session_time ) ? date( 'g', $session_time ) : date( 'g' ); 1608 $session_minutes = ( $session_time ) ? date( 'i', $session_time ) : '00'; 1609 $session_meridiem = ( $session_time ) ? date( 'a', $session_time ) : 'am'; 1610 $session_type = get_post_meta( $post->ID, '_wcpt_session_type', true ); 1611 $session_slides = get_post_meta( $post->ID, '_wcpt_session_slides', true ); 1612 $session_video = get_post_meta( $post->ID, '_wcpt_session_video', true ); 1559 1613 ?> 1560 1614 1561 1615 <?php wp_nonce_field( 'edit-session-info', 'wcpt-meta-session-info' ); ?> 1562 1616 1563 1617 <p> 1564 1618 <label for="wcpt-session-date"><?php _e( 'Date:', 'wordcamporg' ); ?></label> 1565 <input type="text" id="wcpt-session-date" data-date="<?php echo esc_attr( $session_date ); ?>" name="wcpt-session-date" value="<?php echo esc_attr( $session_date ); ?>" /><br/>1619 <input type="text" id="wcpt-session-date" data-date="<?php echo esc_attr( $session_date ); ?>" name="wcpt-session-date" value="<?php echo esc_attr( $session_date ); ?>"/><br/> 1566 1620 <label><?php _e( 'Time:', 'wordcamporg' ); ?></label> 1567 1621 1568 1622 <select name="wcpt-session-hour" aria-label="<?php _e( 'Session Start Hour', 'wordcamporg' ); ?>"> … … class WordCamp_Post_Types_Plugin { 1597 1651 1598 1652 <p> 1599 1653 <label for="wcpt-session-slides"><?php _e( 'Slides URL:', 'wordcamporg' ); ?></label> 1600 <input type="text" class="widefat" id="wcpt-session-slides" name="wcpt-session-slides" value="<?php echo esc_url( $session_slides ); ?>" 1654 <input type="text" class="widefat" id="wcpt-session-slides" name="wcpt-session-slides" value="<?php echo esc_url( $session_slides ); ?>"/> 1601 1655 </p> 1602 1656 1603 1657 <p> 1604 1658 <label for="wcpt-session-video"><?php _e( 'WordPress.TV URL:', 'wordcamporg' ); ?></label> 1605 <input type="text" class="widefat" id="wcpt-session-video" name="wcpt-session-video" value="<?php echo esc_url( $session_video ); ?>" 1659 <input type="text" class="widefat" id="wcpt-session-video" name="wcpt-session-video" value="<?php echo esc_url( $session_video ); ?>"/> 1606 1660 </p> 1607 1661 1608 1662 <?php … … class WordCamp_Post_Types_Plugin { 1614 1668 * @param WP_Post $sponsor 1615 1669 */ 1616 1670 function metabox_sponsor_info( $sponsor ) { 1617 $company_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_company_name', true ); 1618 $website = get_post_meta( $sponsor->ID, '_wcpt_sponsor_website', true ); 1619 $first_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_first_name', true ); 1620 $last_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_last_name', true ); 1621 $email_address = get_post_meta( $sponsor->ID, '_wcpt_sponsor_email_address', true ); 1622 $phone_number = get_post_meta( $sponsor->ID, '_wcpt_sponsor_phone_number', true ); 1623 $vat_number = get_post_meta( $sponsor->ID, '_wcpt_sponsor_vat_number', true ); 1624 $twitter_handle = get_post_meta( $sponsor->ID, '_wcpt_sponsor_twitter_handle', true ); 1625 1626 $street_address1 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address1', true ); 1627 $street_address2 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address2', true ); 1628 $city = get_post_meta( $sponsor->ID, '_wcpt_sponsor_city', true ); 1629 $state = get_post_meta( $sponsor->ID, '_wcpt_sponsor_state', true ); 1630 $zip_code = get_post_meta( $sponsor->ID, '_wcpt_sponsor_zip_code', true ); 1631 $country = get_post_meta( $sponsor->ID, '_wcpt_sponsor_country', true ); 1671 $company_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_company_name', true ); 1672 $website = get_post_meta( $sponsor->ID, '_wcpt_sponsor_website', true ); 1673 $first_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_first_name', true ); 1674 $last_name = get_post_meta( $sponsor->ID, '_wcpt_sponsor_last_name', true ); 1675 $email_address = get_post_meta( $sponsor->ID, '_wcpt_sponsor_email_address', true ); 1676 $phone_number = get_post_meta( $sponsor->ID, '_wcpt_sponsor_phone_number', true ); 1677 $vat_number = get_post_meta( $sponsor->ID, '_wcpt_sponsor_vat_number', true ); 1678 $twitter_handle = get_post_meta( $sponsor->ID, '_wcpt_sponsor_twitter_handle', true ); 1679 1680 $street_address1 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address1', true ); 1681 $street_address2 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address2', true ); 1682 $city = get_post_meta( $sponsor->ID, '_wcpt_sponsor_city', true ); 1683 $state = get_post_meta( $sponsor->ID, '_wcpt_sponsor_state', true ); 1684 $zip_code = get_post_meta( $sponsor->ID, '_wcpt_sponsor_zip_code', true ); 1685 $country = get_post_meta( $sponsor->ID, '_wcpt_sponsor_country', true ); 1686 1687 if ( $state === $this->get_sponsor_info_state_default_value() ) { 1688 $state = ''; 1689 } 1632 1690 1633 1691 $available_countries = array( 'Abkhazia', 'Afghanistan', 'Aland', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Ascension', 'Ashmore and Cartier Islands', 'Australia', 'Australian Antarctic Territory', 'Austria', 'Azerbaijan', 'Bahamas, The', 'Bahrain', 'Baker Island', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Bouvet Island', 'Brazil', 'British Antarctic Territory', 'British Indian Ocean Territory', 'British Sovereign Base Areas', 'British Virgin Islands', 'Brunei', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', 'Central African Republic', 'Chad', 'Chile', "China, People's Republic of", 'China, Republic of (Taiwan)', 'Christmas Island', 'Clipperton Island', 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Congo, (Congo Brazzaville)', 'Congo, (Congo Kinshasa)', 'Cook Islands', 'Coral Sea Islands', 'Costa Rica', "Cote d'Ivoire (Ivory Coast)", 'Croatia', 'Cuba', 'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Falkland Islands (Islas Malvinas)', 'Faroe Islands', 'Fiji', 'Finland', 'France', 'French Guiana', 'French Polynesia', 'French Southern and Antarctic Lands', 'Gabon', 'Gambia, The', 'Georgia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Greenland', 'Grenada', 'Guadeloupe', 'Guam', 'Guatemala', 'Guernsey', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Heard Island and McDonald Islands', 'Honduras', 'Hong Kong', 'Howland Island', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Isle of Man', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jarvis Island', 'Jersey', 'Johnston Atoll', 'Jordan', 'Kazakhstan', 'Kenya', 'Kingman Reef', 'Kiribati', 'Korea, North', 'Korea, South', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macau', 'Macedonia', 'Madagascar', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Martinique', 'Mauritania', 'Mauritius', 'Mayotte', 'Mexico', 'Micronesia', 'Midway Islands', 'Moldova', 'Monaco', 'Mongolia', 'Montenegro', 'Montserrat', 'Morocco', 'Mozambique', 'Myanmar (Burma)', 'Nagorno-Karabakh', 'Namibia', 'Nauru', 'Navassa Island', 'Nepal', 'Netherlands', 'Netherlands Antilles', 'New Caledonia', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Niue', 'Norfolk Island', 'Northern Cyprus', 'Northern Mariana Islands', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Palmyra Atoll', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Peter I Island', 'Philippines', 'Pitcairn Islands', 'Poland', 'Portugal', 'Pridnestrovie (Transnistria)', 'Puerto Rico', 'Qatar', 'Queen Maud Land', 'Reunion', 'Romania', 'Ross Dependency', 'Russia', 'Rwanda', 'Saint Barthelemy', 'Saint Helena', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Martin', 'Saint Pierre and Miquelon', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'Somaliland', 'South Africa', 'South Georgia & South Sandwich Islands', 'South Ossetia', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Svalbard', 'Swaziland', 'Sweden', 'Switzerland', 'Syria', 'Tajikistan', 'Tanzania', 'Thailand', 'Timor-Leste (East Timor)', 'Togo', 'Tokelau', 'Tonga', 'Trinidad and Tobago', 'Tristan da Cunha', 'Tunisia', 'Turkey', 'Turkmenistan', 'Turks and Caicos Islands', 'Tuvalu', 'U.S. Virgin Islands', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Vatican City', 'Venezuela', 'Vietnam', 'Wake Island', 'Wallis and Futuna', 'Yemen', 'Zambia', 'Zimbabwe' ); 1634 1692 // todo use WordCamp_Budgets::get_valid_countries_iso3166() instead. need to switch multi-event sponsors at same time. … … class WordCamp_Post_Types_Plugin { 1639 1697 } 1640 1698 1641 1699 /** 1700 * Returns the default value for the state input when it's empty 1701 * 1702 * @return string 1703 */ 1704 protected function get_sponsor_info_state_default_value() { 1705 return 'Not Applicable'; 1706 } 1707 1708 /** 1642 1709 * Render the Invoice Sponsor metabox view 1643 1710 * 1644 1711 * @param WP_Post $sponsor … … class WordCamp_Post_Types_Plugin { 1649 1716 $existing_invoices = get_posts( array( 1650 1717 'post_type' => \WordCamp\Budgets\Sponsor_Invoices\POST_TYPE, 1651 1718 'post_status' => 'any', 1652 'posts_per_page' => - 1719 'posts_per_page' => -1, 1653 1720 1654 1721 'meta_query' => array( 1655 1722 array( … … class WordCamp_Post_Types_Plugin { 1681 1748 * Fired when a post is saved, makes sure additional metadata is also updated. 1682 1749 */ 1683 1750 function save_post_speaker( $post_id, $post ) { 1684 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_speaker' || ! current_user_can( 'edit_post', $post_id ) ) 1751 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_speaker' || ! current_user_can( 'edit_post', $post_id ) ) { 1685 1752 return; 1753 } 1686 1754 1687 1755 if ( isset( $_POST['wcpt-meta-speaker-info'] ) && wp_verify_nonce( $_POST['wcpt-meta-speaker-info'], 'edit-speaker-info' ) ) { 1688 $email 1756 $email = sanitize_text_field( $_POST['wcpt-gravatar-email'] ); 1689 1757 $wporg_username = sanitize_text_field( $_POST['wcpt-wporg-username'] ); 1690 $wporg_user 1758 $wporg_user = wcorg_get_user_by_canonical_names( $wporg_username ); 1691 1759 1692 if ( empty( $email ) ) 1760 if ( empty( $email ) ) { 1693 1761 delete_post_meta( $post_id, '_wcb_speaker_email' ); 1694 elseif ( $email && is_email( $email ) )1762 } elseif ( $email && is_email( $email ) ) { 1695 1763 update_post_meta( $post_id, '_wcb_speaker_email', $email ); 1764 } 1696 1765 1697 if ( ! $wporg_user ) 1766 if ( ! $wporg_user ) { 1698 1767 delete_post_meta( $post_id, '_wcpt_user_id' ); 1699 else1768 } else { 1700 1769 update_post_meta( $post_id, '_wcpt_user_id', $wporg_user->ID ); 1770 } 1701 1771 } 1702 1772 } 1703 1773 … … class WordCamp_Post_Types_Plugin { 1705 1775 * When an Organizer post is saved, update some meta data. 1706 1776 */ 1707 1777 function save_post_organizer( $post_id, $post ) { 1708 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_organizer' || ! current_user_can( 'edit_post', $post_id ) ) 1778 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_organizer' || ! current_user_can( 'edit_post', $post_id ) ) { 1709 1779 return; 1780 } 1710 1781 1711 1782 if ( isset( $_POST['wcpt-meta-organizer-info'] ) && wp_verify_nonce( $_POST['wcpt-meta-organizer-info'], 'edit-organizer-info' ) ) { 1712 1783 $wporg_username = sanitize_text_field( $_POST['wcpt-wporg-username'] ); 1713 1784 $wporg_user = wcorg_get_user_by_canonical_names( $wporg_username ); 1714 1785 1715 if ( ! $wporg_user ) 1786 if ( ! $wporg_user ) { 1716 1787 delete_post_meta( $post_id, '_wcpt_user_id' ); 1717 else1788 } else { 1718 1789 update_post_meta( $post_id, '_wcpt_user_id', $wporg_user->ID ); 1790 } 1719 1791 } 1720 1792 } 1721 1793 … … class WordCamp_Post_Types_Plugin { 1723 1795 * Fired when a post is saved, updates additional sessions metadada. 1724 1796 */ 1725 1797 function save_post_session( $post_id, $post ) { 1726 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_session' ) 1798 if ( wp_is_post_revision( $post_id ) || $post->post_type != 'wcb_session' ) { 1727 1799 return; 1800 } 1728 1801 1729 1802 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 ) ) { 1730 1803 … … class WordCamp_Post_Types_Plugin { 1746 1819 1747 1820 // Update session type 1748 1821 $session_type = sanitize_text_field( $_POST['wcpt-session-type'] ); 1749 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) 1822 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) { 1750 1823 $session_type = 'session'; 1824 } 1751 1825 1752 1826 update_post_meta( $post_id, '_wcpt_session_type', $session_type ); 1753 1827 … … class WordCamp_Post_Types_Plugin { 1765 1839 $speakers_list = get_post_meta( $post_id, '_wcb_session_speakers', true ); 1766 1840 $speakers_list = explode( ',', $speakers_list ); 1767 1841 1768 if ( ! is_array( $speakers_list ) ) 1842 if ( ! is_array( $speakers_list ) ) { 1769 1843 $speakers_list = array(); 1844 } 1770 1845 1771 1846 $speaker_ids = array(); 1772 $speakers 1847 $speakers = array_unique( array_map( 'trim', $speakers_list ) ); 1773 1848 1774 1849 foreach ( $speakers as $speaker_name ) { 1775 if ( empty( $speaker_name ) ) 1850 if ( empty( $speaker_name ) ) { 1776 1851 continue; 1852 } 1777 1853 1778 1854 /* 1779 1855 * Look for speakers by their names. … … class WordCamp_Post_Types_Plugin { 1785 1861 * here to make it more forgiving. 1786 1862 */ 1787 1863 $speaker = get_page_by_title( $speaker_name, OBJECT, 'wcb_speaker' ); 1788 if ( $speaker ) 1864 if ( $speaker ) { 1789 1865 $speaker_ids[] = $speaker->ID; 1866 } 1790 1867 } 1791 1868 1792 1869 // Add speaker IDs to post meta. 1793 1870 $speaker_ids = array_unique( $speaker_ids ); 1794 1871 delete_post_meta( $post_id, '_wcpt_speaker_id' ); 1795 foreach ( $speaker_ids as $speaker_id ) 1872 foreach ( $speaker_ids as $speaker_id ) { 1796 1873 add_post_meta( $post_id, '_wcpt_speaker_id', $speaker_id ); 1874 } 1797 1875 1798 1876 // Set the speaker as the author of the session post, so the single 1799 1877 // view doesn't confuse users who see "posted by [organizer name]" … … class WordCamp_Post_Types_Plugin { 1802 1880 $user = get_user_by( 'id', $wporg_user_id ); 1803 1881 1804 1882 if ( $user ) { 1805 remove_action( 'save_post', array( $this, 'save_post_session' ), 10, 2 ); 1883 remove_action( 'save_post', array( $this, 'save_post_session' ), 10, 2 ); // avoid infinite recursion 1806 1884 wp_update_post( array( 1807 1885 'ID' => $post_id, 1808 'post_author' => $user->ID 1886 'post_author' => $user->ID, 1809 1887 ) ); 1810 1888 add_action( 'save_post', array( $this, 'save_post_session' ), 10, 2 ); 1811 1889 … … class WordCamp_Post_Types_Plugin { 1824 1902 1825 1903 if ( isset( $_POST['wcpt-meta-sponsor-info'] ) && wp_verify_nonce( $_POST['wcpt-meta-sponsor-info'], 'edit-sponsor-info' ) ) { 1826 1904 $text_values = array( 1827 'company_name', 1828 'street_address1', 'street_address2', 'city', 'state', 'zip_code', 'country' 1905 'company_name', 'first_name', 'last_name', 'email_address', 'phone_number', 'vat_number', 'twitter_handle', 1906 'street_address1', 'street_address2', 'city', 'state', 'zip_code', 'country', 1829 1907 ); 1830 1908 1831 1909 foreach ( $text_values as $id ) { 1832 1910 $values[ $id ] = sanitize_text_field( $_POST["_wcpt_sponsor_$id"] ); 1833 1911 } 1834 1912 1913 if ( empty( $values['state'] ) ) { 1914 $values['state'] = $this->get_sponsor_info_state_default_value(); 1915 } 1916 1835 1917 $values['website'] = esc_url_raw( $_POST['_wcpt_sponsor_website'] ); 1836 1918 // 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/ 1837 1919 1838 1920 $values['first_name'] = ucfirst( $values['first_name'] ); 1839 $values['last_name' ] = ucfirst( $values['last_name'] );1921 $values['last_name'] = ucfirst( $values['last_name'] ); 1840 1922 1841 foreach ( $values as $id => $value ) {1923 foreach ( $values as $id => $value ) { 1842 1924 if ( empty( $value ) ) { 1843 1925 delete_post_meta( $post_id, "_wcpt_sponsor_$id" ); 1844 1926 } else { … … class WordCamp_Post_Types_Plugin { 1854 1936 function register_post_types() { 1855 1937 // Speaker post type labels. 1856 1938 $labels = array( 1857 'name' 1858 'singular_name' 1859 'add_new' 1860 'add_new_item' 1861 'edit' 1862 'edit_item' 1863 'new_item' 1864 'view' 1865 'view_item' 1866 'search_items' 1867 'not_found' 1868 'not_found_in_trash' 1869 'parent_item_colon' 1939 'name' => __( 'Speakers', 'wordcamporg' ), 1940 'singular_name' => __( 'Speaker', 'wordcamporg' ), 1941 'add_new' => __( 'Add New', 'wordcamporg' ), 1942 'add_new_item' => __( 'Create New Speaker', 'wordcamporg' ), 1943 'edit' => __( 'Edit', 'wordcamporg' ), 1944 'edit_item' => __( 'Edit Speaker', 'wordcamporg' ), 1945 'new_item' => __( 'New Speaker', 'wordcamporg' ), 1946 'view' => __( 'View Speaker', 'wordcamporg' ), 1947 'view_item' => __( 'View Speaker', 'wordcamporg' ), 1948 'search_items' => __( 'Search Speakers', 'wordcamporg' ), 1949 'not_found' => __( 'No speakers found', 'wordcamporg' ), 1950 'not_found_in_trash' => __( 'No speakers found in Trash', 'wordcamporg' ), 1951 'parent_item_colon' => __( 'Parent Speaker:', 'wordcamporg' ), 1870 1952 ); 1871 1953 1872 1954 // Register speaker post type. 1873 1955 register_post_type( 'wcb_speaker', array( 1874 'labels' 1875 'rewrite' 1876 'supports' 1877 'menu_position' 1878 'public' 1879 'show_ui' 1880 'can_export' 1881 'capability_type' 1882 'hierarchical' 1883 'query_var' 1884 'menu_icon' 1885 'show_in_rest' 1886 'rest_base' 1956 'labels' => $labels, 1957 'rewrite' => array( 'slug' => 'speaker', 'with_front' => true ), 1958 'supports' => array( 'title', 'editor', 'author', 'revisions', 'comments', 'custom-fields' ), 1959 'menu_position' => 20, 1960 'public' => true, 1961 'show_ui' => true, 1962 'can_export' => true, 1963 'capability_type' => 'post', 1964 'hierarchical' => false, 1965 'query_var' => true, 1966 'menu_icon' => 'dashicons-megaphone', 1967 'show_in_rest' => true, 1968 'rest_base' => 'speakers', 1887 1969 ) ); 1888 1970 1889 1971 // Session post type labels. 1890 1972 $labels = array( 1891 'name' 1892 'singular_name' 1893 'add_new' 1894 'add_new_item' 1895 'edit' 1896 'edit_item' 1897 'new_item' 1898 'view' 1899 'view_item' 1900 'search_items' 1901 'not_found' 1902 'not_found_in_trash' 1903 'parent_item_colon' 1973 'name' => __( 'Sessions', 'wordcamporg' ), 1974 'singular_name' => __( 'Session', 'wordcamporg' ), 1975 'add_new' => __( 'Add New', 'wordcamporg' ), 1976 'add_new_item' => __( 'Create New Session', 'wordcamporg' ), 1977 'edit' => __( 'Edit', 'wordcamporg' ), 1978 'edit_item' => __( 'Edit Session', 'wordcamporg' ), 1979 'new_item' => __( 'New Session', 'wordcamporg' ), 1980 'view' => __( 'View Session', 'wordcamporg' ), 1981 'view_item' => __( 'View Session', 'wordcamporg' ), 1982 'search_items' => __( 'Search Sessions', 'wordcamporg' ), 1983 'not_found' => __( 'No sessions found', 'wordcamporg' ), 1984 'not_found_in_trash' => __( 'No sessions found in Trash', 'wordcamporg' ), 1985 'parent_item_colon' => __( 'Parent Session:', 'wordcamporg' ), 1904 1986 ); 1905 1987 1906 1988 // Register session post type. 1907 1989 register_post_type( 'wcb_session', array( 1908 'labels' 1909 'rewrite' 1910 'supports' 1911 'menu_position' 1912 'public' 1913 'show_ui' 1914 'can_export' 1915 'capability_type' 1916 'hierarchical' 1917 'query_var' 1918 'menu_icon' 1919 'show_in_rest' 1920 'rest_base' 1990 'labels' => $labels, 1991 'rewrite' => array( 'slug' => 'session', 'with_front' => false ), 1992 'supports' => array( 'title', 'editor', 'author', 'revisions', 'thumbnail', 'custom-fields' ), 1993 'menu_position' => 21, 1994 'public' => true, 1995 'show_ui' => true, 1996 'can_export' => true, 1997 'capability_type' => 'post', 1998 'hierarchical' => false, 1999 'query_var' => true, 2000 'menu_icon' => 'dashicons-schedule', 2001 'show_in_rest' => true, 2002 'rest_base' => 'sessions', 1921 2003 ) ); 1922 2004 1923 2005 // Sponsor post type labels. 1924 2006 $labels = array( 1925 'name' 1926 'singular_name' 1927 'add_new' 1928 'add_new_item' 1929 'edit' 1930 'edit_item' 1931 'new_item' 1932 'view' 1933 'view_item' 1934 'search_items' 1935 'not_found' 1936 'not_found_in_trash' 1937 'parent_item_colon' 2007 'name' => __( 'Sponsors', 'wordcamporg' ), 2008 'singular_name' => __( 'Sponsor', 'wordcamporg' ), 2009 'add_new' => __( 'Add New', 'wordcamporg' ), 2010 'add_new_item' => __( 'Create New Sponsor', 'wordcamporg' ), 2011 'edit' => __( 'Edit', 'wordcamporg' ), 2012 'edit_item' => __( 'Edit Sponsor', 'wordcamporg' ), 2013 'new_item' => __( 'New Sponsor', 'wordcamporg' ), 2014 'view' => __( 'View Sponsor', 'wordcamporg' ), 2015 'view_item' => __( 'View Sponsor', 'wordcamporg' ), 2016 'search_items' => __( 'Search Sponsors', 'wordcamporg' ), 2017 'not_found' => __( 'No sponsors found', 'wordcamporg' ), 2018 'not_found_in_trash' => __( 'No sponsors found in Trash', 'wordcamporg' ), 2019 'parent_item_colon' => __( 'Parent Sponsor:', 'wordcamporg' ), 1938 2020 ); 1939 2021 1940 2022 // Register sponsor post type. 1941 2023 register_post_type( 'wcb_sponsor', array( 1942 'labels' 1943 'rewrite' 1944 'supports' 1945 'menu_position' 1946 'public' 1947 'show_ui' 1948 'can_export' 1949 'capability_type' 1950 'hierarchical' 1951 'query_var' 1952 'menu_icon' 1953 'show_in_rest' 1954 'rest_base' 2024 'labels' => $labels, 2025 'rewrite' => array( 'slug' => 'sponsor', 'with_front' => false ), 2026 'supports' => array( 'title', 'editor', 'revisions', 'thumbnail', 'custom-fields' ), 2027 'menu_position' => 21, 2028 'public' => true, 2029 'show_ui' => true, 2030 'can_export' => true, 2031 'capability_type' => 'post', 2032 'hierarchical' => false, 2033 'query_var' => true, 2034 'menu_icon' => 'dashicons-heart', 2035 'show_in_rest' => true, 2036 'rest_base' => 'sponsors', 1955 2037 ) ); 1956 2038 1957 2039 // Organizer post type labels. 1958 2040 $labels = array( 1959 'name' 1960 'singular_name' 1961 'add_new' 1962 'add_new_item' 1963 'edit' 1964 'edit_item' 1965 'new_item' 1966 'view' 1967 'view_item' 1968 'search_items' 1969 'not_found' 1970 'not_found_in_trash' 1971 'parent_item_colon' 2041 'name' => __( 'Organizers', 'wordcamporg' ), 2042 'singular_name' => __( 'Organizer', 'wordcamporg' ), 2043 'add_new' => __( 'Add New', 'wordcamporg' ), 2044 'add_new_item' => __( 'Create New Organizer', 'wordcamporg' ), 2045 'edit' => __( 'Edit', 'wordcamporg' ), 2046 'edit_item' => __( 'Edit Organizer', 'wordcamporg' ), 2047 'new_item' => __( 'New Organizer', 'wordcamporg' ), 2048 'view' => __( 'View Organizer', 'wordcamporg' ), 2049 'view_item' => __( 'View Organizer', 'wordcamporg' ), 2050 'search_items' => __( 'Search Organizers', 'wordcamporg' ), 2051 'not_found' => __( 'No organizers found', 'wordcamporg' ), 2052 'not_found_in_trash' => __( 'No organizers found in Trash', 'wordcamporg' ), 2053 'parent_item_colon' => __( 'Parent Organizer:', 'wordcamporg' ), 1972 2054 ); 1973 2055 1974 2056 // Register organizer post type. 1975 2057 register_post_type( 'wcb_organizer', array( 1976 'labels' 1977 'rewrite' 1978 'supports' 1979 'menu_position' 1980 'public' 1981 1982 'show_ui' 1983 'can_export' 1984 'capability_type' 1985 'hierarchical' 1986 'query_var' 1987 'menu_icon' 2058 'labels' => $labels, 2059 'rewrite' => array( 'slug' => 'organizer', 'with_front' => false ), 2060 'supports' => array( 'title', 'editor', 'revisions' ), 2061 'menu_position' => 22, 2062 'public' => false, 2063 // todo public or publicly_queryable = true, so consistent with others? at the very least set show_in_json = true 2064 'show_ui' => true, 2065 'can_export' => true, 2066 'capability_type' => 'post', 2067 'hierarchical' => false, 2068 'query_var' => true, 2069 'menu_icon' => 'dashicons-groups', 1988 2070 ) ); 1989 2071 } 1990 2072 … … class WordCamp_Post_Types_Plugin { 1994 2076 function register_taxonomies() { 1995 2077 // Labels for tracks. 1996 2078 $labels = array( 1997 'name' 1998 'singular_name' 1999 'search_items' 2000 'popular_items' => __( 'Popular Tracks','wordcamporg' ),2001 'all_items' 2002 'edit_item' 2003 'update_item' 2004 'add_new_item' 2005 'new_item_name' 2079 'name' => __( 'Tracks', 'wordcamporg' ), 2080 'singular_name' => __( 'Track', 'wordcamporg' ), 2081 'search_items' => __( 'Search Tracks', 'wordcamporg' ), 2082 'popular_items' => __( 'Popular Tracks', 'wordcamporg' ), 2083 'all_items' => __( 'All Tracks', 'wordcamporg' ), 2084 'edit_item' => __( 'Edit Track', 'wordcamporg' ), 2085 'update_item' => __( 'Update Track', 'wordcamporg' ), 2086 'add_new_item' => __( 'Add Track', 'wordcamporg' ), 2087 'new_item_name' => __( 'New Track', 'wordcamporg' ), 2006 2088 ); 2007 2089 2008 2090 // Register the Tracks taxonomy. … … class WordCamp_Post_Types_Plugin { 2019 2101 2020 2102 // Labels for sponsor levels. 2021 2103 $labels = array( 2022 'name' 2023 'singular_name' 2024 'search_items' 2025 'popular_items' 2026 'all_items' 2027 'edit_item' 2028 'update_item' 2029 'add_new_item' 2030 'new_item_name' 2104 'name' => __( 'Sponsor Levels', 'wordcamporg' ), 2105 'singular_name' => __( 'Sponsor Level', 'wordcamporg' ), 2106 'search_items' => __( 'Search Sponsor Levels', 'wordcamporg' ), 2107 'popular_items' => __( 'Popular Sponsor Levels', 'wordcamporg' ), 2108 'all_items' => __( 'All Sponsor Levels', 'wordcamporg' ), 2109 'edit_item' => __( 'Edit Sponsor Level', 'wordcamporg' ), 2110 'update_item' => __( 'Update Sponsor Level', 'wordcamporg' ), 2111 'add_new_item' => __( 'Add Sponsor Level', 'wordcamporg' ), 2112 'new_item_name' => __( 'New Sponsor Level', 'wordcamporg' ), 2031 2113 ); 2032 2114 2033 2115 // Register sponsor level taxonomy … … class WordCamp_Post_Types_Plugin { 2044 2126 2045 2127 // Labels for organizer teams. 2046 2128 $labels = array( 2047 'name' => __( 'Teams', 2048 'singular_name' => __( 'Team', 2049 'search_items' => __( 'Search Teams', 2129 'name' => __( 'Teams', 'wordcamporg' ), 2130 'singular_name' => __( 'Team', 'wordcamporg' ), 2131 'search_items' => __( 'Search Teams', 'wordcamporg' ), 2050 2132 'popular_items' => __( 'Popular Teams', 'wordcamporg' ), 2051 'all_items' => __( 'All Teams', 2052 'edit_item' => __( 'Edit Team', 2053 'update_item' => __( 'Update Team', 2054 'add_new_item' => __( 'Add Team', 2055 'new_item_name' => __( 'New Team', 2133 'all_items' => __( 'All Teams', 'wordcamporg' ), 2134 'edit_item' => __( 'Edit Team', 'wordcamporg' ), 2135 'update_item' => __( 'Update Team', 'wordcamporg' ), 2136 'add_new_item' => __( 'Add Team', 'wordcamporg' ), 2137 'new_item_name' => __( 'New Team', 'wordcamporg' ), 2056 2138 ); 2057 2139 2058 2140 // Register organizer teams taxonomy … … class WordCamp_Post_Types_Plugin { 2071 2153 2072 2154 // Labels for speaker groups. 2073 2155 $labels = array( 2074 'name' => __( 'Groups', 2075 'singular_name' => __( 'Group', 2076 'search_items' => __( 'Search Groups', 2156 'name' => __( 'Groups', 'wordcamporg' ), 2157 'singular_name' => __( 'Group', 'wordcamporg' ), 2158 'search_items' => __( 'Search Groups', 'wordcamporg' ), 2077 2159 'popular_items' => __( 'Popular Groups', 'wordcamporg' ), 2078 'all_items' => __( 'All Groups', 2079 'edit_item' => __( 'Edit Group', 2080 'update_item' => __( 'Update Group', 2081 'add_new_item' => __( 'Add Group', 2082 'new_item_name' => __( 'New Group', 2160 'all_items' => __( 'All Groups', 'wordcamporg' ), 2161 'edit_item' => __( 'Edit Group', 'wordcamporg' ), 2162 'update_item' => __( 'Update Group', 'wordcamporg' ), 2163 'add_new_item' => __( 'Add Group', 'wordcamporg' ), 2164 'new_item_name' => __( 'New Group', 'wordcamporg' ), 2083 2165 ); 2084 2166 2085 2167 // Register speaker groups taxonomy … … class WordCamp_Post_Types_Plugin { 2105 2187 * override. 2106 2188 * 2107 2189 * @uses current_filter() 2108 * @see __construct()2190 * @see __construct() 2109 2191 */ 2110 2192 function manage_post_types_columns( $columns ) { 2111 2193 $current_filter = current_filter(); … … class WordCamp_Post_Types_Plugin { 2113 2195 switch ( $current_filter ) { 2114 2196 case 'manage_wcb_organizer_posts_columns': 2115 2197 // Insert at offset 1, that's right after the checkbox. 2116 $columns = array_slice( $columns, 0, 1, true ) + array( 'wcb_organizer_avatar' => __( 'Avatar', 'wordcamporg' ) ) 2198 $columns = array_slice( $columns, 0, 1, true ) + array( 'wcb_organizer_avatar' => __( 'Avatar', 'wordcamporg' ) ) + array_slice( $columns, 1, null, true ); 2117 2199 break; 2118 2200 2119 2201 case 'manage_wcb_speaker_posts_columns': 2120 2202 $original_columns = $columns; 2121 2203 2122 $columns = 2204 $columns = array_slice( $original_columns, 0, 1, true ); 2123 2205 $columns += array( 'wcb_speaker_avatar' => __( 'Avatar', 'wordcamporg' ) ); 2124 2206 $columns += array_slice( $original_columns, 1, 1, true ); 2125 2207 $columns += array( 2126 'wcb_speaker_email' => __( 'Gravatar Email', 2208 'wcb_speaker_email' => __( 'Gravatar Email', 'wordcamporg' ), 2127 2209 'wcb_speaker_wporg_username' => __( 'WordPress.org Username', 'wordcamporg' ), 2128 2210 ); 2129 2211 $columns += array_slice( $original_columns, 2, null, true ); … … class WordCamp_Post_Types_Plugin { 2132 2214 2133 2215 case 'manage_wcb_session_posts_columns': 2134 2216 $columns = array_slice( $columns, 0, 2, true ) + array( 'wcb_session_speakers' => __( 'Speakers', 'wordcamporg' ) ) + array_slice( $columns, 2, null, true ); 2135 $columns = array_slice( $columns, 0, 1, true ) + array( 'wcb_session_time' => __( 'Time', 'wordcamporg' ) )+ array_slice( $columns, 1, null, true );2217 $columns = array_slice( $columns, 0, 1, true ) + array( 'wcb_session_time' => __( 'Time', 'wordcamporg' ) ) + array_slice( $columns, 1, null, true ); 2136 2218 break; 2137 2219 default: 2138 2220 } … … class WordCamp_Post_Types_Plugin { 2162 2244 break; 2163 2245 2164 2246 case 'wcb_speaker_wporg_username': 2165 $user_id 2247 $user_id = get_post_meta( get_the_ID(), '_wcpt_user_id', true ); 2166 2248 $wporg_user = get_user_by( 'id', $user_id ); 2167 2249 2168 2250 if ( $wporg_user ) { … … class WordCamp_Post_Types_Plugin { 2176 2258 $speakers_ids = array_map( 'absint', (array) get_post_meta( $post_id, '_wcpt_speaker_id' ) ); 2177 2259 if ( ! empty( $speakers_ids ) ) { 2178 2260 $speakers = get_posts( array( 2179 'post_type' => 'wcb_speaker',2261 'post_type' => 'wcb_speaker', 2180 2262 'posts_per_page' => -1, 2181 'post__in' => $speakers_ids,2263 'post__in' => $speakers_ids, 2182 2264 ) ); 2183 2265 } 2184 2266 … … class WordCamp_Post_Types_Plugin { 2206 2288 function manage_sortable_columns( $sortable ) { 2207 2289 $current_filter = current_filter(); 2208 2290 2209 if ( 'manage_edit-wcb_session_sortable_columns' == $current_filter ) 2291 if ( 'manage_edit-wcb_session_sortable_columns' == $current_filter ) { 2210 2292 $sortable['wcb_session_time'] = '_wcpt_session_time'; 2293 } 2211 2294 2212 2295 return $sortable; 2213 2296 } … … class WordCamp_Post_Types_Plugin { 2218 2301 function display_post_states( $states ) { 2219 2302 $post = get_post(); 2220 2303 2221 if ( 'wcb_session' != $post->post_type ) 2304 if ( 'wcb_session' != $post->post_type ) { 2222 2305 return $states; 2306 } 2223 2307 2224 2308 $session_type = get_post_meta( $post->ID, '_wcpt_session_type', true ); 2225 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) 2309 if ( ! in_array( $session_type, array( 'session', 'custom' ) ) ) { 2226 2310 $session_type = 'session'; 2311 } 2227 2312 2228 if ( 'session' == $session_type ) 2313 if ( 'session' == $session_type ) { 2229 2314 $states['wcpt-session-type'] = __( 'Session', 'wordcamporg' ); 2230 elseif ( 'custom' == $session_type )2315 } elseif ( 'custom' == $session_type ) { 2231 2316 $states['wcpt-session-type'] = __( 'Custom', 'wordcamporg' ); 2317 } 2232 2318 2233 2319 return $states; 2234 2320 } … … class WordCamp_Post_Types_Plugin { 2239 2325 function register_widgets() { 2240 2326 require_once( 'inc/widgets.php' ); 2241 2327 2242 register_widget( 'WCB_Widget_Sponsors' 2243 register_widget( 'WCPT_Widget_Speakers' 2244 register_widget( 'WCPT_Widget_Sessions' 2328 register_widget( 'WCB_Widget_Sponsors' ); 2329 register_widget( 'WCPT_Widget_Speakers' ); 2330 register_widget( 'WCPT_Widget_Sessions' ); 2245 2331 register_widget( 'WCPT_Widget_Organizers' ); 2246 2332 } 2247 2333 … … class WordCamp_Post_Types_Plugin { 2257 2343 continue; 2258 2344 } 2259 2345 2260 $num_posts 2346 $num_posts = wp_count_posts( $post_type ); 2261 2347 $post_type_object = get_post_type_object( $post_type ); 2262 2348 2263 2349 if ( $num_posts && $num_posts->publish ) { … … class WordCamp_Post_Types_Plugin { 2292 2378 * Comments and pings on speakers closed by default. 2293 2379 * 2294 2380 * @param string $status Default comment status. 2381 * 2295 2382 * @return string Resulting status. 2296 2383 */ 2297 2384 public function default_comment_ping_status( $status ) { 2298 2385 $screen = get_current_screen(); 2299 if ( ! empty( $screen->post_type ) && $screen->post_type == 'wcb_speaker' ) 2386 if ( ! empty( $screen->post_type ) && $screen->post_type == 'wcb_speaker' ) { 2300 2387 $status = 'closed'; 2388 } 2301 2389 2302 2390 return $status; 2303 2391 }