Ticket #2743: 2743-2.patch
File 2743-2.patch, 13.2 KB (added by , 15 years ago) |
---|
-
bp-activity.php
67 67 function bp_activity_directory_activity_setup() { 68 68 global $bp; 69 69 70 if ( $bp->current_component == $bp->activity->slug && empty( $bp->current_action ) ) {70 if ( is_front_page() && bp_is_component_front_page( $bp->activity->slug ) || $bp->current_component == $bp->activity->slug && empty( $bp->current_action ) ) { 71 71 $bp->is_directory = true; 72 72 73 73 do_action( 'bp_activity_directory_activity_setup' ); -
bp-themes/bp-default/functions.php
107 107 } 108 108 109 109 /** 110 * Filter the dropdown for selecting the page to show on front to include "Activity Stream" 110 * In BuddyPress 1.2.x, this function filtered the dropdown on the Settings > Reading screen for selecting 111 * the page to show on front to include "Activity Stream." 112 * As of 1.3.x, it is no longer required. 111 113 * 114 * @deprecated 1.3 115 * @deprecated Don't use this, really. 112 116 * @param string $page_html A list of pages as a dropdown (select list) 113 * @see wp_dropdown_pages()114 117 * @return string 115 * @ package BuddyPress Theme118 * @see wp_dropdown_pages() 116 119 * @since 1.2 117 120 */ 118 121 function bp_dtheme_wp_pages_filter( $page_html ) { 119 if ( !bp_is_active( 'activity' ) ) 120 return $page_html; 121 122 if ( 'page_on_front' != substr( $page_html, 14, 13 ) ) 123 return $page_html; 124 125 $selected = false; 126 $page_html = str_replace( '</select>', '', $page_html ); 127 128 if ( bp_dtheme_page_on_front() == 'activity' ) 129 $selected = ' selected="selected"'; 130 131 $page_html .= '<option class="level-0" value="activity"' . $selected . '>' . __( 'Activity Stream', 'buddypress' ) . '</option></select>'; 122 _deprecated_function( __FUNCTION__, '1.3', "Don't use this, really." ); 132 123 return $page_html; 133 124 } 134 add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' );135 125 136 126 /** 137 * Hijack the saving of page on front setting to save the activity stream setting 127 * In BuddyPress 1.2.x, this function hijacked the saving of page on front setting to save the activity stream setting. 128 * As of 1.3.x, it is no longer required. 138 129 * 130 * @deprecated 1.3 131 * @deprecated Don't use this, really. 139 132 * @param $string $oldvalue Previous value of get_option( 'page_on_front' ) 140 133 * @param $string $oldvalue New value of get_option( 'page_on_front' ) 141 134 * @return string 142 * @package BuddyPress Theme143 135 * @since 1.2 144 136 */ 145 137 function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) { 138 _deprecated_function( __FUNCTION__, '1.3', "Don't use this, really." ); 146 139 if ( !is_admin() || !is_super_admin() ) 147 140 return false; 148 141 149 if ( 'activity' == $_POST['page_on_front'] ) 150 return 'activity'; 151 else 152 return $oldvalue; 142 return $oldvalue; 153 143 } 154 add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 );155 144 156 145 /** 157 * Load the activity stream template if settings allow 146 * In BuddyPress 1.2.x, this function loaded the activity stream template if the front page display settings allow. 147 * As of 1.3.x, it is no longer required. 158 148 * 149 * @deprecated 1.3 150 * @deprecated Don't use this, really. 159 151 * @param string $template Absolute path to the page template 160 152 * @return string 161 * @global WP_Query $wp_query WordPress query object162 * @package BuddyPress Theme163 153 * @since 1.2 164 154 */ 165 155 function bp_dtheme_page_on_front_template( $template ) { 166 global $wp_query; 167 168 if ( empty( $wp_query->post->ID ) ) 169 return locate_template( array( 'activity/index.php' ), false ); 170 else 171 return $template; 156 _deprecated_function( __FUNCTION__, '1.3', "Don't use this, really." ); 157 return $template; 172 158 } 173 add_filter( 'page_template', 'bp_dtheme_page_on_front_template' );174 159 175 160 /** 176 161 * Return the ID of a page set as the home page. 177 162 * 178 163 * @return false|int ID of page set as the home page 179 * @package BuddyPress Theme180 164 * @since 1.2 181 165 */ 182 166 function bp_dtheme_page_on_front() { … … 187 171 } 188 172 189 173 /** 190 * Force the page ID as a string to stop the get_posts query from kicking up a fuss. 174 * In BuddyPress 1.2.x, this forced the page ID as a string to stop the get_posts query from kicking up a fuss. 175 * As of 1.3.x, it is no longer required. 191 176 * 192 * @ global WP_Query $wp_query WordPress query object193 * @ package BuddyPress Theme177 * @deprecated 1.3 178 * @deprecated Don't use this, really. 194 179 * @since 1.2 195 180 */ 196 181 function bp_dtheme_fix_get_posts_on_activity_front() { 197 global $wp_query; 198 199 if ( !empty($wp_query->query_vars['page_id']) && 'activity' == $wp_query->query_vars['page_id'] ) 200 $wp_query->query_vars['page_id'] = '"activity"'; 182 _deprecated_function( __FUNCTION__, '1.3', "Don't use this, really." ); 201 183 } 202 add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' );203 184 204 185 /** 205 * WP 3.0 requires there to be a non-null post in the posts array 186 * In BuddyPress 1.3, this was used as part of the code that set the activity stream to be on the front page. 187 * As of 1.3.x, it is no longer required. 206 188 * 189 * @deprecated 1.3 190 * @deprecated Don't use this, really. 207 191 * @param array $posts Posts as retrieved by WP_Query 208 * @global WP_Query $wp_query WordPress query object209 192 * @return array 210 * @package BuddyPress Theme211 193 * @since 1.2.5 212 194 */ 213 195 function bp_dtheme_fix_the_posts_on_activity_front( $posts ) { 214 global $wp_query; 215 216 // NOTE: the double quotes around '"activity"' are thanks to our previous function bp_dtheme_fix_get_posts_on_activity_front() 217 if ( empty( $posts ) && !empty( $wp_query->query_vars['page_id'] ) && '"activity"' == $wp_query->query_vars['page_id'] ) 218 $posts = array( (object) array( 'ID' => 'activity' ) ); 219 196 _deprecated_function( __FUNCTION__, '1.3', "Don't use this, really." ); 220 197 return $posts; 221 198 } 222 add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' );223 199 224 200 /** 225 201 * Add secondary avatar image to this activity stream's record, if supported … … 358 334 function bp_dtheme_main_nav( $args ) { 359 335 ?> 360 336 <ul id="nav"> 361 <li<?php if ( bp_is_front_page() ) : ?> class="selected"<?php endif; ?>>337 <li<?php if ( is_front_page() ) : ?> class="selected"<?php endif; ?>> 362 338 <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a> 363 339 </li> 364 340 -
bp-core/bp-core-templatetags.php
1503 1503 1504 1504 /* Template is_() functions to determine the current page */ 1505 1505 1506 /** 1507 * Checks if the site's front page is set to the specified BuddyPress component page in wp-admin's Settings > Reading screen. 1508 * 1509 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 1510 * @global $current_blog WordPress global containing information and settings for the current blog being viewed. 1511 * @param string $component Optional; name of the component to check for. If not specified, uses $bp->current_component. 1512 * @return bool True if the specified component is set to be the site's front page. 1513 * @since 1.3 1514 */ 1515 function bp_is_component_front_page( $component='' ) { 1516 global $bp, $current_blog; 1517 1518 if ( !$component && !empty( $bp->current_component ) ) 1519 $component = $bp->current_component; 1520 1521 if ( is_main_site() ) 1522 $path = bp_core_get_site_path(); 1523 else 1524 $path = $current_blog->path; 1525 1526 if ( 'page' != get_option( 'show_on_front' ) || !$component || !isset( $bp->pages ) || !isset( $bp->pages->{$component} ) || $_SERVER['REQUEST_URI'] != $path ) 1527 return false; 1528 1529 return apply_filters( 'bp_is_front_page_set_to', ( $bp->pages->{$component}->id == get_option( 'page_on_front' ) ), $component ); 1530 } 1531 1506 1532 function bp_is_blog_page() { 1507 1533 global $bp, $is_member_page, $wp_query; 1508 1534 … … 1527 1553 } 1528 1554 function bp_is_home() { return bp_is_my_profile(); } 1529 1555 1556 /** 1557 * Is the user on the front page of the site? 1558 * 1559 * @deprecated 1.3 1560 * @deprecated Use is_front_page() 1561 * @return bool 1562 */ 1530 1563 function bp_is_front_page() { 1531 if ( 'posts' == get_option('show_on_front') && is_home() ) 1532 return true; 1533 else if ( bp_is_activity_front_page() ) 1534 return true; 1535 else 1536 return is_front_page(); 1564 _deprecated_function( __FUNCTION__, '1.3', "is_front_page()" ); 1565 return is_front_page(); 1537 1566 } 1538 1567 1539 function bp_is_activity_front_page() {1540 global $current_blog;1541 1542 if ( is_main_site() )1543 $path = bp_core_get_site_path();1544 else1545 $path = $current_blog->path;1546 1547 return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == $path );1548 }1549 1550 1568 function bp_is_directory() { 1551 1569 global $bp; 1552 1570 … … 1965 1983 1966 1984 $bp_classes = array(); 1967 1985 1968 if ( bp_is_front_page() )1986 if ( is_front_page() ) 1969 1987 $bp_classes[] = 'home-page'; 1970 1988 1971 1989 if ( bp_is_directory() ) … … 1974 1992 if ( bp_is_user_profile() && !bp_is_blog_page() ) 1975 1993 $bp_classes[] = 'profile'; 1976 1994 1977 if ( bp_is_activity_component() && !bp_is_blog_page() || ( bp_is_activity_front_page() && bp_is_front_page()) )1995 if ( bp_is_activity_component() && !bp_is_blog_page() || is_front_page() && bp_is_active( 'activity' ) && bp_is_component_front_page( $bp->activity->slug ) ) 1978 1996 $bp_classes[] = 'activity'; 1979 1997 1980 if ( bp_is_blogs_component() && !bp_is_blog_page() )1998 if ( bp_is_blogs_component() && !bp_is_blog_page() || is_front_page() && bp_is_active( 'blogs' ) && bp_is_component_front_page( $bp->blogs->slug ) ) 1981 1999 $bp_classes[] = 'blogs'; 1982 2000 1983 2001 if ( bp_is_messages_component() && !bp_is_blog_page() ) 1984 2002 $bp_classes[] = 'messages'; 1985 2003 1986 if ( bp_is_friends_component() && !bp_is_blog_page() )2004 if ( bp_is_friends_component() && !bp_is_blog_page() || is_front_page() && bp_is_active( 'members' ) && bp_is_component_front_page( $bp->members->slug ) ) 1987 2005 $bp_classes[] = 'friends'; 1988 2006 1989 if ( bp_is_groups_component() && !bp_is_blog_page() )2007 if ( bp_is_groups_component() && !bp_is_blog_page() || is_front_page() && bp_is_active( 'groups' ) && bp_is_component_front_page( $bp->groups->slug ) ) 1990 2008 $bp_classes[] = 'groups'; 1991 2009 1992 2010 if ( bp_is_settings_component() && !bp_is_blog_page() ) -
bp-core/bp-core-catchuri.php
222 222 global $post, $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset; 223 223 224 224 // 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; 225 if ( isset( $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) 226 if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) ) 227 return false; 227 228 228 229 // Set the root object as the current wp_query-ied item 229 230 $object_id = 0; -
bp-blogs.php
71 71 function bp_blogs_directory_blogs_setup() { 72 72 global $bp; 73 73 74 if ( is_multisite() && $bp->current_component == $bp->blogs->slug && empty( $bp->current_action) ) {74 if ( is_multisite() && ( is_front_page() && bp_is_component_front_page( $bp->blogs->slug ) || $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) ) { 75 75 $bp->is_directory = true; 76 76 77 77 do_action( 'bp_blogs_directory_blogs_setup' ); -
bp-forums.php
44 44 function bp_forums_directory_forums_setup() { 45 45 global $bp; 46 46 47 if ( $bp->current_component == $bp->forums->slug ) {47 if ( bp_forums_is_installed_correctly() && is_front_page() && bp_is_component_front_page( $bp->forums->slug ) || $bp->current_component == $bp->forums->slug ) { 48 48 if ( (int) $bp->site_options['bp-disable-forum-directory'] || !bp_is_active( 'groups' ) ) 49 49 return false; 50 50 -
bp-groups.php
156 156 function groups_directory_groups_setup() { 157 157 global $bp; 158 158 159 if ( $bp->current_component == $bp->groups->slug && empty( $bp->current_action ) && empty( $bp->current_item ) ) {159 if ( is_front_page() && bp_is_component_front_page( $bp->groups->slug ) || $bp->current_component == $bp->groups->slug && empty( $bp->current_action ) && empty( $bp->current_item ) ) { 160 160 $bp->is_directory = true; 161 161 162 162 do_action( 'groups_directory_groups_setup' ); -
bp-core.php
399 399 function bp_core_action_directory_members() { 400 400 global $bp; 401 401 402 if ( is_ null( $bp->displayed_user->id ) && $bp->current_component == $bp->members->slug ) {402 if ( is_front_page() && bp_is_component_front_page( $bp->members->slug ) || is_null( $bp->displayed_user->id ) && $bp->current_component == $bp->members->slug ) { 403 403 $bp->is_directory = true; 404 404 405 405 do_action( 'bp_core_action_directory_members' );