Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/27/2010 10:21:26 PM (16 years ago)
Author:
djpaul
Message:

Allow any component to be set to display on the front page. Fixes #2743.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-templatetags.php

    r3479 r3488  
    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;
     
    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();
    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 */
    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
     
    19802010        $bp_classes = array();
    19812011
    1982         if ( bp_is_front_page() )
     2012        if ( is_front_page() )
    19832013            $bp_classes[] = 'home-page';
    19842014
     
    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
     
    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
Note: See TracChangeset for help on using the changeset viewer.