Make WordPress Core


Ignore:
Timestamp:
01/22/2019 09:54:26 PM (7 years ago)
Author:
peterwilsoncc
Message:

Formatting: Prevent wp_targeted_link_rel() adding an empty attribute.

Bypass adding a rel attribute when the wp_targeted_link_rel filter returns an empty string or other falsy result.

Props mcmwebsol, spartank, meatman89fs.
Fixes #45352.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/WPTargetedLinkRel.php

    r42770 r44691  
    7272        $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
    7373    }
     74
     75    /**
     76     * Ensure empty rel attributes are not added.
     77     *
     78     * @ticket 45352.
     79     */
     80    public function test_ignore_if_wp_targeted_link_rel_nulled() {
     81        add_filter( 'wp_targeted_link_rel', '__return_empty_string' );
     82        $content  = '<p>Links: <a href="/" target="_blank">Do not change me</a></p>';
     83        $expected = '<p>Links: <a href="/" target="_blank">Do not change me</a></p>';
     84        $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
     85    }
    7486}
Note: See TracChangeset for help on using the changeset viewer.