Changeset 3488
- Timestamp:
- 11/27/2010 10:21:26 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-catchuri.php
r3464 r3488 105 105 106 106 // Reset the keys by merging with an empty array 107 $bp_uri = array_merge( array(), $bp_uri ); 108 $bp_unfiltered_uri = $bp_uri; 107 $bp_uri = array_merge( array(), $bp_uri ); 108 $bp_unfiltered_uri = $bp_uri; 109 110 // If a component is set to the front page, force its name into $bp_uri so that $current_component is populated 111 if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && empty( $bp_uri ) ) { 112 $post = get_post( get_option( 'page_on_front' ) ); 113 if ( !empty( $post ) ) 114 $bp_uri[0] = $post->post_name; 115 } 109 116 110 117 // Find a match within registered BuddyPress controlled WP pages (check members first) … … 215 222 * @package BuddyPress Core 216 223 * @param $username str Username to check. 217 * @global $wpdb WordPress DB access object. 218 * @return false on no match 219 * @return int the user ID of the matched user. 224 * @return false|int The user ID of the matched user, or false. 220 225 */ 221 226 function bp_core_load_template( $templates ) { 222 global $ post, $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;227 global $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset; 223 228 224 229 // Determine if the root object WP page exists for this request (TODO: is there an API function for this? 225 if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) ) 226 return false; 227 228 // Set the root object as the current wp_query-ied item 229 $object_id = 0; 230 foreach ( (array)$bp->pages as $page ) { 231 if ( isset( $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) && $page->name == $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) 232 $object_id = $page->id; 233 } 234 235 // Make the queried/post object an actual valid page 236 if ( !empty( $object_id ) ) { 237 $wp_query->queried_object = &get_post( $object_id ); 238 $wp_query->queried_object_id = $object_id; 239 240 $post = $wp_query->queried_object; 241 } 230 if ( !empty( $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) 231 if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) ) 232 return false; 242 233 243 234 // Fetch each template and add the php suffix … … 246 237 247 238 // Filter the template locations so that plugins can alter where they are located 248 if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) { 249 // Template was located, lets set this as a valid page and not a 404. 250 status_header( 200 ); 251 $wp_query->is_page = true; 252 $wp_query->is_404 = false; 253 239 if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) 254 240 load_template( apply_filters( 'bp_load_template', $located_template ) ); 255 }256 241 257 242 // Kill any other output after this. -
trunk/bp-core/bp-core-signup.php
r3442 r3488 16 16 17 17 $bp->is_directory = false; 18 19 if ( bp_is_component_front_page( 'register' ) && ( is_user_logged_in() || !bp_get_signup_allowed() ) ) 20 bp_core_redirect( $bp->root_domain . '/' . $bp->members->slug ); 18 21 19 22 /* If the user is logged in, redirect away from here */ -
trunk/bp-core/bp-core-templatetags.php
r3479 r3488 1518 1518 /* Template is_() functions to determine the current page */ 1519 1519 1520 /** 1521 * Checks if the site's front page is set to the specified BuddyPress component page in wp-admin's Settings > Reading screen. 1522 * 1523 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 1524 * @global $current_blog WordPress global containing information and settings for the current blog being viewed. 1525 * @param string $component Optional; name of the component to check for. If not specified, uses $bp->current_component. 1526 * @return bool True if the specified component is set to be the site's front page. 1527 * @since 1.3 1528 */ 1529 function bp_is_component_front_page( $component='' ) { 1530 global $bp, $current_blog; 1531 1532 if ( !$component && !empty( $bp->current_component ) ) 1533 $component = $bp->current_component; 1534 1535 if ( is_main_site() ) 1536 $path = bp_core_get_site_path(); 1537 else 1538 $path = $current_blog->path; 1539 1540 if ( 'page' != get_option( 'show_on_front' ) || !$component || empty( $bp->pages->{$component} ) || $_SERVER['REQUEST_URI'] != $path ) 1541 return false; 1542 1543 return apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == get_option( 'page_on_front' ) ), $component ); 1544 } 1545 1520 1546 function bp_is_blog_page() { 1521 1547 global $bp, $is_member_page, $wp_query; … … 1542 1568 function bp_is_home() { return bp_is_my_profile(); } 1543 1569 1570 /** 1571 * Is the user on the front page of the site? 1572 * 1573 * @deprecated 1.3 1574 * @deprecated Use is_front_page() 1575 * @return bool 1576 */ 1544 1577 function bp_is_front_page() { 1545 if ( 'posts' == get_option('show_on_front') && is_home() ) 1546 return true; 1547 else if ( bp_is_activity_front_page() ) 1548 return true; 1549 else 1550 return is_front_page(); 1551 } 1552 1578 _deprecated_function( __FUNCTION__, '1.3', "is_front_page()" ); 1579 return is_front_page(); 1580 } 1581 1582 /** 1583 * Is the front page of the site set to the Activity component? 1584 * 1585 * @deprecated 1.3 1586 * @deprecated Use bp_is_component_front_page( 'activity' ) 1587 * @return bool 1588 */ 1553 1589 function bp_is_activity_front_page() { 1554 global $current_blog; 1555 1556 if ( is_main_site() ) 1557 $path = bp_core_get_site_path(); 1558 else 1559 $path = $current_blog->path; 1560 1561 return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == $path ); 1590 _deprecated_function( __FUNCTION__, '1.3', "bp_is_component_front_page( 'activity' )" ); 1591 return bp_is_component_front_page( 'activity' ); 1562 1592 } 1563 1593 … … 1980 2010 $bp_classes = array(); 1981 2011 1982 if ( bp_is_front_page() )2012 if ( is_front_page() ) 1983 2013 $bp_classes[] = 'home-page'; 1984 2014 … … 1989 2019 $bp_classes[] = 'profile'; 1990 2020 1991 if ( bp_is_activity_component() && !bp_is_blog_page() || ( bp_is_activity_front_page() && bp_is_front_page() ))2021 if ( bp_is_activity_component() && !bp_is_blog_page() ) 1992 2022 $bp_classes[] = 'activity'; 1993 2023 1994 if ( bp_is_blogs_component() && !bp_is_blog_page() 2024 if ( bp_is_blogs_component() && !bp_is_blog_page() ) 1995 2025 $bp_classes[] = 'blogs'; 1996 2026 … … 1998 2028 $bp_classes[] = 'messages'; 1999 2029 2000 if ( bp_is_friends_component() && !bp_is_blog_page() 2030 if ( bp_is_friends_component() && !bp_is_blog_page() ) 2001 2031 $bp_classes[] = 'friends'; 2002 2032 2003 if ( bp_is_groups_component() && !bp_is_blog_page() 2033 if ( bp_is_groups_component() && !bp_is_blog_page() ) 2004 2034 $bp_classes[] = 'groups'; 2005 2035 -
trunk/bp-themes/bp-default/functions.php
r3462 r3488 155 155 156 156 /** 157 * Filter the dropdown for selecting the page to show on front to include "Activity Stream" 158 * 157 * In BuddyPress 1.2.x, this function filtered the dropdown on the Settings > Reading screen for selecting 158 * the page to show on front to include "Activity Stream." 159 * As of 1.3.x, it is no longer required. 160 * 161 * @deprecated 1.3 162 * @deprecated No longer required. 159 163 * @param string $page_html A list of pages as a dropdown (select list) 164 * @return string 160 165 * @see wp_dropdown_pages() 161 * @return string162 * @package BuddyPress Theme163 166 * @since 1.2 164 167 */ 165 168 function bp_dtheme_wp_pages_filter( $page_html ) { 166 if ( !bp_is_active( 'activity' ) ) 167 return $page_html; 168 169 if ( 'page_on_front' != substr( $page_html, 14, 13 ) ) 170 return $page_html; 171 172 $selected = false; 173 $page_html = str_replace( '</select>', '', $page_html ); 174 175 if ( bp_dtheme_page_on_front() == 'activity' ) 176 $selected = ' selected="selected"'; 177 178 $page_html .= '<option class="level-0" value="activity"' . $selected . '>' . __( 'Activity Stream', 'buddypress' ) . '</option></select>'; 169 _deprecated_function( __FUNCTION__, '1.3', "No longer required." ); 179 170 return $page_html; 180 171 } 181 add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' ); 182 183 /** 184 * Hijack the saving of page on front setting to save the activity stream setting 185 * 172 173 /** 174 * In BuddyPress 1.2.x, this function hijacked the saving of page on front setting to save the activity stream setting. 175 * As of 1.3.x, it is no longer required. 176 * 177 * @deprecated 1.3 178 * @deprecated No longer required. 186 179 * @param $string $oldvalue Previous value of get_option( 'page_on_front' ) 187 180 * @param $string $oldvalue New value of get_option( 'page_on_front' ) 188 181 * @return string 189 * @package BuddyPress Theme190 182 * @since 1.2 191 183 */ 192 184 function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) { 185 _deprecated_function( __FUNCTION__, '1.3', "No longer required." ); 193 186 if ( !is_admin() || !is_super_admin() ) 194 187 return false; 195 188 196 if ( 'activity' == $_POST['page_on_front'] ) 197 return 'activity'; 198 else 199 return $oldvalue; 200 } 201 add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 ); 202 203 /** 204 * Load the activity stream template if settings allow 205 * 189 return $oldvalue; 190 } 191 192 /** 193 * In BuddyPress 1.2.x, this function loaded the activity stream template if the front page display settings allow. 194 * As of 1.3.x, it is no longer required. 195 * 196 * @deprecated 1.3 197 * @deprecated No longer required. 206 198 * @param string $template Absolute path to the page template 207 199 * @return string 208 * @global WP_Query $wp_query WordPress query object209 * @package BuddyPress Theme210 200 * @since 1.2 211 201 */ 212 202 function bp_dtheme_page_on_front_template( $template ) { 213 global $wp_query; 214 215 if ( empty( $wp_query->post->ID ) ) 216 return locate_template( array( 'activity/index.php' ), false ); 217 else 218 return $template; 219 } 220 add_filter( 'page_template', 'bp_dtheme_page_on_front_template' ); 203 _deprecated_function( __FUNCTION__, '1.3', "No longer required." ); 204 return $template; 205 } 221 206 222 207 /** … … 224 209 * 225 210 * @return false|int ID of page set as the home page 226 * @package BuddyPress Theme227 211 * @since 1.2 228 212 */ … … 235 219 236 220 /** 237 * Force the page ID as a string to stop the get_posts query from kicking up a fuss. 238 * 239 * @global WP_Query $wp_query WordPress query object 240 * @package BuddyPress Theme 221 * In BuddyPress 1.2.x, this forced the page ID as a string to stop the get_posts query from kicking up a fuss. 222 * As of 1.3.x, it is no longer required. 223 * 224 * @deprecated 1.3 225 * @deprecated No longer required. 241 226 * @since 1.2 242 227 */ 243 228 function bp_dtheme_fix_get_posts_on_activity_front() { 244 global $wp_query; 245 246 if ( !empty($wp_query->query_vars['page_id']) && 'activity' == $wp_query->query_vars['page_id'] ) 247 $wp_query->query_vars['page_id'] = '"activity"'; 248 } 249 add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' ); 250 251 /** 252 * WP 3.0 requires there to be a non-null post in the posts array 253 * 229 _deprecated_function( __FUNCTION__, '1.3', "No longer required." ); 230 } 231 232 /** 233 * In BuddyPress 1.3, this was used as part of the code that set the activity stream to be on the front page. 234 * As of 1.3.x, it is no longer required. 235 * 236 * @deprecated 1.3 237 * @deprecated No longer required. 254 238 * @param array $posts Posts as retrieved by WP_Query 255 * @global WP_Query $wp_query WordPress query object256 239 * @return array 257 * @package BuddyPress Theme258 240 * @since 1.2.5 259 241 */ 260 242 function bp_dtheme_fix_the_posts_on_activity_front( $posts ) { 261 global $wp_query; 262 263 // NOTE: the double quotes around '"activity"' are thanks to our previous function bp_dtheme_fix_get_posts_on_activity_front() 264 if ( empty( $posts ) && !empty( $wp_query->query_vars['page_id'] ) && '"activity"' == $wp_query->query_vars['page_id'] ) 265 $posts = array( (object) array( 'ID' => 'activity' ) ); 266 243 _deprecated_function( __FUNCTION__, '1.3', "No longer required." ); 267 244 return $posts; 268 245 } 269 add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' );270 246 271 247 /** … … 406 382 ?> 407 383 <ul id="nav"> 408 <li<?php if ( bp_is_front_page() ) : ?> class="selected"<?php endif; ?>>384 <li<?php if ( is_front_page() ) : ?> class="selected"<?php endif; ?>> 409 385 <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a> 410 386 </li>
Note: See TracChangeset
for help on using the changeset viewer.