Make WordPress Core


Ignore:
Timestamp:
03/21/2019 07:47:29 PM (7 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/post/nav-menu.php

    r43571 r44966  
    862862        }
    863863
     864        /**
     865         * @ticket 44005
     866         * @group privacy
     867         */
     868        function test_no_privacy_policy_class_applied() {
     869                $page_id = self::factory()->post->create(
     870                        array(
     871                                'post_type'  => 'page',
     872                                'post_title' => 'Privacy Policy Page',
     873                        )
     874                );
     875
     876                wp_update_nav_menu_item(
     877                        $this->menu_id,
     878                        0,
     879                        array(
     880                                'menu-item-type'      => 'post_type',
     881                                'menu-item-object'    => 'page',
     882                                'menu-item-object-id' => $page_id,
     883                                'menu-item-status'    => 'publish',
     884                        )
     885                );
     886
     887                $menu_items = wp_get_nav_menu_items( $this->menu_id );
     888                _wp_menu_item_classes_by_context( $menu_items );
     889
     890                $classes = $menu_items[0]->classes;
     891
     892                $this->assertNotContains( 'menu-item-privacy-policy', $classes );
     893        }
     894
     895        /**
     896         * @ticket 44005
     897         * @group privacy
     898         */
     899        function test_class_applied_to_privacy_policy_page_item() {
     900                $page_id = self::factory()->post->create(
     901                        array(
     902                                'post_type'  => 'page',
     903                                'post_title' => 'Privacy Policy Page',
     904                        )
     905                );
     906                update_option( 'wp_page_for_privacy_policy', $page_id );
     907
     908                wp_update_nav_menu_item(
     909                        $this->menu_id,
     910                        0,
     911                        array(
     912                                'menu-item-type'      => 'post_type',
     913                                'menu-item-object'    => 'page',
     914                                'menu-item-object-id' => $page_id,
     915                                'menu-item-status'    => 'publish',
     916                        )
     917                );
     918
     919                $menu_items = wp_get_nav_menu_items( $this->menu_id );
     920                _wp_menu_item_classes_by_context( $menu_items );
     921
     922                $classes = $menu_items[0]->classes;
     923
     924                delete_option( 'wp_page_for_privacy_policy' );
     925
     926                $this->assertContains( 'menu-item-privacy-policy', $classes );
     927        }
     928
    864929}
Note: See TracChangeset for help on using the changeset viewer.