Skip to content

Commit

Permalink
[#495] testing out pattern for custom menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-schmidt-viget committed Mar 1, 2024
1 parent fd0464a commit d70a2fd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
14 changes: 13 additions & 1 deletion client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ function (): void {
'inserter' => true,
];

$nonprofit_navigation = [
'name' => 'nonprofit-navigation',
'path' => goodbids()->get_view_path( 'patterns/nonprofit-navigation.php' ),
'title' => __( 'Nonprofit Navigation', 'goodbids' ),
'description' => _x( 'Default Nonprofit Navigation', 'Block pattern description', 'goodbids' ),
'categories' => [ 'goodbids' ],
'keywords' => [ 'navigation' ],
'source' => 'plugin',
'inserter' => true,
];

$section_sidebar_chapters = [
'name' => 'section-sidebar-chapters',
'path' => goodbids()->get_view_path( 'patterns/section-sidebar-chapters.php' ),
Expand Down Expand Up @@ -167,6 +178,7 @@ function (): void {
$hero_banner,
$logo_grid,
$nonprofit_interest_form,
$nonprofit_navigation,
$section_sidebar_chapters,
$template_about,
$template_auction,
Expand Down Expand Up @@ -212,7 +224,7 @@ public function register_pattern( array $pattern ): bool {

if ( empty( $pattern['slug'] ) ) {
list( $namespace, $slug ) = explode( '/', $name );
$pattern['slug'] = $slug;
$pattern['slug'] = $slug;
}

if ( empty( $pattern['categories'] ) ) {
Expand Down
23 changes: 23 additions & 0 deletions client-mu-plugins/goodbids/src/classes/Network/Sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -1038,4 +1038,27 @@ private function get_page_path( string $path ): ?WP_Post {

return get_page_by_path( $path ); // phpcs:ignore
}


/**
* Return the nonprofit navigation
*
* @return array
*
* @since 1.0.0
*/
public function get_nonprofit_navigation(): array {
return [
[
'label' => 'Explore Auctions',
'ID' => 4,
'url' => '/explore-auctions',
],
[
'label' => 'About GOODBIDS',
'ID' => 3,
'url' => '/about',
],
];
}
}
17 changes: 17 additions & 0 deletions client-mu-plugins/goodbids/views/patterns/nonprofit-navigation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* Template part for displaying the navigation
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package GoodBids
*/
$nav_items = goodbids()->sites->get_nonprofit_navigation();
?>

<!-- wp:navigation -->
<?php foreach ( $nav_items as $nav_item ) : ?>
<!-- wp:navigation-link {"label":"<?php echo esc_html( $nav_item['label'] ); ?>","type":"page","id":<?php echo esc_html( $nav_item['ID'] ); ?>,"url":"<?php echo esc_url( $nav_item['url'] ); ?>","kind":"post-type"} /-->
<?php endforeach; ?>
<!-- /wp:navigation -->
<!-- wp:woocommerce/customer-account {"displayStyle":"text_only","iconStyle":"alt","iconClass":"wc-block-customer-account__account-icon","className":"btn","textColor":"contrast","fontSize":"x-small","style":{"layout":{"selfStretch":"fit","flexSize":null},"elements":{"link":{"color":{"text":"var:preset|color|contrast"}}}}} /-->
8 changes: 1 addition & 7 deletions themes/goodbids-nonprofit/patterns/header-nonprofit.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@
<!-- wp:group {"style":{"spacing":{"blockGap":"var:preset|spacing|20"}},"layout":{"type":"flex","flexWrap":"wrap"}} -->
<div class="wp-block-group">
<!-- wp:navigation -->
<!-- wp:navigation-link {"label":"test","type":"page","id":43,"url":"http://nonprofit.goodbids.vipdev.lndo.site/my-account/","kind":"post-type"} /-->
<!-- wp:navigation-link {"label":"test","type":"page","id":40,"url":"http://nonprofit.goodbids.vipdev.lndo.site/shop/","kind":"post-type"} /-->
<!-- /wp:navigation -->
<!-- wp:woocommerce/customer-account {"displayStyle":"text_only","iconStyle":"alt","iconClass":"wc-block-customer-account__account-icon","className":"btn","textColor":"contrast","fontSize":"x-small","style":{"layout":{"selfStretch":"fit","flexSize":null},"elements":{"link":{"color":{"text":"var:preset|color|contrast"}}}}} /-->
<!-- wp:pattern {"slug":"goodbids/nonprofit-navigation"} /-->
</div>
<!-- /wp:group -->
</div>
Expand Down

0 comments on commit d70a2fd

Please sign in to comment.