Changeset 935
- Timestamp:
- 10/25/2014 06:00:53 AM (10 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/css/shortcodes.css
r502 r935 74 74 } 75 75 } 76 77 /* 78 * [sessions] 79 * [speakers] 80 */ 81 #session-speaker-names, 82 #speaker-session-names { 83 margin-left: 0; 84 } 85 86 #session-speaker-names li, 87 #speaker-session-names li { 88 list-style-type: none; 89 } -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php
r934 r935 47 47 48 48 add_filter( 'the_content', array( $this, 'add_avatar_to_speaker_posts' ) ); 49 add_filter( 'the_content', array( $this, 'add_speaker_info_to_session_posts' ) ); 50 add_filter( 'the_content', array( $this, 'add_session_info_to_speaker_posts' ) ); 49 51 } 50 52 … … 196 198 197 199 function wp_enqueue_scripts() { 198 wp_enqueue_style( 'wcb_shortcodes', plugins_url( 'css/shortcodes.css', __FILE__ ), array(), 1);200 wp_enqueue_style( 'wcb_shortcodes', plugins_url( 'css/shortcodes.css', __FILE__ ), array(), 2 ); 199 201 } 200 202 … … 1072 1074 $avatar = get_avatar( get_post_meta( $post->ID, '_wcb_speaker_email', true ) ); 1073 1075 return '<div class="speaker-avatar">' . $avatar . '</div>' . $content; 1076 } 1077 1078 /** 1079 * Add speaker information to Session posts 1080 * 1081 * We don't enable it for sites that were created before it was committed, because some will have already 1082 * crafted the bio to include this content, so duplicating it would look wrong, but we still allow older 1083 * sites to opt-in. 1084 * 1085 * @param string $content 1086 * 1087 * @return string 1088 */ 1089 function add_speaker_info_to_session_posts( $content ) { 1090 global $post; 1091 $enabled_site_ids = array( 364 ); // 2014.sf 1092 1093 if ( 'wcb_session' !== $post->post_type ) { 1094 return $content; 1095 } 1096 1097 $site_id = get_current_blog_id(); 1098 if ( $site_id <= 463 && ! in_array( $site_id, $enabled_site_ids ) ) { 1099 return $content; 1100 } 1101 1102 $speaker_ids = (array) get_post_meta( $post->ID, '_wcpt_speaker_id' ); 1103 1104 if ( empty ( $speaker_ids ) ) { 1105 return $content; 1106 } 1107 1108 $speaker_args = array( 1109 'post_type' => 'wcb_speaker', 1110 'posts_per_page' => -1, 1111 'post__in' => $speaker_ids, 1112 'orderby' => 'title', 1113 'order' => 'asc', 1114 ); 1115 1116 $speakers = new WP_Query( $speaker_args ); 1117 1118 if ( ! $speakers->have_posts() ) { 1119 return $content; 1120 } 1121 1122 $speakers_html = sprintf( 1123 '<h2 class="session-speakers">%s</h2>', 1124 _n( 1125 __( 'Speaker', 'wordcamporg' ), 1126 __( 'Speakers', 'wordcamporg' ), 1127 $speakers->post_count 1128 ) 1129 ); 1130 1131 $speakers_html .= '<ul id="session-speaker-names">'; 1132 while ( $speakers->have_posts() ) { 1133 $speakers->the_post(); 1134 $speakers_html .= sprintf( '<li><a href="%s">%s</a></li>', get_the_permalink(), get_the_title() ); 1135 } 1136 $speakers_html .= '</ul>'; 1137 1138 wp_reset_postdata(); 1139 1140 return $content . $speakers_html; 1141 } 1142 1143 /** 1144 * Add session information to Speaker posts 1145 * 1146 * We don't enable it for sites that were created before it was committed, because some will have already 1147 * crafted the bio to include this content, so duplicating it would look wrong, but we still allow older 1148 * sites to opt-in. 1149 * 1150 * @param string $content 1151 * 1152 * @return string 1153 */ 1154 function add_session_info_to_speaker_posts( $content ) { 1155 global $post; 1156 $enabled_site_ids = array( 364 ); // 2014.sf 1157 1158 if ( 'wcb_speaker' !== $post->post_type ) { 1159 return $content; 1160 } 1161 1162 $site_id = get_current_blog_id(); 1163 if ( $site_id <= 463 && ! in_array( $site_id, $enabled_site_ids ) ) { 1164 return $content; 1165 } 1166 1167 $session_args = array( 1168 'post_type' => 'wcb_session', 1169 'posts_per_page' => -1, 1170 'meta_key' => '_wcpt_speaker_id', 1171 'meta_value' => $post->ID, 1172 'orderby' => 'title', 1173 'order' => 'asc', 1174 ); 1175 1176 $sessions = new WP_Query( $session_args ); 1177 1178 if ( ! $sessions->have_posts() ) { 1179 return $content; 1180 } 1181 1182 $sessions_html = sprintf( 1183 '<h2 class="speaker-sessions">%s</h2>', 1184 _n( 1185 __( 'Session', 'wordcamporg' ), 1186 __( 'Sessions', 'wordcamporg' ), 1187 $sessions->post_count 1188 ) 1189 ); 1190 1191 $sessions_html .= '<ul id="speaker-session-names">'; 1192 while ( $sessions->have_posts() ) { 1193 $sessions->the_post(); 1194 $sessions_html .= sprintf( '<li><a href="%s">%s</a></li>', get_the_permalink(), get_the_title() ); 1195 } 1196 $sessions_html .= '</ul>'; 1197 1198 wp_reset_postdata(); 1199 1200 return $content . $sessions_html; 1074 1201 } 1075 1202
Note: See TracChangeset
for help on using the changeset viewer.