Make WordPress Core


Ignore:
Timestamp:
03/21/2019 07:47:29 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Privacy: Introduce Privacy Policy page helpers:

  • is_privacy_policy() template tag
  • privacy-policy.php template
  • .privacy-policy body class
  • .menu-item-privacy-policy menu item class

Props garrett-eclipse, birgire, xkon, Clorith.
Fixes #44005.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/template.php

    r43571 r44966  
    1414    protected static $post;
    1515
     16    /**
     17     * Page For Privacy Policy.
     18     *
     19     * @since 5.2.0
     20     *
     21     * @var WP_Post $page_for_privacy_policy
     22     */
     23    protected static $page_for_privacy_policy;
     24
    1625    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
    1726        self::$page_on_front = $factory->post->create_and_get(
     
    4655        set_post_format( self::$post, 'quote' );
    4756        add_post_meta( self::$post->ID, '_wp_page_template', 'templates/post.php' );
     57
     58        self::$page_for_privacy_policy = $factory->post->create_and_get(
     59            array(
     60                'post_type'  => 'page',
     61                'post_title' => 'Privacy Policy',
     62            )
     63        );
    4864    }
    4965
     
    267283                'page-page-name-%f0%9f%98%80.php',
    268284                'page-' . self::$page->ID . '.php',
     285                'page.php',
     286                'singular.php',
     287            )
     288        );
     289    }
     290
     291    /**
     292     * @ticket 44005
     293     * @group privacy
     294     */
     295    public function test_privacy_template_hierarchy() {
     296        update_option( 'wp_page_for_privacy_policy', self::$page_for_privacy_policy->ID );
     297
     298        $this->assertTemplateHierarchy(
     299            get_permalink( self::$page_for_privacy_policy->ID ),
     300            array(
     301                'privacy-policy.php',
     302                'page-privacy-policy.php',
     303                'page-' . self::$page_for_privacy_policy->ID . '.php',
    269304                'page.php',
    270305                'singular.php',
     
    437472            'front_page'        => 'is_front_page',
    438473            'home'              => 'is_home',
     474            'privacy_policy'    => 'is_privacy_policy',
    439475            'post_type_archive' => 'is_post_type_archive',
    440476            'taxonomy'          => 'is_tax',
Note: See TracChangeset for help on using the changeset viewer.