<?php
/**
 * Template part for displaying page content in page.php.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Pen
 */

$pen_is_singular = is_singular();
?>
<article id="post-<?php the_ID(); ?>" <?php echo pen_post_classes(); /* phpcs:ignore */ ?>>
<?php
$background_image_dynamic = pen_content_title_background( $pen_is_singular, get_the_ID() );
?>
	<header class="entry-header<?php echo pen_class_lists( 'header_display_override' ); /* phpcs:ignore */ ?>"<?php if ( $background_image_dynamic ) { echo ' style="background-image:url(' . $background_image_dynamic . ');background-size:cover"'; /* phpcs:ignore */ } ?>>
<?php
the_title(
	sprintf(
		'<h1 class="entry-title%s">',
		pen_class_lists( 'title_display_override' )
	),
	'</h1>'
);

echo pen_html_share( 'header' ); /* phpcs:ignore */
?>
	</header><!-- .entry-header -->
<?php
pen_sidebar_get( 'sidebar-content-top' );

ob_start( 'trim' );
the_content();
$content = ob_get_clean();

ob_start( 'trim' );
get_template_part( 'partials/content', 'thumbnail' );
$thumbnail = ob_get_clean();

ob_start( 'trim' );
echo $thumbnail; /* phpcs:ignore */
if ( $content ) {
	?>
	<div class="pen_content_wrapper">
	<?php
	echo $content; /* phpcs:ignore */
	?>
	</div>
	<?php
}

pen_html_pagination_content();

$classes = trim(
	implode(
		' ',
		array_filter(
			array(
				'entry-content',
				'clearfix',
				trim( pen_class_lists( 'summary_display_override' ) ),
				$thumbnail ? 'pen_has_thumbnail' : 'pen_without_thumbnail',
			)
		)
	)
);

$content = ob_get_clean();
if ( $content ) {
	?>
	<div class="<?php echo esc_attr( $classes ); ?>">
	<?php
	echo $content; /* phpcs:ignore */
	echo pen_html_share( 'content' ); /* phpcs:ignore */
	?>
	</div><!-- .entry-content -->
	<?php
}

pen_sidebar_get( 'sidebar-content-bottom' );

$edit_link    = ( ! $pen_is_singular ) ? get_edit_post_link() : false;
$social_share = pen_html_share( 'footer' );
if ( $edit_link || $social_share ) {
	?>
	<footer class="entry-footer<?php echo pen_class_lists( 'footer_display_override' ); /* phpcs:ignore */ ?>">
		<div class="pen_actions">
	<?php
	if ( $edit_link ) {
		edit_post_link(
			sprintf(
				/* Translators: %s: Name of current post */
				esc_html__( 'Edit %s', 'pen' ),
				the_title( '<span class="screen-reader-text">"', '"</span>', false )
			),
			'<span class="edit-link">',
			'</span>'
		);
	}
	echo $social_share; /* phpcs:ignore */
	?>
		</div>
	</footer><!-- .entry-footer -->
	<?php
}

echo pen_html_configuration_overview(); /* phpcs:ignore */

if ( $pen_is_singular ) {
	pen_html_jump_menu( 'content' );
}
?>
</article><!-- #post-<?php the_ID(); ?> -->