Skip to content

Commit

Permalink
Move the search bar control into the site-title.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Jun 7, 2022
1 parent e64fb7b commit 4270778
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 26 deletions.
43 changes: 20 additions & 23 deletions source/wp-content/themes/wporg-developer/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@

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

$show_search = DevHub\should_show_search_bar();

?>

<header id="masthead" class="site-header<?php if ( is_front_page() ) { echo ' home'; } ?>" role="banner">
<?php if ( function_exists( 'wporg_is_handbook' ) && wporg_is_handbook() && ! is_search() ) : ?>
<a href="#" id="secondary-toggle" onclick="return false;"><strong><?php _e( 'Menu', 'wporg' ); ?></strong></a>
<?php endif; ?>
<div class="site-branding">
<div class="site-branding <?php echo $show_search ? 'has-search-form': '' ?> ">

<h1 class="site-title">
<a href="<?php echo esc_url( DevHub\get_site_section_url() ); ?>" rel="home"><?php echo DevHub\get_site_section_title(); ?></a>
</h1>
Expand All @@ -24,33 +27,27 @@
<p class="site-description"><?php _e( 'The freedom to build.', 'wporg' ); ?></p>
<?php endif; ?>

<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle dashicons dashicons-arrow-down-alt2" aria-controls="primary-menu" aria-expanded="false" aria-label="<?php esc_attr_e( 'Primary Menu', 'wporg' ); ?>"></button>
<?php
$active_menu = is_post_type_archive( 'command' ) || is_singular( 'command' ) ? 'devhub-cli-menu' : 'devhub-menu';
wp_nav_menu( array(
'theme_location' => $active_menu,
'container_class' => 'menu-container',
'container_id' => 'primary-menu',
) ); ?>
</nav>
<?php if ( $show_search ) : ?>
<div class="site-breadcrumb">
<?php get_search_form( array( 'showFilters' => false ) ); ?>
</div>
<?php else: ?>
<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle dashicons dashicons-arrow-down-alt2" aria-controls="primary-menu" aria-expanded="false" aria-label="<?php esc_attr_e( 'Primary Menu', 'wporg' ); ?>"></button>
<?php
$active_menu = is_post_type_archive( 'command' ) || is_singular( 'command' ) ? 'devhub-cli-menu' : 'devhub-menu';
wp_nav_menu( array(
'theme_location' => $active_menu,
'container_class' => 'menu-container',
'container_id' => 'primary-menu',
) ); ?>
</nav>
<?php endif; ?>
</div>
</header><!-- #masthead -->

<div id="page" class="hfeed site devhub-wrap">
<a href="#main" class="screen-reader-text"><?php _e( 'Skip to content', 'wporg' ); ?></a>

<?php do_action( 'before' ); ?>
<?php
if ( DevHub\should_show_search_bar() ) : ?>
<div id="inner-search">
<?php get_search_form(); ?>
<div id="inner-search-icon-container">
<div id="inner-search-icon">
<div class="dashicons dashicons-search"><span class="screen-reader-text"><?php _e( 'Search', 'wporg' ); ?></span></div>
</div>
</div>
</div>

<?php endif; ?>
<div id="content" class="site-content">
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __construct( $args = array() ) {
'network' => false,
//'show_edit_link' => false,
'show_title' => true,
'show_browse' => true,
'show_browse' => false,
'echo' => true,

/* Post taxonomy (examples follow). */
Expand Down
6 changes: 6 additions & 0 deletions source/wp-content/themes/wporg-developer/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,12 @@
max-width: 960px;
padding: 0 10px;
position: relative;

&.has-search-form {
display: flex;
justify-content: space-between;
align-items: center;
}
}

.site-title {
Expand Down
11 changes: 9 additions & 2 deletions source/wp-content/themes/wporg-developer/searchform.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
*
* @package wporg-developer
*/

$showFilters = true;

if(array_key_exists('showFilters', $args)){
$showFilters = $args['showFilters'];
}

?>
<div class="search-section section clear <?php if ( ! ( is_page( 'reference' ) || is_search() || is_404() ) ) { echo 'hide-if-js'; } ?>">
<div class="search-section section clear">

<?php
$is_handbook = $GLOBALS['wp_query']->is_handbook;
Expand All @@ -22,7 +29,7 @@
<label for="search-field" class="screen-reader-text"><?php _ex( 'Search for:', 'label', 'wporg' ); ?></label>
<input type="text" id="search-field" class="search-field" placeholder="<?php echo esc_attr_x( 'Search &hellip;', 'placeholder', 'wporg' ); ?>" value="<?php echo esc_attr( get_search_query() ); ?>" name="s">
<button class="button button-primary button-search"><i class="dashicons dashicons-search"></i><span class="screen-reader-text"><?php _e( 'Search plugins', 'wporg' ); ?></span></button>
<?php if ( $filters ) : ?>
<?php if ( $filters && $showFilters ) : ?>

<div class="search-post-type">
<span><?php _e( 'Filter by type:', 'wporg' ); ?></span>
Expand Down
6 changes: 6 additions & 0 deletions source/wp-content/themes/wporg-developer/stylesheets/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4270778

Please sign in to comment.