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/src/wp-includes/class-wp-query.php

    r44941 r44966  
    325325         */
    326326        public $is_home = false;
     327
     328        /**
     329         * Signifies whether the current query is for the Privacy Policy page.
     330         *
     331         * @since 5.2.0
     332         * @var bool
     333         */
     334        public $is_privacy_policy = false;
    327335
    328336        /**
     
    464472                $this->is_trackback         = false;
    465473                $this->is_home              = false;
     474                $this->is_privacy_policy    = false;
    466475                $this->is_404               = false;
    467476                $this->is_paged             = false;
     
    9991008                                $this->is_posts_page = true;
    10001009                        }
     1010
     1011                        if ( isset( $this->queried_object_id ) && $this->queried_object_id == get_option( 'wp_page_for_privacy_policy' ) ) {
     1012                                $this->is_privacy_policy = true;
     1013                        }
    10011014                }
    10021015
     
    10061019                                $this->is_home       = true;
    10071020                                $this->is_posts_page = true;
     1021                        }
     1022
     1023                        if ( $qv['page_id'] == get_option( 'wp_page_for_privacy_policy' ) ) {
     1024                                $this->is_privacy_policy = true;
    10081025                        }
    10091026                }
     
    38793896
    38803897        /**
     3898         * Is the query for the Privacy Policy page?
     3899         *
     3900         * This is the page which shows the Privacy Policy content of your site.
     3901         *
     3902         * Depends on the site's "Change your Privacy Policy page" Privacy Settings 'wp_page_for_privacy_policy'.
     3903         *
     3904         * This function will return true only on the page you set as the "Privacy Policy page".
     3905         *
     3906         * @since 5.2.0
     3907         *
     3908         * @return bool True, if Privacy Policy page.
     3909         */
     3910        public function is_privacy_policy() {
     3911                if ( get_option( 'wp_page_for_privacy_policy' ) && $this->is_page( get_option( 'wp_page_for_privacy_policy' ) ) ) {
     3912                        return true;
     3913                } else {
     3914                        return false;
     3915                }
     3916        }
     3917
     3918        /**
    38813919         * Is the query for an existing month archive?
    38823920         *
Note: See TracChangeset for help on using the changeset viewer.