Changeset 499
- Timestamp:
- 04/04/2014 12:39:30 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/buddypress.org/public_html/wp-content/plugins/buddypress-org/extensions.php
r447 r499 77 77 /** Other Functions ***********************************************************/ 78 78 79 /** 80 * Function (hooked to 'init') to handle redirect logic from various rearranged 81 * BuddyPress.org root site page locations. 82 * 83 * @author johnjamesjacoby 84 * @return if not BuddyPress.org root site 85 */ 79 86 function bporg_redirect() { 87 88 // Explode the request (could use parse_url() here too) 80 89 $uri_chunks = explode( '/', $_SERVER['REQUEST_URI'] ); 81 90 82 91 // Redirect /forums/ to /support/ 83 if ( $uri_chunks[1] == 'forums' && empty( $uri_chunks[2] ) )92 if ( $uri_chunks[1] === 'forums' && empty( $uri_chunks[2] ) ) { 84 93 bp_core_redirect( 'http://buddypress.org/support/' ); 94 } 85 95 86 96 // Redirect members directory to root to block heavy paginated user queries 87 if ( ( $uri_chunks[1] == 'members' ) || ( $uri_chunks[1] == 'community' && $uri_chunks[2] == 'members' && empty( $uri_chunks[3] ) ) )97 if ( ( $uri_chunks[1] === 'members' ) && empty( $uri_chunks[2] ) ) { 88 98 bp_core_redirect( 'http://buddypress.org' ); 89 90 // Redirect members directory to root to block heavy paginated user queries 91 if ( $uri_chunks[1] == 'community' && $uri_chunks[2] == 'groups' ) { 92 93 if ( !empty( $uri_chunks[5] ) && ( $uri_chunks[5] == 'topic' ) ) { 99 } 100 101 // Redirect old members profile pages to 102 if ( ( $uri_chunks[1] === 'community' ) && ( $uri_chunks[2] === 'members' ) && ! empty( $uri_chunks[3] ) ) { 103 bp_core_redirect( 'http://buddypress.org/members/' . $uri_chunks[3] . '/' ); 104 } 105 106 // Redirect old plugin groups to deprecated plugin forums 107 if ( ( $uri_chunks[1] === 'community' ) && ( $uri_chunks[2] === 'groups' ) ) { 108 109 // Single group topic redirect 110 if ( !empty( $uri_chunks[5] ) && ( $uri_chunks[5] === 'topic' ) ) { 94 111 bp_core_redirect( 'http://buddypress.org/support/topic/' . $uri_chunks[6] . '/' ); 95 112 96 } elseif ( empty( $uri_chunks[4] ) || ( $uri_chunks[4] == 'forum' ) ) { 113 // Single group forum redirect 114 } elseif ( empty( $uri_chunks[4] ) || ( $uri_chunks[4] === 'forum' ) ) { 97 115 98 116 // Use legacy group slug … … 103 121 } else { 104 122 105 // New forums locations123 // New BuddyPress project forums locations 106 124 switch ( $uri_chunks[3] ) { 107 125 case 'gallery' : … … 133 151 134 152 // Redirect /support/topics/ to /support/ 135 if ( $uri_chunks[1] == 'support' && ( !empty( $uri_chunks[2] ) && ( 'topics' == $uri_chunks[2] ) ) )153 if ( $uri_chunks[1] === 'support' && ( !empty( $uri_chunks[2] ) && ( 'topics' === $uri_chunks[2] ) ) ) { 136 154 bp_core_redirect( 'http://buddypress.org/support/' ); 137 138 // Redirect /members/ to /community/members/ 139 if ( $uri_chunks[1] == 'members' && !empty( $uri_chunks[2] ) ) 140 bp_core_redirect( 'http://buddypress.org/community/members/' . strtolower( $uri_chunks[2] ) . '/' ); 141 } 142 add_action( 'init', 'bporg_redirect' ); 155 } 156 } 157 if ( 'buddypress.org' === $_SERVER['HTTP_HOST'] && ! is_admin() && defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ) { 158 add_action( 'init', 'bporg_redirect', 1 ); // before bp_init 159 } 143 160 144 161 function wporg_profiles_redirect() { 145 162 $uri_chunks = explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ) ); 146 163 if ( 'users' == $uri_chunks[0] ) { 147 if ( ! empty( $uri_chunks[1] ) ) 164 if ( ! empty( $uri_chunks[1] ) ) { 148 165 wp_redirect( 'http://profiles.wordpress.org/' . $uri_chunks[1] . '/', 301 ); 149 else166 } else { 150 167 wp_redirect( 'http://wordpress.org/' ); 168 } 151 169 exit; 152 170 } 153 171 154 if ( get_user_by( 'slug', $uri_chunks[0] ) ) 172 if ( get_user_by( 'slug', $uri_chunks[0] ) ) { 155 173 return; 174 } 175 156 176 if ( $user = get_user_by( 'login', urldecode( $uri_chunks[0] ) ) ) { 157 177 wp_redirect( 'http://profiles.wordpress.org/' . $user->user_nicename . '/', 301 ); … … 167 187 168 188 function wporg_profiles_maybe_template_redirect() { 169 if ( is_robots() || is_feed() || is_trackback() ) 189 if ( is_robots() || is_feed() || is_trackback() ) { 170 190 return; 191 } 171 192 172 193 ob_start();
Note: See TracChangeset
for help on using the changeset viewer.