Skip to:

Opened 15 months ago

Last modified 9 months ago

#8842 new defect (bug)

Filter to stop assets loading outside of BuddyPress Core is not working

Reported by: defries's profile DeFries Owned by:
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version: 11.1.0
Component: Core Keywords: needs-patch


Inside a WordPress multi-site environment, I have BuddPress network activated. I've added the following to the top of my bp-custom.php file:

 * Stop loading BuddyPress assets in places where that's not needed.
add_filter( 'bp_enqueue_assets_in_bp_pages_only', '__return_true' );

However, the assets are still loaded everywhere. There's no change in what's loaded. Full context: the root of the site is a subdomain of the multi-site, and I'm checking a domain-mapped subsite's frontpage. I've added a screenshot of what I'm still seeing be loaded.

Attachments (1)

Screenshot_Brave Browser_2023-02-17_11.35.48@2x.jpg​ (107.7 KB) - added by DeFries 15 months ago.
Screenprint of the site's source code.

Download all attachments as: .zip

Change History (7)

15 months ago

Screenprint of the site's source code.

#1 @imath
15 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 12.0.0

Hi @DeFries

Thanks a lot for your feedback 😍. It’s actually another issue, the filter is avoiding loading the template pack assets (the big buddypress.js & css).

I agree we should also load BP Block assets when they are used only. We’ll try to work on this moving to Block API v2 during 12.0.0 dev cycle.

#2 @DeFries
15 months ago

Ah, okay. My assumption was indeed that these stylesheets would also not be loaded where they didn't make any sense to be loaded.

Looking forward to 12.0.0 then ☺️.

#3 @imath
14 months ago

In 13440:

BP Blocks: introduce a new $metadata argument to use WP Block API v2

The bp_register_block() array of arguments now accepts a $metadata
argument to inform about the path to a block block.json dir path. If
it's used this function is now is simple wrapper of WordPress's
register_block_type_from_metadata() function.

Closes ​
See #8842
See #8457
Fixes #8855

#4 @imath
13 months ago

In 13464:

Update all BP Blocks & Modern JS PHP registration code

  • Use the metadata argument of the bp_register_block() function to load all BP Blocks JSON files.
  • Get BP Blocks dependencies using the @wordpress/scripts index.asset.php generated files.
  • Although the BP Blocks category has been replaced by the BP Blocks collection, leave the no more used bp_block_category() function in place in case some third party plugins are using it for their custom blocks.
  • PHPUnit tests: make sure to unregister all BP Blocks when using the BP_UnitTestCase->go_to() method.

See #8842
Fixes #8457
Closes ​

This ticket was mentioned in ​Slack in #buddypress by imath. ​View the logs.

9 months ago

#6 @imath
9 months ago

  • Milestone changed from 12.0.0 to Awaiting Contributions

These BP Block styles are only loaded when used in Block themes, but regular themes are still loading them everywhere. I can't remember if WordPress is providing a way to avoid this in regular themes. If someone can give me the documentation/make link I'll be happy to come back on this ticket. In the meantime, moving this ticket in awaiting-contributions.

Note: See TracTickets for help on using tickets.