mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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:
@@ -325,6 +325,14 @@ class WP_Query {
|
||||
*/
|
||||
public $is_home = false;
|
||||
|
||||
/**
|
||||
* Signifies whether the current query is for the Privacy Policy page.
|
||||
*
|
||||
* @since 5.2.0
|
||||
* @var bool
|
||||
*/
|
||||
public $is_privacy_policy = false;
|
||||
|
||||
/**
|
||||
* Signifies whether the current query couldn't find anything.
|
||||
*
|
||||
@@ -463,6 +471,7 @@ class WP_Query {
|
||||
$this->is_comment_feed = false;
|
||||
$this->is_trackback = false;
|
||||
$this->is_home = false;
|
||||
$this->is_privacy_policy = false;
|
||||
$this->is_404 = false;
|
||||
$this->is_paged = false;
|
||||
$this->is_admin = false;
|
||||
@@ -998,6 +1007,10 @@ class WP_Query {
|
||||
$this->is_home = true;
|
||||
$this->is_posts_page = true;
|
||||
}
|
||||
|
||||
if ( isset( $this->queried_object_id ) && $this->queried_object_id == get_option( 'wp_page_for_privacy_policy' ) ) {
|
||||
$this->is_privacy_policy = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $qv['page_id'] ) {
|
||||
@@ -1006,6 +1019,10 @@ class WP_Query {
|
||||
$this->is_home = true;
|
||||
$this->is_posts_page = true;
|
||||
}
|
||||
|
||||
if ( $qv['page_id'] == get_option( 'wp_page_for_privacy_policy' ) ) {
|
||||
$this->is_privacy_policy = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $qv['post_type'] ) ) {
|
||||
@@ -3877,6 +3894,27 @@ class WP_Query {
|
||||
return (bool) $this->is_home;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the query for the Privacy Policy page?
|
||||
*
|
||||
* This is the page which shows the Privacy Policy content of your site.
|
||||
*
|
||||
* Depends on the site's "Change your Privacy Policy page" Privacy Settings 'wp_page_for_privacy_policy'.
|
||||
*
|
||||
* This function will return true only on the page you set as the "Privacy Policy page".
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return bool True, if Privacy Policy page.
|
||||
*/
|
||||
public function is_privacy_policy() {
|
||||
if ( get_option( 'wp_page_for_privacy_policy' ) && $this->is_page( get_option( 'wp_page_for_privacy_policy' ) ) ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the query for an existing month archive?
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user