WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 4 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:

Description

If one could use wp_enqueue_style to set the "rel" attribute, it would make using Less.js(http://lesscss.org/#usage) a lot easier in WordPress. And would reduce the need for core function filtering (http://wordpress.stackexchange.com/questions/20876/less-css-enqueue-style-with-add-filter-to-change-rel-attribute) 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(http://getbootstrap.com/getting-started/#download-cdn) is pushing it.

I hope this is useful.

Change History (3)

#1 @nacin
6 years ago

  • Component changed from General to Script Loader

#2 @dcondrey
6 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
4 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.