Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/29/2011 01:51:02 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Improve the current title area of breadcrumbs.
Improve behavior of redirect field.
Allow single topic shortcodes to use pagination, and properly redirect on new replies.
Use wp_safe_redirect() in places where redirect_to fields are used.
Move theme compatibility setup function out of main bbPress class and into bbp-core-compatibility.php.
Move bbp_setup_theme_compat action off of after_setup_theme and into bbp_init.
Add supplemental functions to get and set if theme compatibility is currently helping load pieces of the current page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r3243 r3265  
    4141 * @uses bbp_unstick_topic() To unstick the topic
    4242 * @uses bbp_get_topic_permalink() To get the topic permalink
    43  * @uses wp_redirect() To redirect to the topic link
     43 * @uses wp_safe_redirect() To redirect to the topic link
    4444 * @uses bbPress::errors::get_error_messages() To get the {@link WP_Error} error
    4545 *                                              messages
     
    240240                /** Redirect **************************************************/
    241241
    242                 $topic_url = bbp_get_topic_permalink( $topic_id );
    243 
    244                 if ( $bbp->trash_status_id == $topic_data['post_status'] )
     242                // Redirect to
     243                $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
     244
     245                // View all?
     246                $count_hidden = (bool) ( !empty( $_GET['view'] ) && ( 'all' == $_GET['view'] ) || ( $topic_data['post_status'] == $bbp->trash_status_id ) );
     247
     248                // Get the topic URL
     249                $topic_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
     250
     251                // Add view all?
     252                if ( !empty( $count_hidden ) )
    245253                    $topic_url = add_query_arg( array( 'view' => 'all' ), $topic_url );
    246254
    247                 $topic_url = apply_filters( 'bbp_new_topic_redirect_to', $topic_url );
     255                // Allow to be filtered
     256                $topic_url = apply_filters( 'bbp_new_topic_redirect_to', $topic_url, $count_hidden, $redirect_to );
    248257
    249258                /** Successful Save *******************************************/
    250259
    251260                // Redirect back to new topic
    252                 wp_redirect( $topic_url );
     261                wp_safe_redirect( $topic_url );
    253262
    254263                // For good measure
     
    294303 *                                 to another
    295304 * @uses bbp_get_topic_permalink() To get the topic permalink
    296  * @uses wp_redirect() To redirect to the topic link
     305 * @uses wp_safe_redirect() To redirect to the topic link
    297306 * @uses bbPress::errors::get_error_messages() To get the {@link WP_Error} error
    298307 *                                              messages
     
    504513                do_action( 'bbp_edit_topic_post_extras', $topic_id );
    505514
     515                /** Redirect **************************************************/
     516
     517                // Redirect to
     518                $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
     519
     520                // View all?
     521                $count_hidden = (bool) ( !empty( $_GET['view'] ) && ( 'all' == $_GET['view'] ) );
     522
     523                // Get the topic URL
     524                $topic_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
     525
     526                // Add view all?
     527                if ( !empty( $count_hidden ) )
     528                    $topic_url = add_query_arg( array( 'view' => 'all' ), $topic_url );
     529
     530                // Allow to be filtered
     531                $topic_url = apply_filters( 'bbp_edit_topic_redirect_to', $topic_url, $count_hidden, $redirect_to );
     532
    506533                /** Successful Edit *******************************************/
    507534
    508535                // Redirect back to new topic
    509                 wp_redirect( bbp_get_topic_permalink( $topic_id ) );
     536                wp_safe_redirect( $topic_url );
    510537
    511538                // For good measure
Note: See TracChangeset for help on using the changeset viewer.