Changeset 7765
- Timestamp:
- 10/02/2026 07:41:28 AM (6 weeks ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
-
CHANGELOG.md (modified) (1 diff)
-
src/includes/admin/metaboxes.php (modified) (1 diff)
-
src/includes/core/actions.php (modified) (2 diffs)
-
src/includes/replies/functions.php (modified) (1 diff)
-
src/includes/topics/functions.php (modified) (1 diff)
-
src/includes/users/engagements.php (modified) (1 diff)
-
tests/phpunit/testcases/admin/subscriptions.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CHANGELOG.md
r7763 r7765 45 45 ### Fixed 46 46 47 - Preserved topic subscriptions when topics and replies are edited in administration. 47 48 - Cache a distinct count of current-site forum-role holders for forum statistics, 48 49 invalidating it when users or their capabilities change. Use the WordPress -
trunk/src/includes/admin/metaboxes.php
r7651 r7765 794 794 function bbp_topic_subscriptions_metabox( $post ) { 795 795 796 // Current user subscription797 $input_value = bbp_is_user_subscribed( bbp_get_current_user_id(), $post->ID )798 ? 'bbp_subscribe' // maintain existing subscription799 : ''; // do not add or remove subscription800 801 796 // Get user IDs 802 797 $user_ids = bbp_get_subscribers( $post->ID ); 803 798 804 799 // Output 805 ?> 806 <input name="bbp_topic_subscription" id="bbp_topic_subscription" type="hidden" value="<?php echo esc_attr( $input_value ); ?>" /> 807 <p><?php 800 ?><p><?php 808 801 809 802 // Relationships -
trunk/src/includes/core/actions.php
r7671 r7765 213 213 add_action( 'bbp_new_reply', 'bbp_update_reply', 10, 7 ); 214 214 add_action( 'bbp_edit_reply', 'bbp_update_reply', 10, 7 ); 215 add_action( 'bbp_new_reply', 'bbp_update_reply_subscription', 10, 5 ); 216 add_action( 'bbp_edit_reply', 'bbp_update_reply_subscription', 10, 5 ); 215 217 216 218 // Before Delete/Trash/Untrash Reply … … 228 230 add_action( 'bbp_new_topic', 'bbp_update_topic', 10, 5 ); 229 231 add_action( 'bbp_edit_topic', 'bbp_update_topic', 10, 5 ); 232 add_action( 'bbp_new_topic', 'bbp_update_topic_subscription', 10, 4 ); 233 add_action( 'bbp_edit_topic', 'bbp_update_topic_subscription', 10, 4 ); 230 234 231 235 // Split/Merge Topic -
trunk/src/includes/replies/functions.php
r7727 r7765 908 908 } 909 909 910 // Handle Subscription Checkbox911 if ( bbp_is_subscriptions_active() && ! empty( $author_id ) && ! empty( $topic_id ) ) {912 913 // Check if subscribed914 $subscribed = bbp_is_user_subscribed( $author_id, $topic_id );915 916 // Check for action917 $subscheck = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) )918 ? true919 : false;920 921 // Subscribed and unsubscribing922 if ( ( true === $subscribed ) && ( false === $subscheck ) ) {923 bbp_remove_user_subscription( $author_id, $topic_id );924 925 // Not subscribed and subscribing926 } elseif ( ( false === $subscribed ) && ( true === $subscheck ) ) {927 bbp_add_user_subscription( $author_id, $topic_id );928 }929 }930 931 910 // Update associated topic values if this is a new reply 932 911 if ( empty( $is_edit ) ) { -
trunk/src/includes/topics/functions.php
r7731 r7765 826 826 } 827 827 828 // Handle Subscription Checkbox829 if ( bbp_is_subscriptions_active() && ! empty( $author_id ) ) {830 831 // Check if subscribed832 $subscribed = bbp_is_user_subscribed( $author_id, $topic_id );833 834 // Check for action835 $subscheck = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) )836 ? true837 : false;838 839 // Subscribed and unsubscribing840 if ( ( true === $subscribed ) && ( false === $subscheck ) ) {841 bbp_remove_user_subscription( $author_id, $topic_id );842 843 // Not subscribed and subscribing844 } elseif ( ( false === $subscribed ) && ( true === $subscheck ) ) {845 bbp_add_user_subscription( $author_id, $topic_id );846 }847 }848 849 828 // Get the topic types 850 829 $topic_types = bbp_get_topic_types( $topic_id ); -
trunk/src/includes/users/engagements.php
r7658 r7765 857 857 858 858 return true; 859 } 860 861 /** 862 * Apply a topic form's subscription choice for its author. 863 * 864 * @since 2.6.20 bbPress (r7765) 865 * 866 * @param int $author_id Topic or reply author ID. 867 * @param int $topic_id Topic ID. 868 */ 869 function bbp_update_user_topic_subscription( $author_id = 0, $topic_id = 0 ) { 870 871 // Bail if subscriptions are disabled or the form has no valid target 872 if ( ! bbp_is_subscriptions_active() || empty( $author_id ) || empty( $topic_id ) ) { 873 return; 874 } 875 876 $subscribed = bbp_is_user_subscribed( $author_id, $topic_id ); 877 $subscheck = ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ); 878 879 if ( $subscribed && ! $subscheck ) { 880 bbp_remove_user_subscription( $author_id, $topic_id ); 881 } elseif ( ! $subscribed && $subscheck ) { 882 bbp_add_user_subscription( $author_id, $topic_id ); 883 } 884 } 885 886 /** 887 * Apply a topic form's subscription choice after saving the topic. 888 * 889 * @since 2.6.20 bbPress (r7765) 890 * 891 * @param int $topic_id Topic ID. 892 * @param int $forum_id Forum ID. 893 * @param array $anonymous_data Anonymous author data. 894 * @param int $author_id Topic author ID. 895 */ 896 function bbp_update_topic_subscription( $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $author_id = 0 ) { 897 bbp_update_user_topic_subscription( $author_id, $topic_id ); 898 } 899 900 /** 901 * Apply a reply form's subscription choice after saving the reply. 902 * 903 * @since 2.6.20 bbPress (r7765) 904 * 905 * @param int $reply_id Reply ID. 906 * @param int $topic_id Topic ID. 907 * @param int $forum_id Forum ID. 908 * @param array $anonymous_data Anonymous author data. 909 * @param int $author_id Reply author ID. 910 */ 911 function bbp_update_reply_subscription( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $author_id = 0 ) { 912 bbp_update_user_topic_subscription( $author_id, $topic_id ); 859 913 } 860 914
Note:
See TracChangeset
for help on using the changeset viewer.