Skip to content

Commit

Permalink
Make 2024: Update header and welcome box
Browse files Browse the repository at this point in the history
Replace header with local nav block.

See #363


git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14025 74240141-8908-4e6f-9713-ba540dce6ec7
  • Loading branch information
Adam Wood committed Sep 6, 2024
1 parent bc358fb commit 096ae02
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 164 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace WordPressdotorg\Make\Breathe;
namespace WordPressdotorg\Make\Breathe_2024;

defined( 'WPINC' ) || die();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace WordPressdotorg\Make\Breathe;
namespace WordPressdotorg\Make\Breathe_2024;

/**
* Sets up theme defaults.
Expand Down Expand Up @@ -55,7 +55,7 @@ function wporg_breathe_scripts() {
// Preload the heading font(s).
if ( is_callable( 'global_fonts_preload' ) ) {
/* translators: Subsets can be any of cyrillic, cyrillic-ext, greek, greek-ext, vietnamese, latin, latin-ext. */
$subsets = _x( 'Latin', 'Heading font subsets, comma separated', 'wporg-forums' );
$subsets = _x( 'Latin', 'Heading font subsets, comma separated', 'wporg-breathe' );
// All headings.
global_fonts_preload( 'Inter', $subsets );
}
Expand Down Expand Up @@ -163,6 +163,65 @@ function _merge_by_slug( ...$arrays ) {
return $result;
}

/**
* Register patterns from the patterns directory.
*/
function wporg_breathe_register_patterns() {
$pattern_directory = new \DirectoryIterator( get_stylesheet_directory() . '/patterns/' );
foreach ( $pattern_directory as $file ) {
if ( $file->isFile() ) {
require $file->getPathname();
}
}
}
add_action( 'init', __NAMESPACE__ . '\wporg_breathe_register_patterns' );

/**
* Get the primary navigation menu object if it exists.
*/
function wporg_breathe_get_local_nav_menu_object() {
$local_nav_menu_locations = get_nav_menu_locations();
$local_nav_menu_object = isset( $local_nav_menu_locations['primary'] )
? wp_get_nav_menu_object( $local_nav_menu_locations['primary'] )
: false;

return $local_nav_menu_object;
}

/**
* Provide a list of local navigation menus.
*/
function wporg_breathe_add_site_navigation_menus( $menus ) {
if ( is_admin() ) {
return;
}
$local_nav_menu_object = wporg_breathe_get_local_nav_menu_object();

if ( ! $local_nav_menu_object ) {
return array();
}

$menu_items = wp_get_nav_menu_items( $local_nav_menu_object->term_id );

if ( ! $menu_items || empty( $menu_items ) ) {
return array();
}

return array(
'breathe' => array_map(
function( $menu_item ) {
return array(
'label' => esc_html( $menu_item->title ),
'url' => esc_url( $menu_item->url )
);
},
// Limit local nav items to 4
array_slice( $menu_items, 0, 4 )
)
);
}
add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\wporg_breathe_add_site_navigation_menus' );

/**
* Add postMessage support for site title and description in the customizer.
*
Expand Down Expand Up @@ -285,7 +344,7 @@ function welcome_box() {
id="make-welcome-toggle"
data-show="<?php esc_attr_e( 'Show welcome box', 'wporg' ); ?>"
data-hide="<?php esc_attr_e( 'Hide welcome box', 'wporg' ); ?>"
><?php _e( 'Hide welcome box', 'wporg' ); ?></button>
><span><?php _e( 'Hide welcome box', 'wporg' ); ?></span></button>
</div>
<div class="entry-content clear" id="make-welcome-content" data-cookie="<?php echo $cookie; ?>" data-hash="<?php echo $content_hash; ?>">
<script type="text/javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,11 @@

echo do_blocks( '<!-- wp:wporg/global-header /-->' );

?>
<header id="masthead" class="site-header" role="banner">
<a href="#" id="secondary-toggle" onclick="return false;"><strong><?php _e( 'Menu' ); ?></strong></a>
<div class="site-branding">
<?php if ( is_front_page() && is_home() ) : ?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php do_action( 'wporg_breathe_before_name', 'front' ); ?><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?>
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php do_action( 'wporg_breathe_before_name', 'nonfront' ); ?><?php bloginfo( 'name' ); ?></a></p>
<?php endif; ?>
</div>
echo do_blocks( '<!-- wp:pattern {"slug":"wporg-breathe/local-nav"} /-->' );

<nav id="site-navigation" class="navigation-main clear" role="navigation">
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'fallback_cb' => false, 'depth' => 1 ) ); ?>
</nav><!-- .navigation-main -->
</header><!-- .site-header -->
do_action( 'wporg_breathe_after_header' );

<?php do_action( 'wporg_breathe_after_header' ); ?>
?>

<div id="page" class="hfeed site">
<?php do_action( 'before' ); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Note: Pledges is a simulated page, rather than actually existing in the database; see `mu-plugins/make-network/team-pledges.php`.
*/

namespace WordPressdotorg\Make\Breathe;
namespace WordPressdotorg\Make\Breathe_2024;
use WordPressdotorg\Make\Pledges;

defined( 'WPINC' ) || die();
Expand Down
Loading

0 comments on commit 096ae02

Please sign in to comment.