diff --git a/client-mu-plugins/goodbids/blocks/nonprofit-navigation/block.json b/client-mu-plugins/goodbids/blocks/nonprofit-navigation/block.json deleted file mode 100644 index 9a90082de..000000000 --- a/client-mu-plugins/goodbids/blocks/nonprofit-navigation/block.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "nonprofit-navigation", - "title": "Nonprofit Navigation", - "description": "Displays the Nonprofit Navigation", - "icon": "admin-links", - "textdomain": "goodbids", - "acf": { - "mode": "preview" - }, - "supports": { - "jsx": false - } -} diff --git a/client-mu-plugins/goodbids/blocks/nonprofit-navigation/block.php b/client-mu-plugins/goodbids/blocks/nonprofit-navigation/block.php deleted file mode 100644 index 364414ffb..000000000 --- a/client-mu-plugins/goodbids/blocks/nonprofit-navigation/block.php +++ /dev/null @@ -1,23 +0,0 @@ - - - - - diff --git a/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php b/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php index ab9ad8663..9dd6937f4 100644 --- a/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php +++ b/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php @@ -108,17 +108,6 @@ 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' ), @@ -178,7 +167,6 @@ function (): void { $hero_banner, $logo_grid, $nonprofit_interest_form, - $nonprofit_navigation, $section_sidebar_chapters, $template_about, $template_auction, diff --git a/client-mu-plugins/goodbids/src/classes/Network/Sites.php b/client-mu-plugins/goodbids/src/classes/Network/Sites.php index bb89dc2de..bd8e84c83 100644 --- a/client-mu-plugins/goodbids/src/classes/Network/Sites.php +++ b/client-mu-plugins/goodbids/src/classes/Network/Sites.php @@ -17,6 +17,7 @@ use WP_Block_Type_Registry; use WP_Post; use WP_Site; +use WP_Query; /** * Network Sites Class @@ -31,6 +32,18 @@ class Sites { */ const ALL_AUCTIONS_TRANSIENT = '_goodbids_all_auctions'; + /** + * @since 1.0.0 + * @var array + */ + const ABOUT_OPTION = 'gb_about_page'; + + /** + * @since 1.0.0 + * @var array + */ + const AUCTIONS_OPTION = 'gb_auctions_page'; + /** * @since 1.0.0 */ @@ -63,6 +76,8 @@ public function __construct() { // Refresh transients when Auctions change status. $this->maybe_clear_transients(); + + $this->set_nonprofit_navigation(); } /** @@ -392,6 +407,8 @@ function (): void { if ( is_wp_error( $about_id ) ) { Log::error( $about_id->get_error_message() ); } + + update_option( self::ABOUT_OPTION, $about_id ); } ); } @@ -432,6 +449,8 @@ function (): void { if ( is_wp_error( $auctions_id ) ) { Log::error( $auctions_id->get_error_message() ); } + + update_option( self::AUCTIONS_OPTION, $auctions_id ); } ); } @@ -625,7 +644,6 @@ function () use ( $auction_data ) { ] ) ->all(); - } /** @@ -1076,24 +1094,46 @@ private function get_page_path( string $path ): ?WP_Post { /** - * Return the nonprofit navigation + * Set the nonprofit navigation * - * @return array + * @return void * * @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', - ], - ]; + public function set_nonprofit_navigation(): void { + add_action( + 'goodbids_nonprofit_verified', + function ( int $site_id ): void { + + $about_id = get_option( self::ABOUT_OPTION ); + $auctions_id = get_option( self::AUCTIONS_OPTION ); + $wp_navigation = new WP_Query( + [ + 'post_type' => 'wp_navigation', + 'post_status' => [ 'publish' ], + ] + ); + $nav_links = [ + get_post( $about_id ), + get_post( $auctions_id ), + ]; + + + ob_start(); + goodbids()->load_view( 'parts/nonprofit-navigation.php', compact( 'nav_links' ) ); + + $navigation_content = [ + 'ID' => $wp_navigation->posts[0]->ID, + 'post_content' => ob_get_clean(), + ]; + + // Update the post into the database + wp_update_post( $navigation_content ); + + if ( is_wp_error( $navigation_content ) ) { + Log::error( $navigation_content->get_error_message() ); + } + } + ); } } diff --git a/client-mu-plugins/goodbids/views/parts/nonprofit-navigation.php b/client-mu-plugins/goodbids/views/parts/nonprofit-navigation.php new file mode 100644 index 000000000..d51ac79ea --- /dev/null +++ b/client-mu-plugins/goodbids/views/parts/nonprofit-navigation.php @@ -0,0 +1,14 @@ + + + + + diff --git a/client-mu-plugins/goodbids/views/patterns/nonprofit-navigation.php b/client-mu-plugins/goodbids/views/patterns/nonprofit-navigation.php deleted file mode 100644 index ceaf0408e..000000000 --- a/client-mu-plugins/goodbids/views/patterns/nonprofit-navigation.php +++ /dev/null @@ -1,17 +0,0 @@ -sites->get_nonprofit_navigation(); -?> - - - - - - - diff --git a/themes/goodbids-nonprofit/patterns/header-nonprofit.php b/themes/goodbids-nonprofit/patterns/header-nonprofit.php index 60cfb564e..c62a1e31a 100644 --- a/themes/goodbids-nonprofit/patterns/header-nonprofit.php +++ b/themes/goodbids-nonprofit/patterns/header-nonprofit.php @@ -21,7 +21,8 @@
- + +