WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/30/2015 11:19:11 PM (6 years ago)
Author:
swissspidy
Message:

Comments: Don't nofollow links within the site.

Fixes #11360.

File:
1 edited

Legend:

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

    r35505 r36125  
    2323        $this->assertEquals( $expected, wp_rel_nofollow( $content ) );
    2424    }
     25
     26    /**
     27     * @ticket 11360
     28     * @dataProvider data_wp_rel_nofollow
     29     */
     30    public function test_wp_rel_nofollow( $input, $output ) {
     31        return $this->assertEquals( wp_slash( $output ), wp_rel_nofollow( $input ) );
     32    }
     33
     34    public function data_wp_rel_nofollow() {
     35        $home_url_http  = set_url_scheme( home_url(), 'http' );
     36        $home_url_https = set_url_scheme( home_url(), 'https' );
     37
     38        return array(
     39            array(
     40                '<a href="">Double Quotes</a>',
     41                '<a href="" rel="nofollow">Double Quotes</a>',
     42            ),
     43            array(
     44                '<a href="https://wordpress.org">Double Quotes</a>',
     45                '<a href="https://wordpress.org" rel="nofollow">Double Quotes</a>',
     46            ),
     47            array(
     48                "<a href='https://wordpress.org'>Single Quotes</a>",
     49                "<a href='https://wordpress.org' rel=\"nofollow\">Single Quotes</a>",
     50            ),
     51            array(
     52                '<a href="https://wordpress.org" title="Title">Multiple attributes</a>',
     53                '<a href="https://wordpress.org" title="Title" rel="nofollow">Multiple attributes</a>',
     54            ),
     55            array(
     56                '<a title="Title" href="https://wordpress.org">Multiple attributes</a>',
     57                '<a title="Title" href="https://wordpress.org" rel="nofollow">Multiple attributes</a>',
     58            ),
     59            array(
     60                '<a data-someflag href="https://wordpress.org">Multiple attributes</a>',
     61                '<a data-someflag href="https://wordpress.org" rel="nofollow">Multiple attributes</a>',
     62            ),
     63            array(
     64                '<a  data-someflag  title="Title"  href="https://wordpress.org" onclick=""  >Everything at once</a>',
     65                '<a  data-someflag  title="Title"  href="https://wordpress.org" onclick=""   rel="nofollow">Everything at once</a>',
     66            ),
     67            array(
     68                '<a href="' . $home_url_http . '/some-url">Home URL (http)</a>',
     69                '<a href="' . $home_url_http . '/some-url">Home URL (http)</a>',
     70            ),
     71            array(
     72                '<a href="' . $home_url_https . '/some-url">Home URL (https)</a>',
     73                '<a href="' . $home_url_https . '/some-url">Home URL (https)</a>',
     74            ),
     75        );
     76    }
    2577}
Note: See TracChangeset for help on using the changeset viewer.