PluginProbe
bbPress / 2.0-beta-2b
bbPress v2.0-beta-2b
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
bbpress / bbp-includes / bbp-core-widgets.php

bbp-core-widgets.php in bbPress 2.0-beta-2b, at bbp-includes/bbp-core-widgets.php

718 lines 22.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress Widgets
5 *
6 * Contains the forum list, topic list, reply list and login form widgets.
7 *
8 * @package bbPress
9 * @subpackage Widgets
10 */
11
12 // Exit if accessed directly
13 if ( !defined( 'ABSPATH' ) ) exit;
14
15 /**
16 * bbPress Login Widget
17 *
18 * Adds a widget which displays the login form
19 *
20 * @since bbPress (r2827)
21 *
22 * @uses WP_Widget
23 */
24 class BBP_Login_Widget extends WP_Widget {
25
26 /**
27 * bbPress Login Widget
28 *
29 * Registers the login widget
30 *
31 * @since bbPress (r2827)
32 *
33 * @uses apply_filters() Calls 'bbp_login_widget_options' with the
34 * widget options
35 */
36 function BBP_Login_Widget() {
37 $widget_ops = apply_filters( 'bbp_login_widget_options', array(
38 'classname' => 'bbp_widget_login',
39 'description' => __( 'The login widget.', 'bbpress' )
40 ) );
41
42 parent::WP_Widget( false, __( 'bbPress Login Widget', 'bbpress' ), $widget_ops );
43 }
44
45 /**
46 * Displays the output, the login form
47 *
48 * @since bbPress (r2827)
49 *
50 * @param mixed $args Arguments
51 * @param array $instance Instance
52 * @uses apply_filters() Calls 'bbp_login_widget_title' with the title
53 * @uses get_template_part() To get the login/logged in form
54 */
55 function widget( $args, $instance ) {
56 extract( $args );
57
58 $title = apply_filters( 'bbp_login_widget_title', $instance['title'] );
59
60 echo $before_widget;
61
62 if ( !empty( $title ) )
63 echo $before_title . $title . $after_title;
64
65 if ( !is_user_logged_in() ) : ?>
66
67 <form method="post" action="<?php bbp_wp_login_action( array( 'context' => 'login_post' ) ); ?>" class="bbp-login-form">
68 <fieldset>
69 <legend><?php _e( 'Login', 'bbpress' ); ?></legend>
70
71 <div class="bbp-username">
72 <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label>
73 <input type="text" name="log" value="<?php bbp_sanitize_val( 'user_login', 'text' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" />
74 </div>
75
76 <div class="bbp-password">
77 <label for="user_pass"><?php _e( 'Password', 'bbpress' ); ?>: </label>
78 <input type="password" name="pwd" value="<?php bbp_sanitize_val( 'user_pass', 'password' ); ?>" size="20" id="user_pass" tabindex="<?php bbp_tab_index(); ?>" />
79 </div>
80
81 <div class="bbp-remember-me">
82 <input type="checkbox" name="rememberme" value="forever" <?php checked( bbp_get_sanitize_val( 'rememberme', 'checkbox' ), true, true ); ?> id="rememberme" tabindex="<?php bbp_tab_index(); ?>" />
83 <label for="rememberme"><?php _e( 'Keep me signed in', 'bbpress' ); ?></label>
84 </div>
85
86 <div class="bbp-submit-wrapper">
87
88 <?php do_action( 'login_form' ); ?>
89
90 <input type="submit" name="user-submit" value="<?php _e( 'Log In', 'bbpress' ); ?>" tabindex="<?php bbp_tab_index(); ?>" class="user-submit" />
91
92 <?php bbp_user_login_fields(); ?>
93
94 </div>
95 </fieldset>
96 </form>
97
98 <?php else : ?>
99
100 <div class="bbp-logged-in">
101 <a href="<?php bbp_user_profile_url( bbp_get_current_user_id() ); ?>"><?php echo get_avatar( bbp_get_current_user_id(), '40' ); ?></a>
102 <h4><?php bbp_user_profile_link( bbp_get_current_user_id() ); ?></h4>
103
104 <?php bbp_logout_link(); ?>
105 </div>
106
107 <?php endif;
108
109 echo $after_widget;
110 }
111
112 /**
113 * Update the login widget options
114 *
115 * @since bbPress (r2827)
116 *
117 * @param array $new_instance The new instance options
118 * @param array $old_instance The old instance options
119 */
120 function update( $new_instance, $old_instance ) {
121 $instance = $old_instance;
122 $instance['title'] = strip_tags( $new_instance['title'] );
123
124 return $instance;
125 }
126
127 /**
128 * Output the login widget options form
129 *
130 * @since bbPress (r2827)
131 *
132 * @param $instance Instance
133 * @uses BBP_Login_Widget::get_field_id() To output the field id
134 * @uses BBP_Login_Widget::get_field_name() To output the field name
135 */
136 function form( $instance ) {
137 $title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; ?>
138
139 <p>
140 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?>
141 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></label>
142 </p>
143
144 <?php
145 }
146 }
147
148 /**
149 * bbPress Views Widget
150 *
151 * Adds a widget which displays the view list
152 *
153 * @since bbPress (r3020)
154 *
155 * @uses WP_Widget
156 */
157 class BBP_Views_Widget extends WP_Widget {
158
159 /**
160 * bbPress View Widget
161 *
162 * Registers the view widget
163 *
164 * @since bbPress (r3020)
165 *
166 * @uses apply_filters() Calls 'bbp_views_widget_options' with the
167 * widget options
168 */
169 function BBP_Views_Widget() {
170 $widget_ops = apply_filters( 'bbp_views_widget_options', array(
171 'classname' => 'widget_display_views',
172 'description' => __( 'A list of views.', 'bbpress' )
173 ) );
174
175 parent::WP_Widget( false, __( 'bbPress View List', 'bbpress' ), $widget_ops );
176 }
177
178 /**
179 * Displays the output, the view list
180 *
181 * @since bbPress (r3020)
182 *
183 * @param mixed $args Arguments
184 * @param array $instance Instance
185 * @uses apply_filters() Calls 'bbp_view_widget_title' with the title
186 * @uses bbp_get_views() To get the views
187 * @uses bbp_view_url() To output the view url
188 * @uses bbp_view_title() To output the view title
189 */
190 function widget( $args, $instance ) {
191
192 // Only output widget contents if views exist
193 if ( bbp_get_views() ) :
194
195 extract( $args );
196
197 $title = apply_filters( 'bbp_view_widget_title', $instance['title'] );
198
199 echo $before_widget;
200 echo $before_title . $title . $after_title; ?>
201
202 <ul>
203
204 <?php foreach ( bbp_get_views() as $view => $args ) : ?>
205
206 <li><a class="bbp-view-title" href="<?php bbp_view_url( $view ); ?>" title="<?php bbp_view_title( $view ); ?>"><?php bbp_view_title( $view ); ?></a></li>
207
208 <?php endforeach; ?>
209
210 </ul>
211
212 <?php echo $after_widget;
213
214 endif;
215 }
216
217 /**
218 * Update the view widget options
219 *
220 * @since bbPress (r3020)
221 *
222 * @param array $new_instance The new instance options
223 * @param array $old_instance The old instance options
224 */
225 function update( $new_instance, $old_instance ) {
226 $instance = $old_instance;
227 $instance['title'] = strip_tags( $new_instance['title'] );
228
229 return $instance;
230 }
231
232 /**
233 * Output the view widget options form
234 *
235 * @since bbPress (r3020)
236 *
237 * @param $instance Instance
238 * @uses BBP_Views_Widget::get_field_id() To output the field id
239 * @uses BBP_Views_Widget::get_field_name() To output the field name
240 */
241 function form( $instance ) {
242 $title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; ?>
243
244 <p>
245 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?>
246 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" />
247 </label>
248 </p>
249
250 <?php
251 }
252 }
253
254 /**
255 * bbPress Forum Widget
256 *
257 * Adds a widget which displays the forum list
258 *
259 * @since bbPress (r2653)
260 *
261 * @uses WP_Widget
262 */
263 class BBP_Forums_Widget extends WP_Widget {
264
265 /**
266 * bbPress Forum Widget
267 *
268 * Registers the forum widget
269 *
270 * @since bbPress (r2653)
271 *
272 * @uses apply_filters() Calls 'bbp_forums_widget_options' with the
273 * widget options
274 */
275 function BBP_Forums_Widget() {
276 $widget_ops = apply_filters( 'bbp_forums_widget_options', array(
277 'classname' => 'widget_display_forums',
278 'description' => __( 'A list of forums.', 'bbpress' )
279 ) );
280
281 parent::WP_Widget( false, __( 'bbPress Forum List', 'bbpress' ), $widget_ops );
282 }
283
284 /**
285 * Displays the output, the forum list
286 *
287 * @since bbPress (r2653)
288 *
289 * @param mixed $args Arguments
290 * @param array $instance Instance
291 * @uses apply_filters() Calls 'bbp_forum_widget_title' with the title
292 * @uses get_option() To get the forums per page option
293 * @uses current_user_can() To check if the current user can read
294 * private() To resety name
295 * @uses bbp_set_query_name() To set the query name to 'bbp_widget'
296 * @uses bbp_reset_query_name() To reset the query name
297 * @uses bbp_has_forums() The main forum loop
298 * @uses bbp_forums() To check whether there are more forums available
299 * in the loop
300 * @uses bbp_the_forum() Loads up the current forum in the loop
301 * @uses bbp_forum_permalink() To display the forum permalink
302 * @uses bbp_forum_title() To display the forum title
303 */
304 function widget( $args, $instance ) {
305 extract( $args );
306
307 $title = apply_filters( 'bbp_forum_widget_title', $instance['title'] );
308 $parent_forum = !empty( $instance['parent_forum'] ) ? $instance['parent_forum'] : '0';
309
310 $forums_query = array(
311 'post_parent' => $parent_forum,
312 'posts_per_page' => get_option( '_bbp_forums_per_page', 15 ),
313 'orderby' => 'menu_order',
314 'order' => 'ASC'
315 );
316
317 bbp_set_query_name( 'bbp_widget' );
318
319 if ( bbp_has_forums( $forums_query ) ) :
320
321 echo $before_widget;
322 echo $before_title . $title . $after_title; ?>
323
324 <ul>
325
326 <?php while ( bbp_forums() ) : bbp_the_forum(); ?>
327
328 <li><a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>" title="<?php bbp_forum_title(); ?>"><?php bbp_forum_title(); ?></a></li>
329
330 <?php endwhile; ?>
331
332 </ul>
333
334 <?php echo $after_widget;
335
336 endif;
337
338 bbp_reset_query_name();
339 }
340
341 /**
342 * Update the forum widget options
343 *
344 * @since bbPress (r2653)
345 *
346 * @param array $new_instance The new instance options
347 * @param array $old_instance The old instance options
348 */
349 function update( $new_instance, $old_instance ) {
350 $instance = $old_instance;
351 $instance['title'] = strip_tags( $new_instance['title'] );
352 $instance['parent_forum'] = $new_instance['parent_forum'];
353
354 return $instance;
355 }
356
357 /**
358 * Output the forum widget options form
359 *
360 * @since bbPress (r2653)
361 *
362 * @param $instance Instance
363 * @uses BBP_Forums_Widget::get_field_id() To output the field id
364 * @uses BBP_Forums_Widget::get_field_name() To output the field name
365 */
366 function form( $instance ) {
367 $title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
368 $parent_forum = !empty( $instance['parent_forum'] ) ? esc_attr( $instance['parent_forum'] ) : 0; ?>
369
370 <p>
371 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?>
372 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" />
373 </label>
374 </p>
375
376 <p>
377 <label for="<?php echo $this->get_field_id( 'parent_forum' ); ?>"><?php _e( 'Parent forum:', 'bbpress' ); ?>
378 <input class="widefat" id="<?php echo $this->get_field_id( 'parent_forum' ); ?>" name="<?php echo $this->get_field_name( 'parent_forum' ); ?>" type="text" value="<?php echo $parent_forum; ?>" />
379 </label>
380
381 <br />
382
383 <small><?php _e( 'Forum ID number. "0" to show only root forums, "-1" to display all forums.', 'bbpress' ); ?></small>
384 </p>
385
386 <?php
387 }
388 }
389
390 /**
391 * bbPress Topic Widget
392 *
393 * Adds a widget which displays the topic list
394 *
395 * @since bbPress (r2653)
396 *
397 * @uses WP_Widget
398 */
399 class BBP_Topics_Widget extends WP_Widget {
400
401 /**
402 * bbPress Topic Widget
403 *
404 * Registers the topic widget
405 *
406 * @since bbPress (r2653)
407 *
408 * @uses apply_filters() Calls 'bbp_topics_widget_options' with the
409 * widget options
410 */
411 function BBP_Topics_Widget() {
412 $widget_ops = apply_filters( 'bbp_topics_widget_options', array(
413 'classname' => 'widget_display_topics',
414 'description' => __( 'A list of recent topics, sorted by popularity or freshness.', 'bbpress' )
415 ) );
416
417 parent::WP_Widget( false, __( 'bbPress Topics List', 'bbpress' ), $widget_ops );
418 }
419
420 /**
421 * Displays the output, the topic list
422 *
423 * @since bbPress (r2653)
424 *
425 * @param mixed $args
426 * @param array $instance
427 * @uses apply_filters() Calls 'bbp_topic_widget_title' with the title
428 * @uses bbp_set_query_name() To set the query name to 'bbp_widget'
429 * @uses bbp_reset_query_name() To reset the query name
430 * @uses bbp_has_topics() The main topic loop
431 * @uses bbp_topics() To check whether there are more topics available
432 * in the loop
433 * @uses bbp_the_topic() Loads up the current topic in the loop
434 * @uses bbp_topic_permalink() To display the topic permalink
435 * @uses bbp_topic_title() To display the topic title
436 * @uses bbp_get_topic_last_active_time() To get the topic last active
437 * time
438 * @uses bbp_get_topic_id() To get the topic id
439 * @uses bbp_get_topic_reply_count() To get the topic reply count
440 */
441 function widget( $args, $instance ) {
442 global $bbp;
443
444 extract( $args );
445
446 $title = apply_filters( 'bbp_topic_widget_title', $instance['title'] );
447 $max_shown = !empty( $instance['max_shown'] ) ? (int) $instance['max_shown'] : 5;
448 $show_date = !empty( $instance['show_date'] ) ? 'on' : false;
449 $parent_forum = !empty( $instance['parent_forum'] ) ? $instance['parent_forum'] : 'any';
450 $pop_check = ( $instance['pop_check'] < $max_shown || empty( $instance['pop_check'] ) ) ? -1 : $instance['pop_check'];
451
452 // Query defaults
453 $topics_query = array(
454 'author' => 0,
455 'post_parent' => $parent_forum,
456 'posts_per_page' => $max_shown > $pop_check ? $max_shown : $pop_check,
457 'posts_per_page' => $max_shown,
458 'show_stickies' => false,
459 'order' => 'DESC',
460 );
461
462 bbp_set_query_name( 'bbp_widget' );
463
464 // Remove any topics from hidden forums
465 $topics_query = bbp_exclude_forum_ids( $topics_query );
466
467 if ( $pop_check < $max_shown && bbp_has_topics( $topics_query ) ) :
468
469 echo $before_widget;
470 echo $before_title . $title . $after_title; ?>
471
472 <ul>
473
474 <?php while ( bbp_topics() ) : bbp_the_topic(); ?>
475
476 <li>
477 <a class="bbp-forum-title" href="<?php bbp_topic_permalink(); ?>" title="<?php bbp_topic_title(); ?>"><?php bbp_topic_title(); ?></a><?php if ( $show_date == 'on' ) _e( ', ' . bbp_get_topic_last_active_time() . ' ago' ); ?>
478 </li>
479
480 <?php endwhile; ?>
481
482 </ul>
483
484 <?php echo $after_widget;
485
486 endif;
487
488 if ( $pop_check >= $max_shown && bbp_has_topics( $default ) ) :
489
490 echo $before_widget;
491 echo $before_title . $title . $after_title;
492
493 while ( bbp_topics() ) {
494 bbp_the_topic();
495 $topics[bbp_get_topic_id()] = bbp_get_topic_reply_count();
496 }
497
498 arsort( $topics );
499 $topic_count = 1;
500
501 ?>
502
503 <ul>
504
505 <?php foreach ( $topics as $topic_id => $topic_reply_count ) : ?>
506
507 <li><a class="bbp-topic-title" href="<?php bbp_topic_permalink( $topic_id ); ?>" title="<?php bbp_topic_title( $topic_id ); ?>"><?php bbp_topic_title( $topic_id ); ?></a><?php if ( $show_date == 'on' ) _e( ', ' . bbp_get_topic_last_active_time( $topic_id ) . ' ago' ); ?></li>
508
509 <?php
510
511 $topic_count++;
512
513 if ( $topic_count > $max_shown )
514 break;
515
516 endforeach; ?>
517
518 </ul>
519
520 <?php echo $after_widget;
521
522 endif;
523
524 bbp_reset_query_name();
525
526 }
527
528 /**
529 * Update the forum widget options
530 *
531 * @since bbPress (r2653)
532 *
533 * @param array $new_instance The new instance options
534 * @param array $old_instance The old instance options
535 */
536 function update( $new_instance, $old_instance ) {
537 $instance = $old_instance;
538 $instance['title'] = strip_tags( $new_instance['title'] );
539 $instance['max_shown'] = strip_tags( $new_instance['max_shown'] );
540 $instance['show_date'] = strip_tags( $new_instance['show_date'] );
541 $instance['pop_check'] = strip_tags( $new_instance['pop_check'] );
542
543 return $instance;
544 }
545
546 /**
547 * Output the topic widget options form
548 *
549 * @since bbPress (r2653)
550 *
551 * @param $instance Instance
552 * @uses BBP_Topics_Widget::get_field_id() To output the field id
553 * @uses BBP_Topics_Widget::get_field_name() To output the field name
554 */
555 function form( $instance ) {
556 $title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
557 $max_shown = !empty( $instance['max_shown'] ) ? esc_attr( $instance['max_shown'] ) : '';
558 $show_date = !empty( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
559 $pop_check = !empty( $instance['pop_check'] ) ? esc_attr( $instance['pop_check'] ) : ''; ?>
560
561 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
562 <p><label for="<?php echo $this->get_field_id( 'max_shown' ); ?>"><?php _e( 'Maximum topics to show:', 'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_shown' ); ?>" name="<?php echo $this->get_field_name( 'max_shown' ); ?>" type="text" value="<?php echo $max_shown; ?>" /></label></p>
563 <p><label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Show post date:', 'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" <?php echo ($show_date == 'on') ? 'checked="checked"' : ''; ?>/></label></p>
564 <p>
565 <label for="<?php echo $this->get_field_id( 'pop_check' ); ?>"><?php _e( 'Popularity check:', 'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'pop_check' ); ?>" name="<?php echo $this->get_field_name( 'pop_check' ); ?>" type="text" value="<?php echo $pop_check; ?>" /></label>
566 <br /><small><?php _e( 'Number of topics back to check reply count to determine popularity. A number less than the maximum number of topics to show disables the check.', 'bbpress' ); ?></small>
567 </p>
568
569 <?php
570 }
571 }
572
573 /**
574 * bbPress Replies Widget
575 *
576 * Adds a widget which displays the replies list
577 *
578 * @since bbPress (r2653)
579 *
580 * @uses WP_Widget
581 */
582 class BBP_Replies_Widget extends WP_Widget {
583
584 /**
585 * bbPress Replies Widget
586 *
587 * Registers the replies widget
588 *
589 * @since bbPress (r2653)
590 *
591 * @uses apply_filters() Calls 'bbp_replies_widget_options' with the
592 * widget options
593 */
594 function BBP_Replies_Widget() {
595 $widget_ops = apply_filters( 'bbp_replies_widget_options', array(
596 'classname' => 'widget_display_replies',
597 'description' => __( 'A list of bbPress recent replies.', 'bbpress' )
598 ) );
599
600 parent::WP_Widget( false, 'bbPress Reply List', $widget_ops );
601 }
602
603 /**
604 * Displays the output, the replies list
605 *
606 * @since bbPress (r2653)
607 *
608 * @param mixed $args
609 * @param array $instance
610 * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title
611 * @uses bbp_set_query_name() To set the query name to 'bbp_widget'
612 * @uses bbp_reset_query_name() To reset the query name
613 * @uses bbp_has_replies() The main reply loop
614 * @uses bbp_replies() To check whether there are more replies available
615 * in the loop
616 * @uses bbp_the_reply() Loads up the current reply in the loop
617 * @uses bbp_get_reply_author_link() To get the reply author link
618 * @uses bbp_get_reply_author() To get the reply author name
619 * @uses bbp_get_reply_id() To get the reply id
620 * @uses bbp_get_reply_url() To get the reply url
621 * @uses bbp_get_reply_excerpt() To get the reply excerpt
622 * @uses bbp_get_reply_topic_title() To get the reply topic title
623 * @uses get_the_date() To get the date of the reply
624 * @uses get_the_time() To get the time of the reply
625 */
626 function widget( $args, $instance ) {
627 global $bbp;
628
629 extract( $args );
630
631 $title = apply_filters( 'bbp_replies_widget_title', $instance['title'] );
632 $max_shown = !empty( $instance['max_shown'] ) ? $instance['max_shown'] : '5';
633 $show_date = !empty( $instance['show_date'] ) ? 'on' : false;
634
635 // Query defaults
636 $replies_query = array(
637 'post_status' => join( ',', array( 'publish', $bbp->closed_status_id ) ),
638 'posts_per_page' => $max_shown,
639 'order' => 'DESC'
640 );
641
642 // Set the query name
643 bbp_set_query_name( 'bbp_widget' );
644
645 // Exclude hidden forums
646 $replies_query = bbp_exclude_forum_ids( $replies_query );
647
648 // Get replies and display them
649 if ( bbp_has_replies( $replies_query ) ) :
650
651 echo $before_widget;
652 echo $before_title . $title . $after_title; ?>
653
654 <ul>
655
656 <?php while ( bbp_replies() ) : bbp_the_reply(); ?>
657
658 <li>
659
660 <?php
661 /* translators: bbpress replies widget: 1: reply author, 2: reply link, 3: reply date, 4: reply time */
662 printf( _x( $show_date == 'on' ? '%1$s on %2$s, %3$s, %4$s' : '%1$s on %2$s', 'widgets', 'bbpress' ), bbp_get_reply_author_link( array( 'type' => 'both', 'size' => 14 ) ), '<a class="bbp-reply-topic-title" href="' . esc_url( bbp_get_reply_url() ) . '" title="' . bbp_get_reply_excerpt( bbp_get_reply_id(), 50 ) . '">' . bbp_get_reply_topic_title() . '</a>', get_the_date(), get_the_time() );
663 ?>
664
665 </li>
666
667 <?php endwhile; ?>
668
669 </ul>
670
671 <?php echo $after_widget;
672
673 endif;
674
675 bbp_reset_query_name();
676 }
677
678 /**
679 * Update the forum widget options
680 *
681 * @since bbPress (r2653)
682 *
683 * @param array $new_instance The new instance options
684 * @param array $old_instance The old instance options
685 */
686 function update( $new_instance, $old_instance ) {
687 $instance = $old_instance;
688 $instance['title'] = strip_tags( $new_instance['title'] );
689 $instance['max_shown'] = strip_tags( $new_instance['max_shown'] );
690 $instance['show_date'] = strip_tags( $new_instance['show_date'] );
691
692 return $instance;
693 }
694
695 /**
696 * Output the reply widget options form
697 *
698 * @since bbPress (r2653)
699 *
700 * @param $instance Instance
701 * @uses BBP_Replies_Widget::get_field_id() To output the field id
702 * @uses BBP_Replies_Widget::get_field_name() To output the field name
703 */
704 function form( $instance ) {
705 $title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
706 $max_shown = !empty( $instance['max_shown'] ) ? esc_attr( $instance['max_shown'] ) : '';
707 $show_date = !empty( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : ''; ?>
708
709 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
710 <p><label for="<?php echo $this->get_field_id( 'max_shown' ); ?>"><?php _e( 'Maximum replies to show:', 'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_shown' ); ?>" name="<?php echo $this->get_field_name( 'max_shown' ); ?>" type="text" value="<?php echo $max_shown; ?>" /></label></p>
711 <p><label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Show post date:', 'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" <?php checked( $show_date, 'on' ); ?>/></label></p>
712
713 <?php
714 }
715 }
716
717 ?>
718