Ticket #1906: 1906.diff
File 1906.diff, 22.6 KB (added by , 12 years ago) |
---|
-
bbp-includes/extend/buddypress.php
226 226 add_filter( 'bbp_get_favorites_permalink', array( $this, 'get_favorites_permalink' ), 10, 2 ); 227 227 add_filter( 'bbp_get_subscriptions_permalink', array( $this, 'get_subscriptions_permalink' ), 10, 2 ); 228 228 229 /** Links and pagination **********************************************/ 230 229 231 // Map forum/topic/replys permalinks to their groups 230 232 add_filter( 'bbp_get_forum_permalink', array( $this, 'map_forum_permalink_to_group' ), 10, 2 ); 231 233 add_filter( 'bbp_get_topic_permalink', array( $this, 'map_topic_permalink_to_group' ), 10, 2 ); 232 234 add_filter( 'bbp_get_reply_permalink', array( $this, 'map_reply_permalink_to_group' ), 10, 2 ); 233 235 236 // Map reply edit links to their groups 237 add_filter( 'bbp_get_reply_edit_url', array( $this, 'map_reply_edit_url_to_group' ), 10, 2 ); 238 239 // Map assorted template function permalinks 240 add_filter( 'post_link', array( $this, 'post_link' ), 10, 3 ); 241 add_filter( 'page_link', array( $this, 'page_link' ), 10, 3 ); 242 add_filter( 'post_type_link', array( $this, 'post_type_link' ), 10, 4 ); 243 234 244 // Canonical redirects for normal URLs 235 245 add_action( 'template_redirect', array( $this, 'redirect_canonical' ) ); 236 246 247 // Group forum pagination 248 add_filter( 'bbp_topic_pagination', array( $this, 'topic_pagination' ) ); 249 add_filter( 'bbp_replies_pagination', array( $this, 'replies_pagination' ) ); 250 237 251 /** Mentions **********************************************************/ 238 252 239 253 // Only link mentions if activity component is active … … 850 864 } 851 865 852 866 /** 853 * Ma p a forumpermalink to the corresponding group867 * Maybe map a bbPress forum/topic/reply permalink to the corresponding group 854 868 * 855 * @since bbPress (r3802) 856 * @param string $url 857 * @param int $forum_id 869 * @param int $post_id 870 * @uses get_post 871 * @uses bbp_is_reply 872 * @uses bbp_get_reply_topic_id 873 * @uses bbp_get_reply_forum_id 874 * @uses bbp_is_topic 875 * @uses bbp_get_topic_forum_id 876 * @uses bbp_is_forum 877 * @uses get_post_field 878 * @uses bbp_get_forum_group_ids 879 * @uses groups_get_group 880 * @uses bp_get_group_admin_permalink 881 * @uses bp_get_group_permalink 882 * @return Bail early if not a group forum post 858 883 * @return string 859 884 */ 860 public function map_forum_permalink_to_group( $url, $forum_id ) { 861 $slug = get_post_field( 'post_name', $forum_id ); 862 $group_ids = bbp_get_forum_group_ids( $forum_id ); 885 private function maybe_map_permalink_to_group( $post_id ) { 886 $post_id = absint( $post_id ); 887 $post = get_post( $post_id ); 888 if ( !$post ) 889 return false; 863 890 864 // If the topic is not associated with a group, don't mess with it 865 if ( !empty( $group_ids ) ) { 891 // Bail early if not a bbPress post type 892 $post_type = $post->post_type; 893 $post_name = $post->post_name; 894 if ( !in_array( $post_type, array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() ) ) ) 895 return false; 866 896 867 // @todo Multiple group forums/forum groups 868 $group_id = $group_ids[0]; 869 $group = groups_get_group( array( 'group_id' => $group_id ) ); 897 // Reply 898 if ( bbp_is_reply( $post_id ) ) { 899 $reply_id = $post_id; 900 $topic_id = bbp_get_reply_topic_id( $post_id ); 901 $forum_id = bbp_get_reply_forum_id( $post_id ); 870 902 871 if ( bp_is_group_admin_screen( $this->forums_slug ) ) { 872 $group_permalink = bp_get_group_admin_permalink( $group ); 873 } else { 874 $group_permalink = bp_get_group_permalink( $group ); 875 } 903 // Topic 904 } elseif ( bbp_is_topic( $post_id ) ) { 905 $topic_id = $post_id; 906 $forum_id = bbp_get_topic_forum_id( $post_id ); 876 907 877 $url = trailingslashit( $group_permalink . $this->forums_slug . '/' . $slug ); 908 // Forum 909 } elseif ( bbp_is_forum( $post_id ) ) { 910 $forum_id = $post_id; 911 912 // Bail 913 } else { 914 return false; 878 915 } 879 916 880 return $url; 917 // Get relevant slugs 918 $forum_slug = get_post_field( 'post_name', $forum_id ); 919 $group_ids = bbp_get_forum_group_ids( $forum_id ); 920 921 // Bail if the post isn't associated with a group 922 if ( empty( $group_ids ) ) 923 return false; 924 925 // @todo Multiple group forums/forum groups 926 $group_id = $group_ids[0]; 927 $group = groups_get_group( array( 'group_id' => $group_id ) ); 928 929 if ( bp_is_group_admin_screen( $this->forums_slug ) ) 930 $group_permalink = bp_get_group_admin_permalink( $group ); 931 else 932 $group_permalink = bp_get_group_permalink( $group ); 933 934 $url = trailingslashit( $group_permalink ) . $this->forums_slug . '/'; 935 936 // Reply link (special case: should usually request the permalink for the reply's topic) 937 if ( bbp_is_reply( $post_id ) ) { 938 $url .= $this->reply_slug . '/' . $post_name; 939 940 // Topic link 941 } elseif ( bbp_is_topic( $post_id ) ) { 942 $url .= $this->topic_slug . '/' . $post_name; 943 944 // Forum link 945 } elseif ( bbp_is_forum( $post_id ) ) { 946 $url .= $post_name; 947 } 948 949 return trailingslashit( $url ); 881 950 } 882 951 883 952 /** 884 * Map a topic permalink to the current group forum953 * Map a forum permalink to its corresponding group 885 954 * 886 955 * @since bbPress (r3802) 887 956 * @param string $url 957 * @param int $forum_id 958 * @uses maybe_map_permalink_to_group 959 * @return string 960 */ 961 public function map_forum_permalink_to_group( $url, $forum_id ) { 962 $new = $this->maybe_map_permalink_to_group( $forum_id ); 963 if ( !$new ) 964 return $url; 965 966 return $new; 967 } 968 969 /** 970 * Map a topic permalink to its group forum 971 * 972 * @since bbPress (r3802) 973 * @param string $url 888 974 * @param int $topic_id 975 * @uses maybe_map_permalink_to_group 889 976 * @return string 890 977 */ 891 978 public function map_topic_permalink_to_group( $url, $topic_id ) { 892 $slug = get_post_field( 'post_name', $topic_id ); 893 $forum_id = bbp_get_topic_forum_id( $topic_id ); 894 $group_ids = bbp_get_forum_group_ids( $forum_id ); 979 $new = $this->maybe_map_permalink_to_group( $topic_id ); 980 if ( !$new ) 981 return $url; 982 983 return $new; 984 } 895 985 896 // If the topic is not associated with a group, don't mess with it 897 if ( !empty( $group_ids ) ) { 986 /** 987 * Map a reply permalink to its group forum 988 * 989 * @since bbPress (r3802) 990 * @param string $url 991 * @param int $reply_id 992 * @uses maybe_map_permalink_to_group 993 * @return string 994 */ 995 public function map_reply_permalink_to_group( $url, $reply_id ) { 996 $topic_id = bbp_get_reply_topic_id( $reply_id ); 898 997 899 // @todo Multiple group forums/forum groups900 $group_id = $group_ids[0];901 $group = groups_get_group( array( 'group_id' => $group_id ) );998 $new = $this->maybe_map_permalink_to_group( $topic_id ); 999 if ( !$new ) 1000 return $url; 902 1001 903 if ( bp_is_group_admin_screen( $this->forums_slug ) ) { 904 $group_permalink = bp_get_group_admin_permalink( $group ); 905 } else { 906 $group_permalink = bp_get_group_permalink( $group ); 907 } 1002 return $new; 1003 } 908 1004 909 $url = trailingslashit( $group_permalink . $this->forums_slug . '/' . $this->topic_slug . '/' . $slug ); 910 } 1005 /** 1006 * Map a reply edit link to its group forum 1007 * 1008 * @param string $url 1009 * @param int $reply_id 1010 * @uses maybe_map_permalink_to_group 1011 * @return string 1012 */ 1013 public function map_reply_edit_url_to_group( $url, $reply_id ) { 1014 $bbp = bbpress(); 911 1015 1016 $new = $this->maybe_map_permalink_to_group( $reply_id ); 1017 if ( !$new ) 1018 return $url; 1019 1020 $url = trailingslashit( $new ) . $bbp->edit_id . '/'; 912 1021 return $url; 913 1022 } 914 1023 915 1024 /** 916 * Map a topic permalink to the currentgroup forum1025 * Map a post link to its group forum 917 1026 * 918 * @since bbPress (r3802)919 1027 * @param string $url 920 * @param int $reply_id 1028 * @param obj $post 1029 * @param boolean $leavename 1030 * @uses maybe_map_permalink_to_group 921 1031 * @return string 922 1032 */ 923 public function map_reply_permalink_to_group( $url, $reply_id ) { 924 $slug = get_post_field( 'post_name', $reply_id ); 925 $forum_id = bbp_get_reply_forum_id( $reply_id ); 926 $group_ids = bbp_get_forum_group_ids( $forum_id ); 1033 public function post_link( $url, $post, $leavename ) { 1034 $post_id = $post->ID; 927 1035 928 // If the topic is not associated with a group, don't mess with it 929 if ( !empty( $group_ids ) ) { 1036 $new = $this->maybe_map_permalink_to_group( $post_id ); 1037 if ( !$new ) 1038 return $url; 930 1039 931 // @todo Multiple group forums/forum groups 932 $group_id = $group_ids[0]; 933 $group = groups_get_group( array( 'group_id' => $group_id ) ); 1040 return $new; 1041 } 934 1042 935 if ( bp_is_group_admin_screen( $this->forums_slug ) ) { 936 $group_permalink = bp_get_group_admin_permalink( $group ); 937 } else { 938 $group_permalink = bp_get_group_permalink( $group ); 939 } 1043 /** 1044 * Map a page link to its group forum 1045 * 1046 * @param string $url 1047 * @param int $post_id 1048 * @param $sample 1049 * @uses maybe_map_permalink_to_group 1050 * @return string 1051 */ 1052 public function page_link( $url, $post_id, $sample ) { 1053 $new = $this->maybe_map_permalink_to_group( $post_id ); 1054 if ( !$new ) 1055 return $url; 940 1056 941 $url = trailingslashit( $group_permalink . $this->forums_slug . '/' . $this->topic_slug . '/' . $slug ); 942 } 943 1057 $url = $new; 944 1058 return $url; 945 1059 } 946 1060 947 1061 /** 1062 * Map a custom post type link to its group forum 1063 * 1064 * @param string $url 1065 * @param obj $post 1066 * @param $leavename 1067 * @param $sample 1068 * @uses maybe_map_permalink_to_group 1069 * @return string 1070 */ 1071 public function post_type_link( $url, $post, $leavename, $sample ) { 1072 $post_id = absint( $post->ID ); 1073 1074 $new = $this->maybe_map_permalink_to_group( $post_id ); 1075 if ( !$new ) 1076 return $url; 1077 1078 return $new; 1079 } 1080 1081 /** 1082 * Fix pagination of topics on forum view 1083 * 1084 * @param array $args 1085 * @global $wp_rewrite 1086 * @uses bbp_get_forum_id() 1087 * @uses maybe_map_permalink_to_group 1088 * @return array 1089 */ 1090 public function topic_pagination( $args ) { 1091 global $wp_rewrite; 1092 1093 // Get forum data 1094 $forum_id = bbp_get_forum_id(); 1095 $new = $this->maybe_map_permalink_to_group( $forum_id ); 1096 if ( !$new ) 1097 return $args; 1098 1099 $base = trailingslashit( $new ) . $wp_rewrite->pagination_base . '/%#%/'; 1100 $args['base'] = $base; 1101 return $args; 1102 } 1103 1104 /** 1105 * Fix pagination of replies on topic view 1106 * 1107 * @param array $args 1108 * @global $wp_rewrite 1109 * @uses bbp_get_topic_id() 1110 * @uses maybe_map_permalink_to_group 1111 * @return array 1112 */ 1113 public function replies_pagination( $args ) { 1114 global $wp_rewrite; 1115 1116 // Get topic data 1117 $topic_id = bbp_get_topic_id(); 1118 $new = $this->maybe_map_permalink_to_group( $topic_id ); 1119 if ( !$new ) 1120 return $args; 1121 1122 $base = trailingslashit( $new ) . $wp_rewrite->pagination_base . '/%#%/'; 1123 $args['base'] = $base; 1124 return $args; 1125 } 1126 1127 /** 948 1128 * Ensure that forum content associated with a BuddyPress group can only be 949 1129 * viewed via the group URL. 950 1130 * … … 966 1146 // @todo Multiple group forums/forum groups 967 1147 $group_id = $group_ids[0]; 968 1148 $group = groups_get_group( array( 'group_id' => $group_id ) ); 969 $group_permalink = bp_get_group_permalink( $group );970 $redirect_to = trailingslashit( $group_permalink . $this->forums_slug );1149 $group_permalink = bp_get_group_permalink( $group ); 1150 $redirect_to = trailingslashit( $group_permalink . $this->forums_slug ); 971 1151 972 1152 if ( !empty( $slug ) ) { 973 1153 $redirect_to = trailingslashit( $redirect_to . $this->topic_slug . '/' . $slug ); … … 1374 1554 //bbp_trash_forum_handler(); 1375 1555 break; 1376 1556 1377 // Permanently delet a forum1557 // Permanently delete a forum 1378 1558 case 'bbp-delete-forum' : 1379 1559 //bbp_delete_forum_handler(); 1380 1560 break; … … 1553 1733 1554 1734 // Forum data 1555 1735 $forum_ids = bbp_get_group_forum_ids( bp_get_current_group_id() ); 1556 $forum_args = array( 'post__in' => $forum_ids, 'post_parent' => null ); ?>1736 $forum_args = array( 'post__in' => $forum_ids, 'post_parent' => null ); 1557 1737 1558 <div id="bbpress-forums"> 1738 // Unset global queries 1739 $bbp->forum_query = new StdClass; 1740 $bbp->topic_query = new StdClass; 1741 $bbp->reply_query = new StdClass; 1559 1742 1743 // Unset global ID's 1744 $bbp->current_forum_id = 0; 1745 $bbp->current_topic_id = 0; 1746 $bbp->current_reply_id = 0; 1747 $bbp->current_topic_tag_id = 0; 1748 1749 // Reset the post data 1750 wp_reset_postdata(); 1751 1752 // Allow admins special views 1753 $post_status = array( bbp_get_closed_status_id(), bbp_get_public_status_id() ); 1754 if ( is_super_admin() || current_user_can( 'moderate' ) || bp_is_item_admin() || bp_is_item_mod() ) 1755 $post_status = array_merge( $post_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ); ?> 1756 1757 <div id="bbpress-forums"> 1758 1560 1759 <?php 1561 1760 1562 1761 // Looking at the group forum root 1563 if ( ! bp_action_variable( $offset ) ) :1762 if ( !bp_action_variable( $offset ) ) : 1564 1763 1565 // Query forums and show them if 1566 if ( !empty( $forum_ids ) && bbp_has_forums( $forum_args ) ) : 1764 // Query forums and show them if they exist 1765 if ( !empty( $forum_ids ) && bbp_has_forums( $forum_args ) ) : 1567 1766 1568 bbp_the_forum();1569 1570 1767 // Only one forum found 1571 if ( $bbp->forum_query->post_count == 1 ) :?> 1768 if ( 1 == $bbp->forum_query->post_count && !bp_is_group_admin_screen( $this->slug ) ) : 1769 // Get forum data 1770 $forum_slug = bp_action_variable( $offset ); 1771 $forum_args = array( 'name' => $forum_slug, 'post_type' => bbp_get_forum_post_type() ); 1772 $forums = get_posts( $forum_args ); 1572 1773 1573 <h3><?php _e( 'Forum', 'bbpress' ); ?></h3>1774 bbp_the_forum(); 1574 1775 1575 <?php bbp_set_query_name( 'bbp_single_forum' ); ?> 1776 // Forum exists 1777 if ( !empty( $forums ) ) : 1778 $forum = $forums[0]; 1576 1779 1577 <?php if ( bbp_has_topics( array( 'post_parent' => bbp_get_forum_id() ) ) ) : ?> 1780 // Set up forum data 1781 $forum_id = bbpress()->current_forum_id = $forum->ID; 1782 bbp_set_query_name( 'bbp_single_forum' ); ?> 1578 1783 1579 < ?php bbp_get_template_part( 'pagination', 'topics' ); ?>1784 <h3><?php bbp_forum_title(); ?></h3> 1580 1785 1581 <?php bbp_get_template_part( ' loop', 'topics'); ?>1786 <?php bbp_get_template_part( 'content', 'single-forum' ); ?> 1582 1787 1583 <?php bbp_get_template_part( 'pagination', 'topics' ); ?>1584 1585 <?php bbp_get_template_part( 'form', 'topic' ); ?>1586 1587 1788 <?php else : ?> 1588 1789 1589 1790 <?php bbp_get_template_part( 'feedback', 'no-topics' ); ?> 1590 1791 1591 1792 <?php bbp_get_template_part( 'form', 'topic' ); ?> 1592 1793 1593 1794 <?php endif; 1594 1795 1595 // More than 1 forum found 1596 elseif ( $bbp->forum_query->post_count > 1) : ?>1796 // More than 1 forum found or group forum admin screen 1797 elseif ( 1 < $bbp->forum_query->post_count || bp_is_group_admin_screen( $this->slug ) ) : ?> 1597 1798 1598 1799 <h3><?php _e( 'Forums', 'bbpress' ); ?></h3> 1599 1800 … … 1626 1827 <p><?php _e( 'This group does not currently have any forums.', 'bbpress' ); ?></p> 1627 1828 </div> 1628 1829 1629 <?php if ( bp_is_group_admin_screen( $this->slug ) ) : 1630 bbp_get_template_part( 'form', 'forum' ); 1631 endif; 1830 <?php if ( bp_is_group_admin_screen( $this->slug ) ) : ?> 1831 1832 <?php bbp_get_template_part( 'form', 'forum' ); ?> 1833 1834 <?php endif; 1835 1632 1836 endif; 1633 1837 1634 1838 // No forums found … … 1638 1842 <p><?php _e( 'This group does not currently have any forums.', 'bbpress' ); ?></p> 1639 1843 </div> 1640 1844 1641 <?php if ( bp_is_group_admin_screen( $this->slug ) ) : 1642 bbp_get_template_part( 'form', 'forum' ); 1643 endif; 1845 <?php if ( bp_is_group_admin_screen( $this->slug ) ) : ?> 1846 1847 <?php bbp_get_template_part( 'form', 'forum' ); ?> 1848 1849 <?php endif; 1850 1644 1851 endif; 1645 1852 1646 1853 // Single forum 1647 elseif ( ( bp_action_variable( $offset ) != $this->slug ) && ( bp_action_variable( $offset ) != $this->topic_slug ) ) :1854 elseif ( bp_action_variable( $offset ) != $this->slug && bp_action_variable( $offset ) != $this->topic_slug && bp_action_variable( $offset ) != $this->reply_slug ) : 1648 1855 1649 // Get the forum1650 $forum_ post_type = bbp_get_forum_post_type();1651 $forum_ slug = bp_action_variable( $offset);1652 $forums = $wpdb->get_row( "SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$forum_slug}' AND post_type = '{$forum_post_type}'", ARRAY_N);1856 // Get forum data 1857 $forum_slug = bp_action_variable( $offset ); 1858 $forum_args = array( 'name' => $forum_slug, 'post_type' => bbp_get_forum_post_type() ); 1859 $forums = get_posts( $forum_args ); 1653 1860 1654 // Forum exists 1655 if ( !empty( $forums ) ) : 1656 $forum_id = $forums[0]; 1657 $bbp->current_forum_id = $forum_id; 1658 bbp_set_query_name( 'bbp_single_forum' ); ?> 1861 // Forum exists 1862 if ( !empty( $forums ) ) : 1863 $forum = $forums[0]; 1659 1864 1660 <h3><?php bbp_forum_title(); ?></h3> 1865 // Set up forum data 1866 $forum_id = bbpress()->current_forum_id = $forum->ID; 1661 1867 1662 <?php bbp_get_template_part( 'content', 'single-forum' ); ?> 1868 // Reset necessary forum_query attributes for forums loop to function 1869 $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); 1870 $bbp->forum_query->in_the_loop = true; 1871 $bbp->forum_query->post = get_post( $forum_id ); 1663 1872 1873 // Forum edit 1874 if ( bp_action_variable( $offset + 1 ) == $bbp->edit_id ) : 1875 global $wp_query, $post; 1876 $wp_query->bbp_is_edit = true; 1877 $wp_query->bbp_is_forum_edit = true; 1878 $post = $forum; 1879 bbp_set_query_name( 'bbp_forum_form' ); ?> 1880 1881 <?php bbp_get_template_part( 'form', 'forum' ); ?> 1882 1883 <?php else : 1884 bbp_set_query_name( 'bbp_single_forum' ); ?> 1885 1886 <h3><?php bbp_forum_title(); ?></h3> 1887 1888 <?php bbp_get_template_part( 'content', 'single-forum' ); ?> 1889 1890 <?php endif; ?> 1891 1664 1892 <?php else : ?> 1665 1893 1666 <?php bbp_get_template_part( 'feedback', 'no-topics'); ?>1894 <?php bbp_get_template_part( 'feedback', 'no-topics' ); ?> 1667 1895 1668 <?php bbp_get_template_part( 'form', 'topic'); ?>1896 <?php bbp_get_template_part( 'form', 'topic' ); ?> 1669 1897 1670 1898 <?php endif; 1671 1899 1672 1900 // Single topic 1673 elseif ( ( bp_action_variable( $offset ) != $this->slug ) && ( bp_action_variable( $offset ) == $this->topic_slug )) :1901 elseif ( bp_action_variable( $offset ) == $this->topic_slug ) : 1674 1902 1675 // Get t he topic1676 $topic_ post_type = bbp_get_topic_post_type();1677 $topic_ slug = bp_action_variable( $offset + 1);1678 $topics = $wpdb->get_row( "SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$topic_slug}' AND post_type = '{$topic_post_type}'", ARRAY_N);1903 // Get topic data 1904 $topic_slug = bp_action_variable( $offset + 1 ); 1905 $topic_args = array( 'name' => $topic_slug, 'post_type' => bbp_get_topic_post_type(), 'post_status' => $post_status ); 1906 $topics = get_posts( $topic_args ); 1679 1907 1680 1908 // Topic exists 1681 1909 if ( !empty( $topics ) ) : 1682 $topic_id = $topics[0]; 1683 $bbp->current_topic_id = $topic_id; 1684 bbp_set_query_name( 'bbp_single_topic' ); ?> 1910 $topic = $topics[0]; 1685 1911 1686 <h3><?php bbp_topic_title(); ?></h3> 1912 // Set up topic data 1913 $topic_id = bbpress()->current_topic_id = $topic->ID; 1914 $forum_id = bbp_get_topic_forum_id( $topic_id ); 1915 1916 // Reset necessary forum_query attributes for topics loop to function 1917 $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); 1918 $bbp->forum_query->in_the_loop = true; 1919 $bbp->forum_query->post = get_post( $forum_id ); 1687 1920 1688 <?php bbp_get_template_part( 'content', 'single-topic' ); ?> 1921 // Reset necessary topic_query attributes for topics loop to function 1922 $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type(); 1923 $bbp->topic_query->in_the_loop = true; 1924 $bbp->topic_query->post = $topic; 1689 1925 1690 <?php else : ?> 1926 // Topic edit 1927 if ( bp_action_variable( $offset + 2 ) == $bbp->edit_id ) : 1928 global $wp_query, $post; 1929 $wp_query->bbp_is_edit = true; 1930 $wp_query->bbp_is_topic_edit = true; 1931 $post = $topic; 1932 1933 // Merge 1934 if ( !empty( $_GET['action'] ) && 'merge' == $_GET['action'] ) : 1935 bbp_set_query_name( 'bbp_topic_merge' ); ?> 1691 1936 1937 <?php bbp_get_template_part( 'form', 'topic-merge' ); ?> 1938 1939 <?php // Split 1940 elseif ( !empty( $_GET['action'] ) && 'split' == $_GET['action'] ) : 1941 bbp_set_query_name( 'bbp_topic_split' ); ?> 1942 1943 <?php bbp_get_template_part( 'form', 'topic-split' ); ?> 1944 1945 <?php // Edit 1946 else : 1947 bbp_set_query_name( 'bbp_topic_form' ); ?> 1948 1949 <?php bbp_get_template_part( 'form', 'topic' ); ?> 1950 1951 <?php endif; 1952 1953 else: 1954 1955 bbp_set_query_name( 'bbp_single_topic' ); ?> 1956 1957 <h3><?php bbp_topic_title(); ?></h3> 1958 1959 <?php bbp_get_template_part( 'content', 'single-topic' ); ?> 1960 1961 <?php endif; 1962 1963 else : ?> 1964 1692 1965 <?php bbp_get_template_part( 'feedback', 'no-topics' ); ?> 1693 1966 1694 1967 <?php bbp_get_template_part( 'form', 'topic' ); ?> 1695 1968 1696 1969 <?php endif; 1970 1971 // Single reply 1972 elseif ( bp_action_variable( $offset ) == $this->reply_slug ) : 1697 1973 1974 // Get reply data 1975 $reply_slug = bp_action_variable( $offset + 1 ); 1976 $reply_args = array( 'name' => $reply_slug, 'post_type' => bbp_get_reply_post_type() ); 1977 $replies = get_posts( $reply_args ); 1978 if ( !$replies ) 1979 return; 1980 $reply = $replies[0]; 1981 1982 // Set up reply data 1983 $reply_id = bbpress()->current_reply_id = $reply->ID; 1984 $topic_id = bbp_get_reply_topic_id( $reply_id ); 1985 $forum_id = bbp_get_reply_forum_id( $reply_id ); 1986 1987 // Reset necessary forum_query attributes for reply to function 1988 $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); 1989 $bbp->forum_query->in_the_loop = true; 1990 $bbp->forum_query->post = get_post( $forum_id ); 1991 1992 // Reset necessary topic_query attributes for reply to function 1993 $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type(); 1994 $bbp->topic_query->in_the_loop = true; 1995 $bbp->topic_query->post = get_post( $topic_id ); 1996 1997 // Reset necessary reply_query attributes for reply to function 1998 $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type(); 1999 $bbp->reply_query->in_the_loop = true; 2000 $bbp->reply_query->post = $reply; 2001 2002 if ( bp_action_variable( $offset + 2 ) == $bbp->edit_id ) : 2003 bbp_set_query_name( 'bbp_reply_form' ); 2004 global $wp_query, $post; 2005 $wp_query->bbp_is_edit = true; 2006 $wp_query->bbp_is_reply_edit = true; 2007 $post = $reply; ?> 2008 2009 <?php bbp_get_template_part( 'form', 'reply' ); ?> 2010 2011 <?php endif; 2012 1698 2013 endif; ?> 1699 2014 1700 2015 </div>