Make WordPress Core

Ticket #44192: 44192.diff

File 44192.diff, 1.6 KB (added by desrosj, 7 years ago)

Changes get_the_privacy_policy_link() link text to be the selected Privacy Policy page's post title. Includes unit test.

  • src/wp-includes/link-template.php

     
    43294329        $privacy_policy_url = get_privacy_policy_url();
    43304330
    43314331        if ( $privacy_policy_url ) {
    4332                 $link = sprintf(
     4332                $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
     4333                $link           = sprintf(
    43334334                        '<a class="privacy-policy-link" href="%s">%s</a>',
    43344335                        esc_url( $privacy_policy_url ),
    4335                         __( 'Privacy Policy' )
     4336                        get_the_title( $policy_page_id )
    43364337                );
    43374338        }
    43384339
  • tests/phpunit/tests/link/getThePrivacyPolicyLink.php

     
    7171
    7272        /**
    7373         * The function should return a valid link if a privacy policy page has been
    74          * created and set as the `wp_page_for_privacy_policy`.
     74         * created and set as the `wp_page_for_privacy_policy`. The post title should
     75         * be used as the link text.
    7576         */
    7677        public function test_get_the_privacy_policy_link_should_return_valid_link_when_privacy_page_set() {
    7778                update_option( 'wp_page_for_privacy_policy', self::$privacy_policy_page_id );
     
    8081
    8182                $this->assertStringStartsWith( '<a', $actual_link );
    8283                $this->assertContains( self::$privacy_policy_url, $actual_link );
     84                $this->assertContains( '>' . WP_TESTS_DOMAIN . ' Privacy Policy</a>', $actual_link );
    8385                $this->assertStringEndsWith( '</a>', $actual_link );
    8486        }
    8587