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.

git-svn-id: https://develop.svn.wordpress.org/trunk@44966 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-03-21 19:47:29 +00:00
parent 49d8c2590c
commit 65bd3654cc
14 changed files with 250 additions and 7 deletions

View File

@@ -13,6 +13,15 @@ class Tests_Template extends WP_UnitTestCase {
protected static $page;
protected static $post;
/**
* Page For Privacy Policy.
*
* @since 5.2.0
*
* @var WP_Post $page_for_privacy_policy
*/
protected static $page_for_privacy_policy;
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
self::$page_on_front = $factory->post->create_and_get(
array(
@@ -45,6 +54,13 @@ class Tests_Template extends WP_UnitTestCase {
);
set_post_format( self::$post, 'quote' );
add_post_meta( self::$post->ID, '_wp_page_template', 'templates/post.php' );
self::$page_for_privacy_policy = $factory->post->create_and_get(
array(
'post_type' => 'page',
'post_title' => 'Privacy Policy',
)
);
}
public function setUp() {
@@ -272,6 +288,25 @@ class Tests_Template extends WP_UnitTestCase {
);
}
/**
* @ticket 44005
* @group privacy
*/
public function test_privacy_template_hierarchy() {
update_option( 'wp_page_for_privacy_policy', self::$page_for_privacy_policy->ID );
$this->assertTemplateHierarchy(
get_permalink( self::$page_for_privacy_policy->ID ),
array(
'privacy-policy.php',
'page-privacy-policy.php',
'page-' . self::$page_for_privacy_policy->ID . '.php',
'page.php',
'singular.php',
)
);
}
/**
* @ticket 18375
*/
@@ -436,6 +471,7 @@ class Tests_Template extends WP_UnitTestCase {
'search' => 'is_search',
'front_page' => 'is_front_page',
'home' => 'is_home',
'privacy_policy' => 'is_privacy_policy',
'post_type_archive' => 'is_post_type_archive',
'taxonomy' => 'is_tax',
'attachment' => 'is_attachment',