# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: \includes\topics
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
|
|
|
954 | 954 | $old_forum_id = bbp_get_forum_id( $old_forum_id ); |
955 | 955 | $new_forum_id = bbp_get_forum_id( $new_forum_id ); |
956 | 956 | |
| 957 | // Update topic forum's ID |
| 958 | bbp_update_topic_forum_id( $topic_id, $new_forum_id ); |
| 959 | |
957 | 960 | /** Stickies **************************************************************/ |
958 | 961 | |
959 | 962 | // Get forum stickies |
… |
… |
|
964 | 967 | |
965 | 968 | // Define local variables |
966 | 969 | $updated_stickies = array(); |
967 | | |
| 970 | |
968 | 971 | // Loop through stickies of forum |
969 | | foreach ( $old_stickies as $sticky_topic_id ) { |
| 972 | foreach ( (array) $old_stickies as $sticky_topic_id ) { |
970 | 973 | |
971 | 974 | // Add non-matches to the updated array |
972 | 975 | if ( $topic_id != $sticky_topic_id ) { |
… |
… |
|
974 | 977 | } |
975 | 978 | } |
976 | 979 | |
977 | | // No more stickies so delete the beta |
978 | | if ( empty( $updated_stickies ) ) { |
979 | | delete_post_meta ( $old_forum_id, '_bbp_sticky_topics' ); |
| 980 | if ( $updated_stickies != $old_stickies ) { |
| 981 | |
| 982 | // No more stickies so delete the beta |
| 983 | if ( empty( $updated_stickies ) ) { |
| 984 | delete_post_meta ( $old_forum_id, '_bbp_sticky_topics' ); |
980 | 985 | |
981 | | // Still stickies so update the meta |
982 | | } else { |
983 | | update_post_meta( $old_forum_id, '_bbp_sticky_topics', $updated_stickies ); |
984 | | } |
985 | | |
986 | | // Topic was sticky, so restick in new forum |
987 | | bbp_stick_topic( $topic_id ); |
| 986 | // Still stickies so update the meta |
| 987 | } else { |
| 988 | update_post_meta( $old_forum_id, '_bbp_sticky_topics', $updated_stickies ); |
| 989 | } |
| 990 | |
| 991 | // Topic was sticky, so restick in new forum |
| 992 | bbp_stick_topic( $topic_id ); |
| 993 | } |
988 | 994 | } |
989 | 995 | |
990 | 996 | /** Topic Replies *********************************************************/ |
… |
… |
|
996 | 1002 | foreach ( $replies as $reply_id ) |
997 | 1003 | bbp_update_reply_forum_id( $reply_id, $new_forum_id ); |
998 | 1004 | |
999 | | // Forum topic meta |
1000 | | bbp_update_topic_forum_id( $topic_id, $new_forum_id ); |
1001 | | |
1002 | 1005 | /** Old forum_id **********************************************************/ |
1003 | 1006 | |
1004 | 1007 | // Get topic ancestors |
1005 | | $ancestors = array_values( array_unique( array_merge( array( $old_forum_id ), (array) get_post_ancestors( $old_forum_id ) ) ) ); |
| 1008 | $old_forum_ancestors = array_values( array_unique( array_merge( array( $old_forum_id ), (array) get_post_ancestors( $old_forum_id ) ) ) ); |
1006 | 1009 | |
1007 | 1010 | // Loop through ancestors |
1008 | | if ( !empty( $ancestors ) ) { |
1009 | | foreach ( $ancestors as $ancestor ) { |
| 1011 | if ( !empty( $old_forum_ancestors ) ) { |
| 1012 | foreach ( $old_forum_ancestors as $ancestor ) { |
1010 | 1013 | |
1011 | 1014 | // If ancestor is a forum, update counts |
1012 | 1015 | if ( bbp_is_forum( $ancestor ) ) { |
… |
… |
|
1022 | 1025 | /** New forum_id **********************************************************/ |
1023 | 1026 | |
1024 | 1027 | // Make sure we're not walking twice |
1025 | | if ( !in_array( $new_forum_id, $ancestors ) ) { |
| 1028 | if ( !in_array( $new_forum_id, $old_forum_ancestors ) ) { |
1026 | 1029 | |
1027 | 1030 | // Get topic ancestors |
1028 | | $ancestors = array_values( array_unique( array_merge( array( $new_forum_id ), (array) get_post_ancestors( $new_forum_id ) ) ) ); |
| 1031 | $new_forum_ancestors = array_values( array_unique( array_merge( array( $new_forum_id ), (array) get_post_ancestors( $new_forum_id ) ) ) ); |
| 1032 | |
| 1033 | // Make sure we're not walking twice |
| 1034 | $new_forum_ancestors = array_diff( $new_forum_ancestors, $old_forum_ancestors ); |
1029 | 1035 | |
1030 | 1036 | // Loop through ancestors |
1031 | | if ( !empty( $ancestors ) ) { |
1032 | | foreach ( $ancestors as $ancestor ) { |
| 1037 | if ( !empty( $new_forum_ancestors ) ) { |
| 1038 | foreach ( $new_forum_ancestors as $ancestor ) { |
1033 | 1039 | |
1034 | 1040 | // If ancestor is a forum, update counts |
1035 | 1041 | if ( bbp_is_forum( $ancestor ) ) { |