Changeset 6791
- Timestamp:
- 03/29/2018 06:03:12 PM (7 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/replies.php
r6790 r6791 80 80 add_filter( 'restrict_manage_posts', array( $this, 'filter_dropdown' ) ); 81 81 add_filter( 'bbp_request', array( $this, 'filter_post_rows' ) ); 82 83 // Empty spam 84 add_filter( 'manage_posts_extra_tablenav', array( $this, 'filter_empty_spam' ) ); 82 85 83 86 // Contextual Help … … 471 474 check_admin_referer( 'approve-reply_' . $reply_id ); 472 475 473 $is_approve = bbp_is_reply_publi shed( $reply_id );476 $is_approve = bbp_is_reply_public( $reply_id ); 474 477 $message = ( true === $is_approve ) 475 478 ? 'unpproved' 476 479 : 'approved'; 477 480 $success = ( true === $is_approve ) 478 ? bbp_ approve_reply( $reply_id )479 : bbp_ unapprove_reply( $reply_id );481 ? bbp_unapprove_reply( $reply_id ) 482 : bbp_approve_reply( $reply_id ); 480 483 481 484 break; … … 801 804 if ( current_user_can( 'moderate', $reply->ID ) ) { 802 805 803 // Show the 'approve' link on pendingposts only and 'unapprove' on published posts only806 // Show the 'approve' link on non-published posts only and 'unapprove' on published posts only 804 807 $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 ); 805 if ( bbp_is_reply_publi shed( $reply->ID ) ) {808 if ( bbp_is_reply_public( $reply->ID ) ) { 806 809 $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this reply', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove reply', 'bbpress' ) . '</a>'; 807 } else if ( ! bbp_is_reply_private( $reply->ID ) ){810 } else { 808 811 $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this reply', 'bbpress' ) . '">' . _x( 'Approve', 'Approve reply', 'bbpress' ) . '</a>'; 809 812 } 810 813 811 814 // Show the 'spam' link on published and pending replies and 'not spam' on spammed replies 812 if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_ pending_status_id(), bbp_get_spam_status_id() ), true ) ) {815 if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id(), bbp_get_spam_status_id() ), true ) ) { 813 816 $spam_uri = wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_spam' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'spam-reply_' . $reply->ID ); 814 if ( bbp_is_reply_spam( $reply->ID ) ) { 817 if ( ! bbp_is_reply_spam( $reply->ID ) ) { 818 $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this reply as spam', 'bbpress' ) . '">' . esc_html__( 'Spam', 'bbpress' ) . '</a>'; 819 } else { 815 820 $actions['unspam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the reply as not spam', 'bbpress' ) . '">' . esc_html__( 'Not Spam', 'bbpress' ) . '</a>'; 816 } else {817 $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this reply as spam', 'bbpress' ) . '">' . esc_html__( 'Spam', 'bbpress' ) . '</a>';818 821 } 819 822 } … … 833 836 if ( ( bbp_get_trash_status_id() === $reply->post_status ) || empty( $trash_days ) ) { 834 837 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $reply->ID, '', true ) ) . "'>" . esc_html__( 'Delete Permanently', 'bbpress' ) . "</a>"; 835 } elseif ( bbp_get_spam_status_id() === $reply->post_status ) {836 unset( $actions['trash'] );837 838 } 838 839 } … … 880 881 public function filter_dropdown() { 881 882 882 // Add "Empty Spam" button for moderators 883 if ( ! empty( $_GET['post_status'] ) && ( bbp_get_spam_status_id() === $_GET['post_status'] ) && current_user_can( 'moderate' ) ) { 883 // Get which forum is selected 884 $selected = ! empty( $_GET['bbp_forum_id'] ) 885 ? (int) $_GET['bbp_forum_id'] 886 : 0; 887 888 // Show the forums dropdown 889 bbp_dropdown( array( 890 'selected' => $selected, 891 'show_none' => esc_html__( 'In all forums', 'bbpress' ) 892 ) ); 893 } 894 895 /** 896 * Add "Empty Spam" button for moderators 897 * 898 * @since 2.6.0 bbPress (r6791) 899 */ 900 public function filter_empty_spam() { 901 902 // Bail if not viewing spam 903 if ( empty( $_GET['post_status'] ) || ( bbp_get_spam_status_id() !== $_GET['post_status'] ) && current_user_can( 'moderate' ) ) { 904 return; 905 } 906 907 ?> 908 909 <div class="alignleft actions"><?php 910 911 // Output the nonce & button 884 912 wp_nonce_field( 'bulk-destroy', '_destroy_nonce' ); 885 913 submit_button( … … 889 917 false 890 918 ); 891 } 892 893 // Get which forum is selected 894 $selected = ! empty( $_GET['bbp_forum_id'] ) 895 ? (int) $_GET['bbp_forum_id'] 896 : 0; 897 898 // Show the forums dropdown 899 bbp_dropdown( array( 900 'selected' => $selected, 901 'show_none' => esc_html__( 'In all forums', 'bbpress' ) 902 ) ); 919 920 ?></div><?php 903 921 } 904 922 -
trunk/src/includes/admin/topics.php
r6790 r6791 84 84 add_filter( 'restrict_manage_posts', array( $this, 'filter_dropdown' ) ); 85 85 add_filter( 'bbp_request', array( $this, 'filter_post_rows' ) ); 86 87 // Empty spam 88 add_filter( 'manage_posts_extra_tablenav', array( $this, 'filter_empty_spam' ) ); 86 89 87 90 // Contextual Help … … 589 592 check_admin_referer( 'approve-topic_' . $topic_id ); 590 593 591 $is_approve = bbp_is_topic_publi shed( $topic_id );592 $message = ( false === $is_approve )594 $is_approve = bbp_is_topic_public( $topic_id ); 595 $message = ( true === $is_approve ) 593 596 ? 'unapproved' 594 597 : 'approved'; 595 $success = ( false === $is_approve )596 ? bbp_ approve_topic( $topic_id )597 : bbp_ unapprove_topic( $topic_id );598 $success = ( true === $is_approve ) 599 ? bbp_unapprove_topic( $topic_id ) 600 : bbp_approve_topic( $topic_id ); 598 601 599 602 break; … … 979 982 // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only 980 983 $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 ); 981 if ( bbp_is_topic_publi shed( $topic->ID ) ) {984 if ( bbp_is_topic_public( $topic->ID ) ) { 982 985 $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this topic', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove Topic', 'bbpress' ) . '</a>'; 983 } elseif ( ! bbp_is_topic_private( $topic->ID ) ) { 984 $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic', 'bbpress' ) . '">' . _x( 'Approve', 'Approve Topic', 'bbpress' ) . '</a>'; 985 $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 986 } else { 987 988 // Do not show 'approve' if already public 989 if ( ! bbp_is_topic_public( $topic->ID ) ) { 990 $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic', 'bbpress' ) . '">' . _x( 'Approve', 'Approve Topic', 'bbpress' ) . '</a>'; 991 } 992 993 // Modify the view link 994 $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 986 995 } 987 996 … … 998 1007 999 1008 // Sticky 1000 // Dont show sticky if topic linksis spam, trash or pending1009 // Dont show sticky if topic is spam, trash or pending 1001 1010 if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) { 1002 1011 $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 ); … … 1011 1020 // Spam 1012 1021 $spam_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'spam-topic_' . $topic->ID ); 1013 if ( bbp_is_topic_spam( $topic->ID ) ) { 1022 if ( ! bbp_is_topic_spam( $topic->ID ) ) { 1023 $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this topic as spam', 'bbpress' ) . '">' . esc_html__( 'Spam', 'bbpress' ) . '</a>'; 1024 } else { 1014 1025 $actions['unspam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the topic as not spam', 'bbpress' ) . '">' . esc_html__( 'Not Spam', 'bbpress' ) . '</a>'; 1015 } else {1016 $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this topic as spam', 'bbpress' ) . '">' . esc_html__( 'Spam', 'bbpress' ) . '</a>';1017 1026 } 1018 1027 } … … 1031 1040 if ( ( bbp_get_trash_status_id() === $topic->post_status ) || empty( $trash_days ) ) { 1032 1041 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $topic->ID, '', true ) ) . "'>" . esc_html__( 'Delete Permanently', 'bbpress' ) . "</a>"; 1033 } elseif ( bbp_get_spam_status_id() === $topic->post_status ) {1034 unset( $actions['trash'] );1035 1042 } 1036 1043 } … … 1078 1085 public function filter_dropdown() { 1079 1086 1080 // Add "Empty Spam" button for moderators 1081 if ( ! empty( $_GET['post_status'] ) && ( bbp_get_spam_status_id() === $_GET['post_status'] ) && current_user_can( 'moderate' ) ) { 1087 // Get which forum is selected 1088 $selected = ! empty( $_GET['bbp_forum_id'] ) 1089 ? (int) $_GET['bbp_forum_id'] 1090 : 0; 1091 1092 // Show the forums dropdown 1093 bbp_dropdown( array( 1094 'selected' => $selected, 1095 'show_none' => esc_html__( 'In all forums', 'bbpress' ) 1096 ) ); 1097 } 1098 1099 /** 1100 * Add "Empty Spam" button for moderators 1101 * 1102 * @since 2.6.0 bbPress (r6791) 1103 */ 1104 public function filter_empty_spam() { 1105 1106 // Bail if not viewing spam 1107 if ( empty( $_GET['post_status'] ) || ( bbp_get_spam_status_id() !== $_GET['post_status'] ) && current_user_can( 'moderate' ) ) { 1108 return; 1109 } 1110 1111 ?> 1112 1113 <div class="alignleft actions"><?php 1114 1115 // Output the nonce & button 1082 1116 wp_nonce_field( 'bulk-destroy', '_destroy_nonce' ); 1083 1117 submit_button( … … 1087 1121 false 1088 1122 ); 1089 } 1090 1091 // Get which forum is selected 1092 $selected = ! empty( $_GET['bbp_forum_id'] ) 1093 ? (int) $_GET['bbp_forum_id'] 1094 : 0; 1095 1096 // Show the forums dropdown 1097 bbp_dropdown( array( 1098 'selected' => $selected, 1099 'show_none' => esc_html__( 'In all forums', 'bbpress' ) 1100 ) ); 1123 1124 ?></div><?php 1101 1125 } 1102 1126 -
trunk/src/includes/common/shortcodes.php
r6573 r6791 443 443 $bbp = bbpress(); 444 444 445 // Reset necessary forum_query attributes for reply sloop to function445 // Reset necessary forum_query attributes for reply loop to function 446 446 $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); 447 447 $bbp->forum_query->in_the_loop = true; 448 448 $bbp->forum_query->post = get_post( $forum_id ); 449 449 450 // Reset necessary reply_query attributes for reply sloop to function450 // Reset necessary reply_query attributes for reply loop to function 451 451 $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type(); 452 452 $bbp->reply_query->in_the_loop = true; -
trunk/src/includes/extend/buddypress/groups.php
r6777 r6791 117 117 add_filter( 'bbp_new_reply_redirect_to', array( $this, 'new_reply_redirect_to' ), 10, 3 ); 118 118 119 // Map forum/topic/reply spermalinks to their groups119 // Map forum/topic/reply permalinks to their groups 120 120 add_filter( 'bbp_get_forum_permalink', array( $this, 'map_forum_permalink_to_group' ), 10, 2 ); 121 121 add_filter( 'bbp_get_topic_permalink', array( $this, 'map_topic_permalink_to_group' ), 10, 2 ); -
trunk/src/includes/replies/functions.php
r6784 r6791 1628 1628 bbp_get_spam_status_id() => _x( 'Spam', 'Spam the reply', 'bbpress' ), 1629 1629 bbp_get_trash_status_id() => _x( 'Trash', 'Trash the reply', 'bbpress' ), 1630 bbp_get_pending_status_id() => _x( 'Pending', 'Mark reply as pending', 'bbpress' ) ,1630 bbp_get_pending_status_id() => _x( 'Pending', 'Mark reply as pending', 'bbpress' ) 1631 1631 ), $reply_id ); 1632 }1633 1634 /**1635 * Return array of public reply statuses.1636 *1637 * @since 2.6.0 bbPress (r6705)1638 *1639 * @return array1640 */1641 function bbp_get_public_reply_statuses() {1642 $statuses = array(1643 bbp_get_public_status_id()1644 );1645 1646 // Filter & return1647 return (array) apply_filters( 'bbp_get_public_reply_statuses', $statuses );1648 1632 } 1649 1633 … … 1776 1760 } 1777 1761 1762 // Get new status 1763 $status = bbp_get_public_status_id(); 1764 1778 1765 // Bail if already approved 1779 if ( bbp_get_pending_status_id() !== $reply->post_status ) {1766 if ( $status === $reply->post_status ) { 1780 1767 return false; 1781 1768 } … … 1785 1772 1786 1773 // Set publish status 1787 $reply->post_status = bbp_get_public_status_id();1774 $reply->post_status = $status; 1788 1775 1789 1776 // No revisions … … 1816 1803 } 1817 1804 1805 // Get new status 1806 $status = bbp_get_pending_status_id(); 1807 1818 1808 // Bail if already pending 1819 if ( bbp_get_pending_status_id()=== $reply->post_status ) {1809 if ( $status === $reply->post_status ) { 1820 1810 return false; 1821 1811 } … … 1825 1815 1826 1816 // Set pending status 1827 $reply->post_status = bbp_get_pending_status_id();1817 $reply->post_status = $status; 1828 1818 1829 1819 // No revisions -
trunk/src/includes/replies/template.php
r6777 r6791 828 828 829 829 /** 830 * Return array of public reply statuses. 831 * 832 * @since 2.6.0 bbPress (r6705) 833 * 834 * @return array 835 */ 836 function bbp_get_public_reply_statuses() { 837 $statuses = array( 838 bbp_get_public_status_id() 839 ); 840 841 // Filter & return 842 return (array) apply_filters( 'bbp_get_public_reply_statuses', $statuses ); 843 } 844 845 /** 846 * Return array of non-public reply statuses. 847 * 848 * @since 2.6.0 bbPress (r6791) 849 * 850 * @return array 851 */ 852 function bbp_get_non_public_reply_statuses() { 853 $statuses = array( 854 bbp_get_trash_status_id(), 855 bbp_get_spam_status_id(), 856 bbp_get_pending_status_id() 857 ); 858 859 // Filter & return 860 return (array) apply_filters( 'bbp_get_non_public_reply_statuses', $statuses ); 861 } 862 863 /** 864 * Is the reply publicly viewable? 865 * 866 * See bbp_get_public_reply_statuses() for public statuses. 867 * 868 * @since 2.6.0 bbPress (r6391) 869 * 870 * @param int $reply_id Optional. Reply id 871 * @return bool True if public, false if not. 872 */ 873 function bbp_is_reply_public( $reply_id = 0 ) { 874 $reply_id = bbp_get_reply_id( $reply_id ); 875 $status = bbp_get_reply_status( $reply_id ); 876 $public = bbp_get_public_reply_statuses(); 877 $is_public = in_array( $status, $public, true ); 878 879 // Filter & return 880 return (bool) apply_filters( 'bbp_is_reply_public', $is_public, $reply_id ); 881 } 882 883 /** 830 884 * Is the reply not spam or deleted? 831 885 * -
trunk/src/includes/topics/functions.php
r6790 r6791 2736 2736 2737 2737 // Get previous topic status meta 2738 $status = bbp_get_closed_status_id(); 2738 2739 $topic_status = get_post_meta( $topic_id, '_bbp_status', true ); 2739 2740 2740 2741 // Bail if already closed and topic status meta exists 2741 if ( bbp_get_closed_status_id()=== $topic->post_status && ! empty( $topic_status ) ) {2742 if ( $status === $topic->post_status && ! empty( $topic_status ) ) { 2742 2743 return false; 2743 2744 } 2744 2745 2745 2746 // Set status meta public 2746 $topic_status = bbp_get_public_status_id();2747 $topic_status = $topic->post_status; 2747 2748 2748 2749 // Execute pre close code … … 2753 2754 2754 2755 // Set closed status 2755 $topic->post_status = bbp_get_closed_status_id();2756 $topic->post_status = $status; 2756 2757 2757 2758 // Toggle revisions off as we are not altering content … … 3171 3172 3172 3173 // Set publish status 3173 $topic->post_status = bbp_get_public_status_id();3174 $topic->post_status = $status; 3174 3175 3175 3176 // No revisions … … 3205 3206 $status = bbp_get_pending_status_id(); 3206 3207 3207 // Bail if already pending3208 if ( $status === $topic->post_status) {3208 // Bail if already unapproved 3209 if ( ! bbp_is_topic_public( $topic_id ) ) { 3209 3210 return false; 3210 3211 }
Note: See TracChangeset
for help on using the changeset viewer.