Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/24/2015 01:32:20 PM (11 years ago)
Author:
johnjamesjacoby
Message:

API: Introduce bbp_redirect()

  • Wraps wp_safe_redirect() & exit() calls
  • Prevents errors from potentially empty wp_get_referrer() results
  • Replace wp_safe_redirect() usages with bbp_redirect()

Fixes #2778.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/topics/functions.php

    r5656 r5658  
    109109 * @uses bbp_unstick_topic() To unstick the topic
    110110 * @uses bbp_get_topic_permalink() To get the topic permalink
    111  * @uses wp_safe_redirect() To redirect to the topic link
     111 * @uses bbp_redirect() To redirect to the topic link
    112112 * @uses bbPress::errors::get_error_messages() To get the {@link WP_Error} error
    113113 *                                              messages
     
    428428
    429429        // Redirect back to new topic
    430         wp_safe_redirect( $redirect_url );
    431 
    432         // For good measure
    433         exit();
     430        bbp_redirect( $redirect_url );
    434431
    435432    // Errors
     
    471468 *                                 to another
    472469 * @uses bbp_get_topic_permalink() To get the topic permalink
    473  * @uses wp_safe_redirect() To redirect to the topic link
     470 * @uses bbp_redirect() To redirect to the topic link
    474471 * @uses bbPress::errors::get_error_messages() To get the {@link WP_Error} error
    475472 *                                              messages
     
    792789
    793790        // Redirect back to new topic
    794         wp_safe_redirect( $topic_url );
    795 
    796         // For good measure
    797         exit();
     791        bbp_redirect( $topic_url );
    798792
    799793    /** Errors ****************************************************************/
     
    11491143 *                    topic ids and source topic's forum id
    11501144 * @uses bbp_get_topic_permalink() To get the topic permalink
    1151  * @uses wp_safe_redirect() To redirect to the topic link
     1145 * @uses bbp_redirect() To redirect to the topic link
    11521146 */
    11531147function bbp_merge_topic_handler( $action = '' ) {
     
    13621356
    13631357    // Redirect back to new topic
    1364     wp_safe_redirect( bbp_get_topic_permalink( $destination_topic->ID ) );
    1365 
    1366     // For good measure
    1367     exit();
     1358    bbp_redirect( bbp_get_topic_permalink( $destination_topic->ID ) );
    13681359}
    13691360
     
    14491440 *                    source topic ids and source topic's forum id
    14501441 * @uses bbp_get_topic_permalink() To get the topic permalink
    1451  * @uses wp_safe_redirect() To redirect to the topic link
     1442 * @uses bbp_redirect() To redirect to the topic link
    14521443 */
    14531444function bbp_split_topic_handler( $action = '' ) {
     
    17451736
    17461737    // Redirect back to the topic
    1747     wp_safe_redirect( bbp_get_topic_permalink( $destination_topic->ID ) );
    1748 
    1749     // For good measure
    1750     exit();
     1738    bbp_redirect( bbp_get_topic_permalink( $destination_topic->ID ) );
    17511739}
    17521740
     
    18111799 * @uses do_action() Calls actions based on the actions with associated args
    18121800 * @uses is_wp_error() To check if the value retrieved is a {@link WP_Error}
    1813  * @uses wp_safe_redirect() To redirect to the url
     1801 * @uses bbp_redirect() To redirect to the url
    18141802 */
    18151803function bbp_edit_topic_tag_handler( $action = '' ) {
     
    19801968    // Redirect back
    19811969    $redirect = ( ! empty( $redirect ) && ! is_wp_error( $redirect ) ) ? $redirect : home_url();
    1982     wp_safe_redirect( $redirect );
    1983 
    1984     // For good measure
    1985     exit();
     1970    bbp_redirect( $redirect );
    19861971}
    19871972
     
    20872072 * @uses bbp_get_topic_permalink() To get the topic link
    20882073 * @uses add_query_arg() To add args to the url
    2089  * @uses wp_safe_redirect() To redirect to the topic
     2074 * @uses bbp_redirect() To redirect to the topic
    20902075 * @uses bbPress::errors:add() To log the error messages
    20912076 */
     
    22322217        }
    22332218
    2234         wp_safe_redirect( $redirect );
    2235 
    2236         // For good measure
    2237         exit();
     2219        bbp_redirect( $redirect );
    22382220
    22392221    // Handle errors
     
    37863768 * @uses current_user_can()
    37873769 * @uses bbp_get_topic_id()
    3788  * @uses wp_safe_redirect()
     3770 * @uses bbp_redirect()
    37893771 * @uses bbp_get_topic_permalink()
    37903772 */
     
    37983780    // User cannot edit topic, so redirect back to topic
    37993781    if ( ! current_user_can( 'edit_topic', bbp_get_topic_id() ) ) {
    3800         wp_safe_redirect( bbp_get_topic_permalink() );
    3801         exit();
     3782        bbp_redirect( bbp_get_topic_permalink() );
    38023783    }
    38033784}
     
    38113792 * @uses current_user_can()
    38123793 * @uses bbp_get_topic_tag_id()
    3813  * @uses wp_safe_redirect()
     3794 * @uses bbp_redirect()
    38143795 * @uses bbp_get_topic_tag_link()
    38153796 */
     
    38233804    // Bail if current user cannot edit topic tags
    38243805    if ( ! current_user_can( 'edit_topic_tags', bbp_get_topic_tag_id() ) ) {
    3825         wp_safe_redirect( bbp_get_topic_tag_link() );
    3826         exit();
    3827     }
    3828 }
     3806        bbp_redirect( bbp_get_topic_tag_link() );
     3807    }
     3808}
Note: See TracChangeset for help on using the changeset viewer.