Changeset 6764 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/inc/widgets.php
- Timestamp:
- 02/26/2018 06:38:19 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.