Changeset 6764 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/inc/back-compat.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/inc/back-compat.php
r5902 r6764 18 18 19 19 $this->stylesheet = wp_get_theme()->get_stylesheet(); 20 $this->template = wp_get_theme()->get_template();20 $this->template = wp_get_theme()->get_template(); 21 21 22 22 // Initialize only if theme requires. … … 71 71 72 72 $speakers = new WP_Query( array( 73 'post_type' => 'wcb_speaker',74 'orderby' => 'title',75 'order' => 'ASC',73 'post_type' => 'wcb_speaker', 74 'orderby' => 'title', 75 'order' => 'ASC', 76 76 'posts_per_page' => -1, 77 77 ) ); 78 78 79 if ( ! $speakers->have_posts() ) 79 if ( ! $speakers->have_posts() ) { 80 80 return ''; 81 } 81 82 82 83 ob_start(); … … 85 86 <div class="cpt-loop speaker-gravatar-list clearfix"> 86 87 <p> 87 <?php while ( $speakers->have_posts() ) : $speakers->the_post(); ?> 88 <?php while ( $speakers->have_posts() ) : 89 $speakers->the_post(); ?> 88 90 <?php 89 91 $href = '#' . esc_attr( $post->post_name ); … … 95 97 <?php endwhile; ?> 96 98 </p> 97 </div> <!-- .cpt-loop -->99 </div> 98 100 99 101 <?php $speakers->rewind_posts(); ?> … … 101 103 102 104 <div class="cpt-loop speakers"> 103 104 105 <div class="grid_6 alpha"> 105 106 106 <?php while ( $speakers->have_posts() ) : $speakers->the_post(); ?> 107 <?php while ( $speakers->have_posts() ) : 108 $speakers->the_post(); ?> 107 109 108 110 <?php 109 if ( get_the_ID() == $half_id ) 110 echo '</div><div class="grid_6 omega">'; 111 112 $odd = ( ( $speakers->current_post + 1 ) % 2 ) ? 'odd' : 'even'; 111 112 if ( get_the_ID() == $half_id ) { 113 echo '</div><div class="grid_6 omega">'; 114 } 115 116 $odd = ( ( $speakers->current_post + 1 ) % 2 ) ? 'odd' : 'even'; 117 113 118 ?> 114 119 … … 122 127 </div> 123 128 </div> 124 125 129 <?php endwhile; ?> 126 130 127 131 </div> 128 </div><!-- .cpt-loop --> 132 </div> 133 129 134 <?php 130 135 … … 143 148 144 149 $sessions = new WP_Query( array( 145 'post_type' => 'wcb_session',146 'orberby' => 'title',147 'order' => 'DESC',150 'post_type' => 'wcb_session', 151 'orberby' => 'title', 152 'order' => 'DESC', 148 153 'posts_per_page' => -1, 149 154 ) ); 150 155 151 if ( ! $sessions->have_posts() ) 152 return; 156 if ( ! $sessions->have_posts() ) { 157 return ''; 158 } 153 159 154 160 ob_start(); … … 156 162 157 163 <div class="cpt-loop sessions"> 158 159 164 <?php $half_id = $this->wcb_optimal_column_split( $sessions, 200 ); ?> 160 165 161 166 <div class="grid_6 alpha"> 162 163 <?php while ( $sessions->have_posts() ) : $sessions->the_post(); ?> 164 165 <?php 167 <?php while ( $sessions->have_posts() ) : 168 $sessions->the_post(); ?> 169 170 <?php 171 166 172 // Close the first column, open the second. 167 if ( get_the_ID() == $half_id ) 173 if ( get_the_ID() == $half_id ) { 168 174 echo '</div><div class="grid_6 omega">'; 169 170 $odd = ( ( $sessions->current_post +1 ) % 2 ) ? 'odd' : 'even'; 171 ?> 172 <div id="post-<?php the_ID(); ?>" <?php post_class( 'session ' . $odd ); ?> > 173 <h3 class="entry-title session-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 174 175 <?php 176 $meta = array(); 175 } 176 177 $odd = ( ( $sessions->current_post + 1 ) % 2 ) ? 'odd' : 'even'; 178 179 ?> 180 181 <div id="post-<?php the_ID(); ?>" <?php post_class( 'session ' . $odd ); ?> > 182 <h3 class="entry-title session-title"> 183 <a href="<?php the_permalink(); ?>"> 184 <?php the_title(); ?> 185 </a> 186 </h3> 187 188 <?php 189 190 $meta = array(); 177 191 $speakers = get_post_meta( get_the_ID(), '_wcb_session_speakers', true ); 178 $track = get_the_terms( get_the_ID(), 'wcb_track' );192 $track = get_the_terms( get_the_ID(), 'wcb_track' ); 179 193 180 194 if ( empty( $track ) ) { … … 185 199 } 186 200 187 if ( ! empty( $speakers ) ) 201 if ( ! empty( $speakers ) ) { 188 202 $meta['speakers'] = sprintf( __( 'Presented by %s', 'wordcamporg' ), esc_html( rtrim( $speakers, ',' ) ) ); 189 190 if ( ! empty( $track ) ) 203 } 204 205 if ( ! empty( $track ) ) { 191 206 $meta['track'] = sprintf( __( '%s Track', 'wordcamporg' ), esc_html( $track ) ); 207 } 192 208 193 209 $track_url = get_term_link( $track, 'wcb_track' ); 194 if ( ! is_wp_error( $track_url ) ) 210 211 if ( ! is_wp_error( $track_url ) ) { 195 212 $meta['track'] = sprintf( '<a href="%s">%s</a>', esc_url( $track_url ), $meta['track'] ); 213 } 196 214 197 215 // Output the meta … … 200 218 printf( '<div class="entry-meta session-speakers session-meta">%s</div>', $meta ); 201 219 } 202 ?> 203 <div class="entry-content session-description"> 204 <?php the_post_thumbnail(); ?> 205 <?php the_content(); ?> 220 221 ?> 222 223 <div class="entry-content session-description"> 224 <?php the_post_thumbnail(); ?> 225 <?php the_content(); ?> 226 </div> 206 227 </div> 207 </div> 208 209 <?php endwhile; ?> 210 211 </div><!-- .grid_6 --> 212 </div><!-- .cpt-loop --> 228 229 <?php endwhile; ?> 230 </div> 231 </div> 213 232 214 233 <?php … … 231 250 ob_start(); 232 251 ?> 252 233 253 <div class="sponsors"> 234 <?php foreach ( $terms as $term ) : ?> 235 <?php 254 <?php foreach ( $terms as $term ) : ?> 255 <?php 256 236 257 $sponsors = new WP_Query( array( 237 'post_type' => 'wcb_sponsor',238 'order' => 'ASC',239 'posts_per_page' => - 1,240 'taxonomy' => $term->taxonomy,241 'term' => $term->slug,258 'post_type' => 'wcb_sponsor', 259 'order' => 'ASC', 260 'posts_per_page' => - 1, 261 'taxonomy' => $term->taxonomy, 262 'term' => $term->slug, 242 263 ) ); 243 264 244 if ( ! $sponsors->have_posts() ) 265 if ( ! $sponsors->have_posts() ) { 245 266 continue; 246 ?> 247 248 <div class="sponsor-level <?php echo $term->slug; ?>"> 249 <h2 class="sponsor-level-title"><?php echo esc_html( $term->name ); ?></h2> 250 251 <?php while ( $sponsors->have_posts() ) : $sponsors->the_post(); ?> 252 <div id="post-<?php the_ID(); ?>" <?php post_class( 'sponsor' ); ?> > 253 <h3 class="entry-title sponsor-title"><a href="<?php the_permalink(); ?>"> 254 <?php ( has_post_thumbnail() ) ? the_post_thumbnail() : the_title(); ?> 255 </a></h3> 256 <div class="entry-content sponsor-description"> 257 <?php the_content(); ?> 267 } 268 269 ?> 270 271 <div class="sponsor-level <?php echo $term->slug; ?>"> 272 <h2 class="sponsor-level-title"> 273 <?php echo esc_html( $term->name ); ?> 274 </h2> 275 276 <?php while ( $sponsors->have_posts() ) : 277 $sponsors->the_post(); ?> 278 279 <div id="post-<?php the_ID(); ?>" <?php post_class( 'sponsor' ); ?> > 280 <h3 class="entry-title sponsor-title"> 281 <a href="<?php the_permalink(); ?>"> 282 <?php ( has_post_thumbnail() ) ? the_post_thumbnail() : the_title(); ?> 283 </a> 284 </h3> 285 286 <div class="entry-content sponsor-description"> 287 <?php the_content(); ?> 288 </div> 258 289 </div> 259 </div><!-- #post --> 260 <?php endwhile; ?> 261 262 </div><!-- .sponsor-level --> 263 <?php endforeach; ?> 264 </div><!-- .sponsors --> 290 291 <?php endwhile; ?> 292 293 </div> 294 <?php endforeach; ?> 295 </div> 296 265 297 <?php 266 298 … … 276 308 * 277 309 * @todo Move to compat 310 * 278 311 * @param WP_Query $query 279 * @param integer $post_cost A character cost attributed to rendering a post. Helps for approximations. 280 * @param integer $min_chars The minimum number of characters per post. Helps for approximations. 312 * @param integer $post_cost A character cost attributed to rendering a post. Helps for approximations. 313 * @param integer $min_chars The minimum number of characters per post. Helps for approximations. 314 * 281 315 * @return Object The starting post ID of the second column. 282 316 */ 283 public function wcb_optimal_column_split( $query, $post_cost =0, $min_chars=0 ) {317 public function wcb_optimal_column_split( $query, $post_cost = 0, $min_chars = 0 ) { 284 318 $query->rewind_posts(); 285 319 … … 290 324 $post = $query->next_post(); 291 325 $length = strlen( $post->post_content ); 292 $total += ( $length < $min_chars ) ? $min_chars : $length;326 $total += ( $length < $min_chars ) ? $min_chars : $length; 293 327 $total += $post_cost; 294 328 $totals[] = array( $total, $post->ID ); … … 313 347 */ 314 348 function wcb_session_entry_meta( $meta ) { 315 if ( get_post_type() != 'wcb_session' ) 349 if ( get_post_type() != 'wcb_session' ) { 316 350 return $meta; 351 } 317 352 318 353 $speakers = get_post_meta( get_the_ID(), '_wcb_session_speakers', true ); 319 $track = get_the_terms( get_the_ID(), 'wcb_track' );354 $track = get_the_terms( get_the_ID(), 'wcb_track' ); 320 355 321 356 if ( empty( $track ) ) { … … 326 361 } 327 362 328 if ( ! empty( $speakers ) ) 363 if ( ! empty( $speakers ) ) { 329 364 $meta['speakers'] = sprintf( __( 'Presented by %s', 'wordcamporg' ), esc_html( $speakers ) ); 330 331 if ( ! empty( $track ) ) 365 } 366 367 if ( ! empty( $track ) ) { 332 368 $meta['track'] = sprintf( __( '%s Track', 'wordcamporg' ), esc_html( $track ) ); 369 } 333 370 334 371 $track_url = get_term_link( $track, 'wcb_track' ); 335 if ( ! is_wp_error( $track_url ) ) 372 if ( ! is_wp_error( $track_url ) ) { 336 373 $meta['track'] = sprintf( '<a href="%s">%s</a>', esc_url( $track_url ), $meta['track'] ); 374 } 337 375 338 376 $order = array(); 339 377 340 if ( ! empty( $meta['speakers'] ) ) 378 if ( ! empty( $meta['speakers'] ) ) { 341 379 $order[] = 'speakers'; 380 } 342 381 343 382 if ( ! empty( $meta['track'] ) ) { … … 353 392 } 354 393 } 355 new WordCamp_Post_Types_Plugin_Back_Compat ;394 new WordCamp_Post_Types_Plugin_Back_Compat();
Note: See TracChangeset
for help on using the changeset viewer.