Ticket #1777: 1777.01.patch
File 1777.01.patch, 4.7 KB (added by , 12 years ago) |
---|
-
bbp-includes/bbp-reply-functions.php
313 313 $reply_url = bbp_get_reply_url( $reply_id, $redirect_to ); 314 314 315 315 // Allow to be filtered 316 $reply_url = apply_filters( 'bbp_new_reply_redirect_to', $reply_url, $redirect_to );316 $reply_url = apply_filters( 'bbp_new_reply_redirect_to', $reply_url, $redirect_to, $reply_id ); 317 317 318 318 /** Successful Save ***********************************************/ 319 319 -
bbp-includes/bbp-extend-buddypress.php
965 965 add_action( 'bp_actions', 'bbp_edit_forum_handler' ); 966 966 add_action( 'bp_actions', 'bbp_edit_topic_handler' ); 967 967 add_action( 'bp_actions', 'bbp_edit_reply_handler' ); 968 969 // Tweak the redirect field 970 add_filter( 'bbp_new_topic_redirect_to', array( $this, 'new_topic_redirect_to' ), 10, 2 ); 971 add_filter( 'bbp_new_reply_redirect_to', array( $this, 'new_reply_redirect_to' ), 10, 3 ); 968 972 } 969 973 970 974 function display() { … … 987 991 // Hide breadcrumb 988 992 add_filter( 'bbp_no_breadcrumb', '__return_true' ); 989 993 990 // Tweak the redirect field991 add_filter( 'bbp_new_topic_redirect_to', array( $this, 'new_topic_redirect_to' ), 10, 2 );992 add_filter( 'bbp_new_reply_redirect_to', array( $this, 'new_reply_redirect_to' ), 10, 2 );993 994 994 $this->display_forums( 0 ); 995 995 } 996 996 … … 1253 1253 'post_status' => $status 1254 1254 ) ); 1255 1255 1256 // Create the initial topic1257 $topic_id = bbp_insert_topic(1258 array(1259 'post_parent' => $forum_id,1260 'post_title' => __( 'Hello World!', 'bbpress' ),1261 'post_content' => __( 'I am the first topic in your group forum. You can keep me, edit me, trash me, or delete me.', 'bbpress' )1262 ),1263 array( 'forum_id' => $forum_id )1264 );1265 1266 // Create the initial reply1267 $reply_id = bbp_insert_reply(1268 array(1269 'post_parent' => $topic_id,1270 'post_title' => __( 'Re: Hello World!', 'bbpress' ),1271 'post_content' => __( 'Oh, and this is what a reply looks like.', 'bbpress' )1272 ),1273 array(1274 'forum_id' => $forum_id,1275 'topic_id' => $topic_id1276 )1277 );1278 1279 1256 // Add the ID's to group meta 1280 1257 groups_update_groupmeta( bp_get_new_group_id(), 'forum_id', $forum_id ); 1281 groups_update_groupmeta( bp_get_new_group_id(), 'first_topic_id', $topic_id );1282 groups_update_groupmeta( bp_get_new_group_id(), 'first_reply_id', $reply_id );1283 1258 1284 1259 break; 1285 1260 case false : … … 1572 1547 * 1573 1548 * @since bbPress (r3653) 1574 1549 * 1575 * @uses groups_get_current_group() 1576 * @uses bp_is_group_admin_screen() 1577 * @uses trailingslashit() 1578 * @uses bp_get_root_domain() 1579 * @uses bp_get_groups_root_slug() 1550 * @param str $redirect_url 1551 * @param str $redirect_to 1580 1552 */ 1581 1553 public function new_topic_redirect_to( $redirect_url = '', $redirect_to = '' ) { 1582 1554 return $redirect_url; 1583 1555 } 1556 1557 /** 1558 * Redirect to the group forum screen 1559 * 1560 * @since bbPress (r3653) 1561 */ 1562 public function new_reply_redirect_to( $redirect_url = '', $redirect_to = '', $reply_id = 0 ) { 1563 global $wp_rewrite; 1564 1565 if ( bp_is_group() ) { 1566 $topic_id = bbp_get_reply_topic_id( $reply_id ); 1567 $topic = bbp_get_topic( $topic_id ); 1568 $reply_position = bbp_get_reply_position( $reply_id, $topic_id ); 1584 1569 1570 // Check if in query with pagination 1571 $reply_page = ceil( (int) $reply_position / (int) bbp_get_replies_per_page() ); 1572 1573 // Hash to add to end of URL 1574 $reply_hash = '#post-' . $reply_id; 1575 1576 // Build the topic URL from the group data 1577 $topic_url = trailingslashit( bp_get_group_permalink( groups_get_current_group() ) ) . trailingslashit( $this->slug ) . trailingslashit( $this->topic_slug ) . trailingslashit( $topic->post_name ); 1578 1579 // Don't include pagination if on first page 1580 if ( 1 >= $reply_page ) { 1581 $redirect_url = trailingslashit( $topic_url ) . $reply_hash; 1582 1583 // Include pagination 1584 } else { 1585 1586 // Pretty permalinks 1587 if ( $wp_rewrite->using_permalinks() ) { 1588 $redirect_url = trailingslashit( $topic_url ) . trailingslashit( $wp_rewrite->pagination_base ) . trailingslashit( $reply_page ) . $reply_hash; 1589 1590 // Yucky links 1591 } else { 1592 $redirect_url = add_query_arg( 'paged', $reply_page, $topic_url ) . $reply_hash; 1593 } 1594 } 1595 1596 // Add topic view query arg back to end if it is set 1597 if ( bbp_get_view_all() ) 1598 $redirect_url = bbp_add_view_all( $redirect_url ); 1599 } 1600 1601 return $redirect_url; 1602 } 1603 1585 1604 /** 1586 1605 * Redirect to the group admin forum edit screen 1587 1606 *