Twenty Seventeen: Fixes front page panels allow pages of any status to be shown.

If you have a published page set to a section but also private, draft, pending or trash at some point in the future it was still showing on the homepage. There was no clarity to the user what was happening. This adds in a check to the post_status variable before displaying panel content and adjusts the customizer to show a placeholder if the page is draft,trashed,deleted. 

Props brettshumaker, sabernhardt.
Fixes #46604.

Built from https://develop.svn.wordpress.org/trunk@58687


git-svn-id: http://core.svn.wordpress.org/trunk@58089 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Tammie Lister 2024-07-08 10:45:18 +00:00
parent 7414d12f0d
commit 54b2903296
2 changed files with 13 additions and 2 deletions

View File

@ -149,16 +149,27 @@ function twentyseventeen_front_page_section( $partial = null, $id = 0 ) {
$twentyseventeencounter = $id;
}
// Only when in Customizer, use a placeholder for an empty panel.
$show_panel_placeholder = false;
global $post; // Modify the global post object before setting up post data.
if ( get_theme_mod( 'panel_' . $id ) ) {
$post = get_post( get_theme_mod( 'panel_' . $id ) );
setup_postdata( $post );
set_query_var( 'panel', $id );
get_template_part( 'template-parts/page/content', 'front-page-panels' );
if ( $post && in_array( $post->post_status, array( 'publish', 'private' ), true ) ) {
get_template_part( 'template-parts/page/content', 'front-page-panels' );
} elseif ( is_customize_preview() ) {
$show_panel_placeholder = true;
}
wp_reset_postdata();
} elseif ( is_customize_preview() ) {
$show_panel_placeholder = true;
}
if ( $show_panel_placeholder ) {
// The output placeholder anchor.
printf(
'<article class="panel-placeholder panel twentyseventeen-panel twentyseventeen-panel%1$s" id="panel%1$s">' .

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-58686';
$wp_version = '6.7-alpha-58687';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.