Make WordPress Core

Opened 8 years ago

Closed 6 years ago

#24954 closed enhancement (duplicate)

Enhance wp_enqueue_style to allow the rel attribute to be set

Reported by: hypedtext Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6
Component: Script Loader Keywords:
Focuses: Cc:


If one could use wp_enqueue_style to set the "rel" attribute, it would make using Less.js( a lot easier in WordPress. And would reduce the need for core function filtering ( which, as a novice coder, scares me as it's one more hack I have to remember.

I'm not sure if that's a core enhancement, but Less.js does seem pretty popular. Even more so now that Bootstrap 3( is pushing it.

I hope this is useful.

Change History (3)

#1 @nacin
8 years ago

  • Component changed from General to Script Loader

#2 @dcondrey
7 years ago

 * Validate explicit rel value if set
 * Set to appropriate value based on URI suffix if not explicit
if ($this->$rel && !is_bool($this->$rel) && preg_match('/^[\p{L}\p{N} .-]+$/', $this->$rel)) {
    $rel = $this->$rel;

} else {
    if (preg_match('/.css$/', $src)) $rel = '';
    elseif (preg_match('/.less$/', $src)) $rel = '/less';
    elseif (preg_match('/.sass/', $src)) $rel = '/sass';
    elseif (preg_match('/.scss/', $src)) $rel = '/scss';
    $rel = 'stylesheet' . $rel;

#3 @ocean90
6 years ago

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

Duplicate of #22249.

Note: See TracTickets for help on using tickets.