PluginProbe
bbPress / 2.0-rc-4
bbPress v2.0-rc-4
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-reply-template.php

bbp-reply-template.php in bbPress 2.0-rc-4, at bbp-includes/bbp-reply-template.php

1,946 lines 61.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress Reply Template Tags
5 *
6 * @package bbPress
7 * @subpackage TemplateTags
8 */
9
10 // Exit if accessed directly
11 if ( !defined( 'ABSPATH' ) ) exit;
12
13 /** Post Type *****************************************************************/
14
15 /**
16 * Return the unique id of the custom post type for replies
17 *
18 * @since bbPress (r2857)
19 *
20 * @uses bbp_get_reply_post_type() To get the reply post type
21 */
22 function bbp_reply_post_type() {
23 echo bbp_get_reply_post_type();
24 }
25 /**
26 * Return the unique id of the custom post type for replies
27 *
28 * @since bbPress (r2857)
29 *
30 * @uses apply_filters() Calls 'bbp_get_forum_post_type' with the forum
31 * post type id
32 * @return string The unique reply post type id
33 */
34 function bbp_get_reply_post_type() {
35 global $bbp;
36
37 return apply_filters( 'bbp_get_reply_post_type', $bbp->reply_post_type );
38 }
39
40 /** Reply Loop Functions ******************************************************/
41
42 /**
43 * The main reply loop. WordPress makes this easy for us
44 *
45 * @since bbPress (r2553)
46 *
47 * @param mixed $args All the arguments supported by {@link WP_Query}
48 * @uses bbp_show_lead_topic() Are we showing the topic as a lead?
49 * @uses bbp_get_topic_id() To get the topic id
50 * @uses bbp_get_reply_post_type() To get the reply post type
51 * @uses bbp_get_topic_post_type() To get the topic post type
52 * @uses bbp_is_query_name() To check if we are getting replies for a widget
53 * @uses get_option() To get the replies per page option
54 * @uses bbp_get_paged() To get the current page value
55 * @uses current_user_can() To check if the current user is capable of editing
56 * others' replies
57 * @uses WP_Query To make query and get the replies
58 * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
59 * @uses get_permalink() To get the permalink
60 * @uses add_query_arg() To add custom args to the url
61 * @uses apply_filters() Calls 'bbp_replies_pagination' with the pagination args
62 * @uses paginate_links() To paginate the links
63 * @uses apply_filters() Calls 'bbp_has_replies' with
64 * bbPres::reply_query::have_posts()
65 * and bbPres::reply_query
66 * @return object Multidimensional array of reply information
67 */
68 function bbp_has_replies( $args = '' ) {
69 global $wp_rewrite, $bbp;
70
71 // Default status
72 $default_status = join( ',', array( 'publish', $bbp->closed_status_id ) );
73
74 // Skip topic_id if in the replies widget query
75 if ( !bbp_is_query_name( 'bbp_widget' ) ) {
76 $parent_args['meta_query'] = array(
77 array(
78 'key' => '_bbp_topic_id',
79 'value' => bbp_get_topic_id(),
80 'compare' => '='
81 )
82 );
83
84 // What are the default allowed statuses (based on user caps)
85 if ( bbp_get_view_all( 'edit_others_replies' ) ) {
86 $default_status = join( ',', array( 'publish', $bbp->closed_status_id, $bbp->spam_status_id, 'trash' ) );
87 }
88 }
89
90 // Default query args
91 $default = array(
92
93 // Post type(s) depending on bbp_show_lead_topic()
94 'post_type' => bbp_show_lead_topic() ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ),
95
96 // 'author', 'date', 'title', 'modified', 'parent', rand',
97 'orderby' => 'date',
98
99 // 'ASC', 'DESC'
100 'order' => 'ASC',
101
102 // Max number
103 'posts_per_page' => get_option( '_bbp_replies_per_page', 15 ),
104
105 // Page Number
106 'paged' => bbp_get_paged(),
107
108 // Reply Search
109 's' => !empty( $_REQUEST['rs'] ) ? $_REQUEST['rs'] : '',
110
111 // Post Status
112 'post_status' => $default_status
113 );
114
115 // Merge the default args and parent args together
116 if ( isset( $parent_args ) )
117 $default = array_merge( $parent_args, $default );
118
119 // Set up topic variables
120 $bbp_r = wp_parse_args( $args, $default );
121
122 // Filter the replies query to allow just-in-time modifications
123 $bbp_r = apply_filters( 'bbp_has_replies_query', $bbp_r );
124
125 // Extract the query variables
126 extract( $bbp_r );
127
128 // Call the query
129 $bbp->reply_query = new WP_Query( $bbp_r );
130
131 // Add pagination values to query object
132 $bbp->reply_query->posts_per_page = $posts_per_page;
133 $bbp->reply_query->paged = $paged;
134
135 // Only add pagination if query returned results
136 if ( !bbp_is_query_name( 'bbp_widget' ) && (int) $bbp->reply_query->found_posts && (int) $bbp->reply_query->posts_per_page ) {
137
138 // If pretty permalinks are enabled, make our pagination pretty
139 if ( $wp_rewrite->using_permalinks() ) {
140
141 // Page or single
142 if ( is_page() || is_single() ) {
143 $base = get_permalink();
144
145 // Topic
146 } else {
147 $base = get_permalink( bbp_get_topic_id() );
148 }
149
150 $base = trailingslashit( $base ) . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
151
152 // Unpretty permalinks
153 } else {
154 $base = add_query_arg( 'paged', '%#%' );
155 }
156
157 // Pagination settings with filter
158 $bbp_replies_pagination = apply_filters( 'bbp_replies_pagination', array(
159 'base' => $base,
160 'format' => '',
161 'total' => ceil( (int) $bbp->reply_query->found_posts / (int) $posts_per_page ),
162 'current' => (int) $bbp->reply_query->paged,
163 'prev_text' => '&larr;',
164 'next_text' => '&rarr;',
165 'mid_size' => 1,
166 'add_args' => ( bbp_get_view_all() ) ? array( 'view' => 'all' ) : false
167 ) );
168
169 // Add pagination to query object
170 $bbp->reply_query->pagination_links = paginate_links( $bbp_replies_pagination );
171
172 // Remove first page from pagination
173 if ( $wp_rewrite->using_permalinks() )
174 $bbp->reply_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links );
175 else
176 $bbp->reply_query->pagination_links = str_replace( '&#038;paged=1', '', $bbp->reply_query->pagination_links );
177 }
178
179 // Return object
180 return apply_filters( 'bbp_has_replies', $bbp->reply_query->have_posts(), $bbp->reply_query );
181 }
182
183 /**
184 * Whether there are more replies available in the loop
185 *
186 * @since bbPress (r2553)
187 *
188 * @uses WP_Query bbPress::reply_query::have_posts() To check if there are more
189 * replies available
190 * @return object Replies information
191 */
192 function bbp_replies() {
193 global $bbp;
194
195 // Put into variable to check against next
196 $have_posts = $bbp->reply_query->have_posts();
197
198 // Reset the post data when finished
199 if ( empty( $have_posts ) )
200 wp_reset_postdata();
201
202 return $have_posts;
203 }
204
205 /**
206 * Loads up the current reply in the loop
207 *
208 * @since bbPress (r2553)
209 *
210 * @uses WP_Query bbPress::reply_query::the_post() To get the current reply
211 * @return object Reply information
212 */
213 function bbp_the_reply() {
214 global $bbp;
215 return $bbp->reply_query->the_post();
216 }
217
218 /**
219 * Output reply id
220 *
221 * @since bbPress (r2553)
222 *
223 * @param $reply_id Optional. Used to check emptiness
224 * @uses bbp_get_reply_id() To get the reply id
225 */
226 function bbp_reply_id( $reply_id = 0 ) {
227 echo bbp_get_reply_id( $reply_id );
228 }
229 /**
230 * Return the id of the reply in a replies loop
231 *
232 * @since bbPress (r2553)
233 *
234 * @param $reply_id Optional. Used to check emptiness
235 * @uses bbPress::reply_query::post::ID To get the reply id
236 * @uses bbp_is_reply() To check if it's a reply page
237 * @uses bbp_is_reply_edit() To check if it's a reply edit page
238 * @uses get_post_field() To get the post's post type
239 * @uses WP_Query::post::ID To get the reply id
240 * @uses bbp_get_reply_post_type() To get the reply post type
241 * @uses apply_filters() Calls 'bbp_get_reply_id' with the reply id and
242 * supplied reply id
243 * @return int The reply id
244 */
245 function bbp_get_reply_id( $reply_id = 0 ) {
246 global $bbp, $wp_query;
247
248 // Easy empty checking
249 if ( !empty( $reply_id ) && is_numeric( $reply_id ) )
250 $bbp_reply_id = $reply_id;
251
252 // Currently inside a replies loop
253 elseif ( isset( $bbp->reply_query->post->ID ) )
254 $bbp_reply_id = $bbp->current_reply_id = $bbp->reply_query->post->ID;
255
256 // Currently viewing a reply
257 elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) )
258 $bbp_reply_id = $bbp->current_reply_id = $wp_query->post->ID;
259
260 // Fallback
261 else
262 $bbp_reply_id = 0;
263
264 // Check if current_reply_id is set, and check post_type if so
265 if ( !empty( $bbp->current_reply_id ) && ( bbp_get_reply_post_type() != get_post_field( 'post_type', $bbp_reply_id ) ) )
266 $bbp->current_reply_id = null;
267
268 return apply_filters( 'bbp_get_reply_id', (int) $bbp_reply_id, $reply_id );
269 }
270
271 /**
272 * Gets a reply
273 *
274 * @since bbPress (r2787)
275 *
276 * @param int|object $reply reply id or reply object
277 * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT
278 * @param string $filter Optional Sanitation filter. See {@link sanitize_post()}
279 * @uses get_post() To get the reply
280 * @uses bbp_get_reply_post_type() To get the reply post type
281 * @uses apply_filters() Calls 'bbp_get_reply' with the reply, output type and
282 * sanitation filter
283 * @return mixed Null if error or reply (in specified form) if success
284 */
285 function bbp_get_reply( $reply, $output = OBJECT, $filter = 'raw' ) {
286 if ( empty( $reply ) || is_numeric( $reply ) )
287 $reply = bbp_get_reply_id( $reply );
288
289 if ( !$reply = get_post( $reply, OBJECT, $filter ) )
290 return $reply;
291
292 if ( $reply->post_type !== bbp_get_reply_post_type() )
293 return null;
294
295 if ( $output == OBJECT ) {
296 return $reply;
297
298 } elseif ( $output == ARRAY_A ) {
299 $_reply = get_object_vars( $reply );
300 return $_reply;
301
302 } elseif ( $output == ARRAY_N ) {
303 $_reply = array_values( get_object_vars( $reply ) );
304 return $_reply;
305
306 }
307
308 return apply_filters( 'bbp_get_reply', $reply, $output, $filter );
309 }
310
311 /**
312 * Output the link to the reply in the reply loop
313 *
314 * @since bbPress (r2553)
315 *
316 * @param int $reply_id Optional. Reply id
317 * @uses bbp_get_reply_permalink() To get the reply permalink
318 */
319 function bbp_reply_permalink( $reply_id = 0 ) {
320 echo bbp_get_reply_permalink( $reply_id );
321 }
322 /**
323 * Return the link to the reply
324 *
325 * @since bbPress (r2553)
326 *
327 * @param int $reply_id Optional. Reply id
328 * @uses bbp_get_reply_id() To get the reply id
329 * @uses get_permalink() To get the permalink of the reply
330 * @uses apply_filters() Calls 'bbp_get_reply_permalink' with the link
331 * and reply id
332 * @return string Permanent link to reply
333 */
334 function bbp_get_reply_permalink( $reply_id = 0 ) {
335 $reply_id = bbp_get_reply_id( $reply_id );
336
337 return apply_filters( 'bbp_get_reply_permalink', get_permalink( $reply_id ), $reply_id );
338 }
339 /**
340 * Output the paginated url to the reply in the reply loop
341 *
342 * @since bbPress (r2679)
343 *
344 * @param int $reply_id Optional. Reply id
345 * @uses bbp_get_reply_url() To get the reply url
346 */
347 function bbp_reply_url( $reply_id = 0 ) {
348 echo bbp_get_reply_url( $reply_id );
349 }
350 /**
351 * Return the paginated url to the reply in the reply loop
352 *
353 * @since bbPress (r2679)
354 *
355 * @param int $reply_id Optional. Reply id
356 * @param $string $redirect_to Optional. Pass a redirect value for use with
357 * shortcodes and other fun things.
358 * @uses bbp_get_reply_id() To get the reply id
359 * @uses bbp_get_reply_topic_id() To get the reply topic id
360 * @uses bbp_get_topic_permalink() To get the topic permalink
361 * @uses bbp_get_reply_position() To get the reply position
362 * @uses get_option() To get the replies per page option
363 * @uses WP_Rewrite::using_permalinks() To check if the blog uses
364 * permalinks
365 * @uses add_query_arg() To add custom args to the url
366 * @uses apply_filters() Calls 'bbp_get_reply_url' with the reply url,
367 * reply id and bool count hidden
368 * @return string Link to reply relative to paginated topic
369 */
370 function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) {
371 global $bbp, $wp_rewrite;
372
373 // Set needed variables
374 $reply_id = bbp_get_reply_id ( $reply_id );
375 $topic_id = bbp_get_reply_topic_id ( $reply_id );
376 $topic_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
377 $reply_position = bbp_get_reply_position ( $reply_id, $topic_id );
378
379 // Check if in query with pagination
380 $reply_page = ceil( $reply_position / get_option( '_bbp_replies_per_page', 15 ) );
381
382 // Hash to add to end of URL
383 $reply_hash = '#post-' . $reply_id;
384
385 // Remove the topic view query arg if its set
386 $topic_url = remove_query_arg( 'view', $topic_url );
387
388 // Don't include pagination if on first page
389 if ( 1 >= $reply_page ) {
390 $url = trailingslashit( $topic_url ) . $reply_hash;
391
392 // Include pagination
393 } else {
394
395 // Pretty permalinks
396 if ( $wp_rewrite->using_permalinks() ) {
397 $url = trailingslashit( $topic_url ) . trailingslashit( $wp_rewrite->pagination_base ) . trailingslashit( $reply_page ) . $reply_hash;
398
399 // Yucky links
400 } else {
401 $url = add_query_arg( 'paged', $reply_page, $topic_url ) . $reply_hash;
402 }
403 }
404
405 // Add topic view query arg back to end if it is set
406 if ( bbp_get_view_all() )
407 $url = bbp_add_view_all( $url );
408
409 return apply_filters( 'bbp_get_reply_url', $url, $reply_id, $redirect_to );
410 }
411
412 /**
413 * Output the title of the reply
414 *
415 * @since bbPress (r2553)
416 *
417 * @param int $reply_id Optional. Reply id
418 * @uses bbp_get_reply_title() To get the reply title
419 */
420 function bbp_reply_title( $reply_id = 0 ) {
421 echo bbp_get_reply_title( $reply_id );
422 }
423
424 /**
425 * Return the title of the reply
426 *
427 * @since bbPress (r2553)
428 *
429 * @param int $reply_id Optional. Reply id
430 * @uses bbp_get_reply_id() To get the reply id
431 * @uses get_the_title() To get the reply title
432 * @uses apply_filters() Calls 'bbp_get_reply_title' with the title and
433 * reply id
434 * @return string Title of reply
435 */
436 function bbp_get_reply_title( $reply_id = 0 ) {
437 $reply_id = bbp_get_reply_id( $reply_id );
438
439 return apply_filters( 'bbp_get_reply_title', get_the_title( $reply_id ), $reply_id );
440 }
441
442 /**
443 * Output the content of the reply
444 *
445 * @since bbPress (r2553)
446 *
447 * @param int $reply_id Optional. reply id
448 * @uses bbp_get_reply_content() To get the reply content
449 */
450 function bbp_reply_content( $reply_id = 0 ) {
451 echo bbp_get_reply_content( $reply_id );
452 }
453 /**
454 * Return the content of the reply
455 *
456 * @since bbPress (r2780)
457 *
458 * @param int $reply_id Optional. reply id
459 * @uses bbp_get_reply_id() To get the reply id
460 * @uses post_password_required() To check if the reply requires pass
461 * @uses get_the_password_form() To get the password form
462 * @uses get_post_field() To get the content post field
463 * @uses apply_filters() Calls 'bbp_get_reply_content' with the content
464 * and reply id
465 * @return string Content of the reply
466 */
467 function bbp_get_reply_content( $reply_id = 0 ) {
468 $reply_id = bbp_get_reply_id( $reply_id );
469
470 // Check if password is required
471 if ( post_password_required( $reply_id ) )
472 return get_the_password_form();
473
474 $content = get_post_field( 'post_content', $reply_id );
475
476 return apply_filters( 'bbp_get_reply_content', $content, $reply_id );
477 }
478
479 /**
480 * Output the excerpt of the reply
481 *
482 * @since bbPress (r2751)
483 *
484 * @param int $reply_id Optional. Reply id
485 * @param int $length Optional. Length of the excerpt. Defaults to 100 letters
486 * @uses bbp_get_reply_excerpt() To get the reply excerpt
487 */
488 function bbp_reply_excerpt( $reply_id = 0, $length = 100 ) {
489 echo bbp_get_reply_excerpt( $reply_id, $length );
490 }
491 /**
492 * Return the excerpt of the reply
493 *
494 * @since bbPress (r2751)
495 *
496 * @param int $reply_id Optional. Reply id
497 * @param int $length Optional. Length of the excerpt. Defaults to 100
498 * letters
499 * @uses bbp_get_reply_id() To get the reply id
500 * @uses get_post_field() To get the excerpt
501 * @uses bbp_get_reply_content() To get the reply content
502 * @uses apply_filters() Calls 'bbp_get_reply_excerpt' with the excerpt,
503 * reply id and length
504 * @return string Reply Excerpt
505 */
506 function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) {
507 $reply_id = bbp_get_reply_id( $reply_id );
508 $length = (int) $length;
509 $excerpt = get_post_field( $reply_id, 'post_excerpt' );
510
511 if ( empty( $excerpt ) )
512 $excerpt = bbp_get_reply_content( $reply_id );
513
514 $excerpt = trim ( strip_tags( $excerpt ) );
515
516 if ( !empty( $length ) && strlen( $excerpt ) > $length ) {
517 $excerpt = substr( $excerpt, 0, $length - 1 );
518 $excerpt .= '&hellip;';
519 }
520
521 return apply_filters( 'bbp_get_reply_excerpt', $excerpt, $reply_id, $length );
522 }
523
524 /**
525 * Append revisions to the reply content
526 *
527 * @since bbPress (r2782)
528 *
529 * @param string $content Optional. Content to which we need to append the revisions to
530 * @param int $reply_id Optional. Reply id
531 * @uses bbp_get_reply_revision_log() To get the reply revision log
532 * @uses apply_filters() Calls 'bbp_reply_append_revisions' with the processed
533 * content, original content and reply id
534 * @return string Content with the revisions appended
535 */
536 function bbp_reply_content_append_revisions( $content = '', $reply_id = 0 ) {
537
538 // Bail if in admin
539 if ( is_admin() )
540 return;
541
542 // Validate the ID
543 $reply_id = bbp_get_reply_id( $reply_id );
544
545 return apply_filters( 'bbp_reply_append_revisions', $content . bbp_get_reply_revision_log( $reply_id ), $content, $reply_id );
546 }
547
548 /**
549 * Output the revision log of the reply
550 *
551 * @since bbPress (r2782)
552 *
553 * @param int $reply_id Optional. Reply id
554 * @uses bbp_get_reply_revision_log() To get the reply revision log
555 */
556 function bbp_reply_revision_log( $reply_id = 0 ) {
557 echo bbp_get_reply_revision_log( $reply_id );
558 }
559 /**
560 * Return the formatted revision log of the reply
561 *
562 * @since bbPress (r2782)
563 *
564 * @param int $reply_id Optional. Reply id
565 * @uses bbp_get_reply_id() To get the reply id
566 * @uses bbp_get_reply_revisions() To get the reply revisions
567 * @uses bbp_get_reply_raw_revision_log() To get the raw revision log
568 * @uses bbp_get_reply_author_display_name() To get the reply author
569 * @uses bbp_get_reply_author_link() To get the reply author link
570 * @uses bbp_convert_date() To convert the date
571 * @uses bbp_get_time_since() To get the time in since format
572 * @uses apply_filters() Calls 'bbp_get_reply_revision_log' with the
573 * log and reply id
574 * @return string Revision log of the reply
575 */
576 function bbp_get_reply_revision_log( $reply_id = 0 ) {
577
578 // Create necessary variables
579 $reply_id = bbp_get_reply_id( $reply_id );
580 $revision_log = bbp_get_reply_raw_revision_log( $reply_id );
581
582 // Check reply and revision log exist
583 if ( empty( $reply_id ) || empty( $revision_log ) || !is_array( $revision_log ) )
584 return false;
585
586 // Get the actual revisions
587 if ( !$revisions = bbp_get_reply_revisions( $reply_id ) )
588 return false;
589
590 $r = "\n\n" . '<ul id="bbp-reply-revision-log-' . $reply_id . '" class="bbp-reply-revision-log">' . "\n\n";
591
592 // Loop through revisions
593 foreach ( (array) $revisions as $revision ) {
594
595 if ( empty( $revision_log[$revision->ID] ) ) {
596 $author_id = $revision->post_author;
597 $reason = '';
598 } else {
599 $author_id = $revision_log[$revision->ID]['author'];
600 $reason = $revision_log[$revision->ID]['reason'];
601 }
602
603 $author = bbp_get_author_link( array( 'size' => 14, 'link_text' => bbp_get_reply_author_display_name( $revision->ID ), 'post_id' => $revision->ID ) );
604 $since = bbp_get_time_since( bbp_convert_date( $revision->post_modified ) );
605
606 $r .= "\t" . '<li id="bbp-reply-revision-log-' . $reply_id . '-item-' . $revision->ID . '" class="bbp-reply-revision-log-item">' . "\n";
607 $r .= "\t\t" . sprintf( __( empty( $reason ) ? 'This reply was modified %1$s ago by %2$s.' : 'This reply was modified %1$s ago by %2$s. Reason: %3$s', 'bbpress' ), $since, $author, $reason ) . "\n";
608 $r .= "\t" . '</li>' . "\n";
609
610 }
611
612 $r .= "\n" . '</ul>' . "\n\n";
613
614 return apply_filters( 'bbp_get_reply_revision_log', $r, $reply_id );
615 }
616 /**
617 * Return the raw revision log of the reply
618 *
619 * @since bbPress (r2782)
620 *
621 * @param int $reply_id Optional. Reply id
622 * @uses bbp_get_reply_id() To get the reply id
623 * @uses get_post_meta() To get the revision log meta
624 * @uses apply_filters() Calls 'bbp_get_reply_raw_revision_log'
625 * with the log and reply id
626 * @return string Raw revision log of the reply
627 */
628 function bbp_get_reply_raw_revision_log( $reply_id = 0 ) {
629 $reply_id = bbp_get_reply_id( $reply_id );
630 $revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true );
631 $revision_log = empty( $revision_log ) ? array() : $revision_log;
632
633 return apply_filters( 'bbp_get_reply_raw_revision_log', $revision_log, $reply_id );
634 }
635
636 /**
637 * Return the revisions of the reply
638 *
639 * @since bbPress (r2782)
640 *
641 * @param int $reply_id Optional. Reply id
642 * @uses bbp_get_reply_id() To get the reply id
643 * @uses wp_get_post_revisions() To get the reply revisions
644 * @uses apply_filters() Calls 'bbp_get_reply_revisions'
645 * with the revisions and reply id
646 * @return string reply revisions
647 */
648 function bbp_get_reply_revisions( $reply_id = 0 ) {
649 $reply_id = bbp_get_reply_id( $reply_id );
650 $revisions = wp_get_post_revisions( $reply_id, array( 'order' => 'ASC' ) );
651
652 return apply_filters( 'bbp_get_reply_revisions', $revisions, $reply_id );
653 }
654
655 /**
656 * Return the revision count of the reply
657 *
658 * @since bbPress (r2782)
659 *
660 * @param int $reply_id Optional. Reply id
661 * @uses bbp_get_reply_revisions() To get the reply revisions
662 * @uses apply_filters() Calls 'bbp_get_reply_revision_count'
663 * with the revision count and reply id
664 * @return string reply revision count
665 */
666 function bbp_get_reply_revision_count( $reply_id = 0 ) {
667 return apply_filters( 'bbp_get_reply_revisions', count( bbp_get_reply_revisions( $reply_id ) ), $reply_id );
668 }
669
670 /**
671 * Output the status of the reply
672 *
673 * @since bbPress (r2667)
674 *
675 * @param int $reply_id Optional. Reply id
676 * @uses bbp_get_reply_status() To get the reply status
677 */
678 function bbp_reply_status( $reply_id = 0 ) {
679 echo bbp_get_reply_status( $reply_id );
680 }
681 /**
682 * Return the status of the reply
683 *
684 * @since bbPress (r2667)
685 *
686 * @param int $reply_id Optional. Reply id
687 * @uses bbp_get_reply_id() To get the reply id
688 * @uses get_post_status() To get the reply status
689 * @uses apply_filters() Calls 'bbp_get_reply_status' with the reply id
690 * @return string Status of reply
691 */
692 function bbp_get_reply_status( $reply_id = 0 ) {
693 $reply_id = bbp_get_reply_id( $reply_id );
694
695 return apply_filters( 'bbp_get_reply_status', get_post_status( $reply_id ), $reply_id );
696 }
697
698 /**
699 * Is the reply marked as spam?
700 *
701 * @since bbPress (r2740)
702 *
703 * @param int $reply_id Optional. Reply id
704 * @uses bbp_get_reply_id() To get the reply id
705 * @uses bbp_get_reply_status() To get the reply status
706 * @return bool True if spam, false if not.
707 */
708 function bbp_is_reply_spam( $reply_id = 0 ) {
709 global $bbp;
710
711 $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) );
712
713 return apply_filters( 'bbp_is_reply_spam', $bbp->spam_status_id == $reply_status, $reply_id );
714 }
715
716 /**
717 * Is the reply trashed?
718 *
719 * @since bbPress (r2884)
720 *
721 * @param int $reply_id Optional. Topic id
722 * @uses bbp_get_reply_id() To get the reply id
723 * @uses bbp_get_reply_status() To get the reply status
724 * @return bool True if spam, false if not.
725 */
726 function bbp_is_reply_trash( $reply_id = 0 ) {
727 global $bbp;
728
729 $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) );
730
731 return apply_filters( 'bbp_is_reply_trash', $bbp->trash_status_id == $reply_status, $reply_id );
732 }
733
734 /**
735 * Is the reply by an anonymous user?
736 *
737 * @since bbPress (r2753)
738 *
739 * @param int $reply_id Optional. Reply id
740 * @uses bbp_get_reply_id() To get the reply id
741 * @uses bbp_get_reply_author_id() To get the reply author id
742 * @uses get_post_meta() To get the anonymous name and email metas
743 * @return bool True if the post is by an anonymous user, false if not.
744 */
745 function bbp_is_reply_anonymous( $reply_id = 0 ) {
746 $reply_id = bbp_get_reply_id( $reply_id );
747
748 $retval = false;
749
750 if ( !bbp_get_reply_author_id( $reply_id ) )
751 $retval = true;
752
753 elseif ( get_post_meta( $reply_id, '_bbp_anonymous_name', true ) )
754 $retval = true;
755
756 elseif ( get_post_meta( $reply_id, '_bbp_anonymous_email', true ) )
757 $retval = true;
758
759 return apply_filters( 'bbp_is_reply_anonymous', $retval );
760 }
761
762 /**
763 * Output the author of the reply
764 *
765 * @since bbPress (r2667)
766 *
767 * @param int $reply_id Optional. Reply id
768 * @uses bbp_get_reply_author() To get the reply author
769 */
770 function bbp_reply_author( $reply_id = 0 ) {
771 echo bbp_get_reply_author( $reply_id );
772 }
773 /**
774 * Return the author of the reply
775 *
776 * @since bbPress (r2667)
777 *
778 * @param int $reply_id Optional. Reply id
779 * @uses bbp_get_reply_id() To get the reply id
780 * @uses bbp_is_reply_anonymous() To check if the reply is by an
781 * anonymous user
782 * @uses get_the_author_meta() To get the reply author display name
783 * @uses get_post_meta() To get the anonymous poster name
784 * @uses apply_filters() Calls 'bbp_get_reply_author' with the reply
785 * author and reply id
786 * @return string Author of reply
787 */
788 function bbp_get_reply_author( $reply_id = 0 ) {
789 $reply_id = bbp_get_reply_id( $reply_id );
790
791 if ( !bbp_is_reply_anonymous( $reply_id ) )
792 $author = get_the_author_meta( 'display_name', bbp_get_reply_author_id( $reply_id ) );
793 else
794 $author = get_post_meta( $reply_id, '_bbp_anonymous_name', true );
795
796 return apply_filters( 'bbp_get_reply_author', $author, $reply_id );
797 }
798
799 /**
800 * Output the author ID of the reply
801 *
802 * @since bbPress (r2667)
803 *
804 * @param int $reply_id Optional. Reply id
805 * @uses bbp_get_reply_author_id() To get the reply author id
806 */
807 function bbp_reply_author_id( $reply_id = 0 ) {
808 echo bbp_get_reply_author_id( $reply_id );
809 }
810 /**
811 * Return the author ID of the reply
812 *
813 * @since bbPress (r2667)
814 *
815 * @param int $reply_id Optional. Reply id
816 * @uses bbp_get_reply_id() To get the reply id
817 * @uses get_post_field() To get the reply author id
818 * @uses apply_filters() Calls 'bbp_get_reply_author_id' with the author
819 * id and reply id
820 * @return string Author id of reply
821 */
822 function bbp_get_reply_author_id( $reply_id = 0 ) {
823 $reply_id = bbp_get_reply_id( $reply_id );
824 $author_id = get_post_field( 'post_author', $reply_id );
825
826 return apply_filters( 'bbp_get_reply_author_id', (int) $author_id, $reply_id );
827 }
828
829 /**
830 * Output the author display_name of the reply
831 *
832 * @since bbPress (r2667)
833 *
834 * @param int $reply_id Optional. Reply id
835 * @uses bbp_get_reply_author_display_name()
836 */
837 function bbp_reply_author_display_name( $reply_id = 0 ) {
838 echo bbp_get_reply_author_display_name( $reply_id );
839 }
840 /**
841 * Return the author display_name of the reply
842 *
843 * @since bbPress (r2667)
844 *
845 * @param int $reply_id Optional. Reply id
846 * @uses bbp_get_reply_id() To get the reply id
847 * @uses bbp_is_reply_anonymous() To check if the reply is by an
848 * anonymous user
849 * @uses bbp_get_reply_author_id() To get the reply author id
850 * @uses get_the_author_meta() To get the reply author's display name
851 * @uses get_post_meta() To get the anonymous poster's name
852 * @uses apply_filters() Calls 'bbp_get_reply_author_display_name' with
853 * the author display name and reply id
854 * @return string Reply's author's display name
855 */
856 function bbp_get_reply_author_display_name( $reply_id = 0 ) {
857 $reply_id = bbp_get_reply_id( $reply_id );
858
859 // Check for anonymous user
860 if ( !bbp_is_reply_anonymous( $reply_id ) )
861 $author_name = get_the_author_meta( 'display_name', bbp_get_reply_author_id( $reply_id ) );
862 else
863 $author_name = get_post_meta( $reply_id, '_bbp_anonymous_name', true );
864
865 return apply_filters( 'bbp_get_reply_author_display_name', esc_attr( $author_name ), $reply_id );
866 }
867
868 /**
869 * Output the author avatar of the reply
870 *
871 * @since bbPress (r2667)
872 *
873 * @param int $reply_id Optional. Reply id
874 * @param int $size Optional. Size of the avatar. Defaults to 40
875 * @uses bbp_get_reply_author_avatar() To get the reply author id
876 */
877 function bbp_reply_author_avatar( $reply_id = 0, $size = 40 ) {
878 echo bbp_get_reply_author_avatar( $reply_id, $size );
879 }
880 /**
881 * Return the author avatar of the reply
882 *
883 * @since bbPress (r2667)
884 *
885 * @param int $reply_id Optional. Reply id
886 * @param int $size Optional. Size of the avatar. Defaults to 40
887 * @uses bbp_get_reply_id() To get the reply id
888 * @uses bbp_is_reply_anonymous() To check if the reply is by an
889 * anonymous user
890 * @uses bbp_get_reply_author_id() To get the reply author id
891 * @uses get_post_meta() To get the anonymous poster's email id
892 * @uses get_avatar() To get the avatar
893 * @uses apply_filters() Calls 'bbp_get_reply_author_avatar' with the
894 * author avatar, reply id and size
895 * @return string Avatar of author of the reply
896 */
897 function bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) {
898 if ( $reply_id = bbp_get_reply_id( $reply_id ) ) {
899 // Check for anonymous user
900 if ( !bbp_is_reply_anonymous( $reply_id ) )
901 $author_avatar = get_avatar( bbp_get_reply_author_id( $reply_id ), $size );
902 else
903 $author_avatar = get_avatar( get_post_meta( $reply_id, '_bbp_anonymous_email', true ), $size );
904 } else {
905 $author_avatar = '';
906 }
907
908 return apply_filters( 'bbp_get_reply_author_avatar', $author_avatar, $reply_id, $size );
909 }
910
911 /**
912 * Output the author link of the reply
913 *
914 * @since bbPress (r2717)
915 *
916 * @param mixed $args Optional. If it is an integer, it is used as reply id.
917 * @uses bbp_get_reply_author_link() To get the reply author link
918 */
919 function bbp_reply_author_link( $args = '' ) {
920 echo bbp_get_reply_author_link( $args );
921 }
922 /**
923 * Return the author link of the reply
924 *
925 * @since bbPress (r2717)
926 *
927 * @param mixed $args Optional. If an integer, it is used as reply id.
928 * @uses bbp_get_reply_id() To get the reply id
929 * @uses bbp_is_reply_anonymous() To check if the reply is by an
930 * anonymous user
931 * @uses bbp_get_reply_author() To get the reply author name
932 * @uses bbp_get_reply_author_url() To get the reply author url
933 * @uses bbp_get_reply_author_avatar() To get the reply author avatar
934 * bbp_get_reply_author_display_name() To get the reply author display
935 * name
936 * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the
937 * author link and args
938 * @return string Author link of reply
939 */
940 function bbp_get_reply_author_link( $args = '' ) {
941 $defaults = array (
942 'post_id' => 0,
943 'link_title' => '',
944 'type' => 'both',
945 'size' => 80
946 );
947
948 $r = wp_parse_args( $args, $defaults );
949 extract( $r );
950
951 // Used as reply_id
952 if ( is_numeric( $args ) )
953 $reply_id = bbp_get_reply_id( $args );
954 else
955 $reply_id = bbp_get_reply_id( $post_id );
956
957 if ( !empty( $reply_id ) ) {
958 if ( empty( $link_title ) )
959 $link_title = sprintf( !bbp_is_reply_anonymous( $reply_id ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), bbp_get_reply_author_display_name( $reply_id ) );
960
961 $link_title = !empty( $link_title ) ? ' title="' . $link_title . '"' : '';
962 $author_url = bbp_get_reply_author_url( $reply_id );
963 $anonymous = bbp_is_reply_anonymous( $reply_id );
964
965 // Get avatar
966 if ( 'avatar' == $type || 'both' == $type )
967 $author_links[] = bbp_get_reply_author_avatar( $reply_id, $size );
968
969 // Get display name
970 if ( 'name' == $type || 'both' == $type )
971 $author_links[] = bbp_get_reply_author_display_name( $reply_id );
972
973 // Add links if not anonymous
974 if ( empty( $anonymous ) ) {
975 foreach ( $author_links as $link_text ) {
976 $author_link[] = sprintf( '<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text );
977 }
978 $author_link = join( '&nbsp;', $author_link );
979
980 // No links if anonymous
981 } else {
982 $author_link = join( '&nbsp;', $author_links );
983 }
984
985 // No replies so link is empty
986 } else {
987 $author_link = '';
988 }
989
990 return apply_filters( 'bbp_get_reply_author_link', $author_link, $args );
991 }
992
993 /**
994 * Output the author url of the reply
995 *
996 * @since bbPress (r2667)
997 *
998 * @param int $reply_id Optional. Reply id
999 * @uses bbp_get_reply_author_url() To get the reply author url
1000 */
1001 function bbp_reply_author_url( $reply_id = 0 ) {
1002 echo bbp_get_reply_author_url( $reply_id );
1003 }
1004 /**
1005 * Return the author url of the reply
1006 *
1007 * @since bbPress (r2667)
1008 *
1009 * @param int $reply_id Optional. Reply id
1010 * @uses bbp_get_reply_id() To get the reply id
1011 * @uses bbp_is_reply_anonymous() To check if the reply
1012 * is by an anonymous
1013 * user
1014 * @uses bbp_get_reply_author_id() To get the reply
1015 * author id
1016 * @uses bbp_get_user_profile_url() To get the user
1017 * profile url
1018 * @uses get_post_meta() To get the anonymous poster's
1019 * website url
1020 * @uses apply_filters() Calls bbp_get_reply_author_url
1021 * with the author url & reply id
1022 * @return string Author URL of the reply
1023 */
1024 function bbp_get_reply_author_url( $reply_id = 0 ) {
1025 $reply_id = bbp_get_reply_id( $reply_id );
1026
1027 // Check for anonymous user
1028 if ( !bbp_is_reply_anonymous( $reply_id ) ) {
1029 $author_url = bbp_get_user_profile_url( bbp_get_reply_author_id( $reply_id ) );
1030 } else {
1031 if ( !$author_url = get_post_meta( $reply_id, '_bbp_anonymous_website', true ) ) {
1032 $author_url = '';
1033 }
1034 }
1035
1036 return apply_filters( 'bbp_get_reply_author_url', $author_url, $reply_id );
1037 }
1038
1039 /**
1040 * Output the reply author email address
1041 *
1042 * @since bbPress (r3445)
1043 *
1044 * @param int $reply_id Optional. Reply id
1045 * @uses bbp_get_reply_author_email() To get the reply author email
1046 */
1047 function bbp_reply_author_email( $reply_id = 0 ) {
1048 echo bbp_get_reply_author_email( $reply_id );
1049 }
1050 /**
1051 * Return the reply author email address
1052 *
1053 * @since bbPress (r3445)
1054 *
1055 * @param int $reply_id Optional. Reply id
1056 * @uses bbp_get_reply_id() To get the reply id
1057 * @uses bbp_is_reply_anonymous() To check if the reply is by an anonymous
1058 * user
1059 * @uses bbp_get_reply_author_id() To get the reply author id
1060 * @uses get_userdata() To get the user data
1061 * @uses get_post_meta() To get the anonymous poster's website email
1062 * @uses apply_filters() Calls bbp_get_reply_author_email with the author
1063 * email & reply id
1064 * @return string Reply author email address
1065 */
1066 function bbp_get_reply_author_email( $reply_id = 0 ) {
1067 $reply_id = bbp_get_reply_id( $reply_id );
1068
1069 // Not anonymous
1070 if ( !bbp_is_reply_anonymous( $reply_id ) ) {
1071
1072 // Use reply author email address
1073 $user_id = bbp_get_reply_author_id( $reply_id );
1074 $user = get_userdata( $user_id );
1075 $author_email = !empty( $user->user_email ) ? $user->user_email : '';
1076
1077 // Anonymous
1078 } else {
1079
1080 // Get email from post meta
1081 $author_email = get_post_meta( $reply_id, '_bbp_anonymous_email', true );
1082
1083 // Sanity check for missing email address
1084 if ( empty( $author_email ) ) {
1085 $author_email = '';
1086 }
1087 }
1088
1089 return apply_filters( 'bbp_get_reply_author_email', $author_email, $reply_id );
1090 }
1091
1092 /**
1093 * Output the topic title a reply belongs to
1094 *
1095 * @since bbPress (r2553)
1096 *
1097 * @param int $reply_id Optional. Reply id
1098 * @uses bbp_get_reply_topic_title() To get the reply topic title
1099 */
1100 function bbp_reply_topic_title( $reply_id = 0 ) {
1101 echo bbp_get_reply_topic_title( $reply_id );
1102 }
1103 /**
1104 * Return the topic title a reply belongs to
1105 *
1106 * @since bbPress (r2553)
1107 *
1108 * @param int $reply_id Optional. Reply id
1109 * @uses bbp_get_reply_id() To get the reply id
1110 * @uses bbp_get_reply_topic_id() To get the reply topic id
1111 * @uses bbp_get_topic_title() To get the reply topic title
1112 * @uses apply_filters() Calls 'bbp_get_reply_topic_title' with the
1113 * topic title and reply id
1114 * @return string Reply's topic's title
1115 */
1116 function bbp_get_reply_topic_title( $reply_id = 0 ) {
1117 $reply_id = bbp_get_reply_id( $reply_id );
1118 $topic_id = bbp_get_reply_topic_id( $reply_id );
1119
1120 return apply_filters( 'bbp_get_reply_topic_title', bbp_get_topic_title( $topic_id ), $reply_id );
1121 }
1122
1123 /**
1124 * Output the topic id a reply belongs to
1125 *
1126 * @since bbPress (r2553)
1127 *
1128 * @param int $reply_id Optional. Reply id
1129 * @uses bbp_get_reply_topic_id() To get the reply topic id
1130 */
1131 function bbp_reply_topic_id( $reply_id = 0 ) {
1132 echo bbp_get_reply_topic_id( $reply_id );
1133 }
1134 /**
1135 * Return the topic id a reply belongs to
1136 *
1137 * @since bbPress (r2553)
1138 *
1139 * @param int $reply_id Optional. Reply id
1140 * @uses bbp_get_reply_id() To get the reply id
1141 * @uses get_post_meta() To get the reply topic id from meta
1142 * @uses get_post_ancestors() To get the reply's ancestors
1143 * @uses get_post_field() To get the ancestor's post type
1144 * @uses bbp_get_topic_post_type() To get the topic post type
1145 * @uses bbp_update_reply_topic_id() To update the reply topic id
1146 * @uses bbp_get_topic_id() To get the topic id
1147 * @uses apply_filters() Calls 'bbp_get_reply_topic_id' with the topic
1148 * id and reply id
1149 * @return int Reply's topic id
1150 */
1151 function bbp_get_reply_topic_id( $reply_id = 0 ) {
1152
1153 // Assume there is no topic id
1154 $topic_id = 0;
1155
1156 // Check that reply_id is valid
1157 if ( $reply_id = bbp_get_reply_id( $reply_id ) )
1158
1159 // Get topic_id from reply
1160 if ( $topic_id = get_post_meta( $reply_id, '_bbp_topic_id', true ) )
1161
1162 // Validate the topic_id
1163 $topic_id = bbp_get_topic_id( $topic_id );
1164
1165 return apply_filters( 'bbp_get_reply_topic_id', (int) $topic_id, $reply_id );
1166 }
1167
1168 /**
1169 * Output the forum id a reply belongs to
1170 *
1171 * @since bbPress (r2679)
1172 *
1173 * @param int $reply_id Optional. Reply id
1174 * @uses bbp_get_reply_forum_id() To get the reply forum id
1175 */
1176 function bbp_reply_forum_id( $reply_id = 0 ) {
1177 echo bbp_get_reply_forum_id( $reply_id );
1178 }
1179 /**
1180 * Return the forum id a reply belongs to
1181 *
1182 * @since bbPress (r2679)
1183 *
1184 * @param int $reply_id Optional. Reply id
1185 * @uses bbp_get_reply_id() To get the reply id
1186 * @uses get_post_meta() To get the reply forum id
1187 * @uses apply_filters() Calls 'bbp_get_reply_forum_id' with the forum
1188 * id and reply id
1189 * @return int Reply's forum id
1190 */
1191 function bbp_get_reply_forum_id( $reply_id = 0 ) {
1192
1193 // Assume there is no forum
1194 $forum_id = 0;
1195
1196 // Check that reply_id is valid
1197 if ( $reply_id = bbp_get_reply_id( $reply_id ) )
1198
1199 // Get forum_id from reply
1200 if ( $forum_id = get_post_meta( $reply_id, '_bbp_forum_id', true ) )
1201
1202 // Validate the forum_id
1203 $forum_id = bbp_get_forum_id( $forum_id );
1204
1205 return apply_filters( 'bbp_get_reply_forum_id', (int) $forum_id, $reply_id );
1206 }
1207
1208 /**
1209 * Output the numeric position of a reply within a topic
1210 *
1211 * @since bbPress (r2984)
1212 *
1213 * @param int $reply_id Optional. Reply id
1214 * @param int $topic_id Optional. Topic id
1215 * @uses bbp_get_reply_position() To get the reply position
1216 */
1217 function bbp_reply_position( $reply_id = 0, $topic_id = 0 ) {
1218 echo bbp_get_reply_position( $reply_id, $topic_id );
1219 }
1220 /**
1221 * Return the numeric position of a reply within a topic
1222 *
1223 * @since bbPress (r2984)
1224 *
1225 * @param int $reply_id Optional. Reply id
1226 * @param int $topic_id Optional. Topic id
1227 * @uses bbp_get_reply_id() To get the reply id
1228 * @uses bbp_get_reply_topic_id() Get the topic id of the reply id
1229 * @uses bbp_get_topic_reply_count() To get the topic reply count
1230 * @uses bbp_get_reply_post_type() To get the reply post type
1231 * @uses bbp_get_public_child_ids() To get the reply ids of the topic id
1232 * @uses bbp_show_lead_topic() Bump the count if lead topic is included
1233 * @uses apply_filters() Calls 'bbp_get_reply_position' with the reply
1234 * position, reply id and topic id
1235 * @return int Reply position
1236 */
1237 function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) {
1238
1239 // Get required data
1240 $reply_position = 0;
1241 $reply_id = bbp_get_reply_id( $reply_id );
1242
1243 // Get topic id
1244 if ( !empty( $topic_id ) )
1245 $topic_id = bbp_get_topic_id( $topic_id );
1246 else
1247 $topic_id = bbp_get_reply_topic_id( $reply_id );
1248
1249 // Make sure the topic has replies before running another query
1250 if ( $reply_count = bbp_get_topic_reply_count( $topic_id ) ) {
1251
1252 // Are we counting hidden replies too?
1253 if ( bbp_get_view_all() )
1254 $topic_replies = bbp_get_all_child_ids ( $topic_id, bbp_get_reply_post_type() );
1255 else
1256 $topic_replies = bbp_get_public_child_ids( $topic_id, bbp_get_reply_post_type() );
1257
1258 // Get reply id's
1259 if ( !empty( $topic_replies ) ) {
1260
1261 // Reverse replies array and search for current reply position
1262 $topic_replies = array_reverse( $topic_replies );
1263
1264 // Position found
1265 if ( $reply_position = array_search( (string) $reply_id, $topic_replies ) ) {
1266
1267 // Bump if topic is in replies loop
1268 if ( !bbp_show_lead_topic() )
1269 $reply_position++;
1270
1271 // Bump now so we don't need to do math later
1272 $reply_position++;
1273 }
1274 }
1275 }
1276
1277 return apply_filters( 'bbp_get_reply_position', (int) $reply_position, $reply_id, $topic_id );
1278 }
1279
1280 /** Reply Admin Links *********************************************************/
1281
1282 /**
1283 * Output admin links for reply
1284 *
1285 * @since bbPress (r2667)
1286 *
1287 * @param mixed $args See {@link bbp_get_reply_admin_links()}
1288 * @uses bbp_get_reply_admin_links() To get the reply admin links
1289 */
1290 function bbp_reply_admin_links( $args = '' ) {
1291 echo bbp_get_reply_admin_links( $args );
1292 }
1293 /**
1294 * Return admin links for reply
1295 *
1296 * @since bbPress (r2667)
1297 *
1298 * @param mixed $args This function supports these arguments:
1299 * - id: Optional. Reply id
1300 * - before: HTML before the links. Defaults to
1301 * '<span class="bbp-admin-links">'
1302 * - after: HTML after the links. Defaults to '</span>'
1303 * - sep: Separator. Defaults to ' | '
1304 * - links: Array of the links to display. By default, edit, trash,
1305 * spam and topic split links are displayed
1306 * @uses bbp_is_topic() To check if it's the topic page
1307 * @uses bbp_is_reply() To check if it's the reply page
1308 * @uses bbp_get_reply_id() To get the reply id
1309 * @uses bbp_get_reply_edit_link() To get the reply edit link
1310 * @uses bbp_get_reply_trash_link() To get the reply trash link
1311 * @uses bbp_get_reply_spam_link() To get the reply spam link
1312 * @uses bbp_get_topic_split_link() To get the topic split link
1313 * @uses current_user_can() To check if the current user can edit or
1314 * delete the reply
1315 * @uses apply_filters() Calls 'bbp_get_reply_admin_links' with the
1316 * reply admin links and args
1317 * @return string Reply admin links
1318 */
1319 function bbp_get_reply_admin_links( $args = '' ) {
1320 global $bbp;
1321
1322 $defaults = array (
1323 'id' => 0,
1324 'before' => '<span class="bbp-admin-links">',
1325 'after' => '</span>',
1326 'sep' => ' | ',
1327 'links' => array()
1328 );
1329
1330 $r = wp_parse_args( $args, $defaults );
1331
1332 $r['id'] = bbp_get_reply_id( (int) $r['id'] );
1333
1334 // If post is a topic, return the topic admin links instead
1335 if ( bbp_is_topic( $r['id'] ) )
1336 return bbp_get_topic_admin_links( $args );
1337
1338 // If post is not a reply, return
1339 if ( !bbp_is_reply( $r['id'] ) )
1340 return;
1341
1342 // Make sure user can edit this reply
1343 if ( !current_user_can( 'edit_reply', $r['id'] ) )
1344 return;
1345
1346 // If topic is trashed, do not show admin links
1347 if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) )
1348 return;
1349
1350 // If no links were passed, default to the standard
1351 if ( empty( $r['links'] ) ) {
1352 $r['links'] = array (
1353 'edit' => bbp_get_reply_edit_link ( $r ),
1354 'split' => bbp_get_topic_split_link( $r ),
1355 'trash' => bbp_get_reply_trash_link( $r ),
1356 'spam' => bbp_get_reply_spam_link ( $r ),
1357 );
1358 }
1359
1360 // Check caps for trashing the topic
1361 if ( !current_user_can( 'delete_reply', $r['id'] ) && !empty( $r['links']['trash'] ) )
1362 unset( $r['links']['trash'] );
1363
1364 // See if links need to be unset
1365 $reply_status = bbp_get_reply_status( $r['id'] );
1366 if ( in_array( $reply_status, array( $bbp->spam_status_id, $bbp->trash_status_id ) ) ) {
1367
1368 // Spam link shouldn't be visible on trashed topics
1369 if ( $reply_status == $bbp->trash_status_id )
1370 unset( $r['links']['spam'] );
1371
1372 // Trash link shouldn't be visible on spam topics
1373 elseif ( isset( $r['links']['trash'] ) && $reply_status == $bbp->spam_status_id )
1374 unset( $r['links']['trash'] );
1375 }
1376
1377 // Process the admin links
1378 $links = implode( $r['sep'], array_filter( $r['links'] ) );
1379
1380 return apply_filters( 'bbp_get_reply_admin_links', $r['before'] . $links . $r['after'], $args );
1381 }
1382
1383 /**
1384 * Output the edit link of the reply
1385 *
1386 * @since bbPress (r2740)
1387 *
1388 * @param mixed $args See {@link bbp_get_reply_edit_link()}
1389 * @uses bbp_get_reply_edit_link() To get the reply edit link
1390 */
1391 function bbp_reply_edit_link( $args = '' ) {
1392 echo bbp_get_reply_edit_link( $args );
1393 }
1394
1395 /**
1396 * Return the edit link of the reply
1397 *
1398 * @since bbPress (r2740)
1399 *
1400 * @param mixed $args This function supports these arguments:
1401 * - id: Reply id
1402 * - link_before: HTML before the link
1403 * - link_after: HTML after the link
1404 * - edit_text: Edit text. Defaults to 'Edit'
1405 * @uses bbp_get_reply_id() To get the reply id
1406 * @uses bbp_get_reply() To get the reply
1407 * @uses current_user_can() To check if the current user can edit the
1408 * reply
1409 * @uses bbp_get_reply_edit_url() To get the reply edit url
1410 * @uses apply_filters() Calls 'bbp_get_reply_edit_link' with the reply
1411 * edit link and args
1412 * @return string Reply edit link
1413 */
1414 function bbp_get_reply_edit_link( $args = '' ) {
1415 $defaults = array (
1416 'id' => 0,
1417 'link_before' => '',
1418 'link_after' => '',
1419 'edit_text' => __( 'Edit', 'bbpress' )
1420 );
1421
1422 $r = wp_parse_args( $args, $defaults );
1423 extract( $r );
1424
1425 $reply = bbp_get_reply( bbp_get_reply_id( (int) $id ) );
1426
1427 // Bypass check if user has caps
1428 if ( !current_user_can( 'edit_others_replies' ) ) {
1429
1430 // User cannot edit or it is past the lock time
1431 if ( empty( $reply ) || !current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) )
1432 return;
1433 }
1434
1435 // No uri to edit reply
1436 if ( !$uri = bbp_get_reply_edit_url( $id ) )
1437 return;
1438
1439 return apply_filters( 'bbp_get_reply_edit_link', $link_before . '<a href="' . $uri . '">' . $edit_text . '</a>' . $link_after, $args );
1440 }
1441
1442 /**
1443 * Output URL to the reply edit page
1444 *
1445 * @since bbPress (r2753)
1446 *
1447 * @param int $reply_id Optional. Reply id
1448 * @uses bbp_get_reply_edit_url() To get the reply edit url
1449 */
1450 function bbp_reply_edit_url( $reply_id = 0 ) {
1451 echo bbp_get_reply_edit_url( $reply_id );
1452 }
1453 /**
1454 * Return URL to the reply edit page
1455 *
1456 * @since bbPress (r2753)
1457 *
1458 * @param int $reply_id Optional. Reply id
1459 * @uses bbp_get_reply_id() To get the reply id
1460 * @uses bbp_get_reply() To get the reply
1461 * @uses bbp_get_reply_post_type() To get the reply post type
1462 * @uses add_query_arg() To add custom args to the url
1463 * @uses home_url() To get the home url
1464 * @uses apply_filters() Calls 'bbp_get_reply_edit_url' with the edit
1465 * url and reply id
1466 * @return string Reply edit url
1467 */
1468 function bbp_get_reply_edit_url( $reply_id = 0 ) {
1469 global $wp_rewrite, $bbp;
1470
1471 if ( !$reply = bbp_get_reply( bbp_get_reply_id( $reply_id ) ) )
1472 return;
1473
1474 // Pretty permalinks
1475 if ( $wp_rewrite->using_permalinks() ) {
1476 $url = $wp_rewrite->root . $bbp->reply_slug . '/' . $reply->post_name . '/edit';
1477 $url = home_url( user_trailingslashit( $url ) );
1478
1479 // Unpretty permalinks
1480 } else {
1481 $url = add_query_arg( array( bbp_get_reply_post_type() => $reply->post_name, 'edit' => '1' ), home_url( '/' ) );
1482 }
1483
1484 return apply_filters( 'bbp_get_reply_edit_url', $url, $reply_id );
1485 }
1486
1487 /**
1488 * Output the trash link of the reply
1489 *
1490 * @since bbPress (r2740)
1491 *
1492 * @param mixed $args See {@link bbp_get_reply_trash_link()}
1493 * @uses bbp_get_reply_trash_link() To get the reply trash link
1494 */
1495 function bbp_reply_trash_link( $args = '' ) {
1496 echo bbp_get_reply_trash_link( $args );
1497 }
1498
1499 /**
1500 * Return the trash link of the reply
1501 *
1502 * @since bbPress (r2740)
1503 *
1504 * @param mixed $args This function supports these arguments:
1505 * - id: Reply id
1506 * - link_before: HTML before the link
1507 * - link_after: HTML after the link
1508 * - sep: Separator
1509 * - trash_text: Trash text
1510 * - restore_text: Restore text
1511 * - delete_text: Delete text
1512 * @uses bbp_get_reply_id() To get the reply id
1513 * @uses bbp_get_reply() To get the reply
1514 * @uses current_user_can() To check if the current user can delete the
1515 * reply
1516 * @uses bbp_is_reply_trash() To check if the reply is trashed
1517 * @uses bbp_get_reply_status() To get the reply status
1518 * @uses add_query_arg() To add custom args to the url
1519 * @uses wp_nonce_url() To nonce the url
1520 * @uses esc_url() To escape the url
1521 * @uses bbp_get_reply_edit_url() To get the reply edit url
1522 * @uses apply_filters() Calls 'bbp_get_reply_trash_link' with the reply
1523 * trash link and args
1524 * @return string Reply trash link
1525 */
1526 function bbp_get_reply_trash_link( $args = '' ) {
1527 $defaults = array (
1528 'id' => 0,
1529 'link_before' => '',
1530 'link_after' => '',
1531 'sep' => ' | ',
1532 'trash_text' => __( 'Trash', 'bbpress' ),
1533 'restore_text' => __( 'Restore', 'bbpress' ),
1534 'delete_text' => __( 'Delete', 'bbpress' )
1535 );
1536
1537 $r = wp_parse_args( $args, $defaults );
1538 extract( $r );
1539
1540 $actions = array();
1541 $reply = bbp_get_reply( bbp_get_reply_id( (int) $id ) );
1542
1543 if ( empty( $reply ) || !current_user_can( 'delete_reply', $reply->ID ) ) {
1544 return;
1545 }
1546
1547 if ( bbp_is_reply_trash( $reply->ID ) ) {
1548 $actions['untrash'] = '<a title="' . esc_attr( __( 'Restore this item from the Trash', 'bbpress' ) ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'untrash', 'reply_id' => $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . '">' . esc_html( $restore_text ) . '</a>';
1549 } elseif ( EMPTY_TRASH_DAYS ) {
1550 $actions['trash'] = '<a title="' . esc_attr( __( 'Move this item to the Trash', 'bbpress' ) ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'trash', 'reply_id' => $reply->ID ) ), 'trash-' . $reply->post_type . '_' . $reply->ID ) ) . '">' . esc_html( $trash_text ) . '</a>';
1551 }
1552
1553 if ( bbp_is_reply_trash( $reply->ID ) || !EMPTY_TRASH_DAYS ) {
1554 $actions['delete'] = '<a title="' . esc_attr( __( 'Delete this item permanently', 'bbpress' ) ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'delete', 'reply_id' => $reply->ID ) ), 'delete-' . $reply->post_type . '_' . $reply->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );">' . esc_html( $delete_text ) . '</a>';
1555 }
1556
1557 // Process the admin links
1558 $actions = implode( $sep, $actions );
1559
1560 return apply_filters( 'bbp_get_reply_trash_link', $link_before . $actions . $link_after, $args );
1561 }
1562
1563 /**
1564 * Output the spam link of the reply
1565 *
1566 * @since bbPress (r2740)
1567 *
1568 * @param mixed $args See {@link bbp_get_reply_spam_link()}
1569 * @uses bbp_get_reply_spam_link() To get the reply spam link
1570 */
1571 function bbp_reply_spam_link( $args = '' ) {
1572 echo bbp_get_reply_spam_link( $args );
1573 }
1574
1575 /**
1576 * Return the spam link of the reply
1577 *
1578 * @since bbPress (r2740)
1579 *
1580 * @param mixed $args This function supports these arguments:
1581 * - id: Reply id
1582 * - link_before: HTML before the link
1583 * - link_after: HTML after the link
1584 * - spam_text: Spam text
1585 * - unspam_text: Unspam text
1586 * @uses bbp_get_reply_id() To get the reply id
1587 * @uses bbp_get_reply() To get the reply
1588 * @uses current_user_can() To check if the current user can edit the
1589 * reply
1590 * @uses bbp_is_reply_spam() To check if the reply is marked as spam
1591 * @uses add_query_arg() To add custom args to the url
1592 * @uses wp_nonce_url() To nonce the url
1593 * @uses esc_url() To escape the url
1594 * @uses bbp_get_reply_edit_url() To get the reply edit url
1595 * @uses apply_filters() Calls 'bbp_get_reply_spam_link' with the reply
1596 * spam link and args
1597 * @return string Reply spam link
1598 */
1599 function bbp_get_reply_spam_link( $args = '' ) {
1600 $defaults = array (
1601 'id' => 0,
1602 'link_before' => '',
1603 'link_after' => '',
1604 'spam_text' => __( 'Spam', 'bbpress' ),
1605 'unspam_text' => __( 'Unspam', 'bbpress' )
1606 );
1607
1608 $r = wp_parse_args( $args, $defaults );
1609 extract( $r );
1610
1611 $reply = bbp_get_reply( bbp_get_reply_id( (int) $id ) );
1612
1613 if ( empty( $reply ) || !current_user_can( 'moderate', $reply->ID ) )
1614 return;
1615
1616 $display = bbp_is_reply_spam( $reply->ID ) ? $unspam_text : $spam_text;
1617
1618 $uri = add_query_arg( array( 'action' => 'bbp_toggle_reply_spam', 'reply_id' => $reply->ID ) );
1619 $uri = esc_url( wp_nonce_url( $uri, 'spam-reply_' . $reply->ID ) );
1620
1621 return apply_filters( 'bbp_get_reply_spam_link', $link_before . '<a href="' . $uri . '">' . $display . '</a>' . $link_after, $args );
1622 }
1623
1624 /**
1625 * Split topic link
1626 *
1627 * Output the split link of the topic (but is bundled with each topic)
1628 *
1629 * @since bbPress (r2756)
1630 *
1631 * @param mixed $args See {@link bbp_get_topic_split_link()}
1632 * @uses bbp_get_topic_split_link() To get the topic split link
1633 */
1634 function bbp_topic_split_link( $args = '' ) {
1635 echo bbp_get_topic_split_link( $args );
1636 }
1637
1638 /**
1639 * Get split topic link
1640 *
1641 * Return the split link of the topic (but is bundled with each reply)
1642 *
1643 * @since bbPress (r2756)
1644 *
1645 * @param mixed $args This function supports these arguments:
1646 * - id: Reply id
1647 * - link_before: HTML before the link
1648 * - link_after: HTML after the link
1649 * - split_text: Split text
1650 * - split_title: Split title attribute
1651 * @uses bbp_get_reply_id() To get the reply id
1652 * @uses bbp_get_reply() To get the reply
1653 * @uses current_user_can() To check if the current user can edit the
1654 * topic
1655 * @uses bbp_get_reply_topic_id() To get the reply topic id
1656 * @uses bbp_get_topic_edit_url() To get the topic edit url
1657 * @uses add_query_arg() To add custom args to the url
1658 * @uses wp_nonce_url() To nonce the url
1659 * @uses esc_url() To escape the url
1660 * @uses apply_filters() Calls 'bbp_get_topic_split_link' with the topic
1661 * split link and args
1662 * @return string Reply spam link
1663 */
1664 function bbp_get_topic_split_link( $args = '' ) {
1665 $defaults = array (
1666 'id' => 0,
1667 'link_before' => '',
1668 'link_after' => '',
1669 'split_text' => __( 'Split', 'bbpress' ),
1670 'split_title' => __( 'Split the topic from this reply', 'bbpress' )
1671 );
1672
1673 $r = wp_parse_args( $args, $defaults );
1674 extract( $r );
1675
1676 $reply_id = bbp_get_reply_id( $id );
1677 $topic_id = bbp_get_reply_topic_id( $reply_id );
1678
1679 if ( empty( $reply_id ) || !current_user_can( 'moderate', $topic_id ) )
1680 return;
1681
1682 $uri = esc_url(
1683 add_query_arg(
1684 array(
1685 'action' => 'split',
1686 'reply_id' => $reply_id
1687 ),
1688 bbp_get_topic_edit_url( $topic_id )
1689 ) );
1690
1691 return apply_filters( 'bbp_get_topic_split_link', $link_before . '<a href="' . $uri . '" title="' . esc_attr( $split_title ) . '">' . $split_text . '</a>' . $link_after, $args );
1692 }
1693
1694 /**
1695 * Output the row class of a reply
1696 *
1697 * @since bbPress (r2678)
1698 */
1699 function bbp_reply_class() {
1700 echo bbp_get_reply_class();
1701 }
1702 /**
1703 * Return the row class of a reply
1704 *
1705 * @since bbPress (r2678)
1706 *
1707 * @uses post_class() To get all the classes including ours
1708 * @uses apply_filters() Calls 'bbp_get_reply_class' with the classes
1709 * @return string Row class of the reply
1710 */
1711 function bbp_get_reply_class() {
1712 global $bbp;
1713
1714 $count = isset( $bbp->reply_query->current_post ) ? $bbp->reply_query->current_post : 1;
1715 $alternate = (int) $count % 2 ? 'even' : 'odd';
1716 $post = post_class( array( $alternate ) );
1717
1718 return apply_filters( 'bbp_reply_class', $post );
1719 }
1720
1721 /**
1722 * Output the topic pagination count
1723 *
1724 * @since bbPress (r2519)
1725 *
1726 * @uses bbp_get_topic_pagination_count() To get the topic pagination count
1727 */
1728 function bbp_topic_pagination_count() {
1729 echo bbp_get_topic_pagination_count();
1730 }
1731 /**
1732 * Return the topic pagination count
1733 *
1734 * @since bbPress (r2519)
1735 *
1736 * @uses bbp_number_format() To format the number value
1737 * @uses bbp_show_lead_topic() Are we showing the topic as a lead?
1738 * @uses apply_filters() Calls 'bbp_get_topic_pagination_count' with the
1739 * pagination count
1740 * @return string Topic pagination count
1741 */
1742 function bbp_get_topic_pagination_count() {
1743 global $bbp;
1744
1745 // Define local variable(s)
1746 $retstr = '';
1747
1748 // Set pagination values
1749 $start_num = intval( ( $bbp->reply_query->paged - 1 ) * $bbp->reply_query->posts_per_page ) + 1;
1750 $from_num = bbp_number_format( $start_num );
1751 $to_num = bbp_number_format( ( $start_num + ( $bbp->reply_query->posts_per_page - 1 ) > $bbp->reply_query->found_posts ) ? $bbp->reply_query->found_posts : $start_num + ( $bbp->reply_query->posts_per_page - 1 ) );
1752 $total = bbp_number_format( $bbp->reply_query->found_posts );
1753
1754 /**
1755 * Translators - _n() should not be needed, as singular/plural strings
1756 * are already separated into unique strings for you
1757 */
1758
1759 // We are not including the lead topic
1760 if ( bbp_show_lead_topic() ) {
1761
1762 // More than 1 reply
1763 if ( $total > 1 ) {
1764
1765 // Single reply in a topic with several pages
1766 if ( (int) $from_num == (int) $to_num ) {
1767 $retstr = sprintf( __( 'Viewing reply %1$s (of %2$s total)', 'bbpress' ), $from_num, $total );
1768
1769 // Several replies in a topic with a single page
1770 } elseif ( empty( $to_num ) ) {
1771 $retstr = sprintf( __( 'Viewing %1$s replies', 'bbpress' ), $total );
1772
1773 // Several replies in a topic with several pages
1774 } elseif ( (int) $from_num != (int) $to_num ) {
1775 $retstr = sprintf( __( 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', 'bbpress' ), $bbp->reply_query->post_count, $from_num, $to_num, $total );
1776 }
1777
1778 // Only one reply
1779 } else {
1780 $retstr = sprintf( __( 'Viewing %1$s reply', 'bbpress' ), $total );
1781 }
1782
1783 // We are including the lead topic
1784 } else {
1785
1786 // More than 1 post
1787 if ( $total > 1 ) {
1788
1789 // Single post in a topic with several pages
1790 if( (int) $from_num == (int) $to_num ) {
1791 $retstr = sprintf( __( 'Viewing post %1$s (of %2$s total)', 'bbpress' ), $from_num, $total );
1792
1793 // Several posts in a topic with a single page
1794 } elseif ( empty( $to_num ) ) {
1795 $retstr = sprintf( __( 'Viewing %1$s posts', 'bbpress' ), $total );
1796
1797 // Several posts in a topic with several pages
1798 } elseif ( (int) $from_num != (int) $to_num ) {
1799 $retstr = sprintf( __( 'Viewing %1$s posts - %2$s through %3$s (of %4$s total)', 'bbpress' ), $bbp->reply_query->post_count, $from_num, $to_num, $total );
1800 }
1801
1802 // Only one post
1803 } elseif ( $total == 1 ) {
1804 $retstr = sprintf( __( 'Viewing %1$s post', 'bbpress' ), $total );
1805 }
1806 }
1807
1808 // Filter and return
1809 return apply_filters( 'bbp_get_topic_pagination_count', $retstr );
1810 }
1811
1812 /**
1813 * Output topic pagination links
1814 *
1815 * @since bbPress (r2519)
1816 *
1817 * @uses bbp_get_topic_pagination_links() To get the topic pagination links
1818 */
1819 function bbp_topic_pagination_links() {
1820 echo bbp_get_topic_pagination_links();
1821 }
1822 /**
1823 * Return topic pagination links
1824 *
1825 * @since bbPress (r2519)
1826 *
1827 * @uses apply_filters() Calls 'bbp_get_topic_pagination_links' with the
1828 * pagination links
1829 * @return string Topic pagination links
1830 */
1831 function bbp_get_topic_pagination_links() {
1832 global $bbp;
1833
1834 if ( !isset( $bbp->reply_query->pagination_links ) || empty( $bbp->reply_query->pagination_links ) )
1835 return false;
1836
1837 return apply_filters( 'bbp_get_topic_pagination_links', $bbp->reply_query->pagination_links );
1838 }
1839
1840 /** Forms *********************************************************************/
1841
1842 /**
1843 * Output the value of reply content field
1844 *
1845 * @since bbPress {unknown}
1846 *
1847 * @uses bbp_get_form_reply_content() To get value of reply content field
1848 */
1849 function bbp_form_reply_content() {
1850 echo bbp_get_form_reply_content();
1851 }
1852 /**
1853 * Return the value of reply content field
1854 *
1855 * @since bbPress {unknown}
1856 *
1857 * @uses bbp_is_reply_edit() To check if it's the reply edit page
1858 * @uses apply_filters() Calls 'bbp_get_form_reply_content' with the content
1859 * @return string Value of reply content field
1860 */
1861 function bbp_get_form_reply_content() {
1862 global $post;
1863
1864 // Get _POST data
1865 if ( 'POST' == strtoupper( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_reply_content'] ) )
1866 $reply_content = $_POST['bbp_reply_content'];
1867
1868 // Get edit data
1869 elseif ( !empty( $post->post_content ) && bbp_is_reply_edit() )
1870 $reply_content = $post->post_content;
1871
1872 // No data
1873 else
1874 $reply_content = '';
1875
1876 return apply_filters( 'bbp_get_form_reply_content', esc_textarea( $reply_content ) );
1877 }
1878
1879 /**
1880 * Output checked value of reply log edit field
1881 *
1882 * @since bbPress {unknown}
1883 *
1884 * @uses bbp_get_form_reply_log_edit() To get the reply log edit value
1885 */
1886 function bbp_form_reply_log_edit() {
1887 echo bbp_get_form_reply_log_edit();
1888 }
1889 /**
1890 * Return checked value of reply log edit field
1891 *
1892 * @since bbPress {unknown}
1893 *
1894 * @uses apply_filters() Calls 'bbp_get_form_reply_log_edit' with the
1895 * log edit value
1896 * @return string Reply log edit checked value
1897 */
1898 function bbp_get_form_reply_log_edit() {
1899 global $post;
1900
1901 // Get _POST data
1902 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_log_reply_edit'] ) )
1903 $reply_revision = $_POST['bbp_log_reply_edit'];
1904
1905 // No data
1906 else
1907 $reply_revision = 1;
1908
1909 return apply_filters( 'bbp_get_form_reply_log_edit', checked( $reply_revision, true, false ) );
1910 }
1911
1912 /**
1913 * Output the value of the reply edit reason
1914 *
1915 * @since bbPress {unknown}
1916 *
1917 * @uses bbp_get_form_reply_edit_reason() To get the reply edit reason value
1918 */
1919 function bbp_form_reply_edit_reason() {
1920 echo bbp_get_form_reply_edit_reason();
1921 }
1922 /**
1923 * Return the value of the reply edit reason
1924 *
1925 * @since bbPress {unknown}
1926 *
1927 * @uses apply_filters() Calls 'bbp_get_form_reply_edit_reason' with the
1928 * reply edit reason value
1929 * @return string Reply edit reason value
1930 */
1931 function bbp_get_form_reply_edit_reason() {
1932 global $post;
1933
1934 // Get _POST data
1935 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_reply_edit_reason'] ) )
1936 $reply_edit_reason = $_POST['bbp_reply_edit_reason'];
1937
1938 // No data
1939 else
1940 $reply_edit_reason = '';
1941
1942 return apply_filters( 'bbp_get_form_reply_edit_reason', esc_attr( $reply_edit_reason ) );
1943 }
1944
1945 ?>
1946