Make WordPress Core

Ticket #44005: 44005.diff

File 44005.diff, 2.5 KB (added by xkon, 6 years ago)

Adds is_privacy_policy() and privacy_policy body class.

  • src/wp-includes/class-wp-query.php

     
    350350        public $is_paged = false;
    351351
    352352        /**
     353         * Signifies whether the current query is for the privacy policy page.
     354         *
     355         * @since 5.2
     356         * @var bool
     357         */
     358        public $is_privacy_policy = false;
     359
     360        /**
    353361         * Signifies whether the current query is for an administrative interface page.
    354362         *
    355363         * @since 1.5.0
     
    39493957        }
    39503958
    39513959        /**
     3960         * Is the query for the privacy policy page?
     3961         *
     3962         * @since 5.2
     3963         *
     3964         * @return bool True, if is privacy policy page.
     3965         */
     3966        public function is_privacy_policy() {
     3967                $page_obj = $this->get_queried_object();
     3968
     3969                if ( (int) get_option( 'wp_page_for_privacy_policy' ) === $page_obj->ID ) {
     3970                        return true;
     3971                } else {
     3972                        return false;
     3973                }
     3974        }
     3975
     3976        /**
    39523977         * Is the query for a post or page preview?
    39533978         *
    39543979         * @since 3.1.0
  • src/wp-includes/post-template.php

     
    622622        if ( is_404() ) {
    623623                $classes[] = 'error404';
    624624        }
     625        if ( is_privacy_policy() ) {
     626                $classes[] = 'privacy-policy';
     627        }
    625628
    626629        if ( is_singular() ) {
    627630                $post_id   = $wp_query->get_queried_object_id();
  • src/wp-includes/query.php

     
    569569}
    570570
    571571/**
     572 * Determines whether the query is for the privacy policy page.
     573 *
     574 * For more information on this and similar theme functions, check out
     575 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
     576 * Conditional Tags} article in the Theme Developer Handbook.
     577 *
     578 * @since 5.2
     579 *
     580 * @global WP_Query $wp_query Global WP_Query instance.
     581 *
     582 * @return bool
     583 */
     584function is_privacy_policy() {
     585        global $wp_query;
     586
     587        if ( ! isset( $wp_query ) ) {
     588                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
     589                return false;
     590        }
     591
     592        return $wp_query->is_privacy_policy();
     593}
     594
     595/**
    572596 * Determines whether the query is for a post or page preview.
    573597 *
    574598 * For more information on this and similar theme functions, check out