'
)
);
/* Load the AJAX functions for the theme */
require_once( TEMPLATEPATH . '/_inc/ajax.php' );
/* Load the javascript for the theme */
wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) );
/* Add the JS needed for blog comment replies */
function bp_dtheme_add_blog_comments_js() {
if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
}
add_action( 'template_redirect', 'bp_dtheme_add_blog_comments_js' );
/* HTML for outputting blog comments as defined by the WP comment API */
function bp_dtheme_blog_comments( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment; ?>
comment_type ) return false; ?>
', '', $page_html );
if ( bp_dtheme_page_on_front() == 'activity' )
$selected = ' selected="selected"';
$page_html .= '';
return $page_html;
}
add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' );
/* Hijack the saving of page on front setting to save the activity stream setting */
function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) {
if ( !is_admin() || !is_site_admin() )
return false;
if ( 'activity' == $_POST['page_on_front'] )
return 'activity';
else
return $oldvalue;
}
add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 );
/* Load the activity stream template if settings allow */
function bp_dtheme_page_on_front_template( $template ) {
global $wp_query;
if ( empty( $wp_query->post->ID ) )
return locate_template( array( 'activity/index.php' ), false );
else
return $template;
}
add_filter( 'page_template', 'bp_dtheme_page_on_front_template' );
/* Return the ID of a page set as the home page. */
function bp_dtheme_page_on_front() {
if ( 'page' != get_option( 'show_on_front' ) )
return false;
return apply_filters( 'bp_dtheme_page_on_front', get_option( 'page_on_front' ) );
}
/* Force the page ID as a string to stop the get_posts query from kicking up a fuss. */
function bp_dtheme_fix_get_posts_on_activity_front() {
global $wp_query;
if ( !empty($wp_query->query_vars['page_id']) && 'activity' == $wp_query->query_vars['page_id'] )
$wp_query->query_vars['page_id'] = '"activity"';
}
add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' );
/* WP 3.0 requires there to be a non-null post in the posts array */
function bp_dtheme_fix_the_posts_on_activity_front( $posts ) {
global $wp_query;
// NOTE: the double quotes around '"activity"' are thanks to our previous function bp_dtheme_fix_get_posts_on_activity_front()
if ( empty( $posts ) && !empty( $wp_query->query_vars['page_id'] ) && '"activity"' == $wp_query->query_vars['page_id'] )
$posts = array( (object) array( 'ID' => 'activity' ) );
return $posts;
}
add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' );
/****
* Custom header image support. You can remove this entirely in a child theme by adding this line
* to your functions.php: define( 'BP_DTHEME_DISABLE_CUSTOM_HEADER', true );
*/
function bp_dtheme_add_custom_header_support() {
/* Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/) */
define( 'HEADER_TEXTCOLOR', 'FFFFFF' );
define( 'HEADER_IMAGE', '%s/_inc/images/default_header.jpg' ); // %s is theme dir uri
define( 'HEADER_IMAGE_WIDTH', 1250 );
define( 'HEADER_IMAGE_HEIGHT', 125 );
function bp_dtheme_header_style() { ?>
custom header image support and sidebar widgets.', 'buddypress' ), admin_url( 'themes.php?page=custom-header' ), admin_url( 'widgets.php' ) ) ?>