WordPress.org

Make WordPress Core


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

    r44941 r44966  
    488488
    489489    return $wp_query->is_home();
     490}
     491
     492/**
     493 * Determines whether the query is for the Privacy Policy page.
     494 *
     495 * The Privacy Policy page is the page that shows the Privacy Policy content of the site.
     496 *
     497 * is_privacy_policy() is dependent on the site's "Change your Privacy Policy page" Privacy Settings 'wp_page_for_privacy_policy'.
     498 *
     499 * This function will return true only on the page you set as the "Privacy Policy page".
     500 *
     501 * For more information on this and similar theme functions, check out
     502 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
     503 * Conditional Tags} article in the Theme Developer Handbook.
     504 *
     505 * @since 5.2.0
     506 *
     507 * @global WP_Query $wp_query Global WP_Query instance.
     508 *
     509 * @return bool
     510 */
     511function is_privacy_policy() {
     512    global $wp_query;
     513
     514    if ( ! isset( $wp_query ) ) {
     515        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
     516        return false;
     517    }
     518
     519    return $wp_query->is_privacy_policy();
    490520}
    491521
Note: See TracChangeset for help on using the changeset viewer.