Ticket #2645: 2645.2.diff
| File 2645.2.diff, 38.5 KB (added by , 12 years ago) |
|---|
-
src/includes/admin/replies.php
158 158 'content' => 159 159 '<p>' . __( 'Hovering over a row in the replies list will display action links that allow you to manage your reply. You can perform the following actions:', 'bbpress' ) . '</p>' . 160 160 '<ul>' . 161 '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that reply. You can also reach that screen by clicking on the reply title.', 'bbpress' ) . '</li>' . 162 //'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your reply, allowing you to update reply details without leaving this screen.', 'bbpress' ) . '</li>' . 163 '<li>' . __( '<strong>Trash</strong> removes your reply from this list and places it in the trash, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 164 '<li>' . __( '<strong>Spam</strong> removes your reply from this list and places it in the spam queue, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 165 '<li>' . __( '<strong>Preview</strong> will show you what your draft reply will look like if you publish it. View will take you to your live site to view the reply. Which link is available depends on your reply’s status.', 'bbpress' ) . '</li>' . 161 '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that reply. You can also reach that screen by clicking on the reply title.', 'bbpress' ) . '</li>' . 162 //'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your reply, allowing you to update reply details without leaving this screen.', 'bbpress' ) . '</li>' . 163 '<li>' . __( '<strong>Trash</strong> removes your reply from this list and places it in the trash, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 164 '<li>' . __( '<strong>Spam</strong> removes your reply from this list and places it in the spam queue, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 165 '<li>' . __( '<strong>View</strong> will take you to your live site to view the reply.', 'bbpress' ) . '</li>' . 166 '<li>' . __( '<strong>Approve</strong> will change the status from pending to publish.', 'bbpress' ) . '</li>' . 166 167 '</ul>' 167 168 ) ); 168 169 … … 434 435 background-color: #faeaea; 435 436 } 436 437 438 .status-pending { 439 background-color: #fef7f1; 440 } 441 437 442 /*]]>*/ 438 443 </style> 439 444 … … 468 473 } 469 474 470 475 // Only proceed if GET is a reply toggle action 471 if ( bbp_is_get_request() && ! empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_reply_spam' ) ) && !empty( $_GET['reply_id'] ) ) {476 if ( bbp_is_get_request() && ! empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_reply_spam', 'bbp_toggle_reply_approve' ) ) && ! empty( $_GET['reply_id'] ) ) { 472 477 $action = $_GET['action']; // What action is taking place? 473 478 $reply_id = (int) $_GET['reply_id']; // What's the reply id? 474 479 $success = false; // Flag … … 486 491 } 487 492 488 493 switch ( $action ) { 494 case 'bbp_toggle_reply_approve' : 495 check_admin_referer( 'approve-reply_' . $reply_id ); 496 497 $is_approve = bbp_is_reply_pending( $reply_id ); 498 $message = $is_approve ? 'approved' : 'unapproved'; 499 $success = $is_approve ? bbp_approve_reply( $reply_id ) : bbp_unapprove_reply( $reply_id ); 500 501 break; 502 489 503 case 'bbp_toggle_reply_spam' : 490 504 check_admin_referer( 'spam-reply_' . $reply_id ); 491 505 … … 496 510 break; 497 511 } 498 512 499 $success = wp_update_post( $post_data );500 513 $message = array( 'bbp_reply_toggle_notice' => $message, 'reply_id' => $reply->ID ); 501 514 502 515 if ( false === $success || is_wp_error( $success ) ) { … … 536 549 } 537 550 538 551 // Only proceed if GET is a reply toggle action 539 if ( bbp_is_get_request() && ! empty( $_GET['bbp_reply_toggle_notice'] ) && in_array( $_GET['bbp_reply_toggle_notice'], array( 'spammed', 'unspammed' ) ) && !empty( $_GET['reply_id'] ) ) {552 if ( bbp_is_get_request() && ! empty( $_GET['bbp_reply_toggle_notice'] ) && in_array( $_GET['bbp_reply_toggle_notice'], array( 'spammed', 'unspammed', 'approved', 'unapproved' ) ) && ! empty( $_GET['reply_id'] ) ) { 540 553 $notice = $_GET['bbp_reply_toggle_notice']; // Which notice? 541 554 $reply_id = (int) $_GET['reply_id']; // What's the reply id? 542 555 $is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure? … … 566 579 ? sprintf( __( 'There was a problem unmarking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) 567 580 : sprintf( __( 'Reply "%1$s" successfully unmarked as spam.', 'bbpress' ), $reply_title ); 568 581 break; 582 583 case 'approved' : 584 $message = ( $is_failure === true ) 585 ? sprintf( __( 'There was a problem approving the reply "%1$s".', 'bbpress' ), $reply_title ) 586 : sprintf( __( 'Reply "%1$s" successfully approved.', 'bbpress' ), $reply_title ); 587 break; 588 589 case 'unapproved' : 590 $message = ( $is_failure === true ) 591 ? sprintf( __( 'There was a problem unapproving the reply "%1$s".', 'bbpress' ), $reply_title ) 592 : sprintf( __( 'Reply "%1$s" successfully unapproved.', 'bbpress' ), $reply_title ); 593 break; 569 594 } 570 595 571 596 // Do additional reply toggle notice filters (admin side) … … 767 792 unset( $actions['view'] ); 768 793 } 769 794 795 // Pending 796 // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only 797 $approve_uri = wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_approve' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'approve-reply_' . $reply->ID ); 798 if ( bbp_is_reply_published( $reply->ID ) ) { 799 $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this reply', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove reply', 'bbpress' ) . '</a>'; 800 } elseif ( ! bbp_is_reply_private( $reply->ID ) ) { 801 $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this reply', 'bbpress' ) . '">' . _x( 'Approve', 'Approve reply', 'bbpress' ) . '</a>'; 802 } 803 770 804 // Only show the actions if the user is capable of viewing them 771 805 if ( current_user_can( 'moderate', $reply->ID ) ) { 772 806 if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_spam_status_id() ) ) ) { -
src/includes/admin/topics.php
157 157 'content' => 158 158 '<p>' . __( 'Hovering over a row in the topics list will display action links that allow you to manage your topic. You can perform the following actions:', 'bbpress' ) . '</p>' . 159 159 '<ul>' . 160 '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.', 'bbpress' ) . '</li>' . 161 '<li>' . __( '<strong>Trash</strong> removes your topic from this list and places it in the trash, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 162 '<li>' . __( '<strong>Spam</strong> removes your topic from this list and places it in the spam queue, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 163 '<li>' . __( '<strong>Preview</strong> will show you what your draft topic will look like if you publish it. View will take you to your live site to view the topic. Which link is available depends on your topic’s status.', 'bbpress' ) . '</li>' . 164 '<li>' . __( '<strong>Close</strong> will mark the selected topic as ’closed’ and disable the option to post new replies to the topic.', 'bbpress' ) . '</li>' . 165 '<li>' . __( '<strong>Stick</strong> will keep the selected topic ’pinned’ to the top the parent forum topic list.', 'bbpress' ) . '</li>' . 166 '<li>' . __( '<strong>Stick <em>(to front)</em></strong> will keep the selected topic ’pinned’ to the top of ALL forums and be visable in any forums topics list.', 'bbpress' ) . '</li>' . 160 '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.', 'bbpress' ) . '</li>' . 161 '<li>' . __( '<strong>Trash</strong> removes your topic from this list and places it in the trash, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 162 '<li>' . __( '<strong>Spam</strong> removes your topic from this list and places it in the spam queue, from which you can permanently delete it.', 'bbpress' ) . '</li>' . 163 '<li>' . __( '<strong>View</strong> will take you to your live site to view the topic.', 'bbpress' ) . '</li>' . 164 '<li>' . __( '<strong>Approve</strong> will change the status from pending to publish.', 'bbpress' ) . '</li>' . 165 '<li>' . __( '<strong>Close</strong> will mark the selected topic as ’closed’ and disable the option to post new replies to the topic.', 'bbpress' ) . '</li>' . 166 '<li>' . __( '<strong>Stick</strong> will keep the selected topic ’pinned’ to the top the parent forum topic list.', 'bbpress' ) . '</li>' . 167 '<li>' . __( '<strong>Stick <em>(to front)</em></strong> will keep the selected topic ’pinned’ to the top of ALL forums and be visable in any forums topics list.', 'bbpress' ) . '</li>' . 167 168 '</ul>' 168 169 ) ); 169 170 … … 449 450 background-color: #faeaea; 450 451 } 451 452 453 .status-pending { 454 background-color: #fef7f1; 455 } 456 452 457 /*]]>*/ 453 458 </style> 454 459 … … 491 496 } 492 497 493 498 // Only proceed if GET is a topic toggle action 494 if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam' ) ) && !empty( $_GET['topic_id'] ) ) {499 if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam', 'bbp_toggle_topic_approve' ) ) && !empty( $_GET['topic_id'] ) ) { 495 500 $action = $_GET['action']; // What action is taking place? 496 501 $topic_id = (int) $_GET['topic_id']; // What's the topic id? 497 502 $success = false; // Flag 498 503 $post_data = array( 'ID' => $topic_id ); // Prelim array 499 $topic = bbp_get_topic( $topic_id ); 504 $topic = bbp_get_topic( $topic_id ); // Verify the topic id 500 505 501 506 // Bail if topic is missing 502 507 if ( empty( $topic ) ) { … … 509 514 } 510 515 511 516 switch ( $action ) { 517 case 'bbp_toggle_topic_approve' : 518 check_admin_referer( 'approve-topic_' . $topic_id ); 519 520 $is_approve = bbp_is_topic_pending( $topic_id ); 521 $message = ( true === $is_approve ) 522 ? 'approved' 523 : 'unapproved'; 524 $success = ( true === $is_approve ) 525 ? bbp_approve_topic( $topic_id ) 526 : bbp_unapprove_topic( $topic_id ); 527 528 break; 529 512 530 case 'bbp_toggle_topic_close' : 513 531 check_admin_referer( 'close-topic_' . $topic_id ); 514 532 … … 594 612 } 595 613 596 614 // Only proceed if GET is a topic toggle action 597 if ( bbp_is_get_request() && ! empty( $_GET['bbp_topic_toggle_notice'] ) && in_array( $_GET['bbp_topic_toggle_notice'], array( 'opened', 'closed', 'super_sticked', 'sticked', 'unsticked', 'spammed', 'unspammed' ) ) && !empty( $_GET['topic_id'] ) ) {615 if ( bbp_is_get_request() && ! empty( $_GET['bbp_topic_toggle_notice'] ) && in_array( $_GET['bbp_topic_toggle_notice'], array( 'opened', 'closed', 'super_sticked', 'sticked', 'unsticked', 'spammed', 'unspammed', 'approved', 'unapproved' ) ) && ! empty( $_GET['topic_id'] ) ) { 598 616 $notice = $_GET['bbp_topic_toggle_notice']; // Which notice? 599 617 $topic_id = (int) $_GET['topic_id']; // What's the topic id? 600 618 $is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure? 601 619 602 // Bai sif no topic_id or notice620 // Bail if no topic_id or notice 603 621 if ( empty( $notice ) || empty( $topic_id ) ) { 604 622 return; 605 623 } 606 624 607 // Bail if topic is missing625 // Get topic and bail if empty 608 626 $topic = bbp_get_topic( $topic_id ); 609 627 if ( empty( $topic ) ) { 610 628 return; … … 654 672 ? sprintf( __( 'There was a problem unmarking the topic "%1$s" as spam.', 'bbpress' ), $topic_title ) 655 673 : sprintf( __( 'Topic "%1$s" successfully unmarked as spam.', 'bbpress' ), $topic_title ); 656 674 break; 675 676 case 'approved' : 677 $message = ( $is_failure === true ) 678 ? sprintf( __( 'There was a problem approving the topic "%1$s".', 'bbpress' ), $topic_title ) 679 : sprintf( __( 'Topic "%1$s" successfully approved.', 'bbpress' ), $topic_title ); 680 break; 681 682 case 'unapproved' : 683 $message = ( $is_failure === true ) 684 ? sprintf( __( 'There was a problem unapproving the topic "%1$s".', 'bbpress' ), $topic_title ) 685 : sprintf( __( 'Topic "%1$s" successfully unapproved.', 'bbpress' ), $topic_title ); 686 break; 657 687 } 658 688 659 689 // Do additional topic toggle notice filters (admin side) … … 842 872 // Only show the actions if the user is capable of viewing them :) 843 873 if ( current_user_can( 'moderate', $topic->ID ) ) { 844 874 875 // Pending 876 // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only 877 $approve_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'approve-topic_' . $topic->ID ); 878 if ( bbp_is_topic_published( $topic->ID ) ) { 879 $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this topic', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove Topic', 'bbpress' ) . '</a>'; 880 } elseif ( ! bbp_is_topic_private( $topic->ID ) ) { 881 $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic', 'bbpress' ) . '">' . _x( 'Approve', 'Approve Topic', 'bbpress' ) . '</a>'; 882 $actions['view'] = '<a href="' . esc_url( bbp_get_topic_permalink( $topic->ID ) ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 883 } 884 845 885 // Close 846 886 // Show the 'close' and 'open' link on published and closed posts only 847 887 if ( in_array( $topic->post_status, array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ) ) { … … 853 893 } 854 894 } 855 895 856 // Dont show sticky if topic links is spam or trash857 if ( ! bbp_is_topic_spam( $topic->ID ) && !bbp_is_topic_trash( $topic->ID ) ) {896 // Dont show sticky if topic links is spam, trash or pending 897 if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) { 858 898 859 899 // Sticky 860 900 $stick_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_' . $topic->ID ); -
src/includes/core/actions.php
155 155 add_action( 'bbp_template_notices', 'bbp_notice_edit_user_success' ); 156 156 add_action( 'bbp_template_notices', 'bbp_notice_edit_user_is_super_admin', 2 ); 157 157 158 // Before Delete/Trash/Untrash Topic158 // Before Delete/Trash/Untrash Forum 159 159 add_action( 'wp_trash_post', 'bbp_trash_forum' ); 160 160 add_action( 'trash_post', 'bbp_trash_forum' ); 161 161 add_action( 'untrash_post', 'bbp_untrash_forum' ); 162 162 add_action( 'delete_post', 'bbp_delete_forum' ); 163 163 164 // After Deleted/Trashed/Untrashed Topic164 // After Deleted/Trashed/Untrashed Forum 165 165 add_action( 'trashed_post', 'bbp_trashed_forum' ); 166 166 add_action( 'untrashed_post', 'bbp_untrashed_forum' ); 167 167 add_action( 'deleted_post', 'bbp_deleted_forum' ); … … 242 242 add_action( 'bbp_deleted_topic', 'bbp_update_topic_walker' ); 243 243 add_action( 'bbp_spammed_topic', 'bbp_update_topic_walker' ); 244 244 add_action( 'bbp_unspammed_topic', 'bbp_update_topic_walker' ); 245 add_action( 'bbp_approve_topic', 'bbp_update_topic_walker' ); 246 add_action( 'bbp_unapprove_topic', 'bbp_update_topic_walker' ); 245 247 246 248 // Update reply branch 247 249 add_action( 'bbp_trashed_reply', 'bbp_update_reply_walker' ); … … 249 251 add_action( 'bbp_deleted_reply', 'bbp_update_reply_walker' ); 250 252 add_action( 'bbp_spammed_reply', 'bbp_update_reply_walker' ); 251 253 add_action( 'bbp_unspammed_reply', 'bbp_update_reply_walker' ); 254 add_action( 'bbp_approve_reply', 'bbp_update_reply_walker' ); 255 add_action( 'bbp_unapprove_reply', 'bbp_update_reply_walker' ); 252 256 253 257 // Users topic & reply counts 254 258 add_action( 'bbp_new_topic', 'bbp_increase_user_topic_count' ); … … 267 271 add_action( 'bbp_untrash_topic', 'bbp_untrash_topic_replies' ); 268 272 add_action( 'bbp_delete_topic', 'bbp_delete_topic_replies' ); 269 273 add_action( 'bbp_spam_topic', 'bbp_spam_topic_replies' ); 270 add_action( 'bbp_unspam_topic', 'bbp_unspam_topic_replies' );274 add_action( 'bbp_unspam_topic', 'bbp_unspam_topic_replies' ); 271 275 272 276 // User status 273 277 // @todo make these sub-actions … … 332 336 // Maybe convert the users password 333 337 add_action( 'bbp_login_form_login', 'bbp_user_maybe_convert_pass' ); 334 338 335 add_action( 'bbp_activation', 'bbp_add_activation_redirect' ); 336 No newline at end of file 339 add_action( 'bbp_activation', 'bbp_add_activation_redirect' ); -
src/includes/replies/functions.php
1163 1163 * @return array 1164 1164 */ 1165 1165 function bbp_get_reply_ancestors( $reply_id = 0 ) { 1166 1166 1167 1167 // Validation 1168 1168 $reply_id = bbp_get_reply_id( $reply_id ); 1169 1169 $ancestors = array(); … … 1469 1469 } 1470 1470 1471 1471 // Remove reply_to from moved reply 1472 delete_post_meta( $move_reply->ID, '_bbp_reply_to' ); 1472 delete_post_meta( $move_reply->ID, '_bbp_reply_to' ); 1473 1473 1474 1474 // It is a new topic and we need to set some default metas to make 1475 1475 // the topic display in bbp_has_topics() list … … 1582 1582 // Setup possible get actions 1583 1583 $possible_actions = array( 1584 1584 'bbp_toggle_reply_spam', 1585 'bbp_toggle_reply_trash' 1585 'bbp_toggle_reply_trash', 1586 'bbp_toggle_reply_approve' 1586 1587 ); 1587 1588 1588 1589 // Bail if actions aren't meant for this function … … 1611 1612 // What action are we trying to perform? 1612 1613 switch ( $action ) { 1613 1614 1615 // Toggle approve 1616 case 'bbp_toggle_reply_approve' : 1617 check_ajax_referer( 'approve-reply_' . $reply_id ); 1618 1619 $is_approve = bbp_is_reply_pending( $reply_id ); 1620 $success = $is_approve ? bbp_approve_reply( $reply_id ) : bbp_unapprove_reply( $reply_id ); 1621 $failure = $is_approve ? __( '<strong>ERROR</strong>: There was a problem approving the reply!', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem unapproving thereply!', 'bbpress' ); 1622 $view_all = !$is_approve; 1623 1624 break; 1625 1614 1626 // Toggle spam 1615 1627 case 'bbp_toggle_reply_spam' : 1616 1628 check_ajax_referer( 'spam-reply_' . $reply_id ); … … 1814 1826 return $reply_id; 1815 1827 } 1816 1828 1829 /** 1830 * Approves a reply 1831 * 1832 * @since bbPress (rXXXX) 1833 * 1834 * @param int $reply_id Reply id 1835 * @uses bbp_get_reply() To get the reply 1836 * @uses do_action() Calls 'bbp_approve_reply' with the reply id 1837 /* @uses add_post_meta() To add the previous status to a meta 1838 /* @uses delete_post_meta() To delete the previous status meta 1839 * @uses wp_update_post() To update the reply with the new status 1840 * @uses do_action() Calls 'bbp_approved_reply' with the reply id 1841 * @return mixed False or {@link WP_Error} on failure, reply id on success 1842 */ 1843 function bbp_approve_reply( $reply_id = 0 ) { 1844 1845 // Get reply 1846 $reply = bbp_get_reply( $reply_id ); 1847 if ( empty( $reply ) ) { 1848 return $reply; 1849 } 1850 1851 // Bail if already approved 1852 if ( bbp_get_pending_status_id() !== $reply->post_status ) { 1853 return false; 1854 } 1855 1856 // Execute pre pending code 1857 do_action( 'bbp_approve_reply', $reply_id ); 1858 1859 // Set publish status 1860 $reply->post_status = bbp_get_public_status_id(); 1861 1862 // No revisions 1863 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 1864 1865 // Update reply 1866 $reply_id = wp_update_post( $reply ); 1867 1868 // Execute post pending code 1869 do_action( 'bbp_approved_reply', $reply_id ); 1870 1871 // Return reply_id 1872 return $reply_id; 1873 } 1874 1875 /** 1876 * Unapproves a reply 1877 * 1878 * @since bbPress (rXXXX) 1879 * 1880 * @param int $reply_id Reply id 1881 * @uses bbp_get_reply() To get the reply 1882 * @uses do_action() Calls 'bbp_unapprove_reply' with the reply id 1883 /* @uses get_post_meta() To get the previous status 1884 /* @uses delete_post_meta() To delete the previous status meta 1885 * @uses wp_update_post() To update the reply with the new status 1886 * @uses do_action() Calls 'bbp_unapproved_reply' with the reply id 1887 * @return mixed False or {@link WP_Error} on failure, reply id on success 1888 */ 1889 function bbp_unapprove_reply( $reply_id = 0 ) { 1890 1891 // Get reply 1892 $reply = bbp_get_reply( $reply_id ); 1893 if ( empty( $reply ) ) { 1894 return $reply; 1895 } 1896 1897 // Bail if already pending 1898 if ( bbp_get_pending_status_id() === $reply->post_status ) { 1899 return false; 1900 } 1901 1902 // Execute pre open code 1903 do_action( 'bbp_unapprove_reply', $reply_id ); 1904 1905 // Set pending status 1906 $reply->post_status = bbp_get_pending_status_id(); 1907 1908 // No revisions 1909 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 1910 1911 // Update reply 1912 $reply_id = wp_update_post( $reply ); 1913 1914 // Execute post open code 1915 do_action( 'bbp_unapproved_reply', $reply_id ); 1916 1917 // Return reply_id 1918 return $reply_id; 1919 } 1920 1817 1921 /** Before Delete/Trash/Untrash ***********************************************/ 1818 1922 1819 1923 /** … … 2334 2438 2335 2439 /** 2336 2440 * Validate a `reply_to` field for hierarchical replies 2337 * 2441 * 2338 2442 * Checks for 2 scenarios: 2339 2443 * -- The reply to ID is actually a reply 2340 2444 * -- The reply to ID does not match the current reply -
src/includes/replies/template.php
150 150 bbp_get_public_status_id(), 151 151 bbp_get_closed_status_id(), 152 152 bbp_get_spam_status_id(), 153 bbp_get_trash_status_id() 153 bbp_get_trash_status_id(), 154 bbp_get_pending_status_id() 154 155 ); 155 156 156 157 // Add support for private status … … 952 953 } 953 954 954 955 /** 956 * Is the reply pending? 957 * 958 * @since bbPress (rXXXX) 959 * 960 * @param int $reply_id Optional. Topic id 961 * @uses bbp_get_reply_id() To get the reply id 962 * @uses bbp_get_reply_status() To get the reply status 963 * @uses apply_filters() Calls 'bbp_is_reply_pending' with the reply id 964 * @return bool True if pending, false if not. 965 */ 966 function bbp_is_reply_pending( $reply_id = 0 ) { 967 $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) ) === bbp_get_pending_status_id(); 968 return (bool) apply_filters( 'bbp_is_reply_pending', (bool) $reply_status, $reply_id ); 969 } 970 971 /** 972 * Is the reply private? 973 * 974 * @since bbPress (rXXXX) 975 * 976 * @param int $reply_id Optional. Topic id 977 * @uses bbp_get_reply_id() To get the reply id 978 * @uses bbp_get_reply_status() To get the reply status 979 * @uses apply_filters() Calls 'bbp_is_reply_private' with the reply id 980 * @return bool True if private, false if not. 981 */ 982 function bbp_is_reply_private( $reply_id = 0 ) { 983 $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) ) === bbp_get_private_status_id(); 984 return (bool) apply_filters( 'bbp_is_reply_private', (bool) $reply_status, $reply_id ); 985 } 986 987 /** 955 988 * Is the reply by an anonymous user? 956 989 * 957 990 * @since bbPress (r2753) … … 1853 1886 // If no links were passed, default to the standard 1854 1887 if ( empty( $r['links'] ) ) { 1855 1888 $r['links'] = apply_filters( 'bbp_reply_admin_links', array( 1856 'edit' => bbp_get_reply_edit_link ( $r ), 1857 'move' => bbp_get_reply_move_link ( $r ), 1858 'split' => bbp_get_topic_split_link( $r ), 1859 'trash' => bbp_get_reply_trash_link( $r ), 1860 'spam' => bbp_get_reply_spam_link ( $r ), 1861 'reply' => bbp_get_reply_to_link ( $r ) 1889 'edit' => bbp_get_reply_edit_link ( $r ), 1890 'move' => bbp_get_reply_move_link ( $r ), 1891 'split' => bbp_get_topic_split_link ( $r ), 1892 'trash' => bbp_get_reply_trash_link ( $r ), 1893 'spam' => bbp_get_reply_spam_link ( $r ), 1894 'approve' => bbp_get_reply_approve_link( $r ), 1895 'reply' => bbp_get_reply_to_link ( $r ) 1862 1896 ), $r['id'] ); 1863 1897 } 1864 1898 1865 1899 // See if links need to be unset 1866 1900 $reply_status = bbp_get_reply_status( $r['id'] ); 1867 if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {1901 if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ) ) ) { 1868 1902 1869 1903 // Spam link shouldn't be visible on trashed topics 1870 1904 if ( bbp_get_trash_status_id() === $reply_status ) { … … 2273 2307 } 2274 2308 2275 2309 /** 2310 * Output the approve link of the reply 2311 * 2312 * @since bbPress (rXXXX) 2313 * 2314 * @param mixed $args See {@link bbp_get_reply_approve_link()} 2315 * @uses bbp_get_reply_approve_link() To get the reply approve link 2316 */ 2317 function bbp_reply_approve_link( $args = '' ) { 2318 echo bbp_get_reply_approve_link( $args ); 2319 } 2320 2321 /** 2322 * Return the approve link of the reply 2323 * 2324 * @since bbPress (rXXXX) 2325 * 2326 * @param mixed $args This function supports these args: 2327 * - id: Optional. Reply id 2328 * - link_before: Before the link 2329 * - link_after: After the link 2330 * - sep: Separator between links 2331 * - approve_text: Approve text 2332 * - unapprove_text: Unapprove text 2333 * @uses bbp_get_reply_id() To get the reply id 2334 * @uses bbp_get_reply() To get the reply 2335 * @uses current_user_can() To check if the current user can approve the reply 2336 * @uses bbp_is_reply_pending() To check if the reply is pending 2337 * @uses add_query_arg() To add custom args to the url 2338 * @uses wp_nonce_url() To nonce the url 2339 * @uses esc_url() To escape the url 2340 * @uses apply_filters() Calls 'bbp_get_reply_approve_link' with the link 2341 * and args 2342 * @return string Reply approve link 2343 */ 2344 function bbp_get_reply_approve_link( $args = '' ) { 2345 2346 // Parse arguments against default values 2347 $r = bbp_parse_args( $args, array( 2348 'id' => 0, 2349 'link_before' => '', 2350 'link_after' => '', 2351 'sep' => ' | ', 2352 'approve_text' => _x( 'Approve', 'Pending Status', 'bbpress' ), 2353 'unapprove_text' => _x( 'Unapprove', 'Pending Status', 'bbpress' ) 2354 ), 'get_reply_approve_link' ); 2355 2356 $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) ); 2357 2358 if ( empty( $reply ) || !current_user_can( 'moderate', $reply->ID ) ) 2359 return; 2360 2361 $display = bbp_is_reply_pending( $reply->ID ) ? $r['approve_text'] : $r['unapprove_text']; 2362 $uri = add_query_arg( array( 'action' => 'bbp_toggle_reply_approve', 'reply_id' => $reply->ID ) ); 2363 $uri = wp_nonce_url( $uri, 'approve-reply_' . $reply->ID ); 2364 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-approve-link">' . $display . '</a>' . $r['link_after']; 2365 2366 return apply_filters( 'bbp_get_reply_approve_link', $retval, $r ); 2367 } 2368 2369 /** 2276 2370 * Output the row class of a reply 2277 2371 * 2278 2372 * @since bbPress (r2678) -
src/includes/topics/functions.php
2112 2112 'bbp_toggle_topic_close', 2113 2113 'bbp_toggle_topic_stick', 2114 2114 'bbp_toggle_topic_spam', 2115 'bbp_toggle_topic_trash' 2115 'bbp_toggle_topic_trash', 2116 'bbp_toggle_topic_approve' 2116 2117 ); 2117 2118 2118 2119 // Bail if actions aren't meant for this function … … 2142 2143 // What action are we trying to perform? 2143 2144 switch ( $action ) { 2144 2145 2146 // Toggle approve/unapprove 2147 case 'bbp_toggle_topic_approve' : 2148 check_ajax_referer( 'approve-topic_' . $topic_id ); 2149 2150 $is_pending = bbp_is_topic_pending( $topic_id ); 2151 $success = true === $is_pending ? bbp_approve_topic( $topic_id ) : bbp_unapprove_topic( $topic_id ); 2152 $failure = true === $is_pending ? __( '<strong>ERROR</strong>: There was a problem approving the topic.', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem unapproving the topic.', 'bbpress' ); 2153 2154 break; 2155 2145 2156 // Toggle open/close 2146 2157 case 'bbp_toggle_topic_close' : 2147 2158 check_ajax_referer( 'close-topic_' . $topic_id ); … … 3174 3185 } 3175 3186 3176 3187 /** 3188 * Approves a topic 3189 * 3190 * @since bbPress (rXXXX) 3191 * 3192 * @param int $topic_id Topic id 3193 * @uses bbp_get_topic() To get the topic 3194 * @uses do_action() Calls 'bbp_approve_topic' with the topic id 3195 /* @uses add_post_meta() To add the previous status to a meta 3196 /* @uses delete_post_meta() To delete the previous status meta 3197 * @uses wp_update_post() To update the topic with the new status 3198 * @uses do_action() Calls 'bbp_approved_topic' with the topic id 3199 * @return mixed False or {@link WP_Error} on failure, topic id on success 3200 */ 3201 function bbp_approve_topic( $topic_id = 0 ) { 3202 3203 // Get topic 3204 $topic = bbp_get_topic( $topic_id ); 3205 if ( empty( $topic ) ) { 3206 return $topic; 3207 } 3208 3209 // Bail if already approved 3210 if ( bbp_get_pending_status_id() !== $topic->post_status ) { 3211 return false; 3212 } 3213 3214 // Execute pre pending code 3215 do_action( 'bbp_approve_topic', $topic_id ); 3216 3217 // Set publish status 3218 $topic->post_status = bbp_get_public_status_id(); 3219 3220 // No revisions 3221 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 3222 3223 // Update topic 3224 $topic_id = wp_update_post( $topic ); 3225 3226 // Execute post pending code 3227 do_action( 'bbp_approved_topic', $topic_id ); 3228 3229 // Return topic_id 3230 return $topic_id; 3231 } 3232 3233 /** 3234 * Unapproves a topic 3235 * 3236 * @since bbPress (rXXXX) 3237 * 3238 * @param int $topic_id Topic id 3239 * @uses bbp_get_topic() To get the topic 3240 * @uses do_action() Calls 'bbp_unapprove_topic' with the topic id 3241 /* @uses get_post_meta() To get the previous status 3242 /* @uses delete_post_meta() To delete the previous status meta 3243 * @uses wp_update_post() To update the topic with the new status 3244 * @uses do_action() Calls 'bbp_unapproved_topic' with the topic id 3245 * @return mixed False or {@link WP_Error} on failure, topic id on success 3246 */ 3247 function bbp_unapprove_topic( $topic_id = 0 ) { 3248 3249 // Get topic 3250 $topic = bbp_get_topic( $topic_id ); 3251 if ( empty( $topic ) ) { 3252 return $topic; 3253 } 3254 3255 // Bail if already pending 3256 if ( bbp_get_pending_status_id() === $topic->post_status ) { 3257 return false; 3258 } 3259 3260 // Execute pre open code 3261 do_action( 'bbp_unapprove_topic', $topic_id ); 3262 3263 // Set pending status 3264 $topic->post_status = bbp_get_pending_status_id(); 3265 3266 // No revisions 3267 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 3268 3269 // Update topic 3270 $topic_id = wp_update_post( $topic ); 3271 3272 // Execute post open code 3273 do_action( 'bbp_unapproved_topic', $topic_id ); 3274 3275 // Return topic_id 3276 return $topic_id; 3277 } 3278 3279 /** 3177 3280 * Unsticks a topic both from front and it's forum 3178 3281 * 3179 3282 * @since bbPress (r2754) -
src/includes/topics/template.php
171 171 bbp_get_public_status_id(), 172 172 bbp_get_closed_status_id(), 173 173 bbp_get_spam_status_id(), 174 bbp_get_trash_status_id() 174 bbp_get_trash_status_id(), 175 bbp_get_pending_status_id() 175 176 ); 176 177 177 178 // Add support for private status … … 1226 1227 } 1227 1228 1228 1229 /** 1230 * Is the topic pending? 1231 * 1232 * @since bbPress (rXXXX) 1233 * 1234 * @param int $topic_id Optional. Topic id 1235 * @uses bbp_get_topic_id() To get the topic id 1236 * @uses bbp_get_topic_status() To get the topic status 1237 * @uses apply_filters() Calls 'bbp_is_topic_pending' with the topic id 1238 * @return bool True if pending, false if not. 1239 */ 1240 function bbp_is_topic_pending( $topic_id = 0 ) { 1241 $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) === bbp_get_pending_status_id(); 1242 return (bool) apply_filters( 'bbp_is_topic_pending', (bool) $topic_status, $topic_id ); 1243 } 1244 1245 /** 1246 * Is the topic private? 1247 * 1248 * @since bbPress (rXXXX) 1249 * 1250 * @param int $topic_id Optional. Topic id 1251 * @uses bbp_get_topic_id() To get the topic id 1252 * @uses bbp_get_topic_status() To get the topic status 1253 * @uses apply_filters() Calls 'bbp_is_topic_private' with the topic id 1254 * @return bool True if private, false if not. 1255 */ 1256 function bbp_is_topic_private( $topic_id = 0 ) { 1257 $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) === bbp_get_private_status_id(); 1258 return (bool) apply_filters( 'bbp_is_topic_private', (bool) $topic_status, $topic_id ); 1259 } 1260 1261 /** 1229 1262 * Is the posted by an anonymous user? 1230 1263 * 1231 1264 * @since bbPress (r2753) … … 2441 2474 2442 2475 if ( empty( $r['links'] ) ) { 2443 2476 $r['links'] = apply_filters( 'bbp_topic_admin_links', array( 2444 'edit' => bbp_get_topic_edit_link ( $r ), 2445 'close' => bbp_get_topic_close_link( $r ), 2446 'stick' => bbp_get_topic_stick_link( $r ), 2447 'merge' => bbp_get_topic_merge_link( $r ), 2448 'trash' => bbp_get_topic_trash_link( $r ), 2449 'spam' => bbp_get_topic_spam_link ( $r ), 2450 'reply' => bbp_get_topic_reply_link( $r ) 2477 'edit' => bbp_get_topic_edit_link ( $r ), 2478 'close' => bbp_get_topic_close_link ( $r ), 2479 'stick' => bbp_get_topic_stick_link ( $r ), 2480 'merge' => bbp_get_topic_merge_link ( $r ), 2481 'trash' => bbp_get_topic_trash_link ( $r ), 2482 'spam' => bbp_get_topic_spam_link ( $r ), 2483 'approve' => bbp_get_topic_approve_link( $r ), 2484 'reply' => bbp_get_topic_reply_link ( $r ) 2451 2485 ), $r['id'] ); 2452 2486 } 2453 2487 2454 2488 // See if links need to be unset 2455 2489 $topic_status = bbp_get_topic_status( $r['id'] ); 2456 if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {2490 if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ) ) ) { 2457 2491 2458 // Close link shouldn't be visible on trashed/spammed topics2492 // Close link shouldn't be visible on trashed/spammed/pending topics 2459 2493 unset( $r['links']['close'] ); 2460 2494 2461 2495 // Spam link shouldn't be visible on trashed topics … … 2728 2762 } 2729 2763 2730 2764 /** 2765 * Output the approve link of the topic 2766 * 2767 * @since bbPress (rXXXX) 2768 * 2769 * @param mixed $args See {@link bbp_get_topic_approve_link()} 2770 * @uses bbp_get_topic_approve_link() To get the topic approve link 2771 */ 2772 function bbp_topic_approve_link( $args = '' ) { 2773 echo bbp_get_topic_approve_link( $args ); 2774 } 2775 2776 /** 2777 * Return the approve link of the topic 2778 * 2779 * @since bbPress (rXXXX) 2780 * 2781 * @param mixed $args This function supports these args: 2782 * - id: Optional. Topic id 2783 * - link_before: Before the link 2784 * - link_after: After the link 2785 * - sep: Separator between links 2786 * - approve_text: Approve text 2787 * - unapprove_text: Unapprove text 2788 * @uses bbp_get_topic_id() To get the topic id 2789 * @uses bbp_get_topic() To get the topic 2790 * @uses current_user_can() To check if the current user can approve the topic 2791 * @uses bbp_is_topic_pending() To check if the topic is pending 2792 * @uses add_query_arg() To add custom args to the url 2793 * @uses wp_nonce_url() To nonce the url 2794 * @uses esc_url() To escape the url 2795 * @uses apply_filters() Calls 'bbp_get_topic_approve_link' with the link 2796 * and args 2797 * @return string Topic approve link 2798 */ 2799 function bbp_get_topic_approve_link( $args = '' ) { 2800 2801 // Parse arguments against default values 2802 $r = bbp_parse_args( $args, array( 2803 'id' => 0, 2804 'link_before' => '', 2805 'link_after' => '', 2806 'sep' => ' | ', 2807 'approve_text' => _x( 'Approve', 'Pending Status', 'bbpress' ), 2808 'unapprove_text' => _x( 'Unapprove', 'Pending Status', 'bbpress' ) 2809 ), 'get_topic_approve_link' ); 2810 2811 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2812 2813 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 2814 return; 2815 2816 $display = bbp_is_topic_pending( $topic->ID ) ? $r['approve_text'] : $r['unapprove_text']; 2817 $uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_approve', 'topic_id' => $topic->ID ) ); 2818 $uri = wp_nonce_url( $uri, 'approve-topic_' . $topic->ID ); 2819 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-topic-approve-link">' . $display . '</a>' . $r['link_after']; 2820 2821 return apply_filters( 'bbp_get_topic_approve_link', $retval, $r ); 2822 } 2823 2824 /** 2731 2825 * Output the stick link of the topic 2732 2826 * 2733 2827 * @since bbPress (r2754) -
src/templates/default/css/bbpress.css
54 54 background-color: #fdd; 55 55 } 56 56 57 #bbpress-forums .status-pending.even, 58 #bbpress-forums .status-pending.odd, 59 #bbpress-forums ul.status-pending a { 60 background-color: #fef7f1; 61 } 62 57 63 #bbpress-forums ul.status-closed, 58 64 #bbpress-forums ul.status-closed a { 59 65 color: #ccc;
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)