Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#5992 closed defect (bug) (no action required)

In `bp_core_load_template()`, save a `locate_template()` call change -- is stopping templates from loading

Reported by: rogercoathup Owned by:
Milestone: Priority: normal
Severity: major Version: 2.1
Component: Core Keywords: reporter-feedback
Cc:

Description

Following change:
https://github.com/buddypress/BuddyPress/commit/7ad29f96ce82be6533a7fe427f886602779e6409

Is stopping plugin component directory templates from loading.


This change has stopped our plugin component screens from loading correctly.

We have a component using bp_core_load_template() to load it's directory page:
bp_core_load_template( apply_filters( 'document_repository_directory_template', 'a21-document-repository/index' ) );

And in our theme, we have the template: /our-theme-dir/a21-document-repository/index.php

The theme is not bp-default and not a derivative of it either. The theme creates a version of BP_Legacy in its buddypress-functions.php file.

There are no filters being applied (i.e. no filters hooked on 'document_repository_directory_template'.)

As a result of this change -- attempts to load the template, result in the template not being set, and the correct template is not loaded.

Is this something we need to change in our setup -- this is theme / plugin that's worked correctly since 1.6 through all upgrades until now. Or is your change in error, and not taking plugin templates into account correctly?

Change History (2)

#1 @r-a-y
5 years ago

  • Keywords reporter-feedback added
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Sorry for the inconvenience, rogercoathup.

bp_core_load_template() is really only supposed to support bp-default themes. The commit that is referenced above is meant to save a file_exists() call and force developers to use theme compatibility.

To use theme compatibility with your plugin, see how BP does it with the Members Directory in the BP_Members_Theme_Compat class:
https://buddypress.trac.wordpress.org/browser/tags/2.1.1/src/bp-members/bp-members-screens.php#L266

Check out line 296 in the is_members() class method as well as the directory_template_hierarchy(), directory_dummy_post() and directory_content() class methods for more info.

You'll basically want to make a copy of the BP_Members_Theme_Compat class and modify it to suit your plugin's needs.

In the meantime, I'm going to mark this as invalid, but feel free to comment for further feedback.

#2 @imath
5 years ago

rogercoathup, there's also a codex article about it, i think it's sill ok, tell me if not:
https://codex.buddypress.org/plugindev/how-to-enjoy-bp-theme-compat-in-plugins/

Note: See TracTickets for help on using tickets.