Skip to:
Content

BuddyPress.org

Ticket #2743: 2743-4.patch

File 2743-4.patch, 13.1 KB (added by boonebgorges, 15 years ago)
  • bp-themes/bp-default/functions.php

     
    154154}
    155155
    156156/**
    157  * Filter the dropdown for selecting the page to show on front to include "Activity Stream"
     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.
    158160 *
     161 * @deprecated 1.3
     162 * @deprecated No longer required.
    159163 * @param string $page_html A list of pages as a dropdown (select list)
    160  * @see wp_dropdown_pages()
    161164 * @return string
    162  * @package BuddyPress Theme
     165 * @see wp_dropdown_pages()
    163166 * @since 1.2
    164167 */
    165168function 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." );
    179170        return $page_html;
    180171}
    181 add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' );
    182172
    183173/**
    184  * Hijack the saving of page on front setting to save the activity stream setting
     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.
    185176 *
     177 * @deprecated 1.3
     178 * @deprecated No longer required.
    186179 * @param $string $oldvalue Previous value of get_option( 'page_on_front' )
    187180 * @param $string $oldvalue New value of get_option( 'page_on_front' )
    188181 * @return string
    189  * @package BuddyPress Theme
    190182 * @since 1.2
    191183 */
    192184function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) {
     185        _deprecated_function( __FUNCTION__, '1.3', "No longer required." );
    193186        if ( !is_admin() || !is_super_admin() )
    194187                return false;
    195188
    196         if ( 'activity' == $_POST['page_on_front'] )
    197                 return 'activity';
    198         else
    199                 return $oldvalue;
     189        return $oldvalue;
    200190}
    201 add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 );
    202191
    203192/**
    204  * Load the activity stream template if settings allow
     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.
    205195 *
     196 * @deprecated 1.3
     197 * @deprecated No longer required.
    206198 * @param string $template Absolute path to the page template
    207199 * @return string
    208  * @global WP_Query $wp_query WordPress query object
    209  * @package BuddyPress Theme
    210200 * @since 1.2
    211201 */
    212202function 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;
     203        _deprecated_function( __FUNCTION__, '1.3', "No longer required." );
     204        return $template;
    219205}
    220 add_filter( 'page_template', 'bp_dtheme_page_on_front_template' );
    221206
    222207/**
    223208 * Return the ID of a page set as the home page.
    224209 *
    225210 * @return false|int ID of page set as the home page
    226  * @package BuddyPress Theme
    227211 * @since 1.2
    228212 */
    229213function bp_dtheme_page_on_front() {
     
    234218}
    235219
    236220/**
    237  * Force the page ID as a string to stop the get_posts query from kicking up a fuss.
     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.
    238223 *
    239  * @global WP_Query $wp_query WordPress query object
    240  * @package BuddyPress Theme
     224 * @deprecated 1.3
     225 * @deprecated No longer required.
    241226 * @since 1.2
    242227 */
    243228function 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"';
     229        _deprecated_function( __FUNCTION__, '1.3', "No longer required." );
    248230}
    249 add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' );
    250231
    251232/**
    252  * WP 3.0 requires there to be a non-null post in the posts array
     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.
    253235 *
     236 * @deprecated 1.3
     237 * @deprecated No longer required.
    254238 * @param array $posts Posts as retrieved by WP_Query
    255  * @global WP_Query $wp_query WordPress query object
    256239 * @return array
    257  * @package BuddyPress Theme
    258240 * @since 1.2.5
    259241 */
    260242function 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." );
    267244        return $posts;
    268245}
    269 add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' );
    270246
    271247/**
    272248 * Add secondary avatar image to this activity stream's record, if supported
     
    405381function bp_dtheme_main_nav( $args ) {
    406382?>
    407383        <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; ?>>
    409385                        <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a>
    410386                </li>
    411387
  • bp-core/bp-core-signup.php

     
    1515                return false;
    1616
    1717        $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 );
    1821
    1922        /* If the user is logged in, redirect away from here */
    2023        if ( is_user_logged_in() )
  • bp-core/bp-core-templatetags.php

     
    15171517
    15181518/* Template is_() functions to determine the current page */
    15191519
     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 */
     1529function 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
    15201546function bp_is_blog_page() {
    15211547        global $bp, $is_member_page, $wp_query;
    15221548
     
    15411567}
    15421568function bp_is_home() { return bp_is_my_profile(); }
    15431569
     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 */
    15441577function 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();
     1578        _deprecated_function( __FUNCTION__, '1.3', "is_front_page()" );
     1579        return is_front_page();
    15511580}
    15521581
     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 */
    15531589function 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' );
    15621592}
    15631593
    15641594function bp_is_directory() {
     
    19792009
    19802010                $bp_classes = array();
    19812011
    1982                 if ( bp_is_front_page() )
     2012                if ( is_front_page() )
    19832013                        $bp_classes[] = 'home-page';
    19842014
    19852015                if ( bp_is_directory() )
     
    19882018                if ( bp_is_user_profile() && !bp_is_blog_page() )
    19892019                        $bp_classes[] = 'profile';
    19902020
    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() )
    19922022                        $bp_classes[] = 'activity';
    19932023
    1994                 if ( bp_is_blogs_component() && !bp_is_blog_page()  )
     2024                if ( bp_is_blogs_component() && !bp_is_blog_page() )
    19952025                        $bp_classes[] = 'blogs';
    19962026
    19972027                if ( bp_is_messages_component() && !bp_is_blog_page()  )
    19982028                        $bp_classes[] = 'messages';
    19992029
    2000                 if ( bp_is_friends_component() && !bp_is_blog_page()  )
     2030                if ( bp_is_friends_component() && !bp_is_blog_page() )
    20012031                        $bp_classes[] = 'friends';
    20022032
    2003                 if ( bp_is_groups_component() && !bp_is_blog_page()  )
     2033                if ( bp_is_groups_component() && !bp_is_blog_page() )
    20042034                        $bp_classes[] = 'groups';
    20052035
    20062036                if ( bp_is_settings_component() && !bp_is_blog_page()  )
  • bp-core/bp-core-catchuri.php

     
    104104        }
    105105
    106106        // 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;
    109109
     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        }
     116
    110117        // Find a match within registered BuddyPress controlled WP pages (check members first)
    111118        foreach ( (array)$bp_pages as $page_key => $bp_page ) {
    112119                if ( in_array( $bp_page->name, (array)$bp_uri ) ) {
     
    214221 *
    215222 * @package BuddyPress Core
    216223 * @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.
    220225 */
    221226function 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;
    223228
    224229        // 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;
     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;
    227233
    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         }
    242 
    243234        // Fetch each template and add the php suffix
    244235        foreach ( (array)$templates as $template )
    245236                $filtered_templates[] = $template . '.php';
    246237
    247238        // 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 ) )
    254240                load_template( apply_filters( 'bp_load_template', $located_template ) );
    255         }
    256241
    257242        // Kill any other output after this.
    258243        die;