Skip to content

Commit 869faa0

Browse files
authored
add _reset_privacy_policy_page_for_post function
1 parent b10d2f9 commit 869faa0

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/wp-includes/post.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4027,6 +4027,26 @@ function _reset_front_page_settings_for_post( $post_id ) {
40274027
unstick_post( $post->ID );
40284028
}
40294029

4030+
/**
4031+
* Resets the Privacy Policy page ID option when the Privacy Policy page
4032+
* is deleted or trashed, to prevent uncached database queries for a
4033+
* non-existent page.
4034+
*
4035+
* @since 7.1.0
4036+
* @access private
4037+
*
4038+
* @param int $post_id The ID of the post being deleted or trashed.
4039+
*/
4040+
function _reset_privacy_policy_page_for_post( $post_id ) {
4041+
$post = get_post( $post_id );
4042+
4043+
if ( $post && 'page' === $post->post_type ) {
4044+
if ( (int) get_option( 'wp_page_for_privacy_policy' ) === (int) $post_id ) {
4045+
update_option( 'wp_page_for_privacy_policy', 0 );
4046+
}
4047+
}
4048+
}
4049+
40304050
/**
40314051
* Moves a post or page to the Trash
40324052
*

0 commit comments

Comments
 (0)