WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 3 months ago

#19742 new enhancement

WP_Styles should pass more info to the filter

Reported by: ptahdunbar Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: has-patch
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)

ticket.19742.diff (1.2 KB) - added by ptahdunbar 2 years ago.

Download all attachments as: .zip

Change History (4)

ptahdunbar2 years ago

comment:1 kovshenin17 months ago

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 rel attribute was filterable, say style_loader_rel or maybe even style_loader_rel-$handle so you could:

add_filter( 'style_loader_rel-my-script', function() { return 'stylesheet/less'; } );
wp_enqueue_script( 'my-script', ... );

Thoughts?

comment:2 bpetty17 months ago

Related: #22249

comment:3 nacin3 months ago

  • Component changed from General to Script Loader
Note: See TracTickets for help on using tickets.