Skip to:
Content

BuddyPress.org

Changeset 2612


Ignore:
Timestamp:
02/07/2010 12:22:22 AM (16 years ago)
Author:
apeatling
Message:

Removing theme options and moving the option to show the activity stream on the front page to the normal WordPress Settings > Reading menu. This stops problems caused when choosing a static WordPress page as the front page.

Location:
trunk/bp-themes/bp-default
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-themes/bp-default/functions.php

    r2605 r2612  
    2121/* Load the javascript for the theme */
    2222wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) );
    23 
    24 /* Make sure the blog index page shows under /[HOME_BLOG_SLUG] if enabled */
    25 function bp_dtheme_show_home_blog() {
    26     global $bp, $query_string, $paged;
    27 
    28     if ( $bp->current_component == BP_HOME_BLOG_SLUG && ( !$bp->current_action || 'page' == $bp->current_action ) ) {
    29         unset( $query_string );
    30 
    31         if ( ( 'page' == $bp->current_action && $bp->action_variables[0] ) && false === strpos( $query_string, 'paged' ) ) {
    32             $query_string .= '&paged=' . $bp->action_variables[0];
    33             $paged = $bp->action_variables[0];
    34         }
    35 
    36         query_posts($query_string);
    37 
    38         bp_core_load_template( 'index', true );
    39     }
    40 }
    41 add_action( 'wp', 'bp_dtheme_show_home_blog', 2 );
    4223
    4324function bp_dtheme_firstname( $name = false, $echo = false ) {
     
    10182}
    10283
    103 function bp_dtheme_show_on_frontpage() {
    104     $settings = get_option( 'bp_dtheme_options' );
    105 
    106     if ( empty( $settings['show_on_frontpage'] ) || 'blog' == $settings['show_on_frontpage'] )
    107         return apply_filters( 'bp_dtheme_show_on_frontpage', 'blog' );
    108 
    109     return apply_filters( 'bp_dtheme_show_on_frontpage', 'activity' );
     84function bp_dtheme_wp_pages_filter( $page_html ) {
     85    if ( 'page_on_front' != substr( $page_html, 14, 13 ) )
     86        return $page_html;
     87
     88    $selected = false;
     89    $page_html = str_replace( '</select>', '', $page_html );
     90
     91    if ( bp_dtheme_page_on_front() == 'activity' )
     92        $selected = ' selected="selected"';
     93
     94    $page_html .= '<option class="level-0" value="activity"' . $selected . '>' . __( 'Activity Stream', 'buddypress' ) . '</option></select>';
     95    return $page_html;
     96}
     97add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' );
     98
     99function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) {
     100    if ( !is_admin() || !is_site_admin() )
     101        return false;
     102
     103    if ( 'activity' == $_POST['page_on_front'] )
     104        return 'activity';
     105    else
     106        return $oldvalue;
     107}
     108add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 );
     109
     110function bp_dtheme_page_on_front_template( $template ) {
     111    global $wp_query;
     112
     113    if ( empty( $wp_query->post->ID ) )
     114        return locate_template( array( 'activity/index.php' ), false );
     115    else
     116        return $template;
     117}
     118add_filter( 'page_template', 'bp_dtheme_page_on_front_template' );
     119
     120/* Return the ID of a page set as the home page. */
     121function bp_dtheme_page_on_front() {
     122    return apply_filters( 'bp_dtheme_page_on_front', get_option( 'page_on_front' ) );
    110123}
    111124
     
    220233}
    221234
    222 /* Load the options page */
    223 if ( is_admin() )
    224     require( TEMPLATEPATH . '/_inc/options.php' );
    225 
    226235/* Adjust home page body class if activity stream is home */
    227236function bp_dtheme_body_class_home( $classes, $bp_classes, $wp_classes, $custom_classes ) {
     
    230239
    231240    if ( bp_is_active( 'activity' ) ) {
    232         if ( 'activity' == bp_dtheme_show_on_frontpage() ) {
     241        if ( 'activity' == bp_dtheme_page_on_front() ) {
    233242            $blog = array_keys( $classes, 'blog-page' );
    234243            $classes[$blog[0]] = 'activity';
  • trunk/bp-themes/bp-default/header.php

    r2610 r2612  
    4545
    4646            <ul id="nav">
    47                 <li<?php if ( bp_is_page( 'home' ) && !is_page() ) : ?> class="selected"<?php endif; ?>>
     47                <li<?php if ( is_front_page() || !bp_current_component() ) : ?> class="selected"<?php endif; ?>>
    4848                    <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a>
    4949                </li>
    5050
    51                 <?php if ( bp_is_active( 'activity' ) ) : ?>
    52                     <?php if ( 'blog' == bp_dtheme_show_on_frontpage() ) : ?>
    53                         <li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
    54                             <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Activity', 'buddypress' ) ?>"><?php _e( 'Activity', 'buddypress' ) ?></a>
    55                         </li>
    56                     <?php else : ?>
    57                         <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) || bp_is_blog_page() && !is_front_page() && !is_page() ) : ?> class="selected"<?php endif; ?>>
    58                             <a href="<?php echo site_url() ?>/<?php echo BP_HOME_BLOG_SLUG ?>/" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a>
    59                         </li>
    60                     <?php endif; ?>
     51                <?php if ( 'activity' != bp_dtheme_page_on_front() && bp_is_active( 'activity' ) ) : ?>
     52                    <li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
     53                        <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Activity', 'buddypress' ) ?>"><?php _e( 'Activity', 'buddypress' ) ?></a>
     54                    </li>
    6155                <?php endif; ?>
    6256
    63                 <li<?php if (  bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
     57                <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
    6458                    <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
    6559                </li>
     
    8377                <?php endif; ?>
    8478
    85                 <?php wp_list_pages( 'title_li=&depth=1' ); ?>
     79                <?php wp_list_pages( 'title_li=&depth=1&exclude=' . bp_dtheme_page_on_front() ); ?>
    8680
    8781                <?php do_action( 'bp_nav_items' ); ?>
Note: See TracChangeset for help on using the changeset viewer.