Changeset 5504
- Timestamp:
- 09/11/2014 02:48:00 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/topics/template.php
r5477 r5504 177 177 bbp_get_closed_status_id(), 178 178 bbp_get_spam_status_id(), 179 bbp_get_trash_status_id() 179 bbp_get_trash_status_id(), 180 bbp_get_pending_status_id() 180 181 ); 181 182 … … 1232 1233 1233 1234 /** 1235 * Is the topic pending? 1236 * 1237 * @since bbPress (r5504) 1238 * 1239 * @param int $topic_id Optional. Topic id 1240 * @uses bbp_get_topic_id() To get the topic id 1241 * @uses bbp_get_topic_status() To get the topic status 1242 * @uses apply_filters() Calls 'bbp_is_topic_pending' with the topic id 1243 * @return bool True if pending, false if not. 1244 */ 1245 function bbp_is_topic_pending( $topic_id = 0 ) { 1246 $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) === bbp_get_pending_status_id(); 1247 return (bool) apply_filters( 'bbp_is_topic_pending', (bool) $topic_status, $topic_id ); 1248 } 1249 1250 /** 1251 * Is the topic private? 1252 * 1253 * @since bbPress (r5504) 1254 * 1255 * @param int $topic_id Optional. Topic id 1256 * @uses bbp_get_topic_id() To get the topic id 1257 * @uses bbp_get_topic_status() To get the topic status 1258 * @uses apply_filters() Calls 'bbp_is_topic_private' with the topic id 1259 * @return bool True if private, false if not. 1260 */ 1261 function bbp_is_topic_private( $topic_id = 0 ) { 1262 $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) === bbp_get_private_status_id(); 1263 return (bool) apply_filters( 'bbp_is_topic_private', (bool) $topic_status, $topic_id ); 1264 } 1265 1266 /** 1234 1267 * Is the posted by an anonymous user? 1235 1268 * … … 2447 2480 if ( empty( $r['links'] ) ) { 2448 2481 $r['links'] = apply_filters( 'bbp_topic_admin_links', array( 2449 'edit' => bbp_get_topic_edit_link ( $r ), 2450 'close' => bbp_get_topic_close_link( $r ), 2451 'stick' => bbp_get_topic_stick_link( $r ), 2452 'merge' => bbp_get_topic_merge_link( $r ), 2453 'trash' => bbp_get_topic_trash_link( $r ), 2454 'spam' => bbp_get_topic_spam_link ( $r ), 2455 'reply' => bbp_get_topic_reply_link( $r ) 2482 'edit' => bbp_get_topic_edit_link ( $r ), 2483 'close' => bbp_get_topic_close_link ( $r ), 2484 'stick' => bbp_get_topic_stick_link ( $r ), 2485 'merge' => bbp_get_topic_merge_link ( $r ), 2486 'trash' => bbp_get_topic_trash_link ( $r ), 2487 'spam' => bbp_get_topic_spam_link ( $r ), 2488 'approve' => bbp_get_topic_approve_link( $r ), 2489 'reply' => bbp_get_topic_reply_link ( $r ) 2456 2490 ), $r['id'] ); 2457 2491 } … … 2459 2493 // See if links need to be unset 2460 2494 $topic_status = bbp_get_topic_status( $r['id'] ); 2461 if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {2462 2463 // Close link shouldn't be visible on trashed/spammed topics2495 if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ) ) ) { 2496 2497 // Close link shouldn't be visible on trashed/spammed/pending topics 2464 2498 unset( $r['links']['close'] ); 2465 2499 … … 2734 2768 2735 2769 /** 2770 * Output the approve link of the topic 2771 * 2772 * @since bbPress (r5504) 2773 * 2774 * @param mixed $args See {@link bbp_get_topic_approve_link()} 2775 * @uses bbp_get_topic_approve_link() To get the topic approve link 2776 */ 2777 function bbp_topic_approve_link( $args = '' ) { 2778 echo bbp_get_topic_approve_link( $args ); 2779 } 2780 2781 /** 2782 * Return the approve link of the topic 2783 * 2784 * @since bbPress (r5504) 2785 * 2786 * @param mixed $args This function supports these args: 2787 * - id: Optional. Topic id 2788 * - link_before: Before the link 2789 * - link_after: After the link 2790 * - sep: Separator between links 2791 * - approve_text: Approve text 2792 * - unapprove_text: Unapprove text 2793 * @uses bbp_get_topic_id() To get the topic id 2794 * @uses bbp_get_topic() To get the topic 2795 * @uses current_user_can() To check if the current user can approve the topic 2796 * @uses bbp_is_topic_pending() To check if the topic is pending 2797 * @uses add_query_arg() To add custom args to the url 2798 * @uses wp_nonce_url() To nonce the url 2799 * @uses esc_url() To escape the url 2800 * @uses apply_filters() Calls 'bbp_get_topic_approve_link' with the link 2801 * and args 2802 * @return string Topic approve link 2803 */ 2804 function bbp_get_topic_approve_link( $args = '' ) { 2805 2806 // Parse arguments against default values 2807 $r = bbp_parse_args( $args, array( 2808 'id' => 0, 2809 'link_before' => '', 2810 'link_after' => '', 2811 'sep' => ' | ', 2812 'approve_text' => _x( 'Approve', 'Pending Status', 'bbpress' ), 2813 'unapprove_text' => _x( 'Unapprove', 'Pending Status', 'bbpress' ) 2814 ), 'get_topic_approve_link' ); 2815 2816 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2817 2818 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) { 2819 return; 2820 } 2821 2822 $display = bbp_is_topic_pending( $topic->ID ) ? $r['approve_text'] : $r['unapprove_text']; 2823 $uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_approve', 'topic_id' => $topic->ID ) ); 2824 $uri = wp_nonce_url( $uri, 'approve-topic_' . $topic->ID ); 2825 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-topic-approve-link">' . $display . '</a>' . $r['link_after']; 2826 2827 return apply_filters( 'bbp_get_topic_approve_link', $retval, $r ); 2828 } 2829 2830 /** 2736 2831 * Output the stick link of the topic 2737 2832 *
Note: See TracChangeset
for help on using the changeset viewer.