Skip to:
Content

Opened 2 years ago

Closed 2 years ago

#1828 closed enhancement (invalid)

bbp_theme_before/after_forum_sub_forums inconsistency

Reported by: JarretC Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: Actions/Filters Keywords: has-patch
Cc:

Description

If you currently hook into bbp_theme_before_forum_sub_forums or bbp_theme_after_forum_sub_forums content isn't echoed where you might expect it to be.

add_action( 'bbp_theme_before_forum_sub_forums', 'jc_before_forum_sub_forums' );

function jc_before_forum_sub_forums() {
	echo 'Hello world!';
}

You'll see in the image subforum-test-1.png that the output is returned in the same exact place that do_action( 'bbp_theme_after_forum_title' ); returns it's output as well. If you ask me this somewhat makes bbp_theme_before/after_forum_sub_forums somewhat useless as there are already actions there to place content.

I propose an addition of args to the bbp_list_forums() function that allow us to place content within the default unordered list of the subforums but before the actual links are displayed. Which if you ask me makes more sense and places the content in the correct area where you might possibly want to add something in.

The patch adds 'list_before' and 'list_after' arguments to the bbp_list_forums() function. If this is acceptable we could most likely do away with bbp_theme_before/after_forum_sub_forums actions.

You can see where the content is placed with the addition of the new argument in subforum-test-2.png which was added using

bbp_list_forums( array( 'list_before' => 'Subforums: ' ) );

Attachments (3)

subforum-test-1.png (5.7 KB) - added by JarretC 2 years ago.
subforum-test-2.png (4.0 KB) - added by JarretC 2 years ago.
bbp_list_forums_new_args.patch (776 bytes) - added by JarretC 2 years ago.

Download all attachments as: .zip

Change History (4)

JarretC2 years ago

JarretC2 years ago

comment:1 johnjamesjacoby2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Three things:

  • bbp_list_forums() already has before/after arguments
  • bbp_parse_args() silently creates before/after filters for you based on the key in the third parameter. In this case they are 'bbp_before_list_forums_parse_args' and 'bbp_after_list_forums_parse_args' respectively. Using these filters, you can hook into 'bbp_after_list_forums_parse_args' and force an override on the 'before' or 'after' arguments of the bbp_list_forums() function, and do whatever you'd like.
  • It's hard to rely on theme actions, since it's possible in the future that other people's themes won't use the same ones.

Closing as invalid, as there are at least a few alternatives.

Last edited 2 years ago by johnjamesjacoby (previous) (diff)
Note: See TracTickets for help on using tickets.