Skip to content
This repository has been archived by the owner on Feb 17, 2025. It is now read-only.

Commit

Permalink
Modern Business: add FSE support
Browse files Browse the repository at this point in the history
This adds required functionality to support rendering FSE header and
footer on all site pages (static and dynamic). It's also includes the
data population functionality, which has now been removed from the plugin
and will be delegated to each theme for maximum flexibility.
  • Loading branch information
vindl committed Jul 13, 2019
1 parent a2a4aa9 commit c9e32e2
Show file tree
Hide file tree
Showing 4 changed files with 466 additions and 0 deletions.
68 changes: 68 additions & 0 deletions modern-business/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* The template for displaying the footer
*
* Contains the closing of the #content div and all content after.
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package WordPress
* @subpackage Twenty_Nineteen
* @since 1.0.0
*/

?>

</div><!-- #content -->

<?php
// If FSE plugin is active, use Footer template part for content.
if( defined( 'A8C_FSE_VERSION' ) ) {
fse_get_header();
}

// Otherwise we'll fall back to default Twenty Nineteen footer below.
?>

<?php if( ! defined( 'A8C_FSE_VERSION' ) ) : ?>
<footer id="colophon" class="site-footer">
<?php get_template_part( 'template-parts/footer/footer', 'widgets' ); ?>
<div class="site-info">
<?php $blog_info = get_bloginfo( 'name' ); ?>
<?php if ( ! empty( $blog_info ) ) : ?>
<a class="site-name" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>,
<?php endif; ?>
<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentynineteen' ) ); ?>" class="imprint">
<?php
/* translators: %s: WordPress. */
printf( __( 'Proudly powered by %s.', 'twentynineteen' ), 'WordPress' );
?>
</a>
<?php
if ( function_exists( 'the_privacy_policy_link' ) ) {
the_privacy_policy_link( '', '<span role="separator" aria-hidden="true"></span>' );
}
?>
<?php if ( has_nav_menu( 'footer' ) ) : ?>
<nav class="footer-navigation" aria-label="<?php esc_attr_e( 'Footer Menu', 'twentynineteen' ); ?>">
<?php
wp_nav_menu(
array(
'theme_location' => 'footer',
'menu_class' => 'footer-menu',
'depth' => 1,
)
);
?>
</nav><!-- .footer-navigation -->
<?php endif; ?>
</div><!-- .site-info -->
</footer><!-- #colophon -->
<?php endif; ?>

</div><!-- #page -->

<?php wp_footer(); ?>

</body>
</html>
5 changes: 5 additions & 0 deletions modern-business/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ function modern_business_scripts() {
* WP.com compatibility file.
*/
require get_stylesheet_directory() . '/inc/wpcom.php';

/**
* Full Site Editing template data population file.
*/
require get_stylesheet_directory() . '/inc/fse-template-data.php';
64 changes: 64 additions & 0 deletions modern-business/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* The header for our theme
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package WordPress
* @subpackage Twenty_Nineteen
* @since 1.0.0
*/
?><!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="profile" href="https://gmpg.org/xfn/11" />
<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<div id="page" class="site">
<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'twentynineteen' ); ?></a>

<?php
// If FSE plugin is active, use Header template part for content.
if( defined( 'A8C_FSE_VERSION' ) ) {
fse_get_header();
}

// Otherwise we'll fall back to default Twenty Nineteen header below.
?>

<?php if( ! defined( 'A8C_FSE_VERSION' ) ) : ?>

<header id="masthead" class="<?php echo is_singular() && twentynineteen_can_show_post_thumbnail() ? 'site-header featured-image' : 'site-header'; ?>">
<div class="site-branding-container">
<?php get_template_part( 'template-parts/header/site', 'branding' ); ?>
</div><!-- .site-branding-container -->

<?php if ( is_singular() && twentynineteen_can_show_post_thumbnail() ) : ?>
<div class="site-featured-image">
<?php
twentynineteen_post_thumbnail();
the_post();
$discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentynineteen_get_discussion_data() : null;

$classes = 'entry-header';
if ( ! empty( $discussion ) && absint( $discussion->responses ) > 0 ) {
$classes = 'entry-header has-discussion';
}
?>
<div class="<?php echo $classes; ?>">
<?php get_template_part( 'template-parts/header/entry', 'header' ); ?>
</div><!-- .entry-header -->
<?php rewind_posts(); ?>
</div>
<?php endif; ?>
</header><!-- #masthead -->
<?php endif; ?>

<div id="content" class="site-content">
Loading

0 comments on commit c9e32e2

Please sign in to comment.