Ticket #3430: 3430.02.patch
File 3430.02.patch, 5.0 KB (added by , 4 years ago) |
---|
-
src/includes/extend/buddypress/functions.php
129 129 if ( bp_is_group_forum_topic() || bp_is_group_forum_topic_edit() ) { 130 130 131 131 // Get the topic 132 $topic = get_posts(array(132 $topic_args = array( 133 133 'name' => bp_action_variable( 1 ), 134 134 'post_status' => array_keys( bbp_get_topic_statuses() ), 135 135 'post_type' => bbp_get_topic_post_type(), 136 136 'numberposts' => 1 137 ) ); 137 ); 138 139 // Pending topic requires a different format 140 $pending_prefix = bbp_get_pending_status_id() . '--'; 141 if ( 0 === strpos( bp_action_variable( 1 ), $pending_prefix ) ) { 142 $id = substr( bp_action_variable( 1 ), strlen( $pending_prefix ) ); 143 if ( is_numeric( $id ) ) { 144 $topic_args['p'] = $id; 145 unset( $topic_args['name'] ); 146 } 147 } 148 149 $topic = get_posts( $topic_args ); 138 150 139 151 // Add the topic title to the <title> 140 152 $new_title .= bbp_get_topic_title( $topic[0]->ID ) . ' ' . $sep . ' '; -
src/includes/extend/buddypress/groups.php
1028 1028 // hide the 'to front' admin links 1029 1029 add_filter( 'bbp_get_topic_stick_link', array( $this, 'hide_super_sticky_admin_link' ), 10, 2 ); 1030 1030 1031 // Get the topic 1032 bbp_has_topics( array( 1033 'name' => bp_action_variable( $offset + 1 ), 1031 $slug = bp_action_variable( $offset + 1 ); 1032 1033 $topic_args = array( 1034 'name' => $slug, 1034 1035 'posts_per_page' => 1, 1035 1036 'show_stickies' => false 1036 ) ); 1037 ); 1038 1039 // Pending topic requires a different format 1040 $pending_prefix = bbp_get_pending_status_id() . '--'; 1041 if ( 0 === strpos( $slug, $pending_prefix ) ) { 1042 $id = substr( $slug, strlen( $pending_prefix ) ); 1043 if ( is_numeric( $id ) ) { 1044 $topic_args['p'] = $id; 1045 unset( $topic_args['name'] ); 1046 } 1047 } 1048 1049 // Get the topic 1050 bbp_has_topics( $topic_args ); 1037 1051 1038 1052 // If no topic, 404 1039 1053 if ( ! bbp_topics() ) { … … 1232 1246 */ 1233 1247 public function new_topic_redirect_to( $redirect_url = '', $redirect_to = '', $topic_id = 0 ) { 1234 1248 if ( bp_is_group() ) { 1235 $topic = bbp_get_topic( $topic_id ); 1236 $topic_hash = '#post-' . $topic_id; 1237 $redirect_url = trailingslashit( bp_get_group_permalink( groups_get_current_group() ) ) . trailingslashit( $this->slug ) . trailingslashit( $this->topic_slug ) . trailingslashit( $topic->post_name ) . $topic_hash; 1249 $topic = bbp_get_topic( $topic_id ); 1250 $slug = trailingslashit( $topic->post_name ); 1251 $topic_hash = '#post-' . $topic_id; 1252 1253 // Pending status 1254 if ( bbp_get_pending_status_id() === get_post_status( $topic_id ) ) { 1255 $slug = bbp_add_view_all( sprintf( '%s--%d', bbp_get_pending_status_id(), $topic_id ), true ); 1256 } 1257 1258 $redirect_url = trailingslashit( bp_get_group_permalink( groups_get_current_group() ) ) . trailingslashit( $this->slug ) . trailingslashit( $this->topic_slug ) . $slug . $topic_hash; 1238 1259 } 1239 1260 1240 1261 return $redirect_url; … … 1432 1453 case bbp_get_topic_post_type() : 1433 1454 $topic_id = $post_id; 1434 1455 $forum_id = bbp_get_topic_forum_id( $post_id ); 1435 $url_end = trailingslashit( $this->topic_slug ) . get_post_field( 'post_name', $post_id ); 1456 $url_end = trailingslashit( $this->topic_slug ); 1457 1458 // Pending status 1459 if ( bbp_get_pending_status_id() === get_post_status( $post_id ) ) { 1460 $url_end .= sprintf( '%s--%d/', bbp_get_pending_status_id(), $post_id ); 1461 1462 // Everything else 1463 } else { 1464 $url_end .= get_post_field( 'post_name', $post_id ); 1465 } 1436 1466 break; 1437 1467 1438 1468 // Forum … … 1464 1494 $group_permalink = trailingslashit( bp_get_group_permalink( $group ) ); 1465 1495 } 1466 1496 1467 return trailingslashit( trailingslashit( $group_permalink . $this->slug ) . $url_end ); 1497 $retval = trailingslashit( trailingslashit( $group_permalink . $this->slug ) . $url_end ); 1498 1499 if ( bbp_get_pending_status_id() === get_post_status( $post_id ) ) { 1500 $retval = bbp_add_view_all( $retval, true ); 1501 } 1502 1503 return $retval; 1468 1504 } 1469 1505 1470 1506 /** … … 1632 1668 $forum_id = bbp_get_topic_forum_id( $topic_id ); 1633 1669 $group_ids = bbp_get_forum_group_ids( $forum_id ); 1634 1670 1671 // Pending status 1672 if ( bbp_get_pending_status_id() === get_post_status( $topic_id ) ) { 1673 $slug = sprintf( '%s--%d', bbp_get_pending_status_id(), $topic_id ); 1674 } 1675 1635 1676 // Not a forum or topic 1636 1677 } else { 1637 1678 return; … … 1651 1692 // Add topic slug to URL 1652 1693 if ( bbp_is_single_topic() ) { 1653 1694 $redirect_to = trailingslashit( $redirect_to . $this->topic_slug . '/' . $slug ); 1695 1696 if ( bbp_get_pending_status_id() === get_post_status( $topic_id ) ) { 1697 $redirect_to = bbp_add_view_all( $redirect_to, true ); 1698 } 1654 1699 } 1655 1700 1656 1701 bp_core_redirect( $redirect_to );