Make WordPress Core


Ignore:
Timestamp:
05/17/2019 12:11:06 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Formatting: Adjust wp_targeted_link_rel() to ensure JSON format is preserved and correct quotes are used when adding the missing rel attribute.

Props birgire, TobiasBg, fierevere, audrasjb, SergeyBiryukov.
Merges [45348] to the 5.2 branch.
Fixes #46316, #47244.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

  • branches/5.2/src/wp-includes/formatting.php

    r45240 r45349  
    30953095        $rel       = 'rel=' . $delimiter . trim( implode( ' ', $parts ) ) . $delimiter;
    30963096        $link_html = str_replace( $rel_match[0], $rel, $link_html );
     3097    } elseif ( preg_match( '|target\s*=\s*?\\\\"|', $link_html ) ) {
     3098        $link_html .= " rel=\\\"$rel\\\"";
     3099    } elseif ( preg_match( '#(target|href)\s*=\s*?\'#', $link_html ) ) {
     3100        $link_html .= " rel='$rel'";
    30973101    } else {
    30983102        $link_html .= " rel=\"$rel\"";
Note: See TracChangeset for help on using the changeset viewer.