bp_register_theme_compat_default_features()
Setup the theme’s features.
Description Description
Note: BP Legacy’s buddypress-functions.php is not loaded in WP Administration as it’s loaded using bp_locate_template(). That’s why this function is here.
Source Source
File: bp-core/bp-core-theme-compatibility.php
function bp_register_theme_compat_default_features() { global $content_width; // Do not set up default features on deactivation. if ( bp_is_deactivation() ) { return; } // If the current theme doesn't need theme compat, bail at this point. if ( ! bp_use_theme_compat_with_current_theme() ) { return; } // Make sure BP Legacy is the Theme Compat in use. if ( 'legacy' !== bp_get_theme_compat_id() ) { return; } // Get the theme. $current_theme = wp_get_theme(); $theme_handle = $current_theme->get_stylesheet(); $parent = $current_theme->parent(); if ( $parent ) { $theme_handle = $parent->get_stylesheet(); } /** * Since Companion stylesheets, the $content_width is smaller * than the width used by BuddyPress, so we need to manually set the * content width for the concerned themes. * * Example: array( stylesheet => content width used by BuddyPress ) */ $bp_content_widths = array( 'twentyfifteen' => 1300, 'twentyfourteen' => 955, 'twentythirteen' => 890, ); // Default values. $bp_content_width = (int) $content_width; $bp_handle = 'bp-legacy-css'; // Specific to themes having companion stylesheets. if ( isset( $bp_content_widths[ $theme_handle ] ) ) { $bp_content_width = $bp_content_widths[ $theme_handle ]; $bp_handle = 'bp-' . $theme_handle; } if ( is_rtl() ) { $bp_handle .= '-rtl'; } $top_offset = 150; $avatar_height = apply_filters( 'bp_core_avatar_full_height', $top_offset ); if ( $avatar_height > $top_offset ) { $top_offset = $avatar_height; } bp_set_theme_compat_feature( 'legacy', array( 'name' => 'cover_image', 'settings' => array( 'components' => array( 'xprofile', 'groups' ), 'width' => $bp_content_width, 'height' => $top_offset + round( $avatar_height / 2 ), 'callback' => 'bp_legacy_theme_cover_image', 'theme_handle' => $bp_handle, ), ) ); }
Changelog Changelog
Version | Description |
---|---|
2.4.0 | Introduced. |