Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Created September 26, 2019 23:44
Show Gist options
  • Select an option

  • Save KaineLabs/4b698fcb3d342969b874257803c770f3 to your computer and use it in GitHub Desktop.

Select an option

Save KaineLabs/4b698fcb3d342969b874257803c770f3 to your computer and use it in GitHub Desktop.
Woffice Theme Fix
<?php
/**
* Woffice Theme Fix.
*/
function yzc_woffice_theme_fix() {
// Get Current Page Path !
$page_path = $_SERVER['REQUEST_URI'];
// Get Members Slug
$members_slug = 'members';
// Get Sub Pages
$sub_pages = explode( '/', $page_path );
// Remove Empty Elements and Re-order
$sub_pages = array_values( array_filter( $sub_pages ) );
// Get Current Component.
$component = isset( $sub_pages[1] ) ? $sub_pages[1] : null;
if (
( $component == $members_slug && ! isset( $sub_pages[2] ) )
||
( $component == $members_slug && isset( $sub_pages[2] ) && $sub_pages[2] == 'type' )
) {
remove_theme_support( 'buddypress-use-legacy' );
}
}
add_action( 'bp_loaded', 'yzc_woffice_theme_fix' );
/**
* Change Members Directory Assets.
*/
function yzc_force_buddypress_assets_location( $path ) {
if ( bp_is_members_directory() ) {
return buddypress()->theme_compat->theme->url;
}
return $path;
}
add_filter( 'bp_get_theme_compat_url', 'yzc_force_buddypress_assets_location', 99 );
/**
* Members Directory - Remove #buddypress ID
*/
function yzc_remove_bp_id() {
?>
<script type="text/javascript">
jQuery( '#buddypress' ).attr( 'id', 'nobuddypress' );
</script>
<?php
}
add_action( 'wp_footer', 'yzc_remove_bp_id' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment