Changeset 6764
- Timestamp:
- 02/26/2018 06:38:19 PM (7 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types
- Files:
-
- 7 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(); -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/inc/rest-api.php
r6268 r6764 72 72 if ( get_option( 'show_avatars' ) ) { 73 73 $avatar_properties = array(); 74 $avatar_sizes = rest_get_avatar_sizes();74 $avatar_sizes = rest_get_avatar_sizes(); 75 75 76 76 foreach ( $avatar_sizes as $size ) { … … 127 127 * @return void 128 128 */ 129 function register_fav_sessions_email() {129 function register_fav_sessions_email() { 130 130 register_rest_route( 131 131 'wc-post-types/v1', // REST namespace + API version … … 136 136 'args' => array( 137 137 'email-address' => array( 138 'required' => true,138 'required' => true, 139 139 'validate_callback' => function( $value, $request, $param ) { 140 140 return is_email( $value ); … … 146 146 147 147 'session-list' => array( 148 'required' => true,148 'required' => true, 149 149 'validate_callback' => function( $value, $request, $param ) { 150 150 $session_ids = explode( ',', $value ); … … 162 162 }, 163 163 ), 164 ) 164 ), 165 165 ) 166 166 ); -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/inc/widgets.php
r3602 r6764 4 4 */ 5 5 6 if ( ! class_exists( 'WCB_Widget_Sponsors' ) ) :7 6 /** 8 7 * Sponsors widget class. … … 11 10 */ 12 11 class WCB_Widget_Sponsors extends WP_Widget { 13 14 12 function __construct() { 15 13 $widget_ops = array( 16 'classname' => 'wcb_widget_sponsors',14 'classname' => 'wcb_widget_sponsors', 17 15 'description' => __( 'Your WordCamp’s Sponsors', 'wordcamporg' ), 18 16 ); … … 28 26 29 27 echo $before_widget; 30 if ( $title ) 28 29 if ( $title ) { 31 30 echo $before_title . $title . $after_title; 31 } 32 32 33 33 // Fetch sponsor levels … … 53 53 <?php foreach ( $terms as $term ) : ?> 54 54 <?php 55 $sponsors = new WP_Query( array( 56 'post_type' => 'wcb_sponsor', 57 'posts_per_page' => -1, 58 'order' => 'ASC', 59 'taxonomy' => $term->taxonomy, 60 'term' => $term->slug, 61 ) ); 62 63 if ( ! $sponsors->have_posts() ) 64 continue; 55 56 $sponsors = new WP_Query( array( 57 'post_type' => 'wcb_sponsor', 58 'posts_per_page' => -1, 59 'order' => 'ASC', 60 'taxonomy' => $term->taxonomy, 61 'term' => $term->slug, 62 ) ); 63 64 if ( ! $sponsors->have_posts() ) { 65 continue; 66 } 67 65 68 ?> 66 69 … … 68 71 <h4 class="sponsor-level-title"><?php echo esc_html( $term->name ); ?></h4> 69 72 70 <?php while ( $sponsors->have_posts() ) : $sponsors->the_post(); ?> 73 <?php while ( $sponsors->have_posts() ) : 74 $sponsors->the_post(); ?> 71 75 72 76 <a class="sponsor-logo" href="<?php the_permalink(); ?>"> … … 86 90 function form( $instance ) { 87 91 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 88 $title = $instance['title'];92 $title = $instance['title']; 89 93 ?> 90 94 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wordcamporg' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> … … 93 97 94 98 function update( $new_instance, $old_instance ) { 95 $instance = $old_instance;96 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '' ) );99 $instance = $old_instance; 100 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '' ) ); 97 101 $instance['title'] = strip_tags( $new_instance['title'] ); 98 102 return $instance; 99 103 } 100 104 } 101 endif; // class_exists102 105 103 106 /** … … 111 114 */ 112 115 class WCPT_Widget_Speakers extends WP_Widget { 113 114 116 protected $cache_time = 3600; // seconds 115 117 116 118 function __construct() { 117 119 $widget_ops = array( 118 'classname' => 'wcpt_widget_speakers',120 'classname' => 'wcpt_widget_speakers', 119 121 'description' => __( 'Your WordCamp’s Speakers', 'wordcamporg' ), 120 122 ); … … 126 128 global $wcpt_plugin; 127 129 128 $transient_key = 'wcpt-' . md5( $args['widget_id'] );130 $transient_key = 'wcpt-' . md5( $args['widget_id'] ); 129 131 $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); 130 132 131 133 echo $args['before_widget']; 132 if ( $instance['title'] ) 134 if ( $instance['title'] ) { 133 135 echo $args['before_title'] . $instance['title'] . $args['after_title']; 136 } 134 137 135 138 if ( false === ( $widget_content = get_transient( $transient_key ) ) ) { … … 137 140 $attr = array(); 138 141 139 if ( $instance['count'] ) 142 if ( $instance['count'] ) { 140 143 $attr['posts_per_page'] = $instance['count']; 141 142 if ( $instance['random'] ) 144 } 145 146 if ( $instance['random'] ) { 143 147 $attr['orderby'] = 'rand'; 148 } 144 149 145 150 $attr_str = array(); 146 foreach ( $attr as $key => $value ) 151 foreach ( $attr as $key => $value ) { 147 152 $attr_str[ $key ] = sprintf( '%s="%s"', $key, esc_attr( $value ) ); 153 } 148 154 $attr_str = implode( ' ', $attr_str ); 149 155 … … 156 162 157 163 $speakers_permalink = $wcpt_plugin->get_wcpt_permalink( 'speakers' ); 158 if ( ! empty( $speakers_permalink ) ) 164 if ( ! empty( $speakers_permalink ) ) { 159 165 printf( '<a class="wcpt-speakers-link" href="%s">%s</a>', esc_url( $speakers_permalink ), esc_html( __( 'View all speakers →', 'wordcamporg' ) ) ); 166 } 160 167 161 168 echo $args['after_widget']; … … 165 172 166 173 function form( $instance ) { 167 $instance = wp_parse_args( (array) $instance, array( 168 'title' => '', 169 'count' => 3, 170 'random' => false, 171 ) ); 172 173 $title = $instance['title']; 174 $count = absint( $instance['count'] ); 174 $instance = wp_parse_args( 175 (array) $instance, 176 array( 177 'title' => '', 178 'count' => 3, 179 'random' => false, 180 ) 181 ); 182 183 $title = $instance['title']; 184 $count = absint( $instance['count'] ); 175 185 $random = (bool) $instance['random']; 186 176 187 ?> 188 177 189 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wordcamporg' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> 178 190 <p><label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of speakers to show:', 'wordcamporg' ); ?> <input type="text" size="3" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo esc_attr( $count ); ?>" /></label></p> … … 186 198 187 199 function update( $new_instance, $old_instance ) { 188 $instance = $old_instance; 189 $new_instance = wp_parse_args( (array) $new_instance, array( 190 'title' => '', 191 'count' => 3, 192 'random' => false, 193 ) ); 194 195 $instance['title'] = strip_tags( $new_instance['title'] ); 196 $instance['count'] = absint( $new_instance['count'] ); 200 $instance = $old_instance; 201 $new_instance = wp_parse_args( 202 (array) $new_instance, 203 array( 204 'title' => '', 205 'count' => 3, 206 'random' => false, 207 ) 208 ); 209 210 $instance['title'] = strip_tags( $new_instance['title'] ); 211 $instance['count'] = absint( $new_instance['count'] ); 197 212 $instance['random'] = (bool) $new_instance['random']; 198 213 … … 213 228 */ 214 229 class WCPT_Widget_Sessions extends WP_Widget { 215 216 230 protected $cache_time = 3600; // seconds 217 231 218 232 function __construct() { 219 233 $widget_ops = array( 220 'classname' => 'wcpt_widget_sessions',234 'classname' => 'wcpt_widget_sessions', 221 235 'description' => __( 'Show off your WordCamp sessions', 'wordcamporg' ), 222 236 ); … … 228 242 global $wcpt_plugin; 229 243 230 $transient_key = 'wcpt-' . md5( $args['widget_id'] );244 $transient_key = 'wcpt-' . md5( $args['widget_id'] ); 231 245 $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); 232 246 233 247 echo $args['before_widget']; 234 if ( $instance['title'] ) 248 if ( $instance['title'] ) { 235 249 echo $args['before_title'] . $instance['title'] . $args['after_title']; 250 } 236 251 237 252 if ( false === ( $widget_content = get_transient( $transient_key ) ) ) { … … 239 254 $attr = array( 240 255 'show_avatars' => 'true', 241 'show_meta' => 'true',256 'show_meta' => 'true', 242 257 'speaker_link' => 'anchor', 243 258 ); 244 259 245 if ( $instance['count'] ) 260 if ( $instance['count'] ) { 246 261 $attr['posts_per_page'] = $instance['count']; 247 248 if ( $instance['random'] ) 262 } 263 264 if ( $instance['random'] ) { 249 265 $attr['orderby'] = 'rand'; 266 } 250 267 251 268 $attr_str = array(); 252 foreach ( $attr as $key => $value ) 269 foreach ( $attr as $key => $value ) { 253 270 $attr_str[ $key ] = sprintf( '%s="%s"', $key, esc_attr( $value ) ); 271 } 254 272 $attr_str = implode( ' ', $attr_str ); 255 273 … … 262 280 263 281 $sessions_permalink = $wcpt_plugin->get_wcpt_permalink( 'sessions' ); 264 if ( ! empty( $sessions_permalink ) ) 282 if ( ! empty( $sessions_permalink ) ) { 265 283 printf( '<a class="wcpt-sessions-link" href="%s">%s</a>', esc_url( $sessions_permalink ), esc_html( __( 'View all sessions →', 'wordcamporg' ) ) ); 284 } 266 285 267 286 echo $args['after_widget']; … … 271 290 272 291 function form( $instance ) { 273 $instance = wp_parse_args( (array) $instance, array( 274 'title' => '', 275 'count' => 3, 276 'random' => false, 277 ) ); 278 279 $title = $instance['title']; 280 $count = absint( $instance['count'] ); 292 $instance = wp_parse_args( 293 (array) $instance, 294 array( 295 'title' => '', 296 'count' => 3, 297 'random' => false, 298 ) 299 ); 300 301 $title = $instance['title']; 302 $count = absint( $instance['count'] ); 281 303 $random = (bool) $instance['random']; 304 282 305 ?> 306 283 307 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wordcamporg' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> 284 308 <p><label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of speakers to show:', 'wordcamporg' ); ?> <input type="text" size="3" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo esc_attr( $count ); ?>" /></label></p> … … 292 316 293 317 function update( $new_instance, $old_instance ) { 294 $instance = $old_instance; 295 $new_instance = wp_parse_args( (array) $new_instance, array( 296 'title' => '', 297 'count' => 3, 298 'random' => false, 299 ) ); 300 301 $instance['title'] = strip_tags( $new_instance['title'] ); 302 $instance['count'] = absint( $new_instance['count'] ); 318 $instance = $old_instance; 319 $new_instance = wp_parse_args( 320 (array) $new_instance, 321 array( 322 'title' => '', 323 'count' => 3, 324 'random' => false, 325 ) 326 ); 327 328 $instance['title'] = strip_tags( $new_instance['title'] ); 329 $instance['count'] = absint( $new_instance['count'] ); 303 330 $instance['random'] = (bool) $new_instance['random']; 304 331 … … 323 350 function __construct() { 324 351 $widget_ops = array( 325 'classname' => 'wcpt_widget_organizers',352 'classname' => 'wcpt_widget_organizers', 326 353 'description' => __( 'Display your organizing team in the sidebar', 'wordcamporg' ), 327 354 ); … … 333 360 global $wcpt_plugin; 334 361 335 $transient_key = 'wcpt-' . md5( $args['widget_id'] );362 $transient_key = 'wcpt-' . md5( $args['widget_id'] ); 336 363 $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); 337 364 338 365 echo $args['before_widget']; 339 if ( $instance['title'] ) 366 if ( $instance['title'] ) { 340 367 echo $args['before_title'] . $instance['title'] . $args['after_title']; 368 } 341 369 342 370 if ( false === ( $widget_content = get_transient( $transient_key ) ) ) { … … 344 372 $attr = array(); 345 373 346 if ( $instance['count'] ) 374 if ( $instance['count'] ) { 347 375 $attr['posts_per_page'] = $instance['count']; 348 349 if ( $instance['random'] ) 376 } 377 378 if ( $instance['random'] ) { 350 379 $attr['orderby'] = 'rand'; 380 } 351 381 352 382 $attr_str = array(); 353 foreach ( $attr as $key => $value ) 383 foreach ( $attr as $key => $value ) { 354 384 $attr_str[ $key ] = sprintf( '%s="%s"', $key, esc_attr( $value ) ); 385 } 355 386 $attr_str = implode( ' ', $attr_str ); 356 387 … … 363 394 364 395 $organizers_permalink = $wcpt_plugin->get_wcpt_permalink( 'organizers' ); 365 if ( ! empty( $organizers_permalink ) ) 396 if ( ! empty( $organizers_permalink ) ) { 366 397 printf( '<a class="wcpt-organizers-link" href="%s">%s</a>', esc_url( $organizers_permalink ), esc_html( __( 'Organizing team →', 'wordcamporg' ) ) ); 398 } 367 399 368 400 echo $args['after_widget']; … … 372 404 373 405 function form( $instance ) { 374 $instance = wp_parse_args( (array) $instance, array( 375 'title' => '', 376 'count' => 3, 377 'random' => false, 378 ) ); 379 380 $title = $instance['title']; 381 $count = absint( $instance['count'] ); 406 $instance = wp_parse_args( 407 (array) $instance, 408 array( 409 'title' => '', 410 'count' => 3, 411 'random' => false, 412 ) 413 ); 414 415 $title = $instance['title']; 416 $count = absint( $instance['count'] ); 382 417 $random = (bool) $instance['random']; 418 383 419 ?> 420 384 421 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wordcamporg' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> 385 422 <p><label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of organizers to show:', 'wordcamporg' ); ?> <input type="text" size="3" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo esc_attr( $count ); ?>" /></label></p> … … 393 430 394 431 function update( $new_instance, $old_instance ) { 395 $instance = $old_instance; 396 $new_instance = wp_parse_args( (array) $new_instance, array( 397 'title' => '', 398 'count' => 3, 399 'random' => false, 400 ) ); 401 402 $instance['title'] = strip_tags( $new_instance['title'] ); 403 $instance['count'] = absint( $new_instance['count'] ); 432 $instance = $old_instance; 433 $new_instance = wp_parse_args( 434 (array) $new_instance, 435 array( 436 'title' => '', 437 'count' => 3, 438 'random' => false, 439 ) 440 ); 441 442 $instance['title'] = strip_tags( $new_instance['title'] ); 443 $instance['count'] = absint( $new_instance['count'] ); 404 444 $instance['random'] = (bool) $new_instance['random']; 405 445 … … 407 447 $transient_key = 'wcpt-' . md5( $this->id ); 408 448 delete_transient( $transient_key ); 449 409 450 return $instance; 410 451 } -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/views/sponsors/metabox-invoice-sponsor.php
r5535 r6764 34 34 </a> 35 35 36 <?php endif; ?> 37 36 <?php endif; -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/views/sponsors/metabox-sponsor-agreement.php
r5784 r6764 1 1 <?php 2 /* @var int $agreement_id */ 3 /* @var string $agreement_url */ 4 /* @var int $mes_id */ 2 3 /** 4 * @var int $agreement_id 5 * @var string $agreement_url 6 * @var int $mes_id 7 */ 8 5 9 ?> 6 10 … … 11 15 <?php if ( $agreement_url ) : ?> 12 16 <p id="sponsor-agreement-view-container"> 13 <a id="sponsor-agreement-view" class="button secondary" href="<?php echo esc_url( $agreement_url ); ?>" target="sponsor-agreement"><?php esc_html_e( 'View Agreement', 'wordcamporg' ); ?></a> 17 <a id="sponsor-agreement-view" class="button secondary" href="<?php echo esc_url( $agreement_url ); ?>" target="sponsor-agreement"> 18 <?php esc_html_e( 'View Agreement', 'wordcamporg' ); ?> 19 </a> 14 20 </p> 15 21 <?php endif; ?> … … 19 25 <p id="sponsor-agreement-description-container" class="description hidden"> 20 26 <?php 27 21 28 printf( 22 wp_kses( 23 __( '<strong>Instructions:</strong> You can generate an agreement for this sponsor <a href="%s">here</a>. Upload a PDF or image file of the signed, dated sponsor agreement.', 'wordcamporg' ), 24 array( 25 'a' => array( 'href' => true ), 26 'strong' => true, 27 ) 28 ), 29 wp_kses_data( __( 30 '<strong>Instructions:</strong> You can generate an agreement for this sponsor <a href="%s">here</a>. Upload a PDF or image file of the signed, dated sponsor agreement.', 'wordcamporg' 31 ) ), 29 32 esc_url( add_query_arg( array( 'page' => 'wcdocs' ), admin_url( 'admin.php' ) ) ) 30 33 ); 34 31 35 ?> 32 36 </p> 37 33 38 <p id="sponsor-agreement-upload-container" class="hidden"> 34 <a id="sponsor-agreement-upload" class="button secondary" href="#"><?php esc_html_e( 'Attach Signed Agreement', 'wordcamporg' ); ?></a> 39 <a id="sponsor-agreement-upload" class="button secondary" href="#"> 40 <?php esc_html_e( 'Attach Signed Agreement', 'wordcamporg' ); ?> 41 </a> 35 42 </p> 36 43 37 44 <p id="sponsor-agreement-view-container" class="hidden"> 38 <a id="sponsor-agreement-view" class="button secondary<?php if ( ! $agreement_url ) echo ' hidden'; ?>" href="<?php echo esc_url( $agreement_url ); ?>" target="sponsor-agreement"><?php esc_html_e( 'View Agreement', 'wordcamporg' ); ?></a> 45 <a id="sponsor-agreement-view" 46 class="button secondary <?php if ( ! $agreement_url ) { echo ' hidden'; } ?>" 47 href="<?php echo esc_url( $agreement_url ); ?>" 48 target="sponsor-agreement"> 49 <?php esc_html_e( 'View Agreement', 'wordcamporg' ); ?> 50 </a> 39 51 </p> 52 40 53 <p id="sponsor-agreement-remove-container" class="hidden"> 41 <a id="sponsor-agreement-remove" href="#"><?php esc_html_e( 'Remove Agreement', 'wordcamporg' ); ?></a> 54 <a id="sponsor-agreement-remove" href="#"> 55 <?php esc_html_e( 'Remove Agreement', 'wordcamporg' ); ?> 56 </a> 42 57 </p> 43 58 44 59 <input id="sponsor-agreement-id" name="_wcpt_sponsor_agreement" type="hidden" value="<?php echo esc_attr( $agreement_id ); ?>" /> 45 60 46 <?php endif; ?>61 <?php endif; -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/views/sponsors/metabox-sponsor-info.php
r6624 r6764 16 16 value="<?php echo esc_attr( $company_name ); ?>" 17 17 maxlength="50" 18 18 required 19 19 /> 20 20 … … 33 33 name="_wcpt_sponsor_website" 34 34 value="<?php echo esc_url( $website ); ?>" 35 35 required 36 36 /> 37 37 … … 102 102 value="<?php echo esc_attr( $phone_number ); ?>" 103 103 maxlength="21" 104 104 required 105 105 /> 106 106 … … 144 144 <li> 145 145 <label for="_wcpt_sponsor_country"> 146 <?php _e( 'Country:', 'wordcamporg' ) ?>146 <?php _e( 'Country:', 'wordcamporg' ); ?> 147 147 </label> 148 148 … … 178 178 name="_wcpt_sponsor_street_address1" 179 179 value="<?php echo esc_attr( $street_address1 ); ?>" 180 180 required 181 181 /> 182 182 … … 209 209 name="_wcpt_sponsor_city" 210 210 value="<?php echo esc_attr( $city ); ?>" 211 211 required 212 212 /> 213 213 … … 245 245 value="<?php echo esc_attr( $zip_code ); ?>" 246 246 maxlength="30" 247 247 required 248 248 /> 249 249 -
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.