Skip to:
Content

BuddyPress.org

Ticket #2743: 2743-2.patch

File 2743-2.patch, 13.2 KB (added by DJPaul, 15 years ago)
  • bp-activity.php

     
    6767function bp_activity_directory_activity_setup() {
    6868        global $bp;
    6969
    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 ) ) {
    7171                $bp->is_directory = true;
    7272
    7373                do_action( 'bp_activity_directory_activity_setup' );
  • bp-themes/bp-default/functions.php

     
    107107}
    108108
    109109/**
    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.
    111113 *
     114 * @deprecated 1.3
     115 * @deprecated Don't use this, really.
    112116 * @param string $page_html A list of pages as a dropdown (select list)
    113  * @see wp_dropdown_pages()
    114117 * @return string
    115  * @package BuddyPress Theme
     118 * @see wp_dropdown_pages()
    116119 * @since 1.2
    117120 */
    118121function 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." );
    132123        return $page_html;
    133124}
    134 add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' );
    135125
    136126/**
    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.
    138129 *
     130 * @deprecated 1.3
     131 * @deprecated Don't use this, really.
    139132 * @param $string $oldvalue Previous value of get_option( 'page_on_front' )
    140133 * @param $string $oldvalue New value of get_option( 'page_on_front' )
    141134 * @return string
    142  * @package BuddyPress Theme
    143135 * @since 1.2
    144136 */
    145137function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) {
     138        _deprecated_function( __FUNCTION__, '1.3', "Don't use this, really." );
    146139        if ( !is_admin() || !is_super_admin() )
    147140                return false;
    148141
    149         if ( 'activity' == $_POST['page_on_front'] )
    150                 return 'activity';
    151         else
    152                 return $oldvalue;
     142        return $oldvalue;
    153143}
    154 add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 );
    155144
    156145/**
    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.
    158148 *
     149 * @deprecated 1.3
     150 * @deprecated Don't use this, really.
    159151 * @param string $template Absolute path to the page template
    160152 * @return string
    161  * @global WP_Query $wp_query WordPress query object
    162  * @package BuddyPress Theme
    163153 * @since 1.2
    164154 */
    165155function 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;
    172158}
    173 add_filter( 'page_template', 'bp_dtheme_page_on_front_template' );
    174159
    175160/**
    176161 * Return the ID of a page set as the home page.
    177162 *
    178163 * @return false|int ID of page set as the home page
    179  * @package BuddyPress Theme
    180164 * @since 1.2
    181165 */
    182166function bp_dtheme_page_on_front() {
     
    187171}
    188172
    189173/**
    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.
    191176 *
    192  * @global WP_Query $wp_query WordPress query object
    193  * @package BuddyPress Theme
     177 * @deprecated 1.3
     178 * @deprecated Don't use this, really.
    194179 * @since 1.2
    195180 */
    196181function 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." );
    201183}
    202 add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' );
    203184
    204185/**
    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.
    206188 *
     189 * @deprecated 1.3
     190 * @deprecated Don't use this, really.
    207191 * @param array $posts Posts as retrieved by WP_Query
    208  * @global WP_Query $wp_query WordPress query object
    209192 * @return array
    210  * @package BuddyPress Theme
    211193 * @since 1.2.5
    212194 */
    213195function 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." );
    220197        return $posts;
    221198}
    222 add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' );
    223199
    224200/**
    225201 * Add secondary avatar image to this activity stream's record, if supported
     
    358334function bp_dtheme_main_nav( $args ) {
    359335?>
    360336        <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; ?>>
    362338                        <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a>
    363339                </li>
    364340
  • bp-core/bp-core-templatetags.php

     
    15031503
    15041504/* Template is_() functions to determine the current page */
    15051505
     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 */
     1515function 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
    15061532function bp_is_blog_page() {
    15071533        global $bp, $is_member_page, $wp_query;
    15081534
     
    15271553}
    15281554function bp_is_home() { return bp_is_my_profile(); }
    15291555
     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 */
    15301563function 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();
    15371566}
    15381567
    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         else
    1545                 $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 
    15501568function bp_is_directory() {
    15511569        global $bp;
    15521570
     
    19651983
    19661984                $bp_classes = array();
    19671985
    1968                 if ( bp_is_front_page() )
     1986                if ( is_front_page() )
    19691987                        $bp_classes[] = 'home-page';
    19701988
    19711989                if ( bp_is_directory() )
     
    19741992                if ( bp_is_user_profile() && !bp_is_blog_page() )
    19751993                        $bp_classes[] = 'profile';
    19761994
    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 ) )
    19781996                        $bp_classes[] = 'activity';
    19791997
    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 ) )
    19811999                        $bp_classes[] = 'blogs';
    19822000
    19832001                if ( bp_is_messages_component() && !bp_is_blog_page()  )
    19842002                        $bp_classes[] = 'messages';
    19852003
    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 ) )
    19872005                        $bp_classes[] = 'friends';
    19882006
    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 ) )
    19902008                        $bp_classes[] = 'groups';
    19912009
    19922010                if ( bp_is_settings_component() && !bp_is_blog_page()  )
  • bp-core/bp-core-catchuri.php

     
    222222        global $post, $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
    223223
    224224        // 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;
    227228
    228229        // Set the root object as the current wp_query-ied item
    229230        $object_id = 0;
  • bp-blogs.php

     
    7171function bp_blogs_directory_blogs_setup() {
    7272        global $bp;
    7373
    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 ) ) ) {
    7575                $bp->is_directory = true;
    7676
    7777                do_action( 'bp_blogs_directory_blogs_setup' );
  • bp-forums.php

     
    4444function bp_forums_directory_forums_setup() {
    4545        global $bp;
    4646
    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 ) {
    4848                if ( (int) $bp->site_options['bp-disable-forum-directory'] || !bp_is_active( 'groups' ) )
    4949                        return false;
    5050
  • bp-groups.php

     
    156156function groups_directory_groups_setup() {
    157157        global $bp;
    158158
    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 ) ) {
    160160                $bp->is_directory = true;
    161161
    162162                do_action( 'groups_directory_groups_setup' );
  • bp-core.php

     
    399399function bp_core_action_directory_members() {
    400400        global $bp;
    401401
    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 ) {
    403403                $bp->is_directory = true;
    404404
    405405                do_action( 'bp_core_action_directory_members' );