Opened 9 years ago
Closed 7 years ago
#6610 closed enhancement (maybelater)
BP Attachments API should allow plugins to use their own custom templates in WP Admin
Reported by: | imath | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.3.0 |
Component: | Media | Keywords: | needs-refresh, trac-tidy-2018 |
Cc: |
Description
Working on the BP Attachments plugin, i've noticed that it was impossible to use its custom templates inside the Administration, although it can on front end.
I think we should allow plugins to use their own templates in WP Admin too.
See attached patch.
Attachments (2)
Change History (16)
#2
@
9 years ago
No problem for the patch, thanks a lot for r10091
Absolutely and i completely agree. What the patch is doing is:
- if it's a legacy template: no filter, so our templates cannot be overriden in the admin.
- if the template is not a legacy template, then allow the path to be filtered.
The idea is to let plugins use the legacy templates and their own templates if they need to, not to override existing legacy templates.
#3
@
9 years ago
OK. I am fine with allowing some customizability here. But the pattern is pretty weird: the filter only kicks in if the attachment template is not found in bp-legacy. I can't think of anywhere else where our template filters work like this - it almost seems *too* restrictive. How about filtering the template just before requiring it?
#4
@
9 years ago
I'm ok :)
When building the patch i remembered the discussion you were mentioning in your previous comment and wanted to make sure the legacy templates were not overriden. Because if the filter happens before, then one of our template could be overriden inside our context.
#5
@
9 years ago
Because if the filter happens before, then one of our template could be overriden inside our context.
Yeah, but that's what I mean about your suggestion being very restrictive. Adding an overly-specific filter here doesn't seem like a sustainable solution if we're going to keep introducing Backbone templates in BuddyPress.
That being said, if we do decide to go with this, I find the filter name and by-reference technique you're using a little opaque. May I suggest something like following?
/** * Filters the fallback attachment template used in the Dashboard when no core template is found. * * Plugin authors should use this to provide their own additional attachment tempalates. * * @since whenever * @param string $fallback_template Template path. */ $fallback_template = apply_filters( 'bp_attachments_get_fallback_template_path', '', $slug, $attachment_template_part ); if ( $fallback_template && file_exists( $fallback_template ) ) { ...
}}}
#6
@
9 years ago
you're right about the by-reference, once again i've overthinked it :) i'll update the patch, thanks a lot for your feedack
#7
@
9 years ago
What about 6610.02.patch ?
It simply adds a filter and the comment is informing the developer we wish to keep template parts in assets/_attachments
private.
#8
@
9 years ago
"For now all attachment template parts located in the assets/_attachments BP Legacy's directory are private. Please do not override them."
Why did we decide this?
This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.
9 years ago
#11
@
9 years ago
- Keywords needs-refresh added; has-patch removed
- Milestone changed from 2.5 to Future Release
As nobody asked for this so far, bumping to future release.
#13
@
7 years ago
- Keywords trac-tidy-2018 added
We're closing this ticket because it has not received any contribution or comments for at least two years. We have decided that it is better to close tickets that are good ideas, which have not gotten (or are unlikely to get) contributions, rather than keep things open indefinitely. This will help us share a more realistic roadmap for BuddyPress with you.
Everyone very much appreciates the time and effort that you spent sharing your idea with us. On behalf of the entire BuddyPress team, thank you.
If you feel strongly that this enhancement should still be added to BuddyPress, and you are able to contribute effort towards it, we encourage you to re-open the ticket, or start a discussion about it in our Slack channel. Please consider that time has proven that good ideas without contributions do not get built.
For more information, see https://bpdevel.wordpress.com/2018/01/21/our-awaiting-contributions-milestone-contains/
or find us on Slack, in the #buddypress channel: https://make.wordpress.org/chat/
I might have broken your patch in [10091] - sorry :)
I don't have strong opinions about this, but it's worth noting that we intentionally named the directory
assets/_attachments
and wrapped admin template fetches inis_admin()
. It might be worth reviewing the Slack discussion here: https://wordpress.slack.com/archives/buddypress/p1427915702000781 I realize that adding a filter is not the same thing as implementing the template hierarchy, but I did want to draw attention to this :)