Skip to content

Commit

Permalink
Twenty Seventeen: Fixes front page panels allow pages of any status t…
Browse files Browse the repository at this point in the history
…o 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@58687 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
karmatosed committed Jul 8, 2024
1 parent bd8f45f commit b9e2bd9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/wp-content/themes/twentyseventeen/inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">' .
Expand Down

0 comments on commit b9e2bd9

Please sign in to comment.