Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active January 9, 2022 17:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/ac97b95c90c496ff445f24e9e859adba to your computer and use it in GitHub Desktop.
Save KaineLabs/ac97b95c90c496ff445f24e9e859adba to your computer and use it in GitHub Desktop.
Add WP Engine Fix.
<?php
/**
* Add WP Engine Fix.
*/
function yz_fix_wpengine_scripts_fix () {
if ( bp_is_group() || is_page( 'activity' ) || bp_is_activity_directory() ) {
wp_enqueue_script( 'buddypress_query',BP_PLUGIN_URL . 'bp-core/js/jquery-query.min.js',array( 'jquery' ) );
wp_enqueue_script( 'buddypress_cookie',BP_PLUGIN_URL . 'bp-core/js/vendor/jquery-cookie.min.js',array( 'jquery' ) );
wp_enqueue_script( 'buddypress_js', YOUZIFY_ASSETS . 'js/buddypress.min.js',array( 'jquery' ));
wp_enqueue_script( 'buddypress_scrollto',BP_PLUGIN_URL . 'bp-core/js/vendor/jquery-scroll-to.min.js',array( 'jquery' ) );
$params = apply_filters( 'bp_core_get_js_strings', array(
// Strings for display.
'accepted' => __( 'Accepted', 'buddypress' ),
'close' => __( 'Close', 'buddypress' ),
'comments' => __( 'comments', 'buddypress' ),
'leave_group_confirm' => __( 'Are you sure you want to leave this group?', 'buddypress' ),
'mark_as_fav' => __( 'Favorite', 'buddypress' ),
'my_favs' => __( 'My Favorites', 'buddypress' ),
'rejected' => __( 'Rejected', 'buddypress' ),
'remove_fav' => __( 'Remove Favorite', 'buddypress' ),
'show_all' => __( 'Show all', 'buddypress' ),
'show_all_comments' => __( 'Show all comments for this thread', 'buddypress' ),
'show_x_comments' => __( 'Show all comments (%d)', 'buddypress' ),
'unsaved_changes' => __( 'Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress' ),
'view' => __( 'View', 'buddypress' ),
// Settings.
'store_filter_settings' => apply_filters( 'bp_legacy_store_filter_settings', is_user_logged_in() ),
) );
wp_localize_script( 'buddypress_js', 'BP_DTheme', $params );
}
}
add_action( 'wp_enqueue_scripts', 'yz_fix_wpengine_scripts_fix' );
@perezcarreno
Copy link

Hello! I just noticed this script is missing the enqueing of "scrollTo". Without it, the site seems to run great until you try to comment on something on the wall.

Here's the missing line:
wp_enqueue_script( 'buddypress_scrollto',BP_PLUGIN_URL . 'bp-core/js/vendor/jquery-scroll-to.min.js',array( 'jquery' ) );

Cheers!

@torrid33
Copy link

This script is also missing the ending ?> for a php script at the bottom.

@torrid33
Copy link

Is BP_PLUGIN_URL set elsewhere or do we need to change that to the url for our site???

@jaymzway
Copy link

jaymzway commented Jan 9, 2022

thank you perezcarreno
torrid
kainlabs this fixxed my error now i can post everything in my website using this complete file script.
Create a file bp-custom.php in /wp-content/plugins folder
Add following script above and paste it inside bp-custom.php you just created Then at the end type
?> to close the php file hit save then refresh your browser and it will definitely work

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