Opened 14 years ago
Closed 5 years ago
#19742 closed enhancement (wontfix)
WP_Styles should pass more info to the filter
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Script Loader | Keywords: | has-patch needs-refresh close reporter-feedback |
| Focuses: | Cc: |
Description
Currently, if your working with wp_enqueue_style(), it's not easy to customize the output of the link element.
The current filter passes the full html along with the style handle. This isn't enough information if you're trying to rebuild the link element.
I'm currently changing rel="stylesheet" to rel="stylesheet/less" for lesscss suport. I'm currently able to achieve this, but I have to know the style handle.
This patch adds a third param which contains all of the style data available for that style.
Attachments (1)
Change History (8)
#6
in reply to:
↑ 1
@
5 years ago
- Keywords reporter-feedback added
Hello @ptahdunbar,
I know it's been a lot of years since this ticket was opened. And it's marked as a close candidate. Before closing it, I want to check with you on what you think of @ kovshenin suggestion?
Hey, just stumbled across this. You have the handle which is a unique ID, and you can get all the info you need by calling
$wp_styles->query()or->get_data()if you need the extras. Does that solve your problem?
Would it be much easier if the
relattribute was filterable, saystyle_loader_relor maybe evenstyle_loader_rel-$handleso you could:
add_filter( 'style_loader_rel-my-script', function() { return 'stylesheet/less'; } ); wp_enqueue_script( 'my-script', ... );Thoughts?
Does this achieve what you need?
#7
@
5 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
Closing this ticket. Why?
- Marked for close 4 years ago
- No reporter followup
- The extra info is available as @ kovshenin suggested
- Since this ticket was opened, the number of args passed with this filter has grown from 2 to 4. Adding a 5th is possible but may be bloat since the extra info is available (as noted in the previous bullet point)
- Ticket #22249 is tracking the ability to access the attributes which would give granular access to
rel.
Hey, just stumbled across this. You have the handle which is a unique ID, and you can get all the info you need by calling
$wp_styles->query()or->get_data()if you need the extras. Does that solve your problem?Would it be much easier if the
relattribute was filterable, saystyle_loader_relor maybe evenstyle_loader_rel-$handleso you could:add_filter( 'style_loader_rel-my-script', function() { return 'stylesheet/less'; } ); wp_enqueue_script( 'my-script', ... );Thoughts?