Skip to:
Content

BuddyPress.org

#8429 closed enhancement (fixed)

Fire a hook when non-BP page is detected

Reported by: gabe462's profile Gabe462 Owned by: imath's profile imath
Milestone: 10.0.0 Priority: normal
Severity: normal Version: 7.1.0
Component: Core Keywords: good-first-bug has-patch commit
Cc:

Description

at /src/bp-core/bp-core-catchuri.php:252

I'd like there to be a do_action( 'bp_not_a_buddypress_page' );

<?php
if ( empty( $matches ) ) {
    do_action( 'bp_not_a_buddypress_page' );
    return false;
}

This leaves a convenient hook that I'd use for preventing enqueueing of BP assets that aren't used on other parts of the site.

Attachments (1)

8429.diff (474 bytes) - added by hasanuzzamanshamim 12 months ago.
Hi, I am also looking for something like this then found this ticket. It would be nice if you decided to add this. I created a patch as you mentioned earlier.

Download all attachments as: .zip

Change History (12)

#1 @johnjamesjacoby
23 months ago

Hello @Gabe462! 👋

Something like this seems like a pretty neat idea. I am +1.

#2 @needle
23 months ago

I'm a +1 on this too for the convenience. IIRC you can test bp_is_blog_page() to achieve the same effect.

#3 @imath
23 months ago

  • Keywords good-first-bug added
  • Milestone changed from Awaiting Review to 8.0.0

Sure! Let's do it!

do_action( 'is_not_buddypress' ) might be a better name ;)

@Gabe462 what about building a patch about it and attach it to this ticket ? We have a nice tutorial about how to do it, if needed: https://codex.buddypress.org/participate-and-contribute/contribute-with-code/

#4 @Gabe462
23 months ago

OK, I will

#5 @r-a-y
22 months ago

I don't think this new hook is necessary. If you want to dequeue assets, hook onto 'wp_enqueue_scripts' as usual and use the is_buddypress() function to determine if the current page is a BuddyPress page, then dequeue anything you do not want loaded.

The proposed hook would still require you to hook onto an action like 'wp_enqueue_scripts' anyway.

Last edited 22 months ago by r-a-y (previous) (diff)

#6 @needle
22 months ago

@r-a-y Whilst I agree with you about there being other methods to dequeue assets (I also posted one above) I can also see that it could be useful to know at the earliest opportunity that it's not a BuddyPress page - and without the possibility that the return values from is_buddyress() or bp_is_blog_page() are being filtered.

#7 @imath
22 months ago

Here's what I suggest, if @Gabe462 builds the patch and add it to this ticket, we include it! Let's reward new contributors 🤩

#8 @imath
19 months ago

  • Milestone changed from 8.0.0 to Awaiting Contributions

Looks like this ticket is not progressing. As it's not a "must have" fix/feature, let's wait for some contributions about it.

@hasanuzzamanshamim
12 months ago

Hi, I am also looking for something like this then found this ticket. It would be nice if you decided to add this. I created a patch as you mentioned earlier.

#9 @hasanuzzamanshamim
12 months ago

  • Keywords has-patch added; needs-patch removed

#10 @imath
12 months ago

  • Keywords commit added
  • Milestone changed from Awaiting Contributions to 10.0.0

Awesome! Thanks for your patch @hasanuzzamanshamim

I will commit it shortly.

#11 @imath
12 months ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13162:

Add an early hook to inform the current page is not a BuddyPress one

Props hasanuzzamanshamim

Fixes #8429

Note: See TracTickets for help on using tickets.