From 9355c7d9c962998c36d8b8e34467550a7f10f8b7 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Wed, 13 Nov 2024 18:13:28 -0500 Subject: [PATCH] Templates: Add "in progress" template and hide content when using template --- .../inc/page-meta-descriptions.php | 21 +++++++++++++++++++ .../templates/page-in-progress.html | 9 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 source/wp-content/themes/wporg-main-2022/templates/page-in-progress.html diff --git a/source/wp-content/themes/wporg-main-2022/inc/page-meta-descriptions.php b/source/wp-content/themes/wporg-main-2022/inc/page-meta-descriptions.php index 29d9a13e..5a5a8cac 100644 --- a/source/wp-content/themes/wporg-main-2022/inc/page-meta-descriptions.php +++ b/source/wp-content/themes/wporg-main-2022/inc/page-meta-descriptions.php @@ -52,6 +52,11 @@ function( $html ) { return $tags; } + // Prevent content from "leaking" in embeds on pages in progress. + if ( 'page-in-progress' === get_post_meta( $post->ID, '_wp_page_template', true ) ) { + return []; + } + // These values are not correct for our page templates. unset( $tags['article:published_time'], $tags['article:modified_time'] ); @@ -212,3 +217,19 @@ function() { add_post_type_support( 'page', 'excerpt' ); } ); + +/** + * Fake the `blog_public` option to prevent search engines from indexing pages in progress. + * + * This setting is used by the `wp_robots_*` functions to add noindex, nofollow meta tags. + */ +add_filter( + 'pre_option_blog_public', + function( $pre ) { + global $post; + if ( $post && 'page-in-progress' === get_post_meta( $post->ID, '_wp_page_template', true ) ) { + return 0; + } + return $pre; + } +); diff --git a/source/wp-content/themes/wporg-main-2022/templates/page-in-progress.html b/source/wp-content/themes/wporg-main-2022/templates/page-in-progress.html new file mode 100644 index 00000000..0749ff04 --- /dev/null +++ b/source/wp-content/themes/wporg-main-2022/templates/page-in-progress.html @@ -0,0 +1,9 @@ + + + +
+ +
+ + +