Skip to content

Instantly share code, notes, and snippets.

@contemplate
Created January 3, 2023 01:13
Show Gist options
  • Select an option

  • Save contemplate/06b3eef9c4c135c63d97048ed0477ea7 to your computer and use it in GitHub Desktop.

Select an option

Save contemplate/06b3eef9c4c135c63d97048ed0477ea7 to your computer and use it in GitHub Desktop.
Buddyboss Jump to Reply fix
// When click on notification then move to particular reply.
moveToReply: function () {
if ( window.location.href.indexOf( '#post-' ) > 0 ) {
var varUrl = window.location.href.split( '#post-' );
var postID = varUrl && undefined !== varUrl[1] ? varUrl[1] : '';
if ( !postID ) {
return;
}
var scrollTop;
if ($('#wpadminbar').length){
//if wpadminbar exists
if ( $( 'body' ).hasClass( 'sticky-header' ) ) {
scrollTop = ( $( '#post-' + postID ).parent().offset().top - $( '#masthead' ).innerHeight() - $( '#wpadminbar' ).innerHeight() );
} else {
scrollTop = ( $( '#post-' + postID ).parent().offset().top - $( '#wpadminbar' ).innerHeight() );
}
}else{
//if wpadminbar doesn't exist
if ( $( 'body' ).hasClass( 'sticky-header' ) ) {
scrollTop = ( $( '#post-' + postID ).parent().offset().top - $( '#masthead' ).innerHeight() );
} else {
scrollTop = ( $( '#post-' + postID ).parent().offset().top );
}
}
$( 'html, body' ).animate( {
scrollTop: scrollTop
}, 200 );
}
}
@contemplate

Copy link
Copy Markdown
Author

Fixes Buddyboss Notification Jump links for Forums.
buddyboss-theme/assets/js/plugins/bbp-reply-ajax.js

  • replace function moveToReply on line 644

buddyboss-theme/inc/plugins/bbpress-helper.php
also cache bust the loading by changing the version:
wp_enqueue_script( 'buddyboss-bbpress-reply-ajax', get_template_directory_uri() . '/assets/js/plugins/bbp-reply-ajax' . $minjs . '.js', array( 'jquery' ), buddyboss_theme()->version(), true );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment