Changeset 6923 for trunk/src/includes/replies/functions.php
- Timestamp:
- 11/09/2019 05:35:42 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/replies/functions.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/replies/functions.php
r6922 r6923 27 27 $reply_data = bbp_parse_args( $reply_data, array( 28 28 'post_parent' => 0, // topic ID 29 'post_status' => bbp_get_public_status_id(),30 29 'post_type' => bbp_get_reply_post_type(), 31 30 'post_author' => bbp_get_current_user_id(), … … 36 35 'comment_status' => 'closed' 37 36 ), 'insert_reply' ); 37 38 // Possibly override status based on parent topic 39 if ( ! empty( $reply_data['post_parent'] ) && empty( $reply_data['post_status'] ) ) { 40 $reply_data['post_status'] = bbp_get_topic_status( $reply_data['post_parent'] ); 41 } 38 42 39 43 // Insert reply … … 96 100 function bbp_insert_reply_update_counts( $reply_id = 0, $topic_id = 0, $forum_id = 0 ) { 97 101 98 // If the reply is public, update the forum/topicreply counts.102 // If the reply is public, update the reply counts. 99 103 if ( bbp_is_reply_published( $reply_id ) ) { 100 104 bbp_increase_topic_reply_count( $topic_id ); 101 105 bbp_increase_forum_reply_count( $forum_id ); 102 106 103 // If the reply isn't public only update the topic reply hidden count.107 // If the reply isn't public only update the reply hidden counts. 104 108 } else { 105 109 bbp_increase_topic_reply_count_hidden( $topic_id ); 110 bbp_increase_forum_reply_count_hidden( $forum_id ); 106 111 } 107 112 } … … 315 320 316 321 // Maybe put into moderation 317 if ( ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {322 if ( bbp_is_topic_pending( $topic_id ) || ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) { 318 323 $reply_status = bbp_get_pending_status_id(); 319 324 … … 920 925 } elseif ( bbp_is_topic( $ancestor ) ) { 921 926 922 // Last reply and active ID's 923 bbp_update_topic_last_reply_id ( $ancestor, $reply_id ); 924 bbp_update_topic_last_active_id( $ancestor, $active_id ); 925 926 // Get the last active time if none was passed 927 $topic_last_active_time = $last_active_time; 928 if ( empty( $last_active_time ) ) { 929 $topic_last_active_time = get_post_field( 'post_date', bbp_get_topic_last_active_id( $ancestor ) ); 927 // Only update if reply is published 928 if ( ! bbp_is_reply_pending( $reply_id ) ) { 929 930 // Last reply and active ID's 931 bbp_update_topic_last_reply_id ( $ancestor, $reply_id ); 932 bbp_update_topic_last_active_id( $ancestor, $active_id ); 933 934 // Get the last active time if none was passed 935 $topic_last_active_time = $last_active_time; 936 if ( empty( $last_active_time ) ) { 937 $topic_last_active_time = get_post_field( 'post_date', bbp_get_topic_last_active_id( $ancestor ) ); 938 } 939 940 bbp_update_topic_last_active_time( $ancestor, $topic_last_active_time ); 930 941 } 931 942 932 // Update the topic last active time regardless of reply status. 933 // See https://bbpress.trac.wordpress.org/ticket/2838 934 bbp_update_topic_last_active_time( $ancestor, $topic_last_active_time ); 935 936 // Only update reply count if we're deleting a reply, or in the dashboard. 943 // Only update reply count if we've deleted a reply 937 944 if ( in_array( current_filter(), array( 'bbp_deleted_reply', 'save_post' ), true ) ) { 938 945 bbp_update_topic_reply_count( $ancestor ); … … 944 951 } elseif ( bbp_is_forum( $ancestor ) ) { 945 952 946 // Last topic and reply ID's947 bbp_update_forum_last_topic_id( $ancestor, $topic_id );948 bbp_update_forum_last_reply_id( $ancestor, $reply_id );949 950 // Last Active951 bbp_update_forum_last_active_id( $ancestor, $active_id );952 953 // Get the last active time if none was passed954 $forum_last_active_time = $last_active_time;955 if ( empty( $last_active_time ) ) {956 $forum_last_active_time = get_post_field( 'post_date', bbp_get_forum_last_active_id( $ancestor ) );957 }958 959 953 // Only update if reply is published 960 if ( bbp_is_reply_published( $reply_id ) ) { 954 if ( bbp_is_reply_pending( $reply_id ) && ! bbp_is_topic_pending( $topic_id ) ) { 955 956 // Last topic and reply ID's 957 bbp_update_forum_last_topic_id( $ancestor, $topic_id ); 958 bbp_update_forum_last_reply_id( $ancestor, $reply_id ); 959 960 // Last Active 961 bbp_update_forum_last_active_id( $ancestor, $active_id ); 962 963 // Get the last active time if none was passed 964 $forum_last_active_time = $last_active_time; 965 if ( empty( $last_active_time ) ) { 966 $forum_last_active_time = get_post_field( 'post_date', bbp_get_forum_last_active_id( $ancestor ) ); 967 } 968 961 969 bbp_update_forum_last_active_time( $ancestor, $forum_last_active_time ); 962 970 } 963 971 964 // Counts 965 // Only update reply count if we're deleting a reply, or in the dashboard. 972 // Only update reply count if we've deleted a reply 966 973 if ( in_array( current_filter(), array( 'bbp_deleted_reply', 'save_post' ), true ) ) { 967 974 bbp_update_forum_reply_count( $ancestor );
Note: See TracChangeset
for help on using the changeset viewer.