Skip to content

Commit

Permalink
[#495] A couple of tweaks, potential bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-viget authored and nathan-schmidt-viget committed Mar 6, 2024
1 parent f533733 commit 0eae952
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions client-mu-plugins/goodbids/src/classes/Network/Sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function __construct() {
// Refresh transients when Auctions change status.
$this->maybe_clear_transients();

// Setup default Nonprofit Navigation.
$this->set_nonprofit_navigation();
}

Expand Down Expand Up @@ -373,7 +374,7 @@ public function add_user_to_site( int $user_id, ?int $site_id = null ): void {
}

/**
* Create the GOODBIDS About page and sets the pattern template
* Creates the GOODBIDS About page and sets the pattern template
*
* @since 1.0.0
*
Expand All @@ -384,9 +385,10 @@ private function create_about_page(): void {
'goodbids_initialize_site',
function (): void {
$about_slug = 'about';
$existing = get_option( self::ABOUT_OPTION );

// Make sure it doesn't already exist.
if ( $this->get_page_path( $about_slug ) ) {
if ( $this->get_page_path( $about_slug ) || $existing ) {
return;
}

Expand All @@ -407,6 +409,7 @@ function (): void {

if ( is_wp_error( $about_id ) ) {
Log::error( $about_id->get_error_message() );
return;
}

update_option( self::ABOUT_OPTION, $about_id );
Expand All @@ -426,9 +429,10 @@ private function create_all_auctions_page(): void {
'goodbids_initialize_site',
function (): void {
$auctions_slug = 'explore-auctions';
$existing = get_option( self::AUCTIONS_OPTION );

// Make sure it doesn't already exist.
if ( $this->get_page_path( $auctions_slug ) ) {
if ( $this->get_page_path( $auctions_slug ) || $existing ) {
return;
}

Expand All @@ -449,6 +453,7 @@ function (): void {

if ( is_wp_error( $auctions_id ) ) {
Log::error( $auctions_id->get_error_message() );
return;
}

update_option( self::AUCTIONS_OPTION, $auctions_id );
Expand All @@ -457,7 +462,7 @@ function (): void {
}

/**
* Delete the sample page
* Attempt to delete the Sample Page
*
* @since 1.0.0
*
Expand Down Expand Up @@ -1112,8 +1117,8 @@ private function get_page_path( string $path ): ?WP_Post {
public function set_nonprofit_navigation(): void {
// TODO: Figure out why it does not fire on setup
add_action(
'goodbids_nonprofit_verified',
function ( int $site_id ): void {
'goodbids_initialize_site',
function (): void {
$about_id = get_option( self::ABOUT_OPTION );
$auctions_id = get_option( self::AUCTIONS_OPTION );

Expand Down Expand Up @@ -1143,10 +1148,10 @@ function ( int $site_id ): void {
];

// Update the navigation into the database
wp_update_post( $navigation_content );
$update = wp_update_post( $navigation_content );

if ( is_wp_error( $navigation_content ) ) {
Log::error( $navigation_content->get_error_message() );
if ( is_wp_error( $update ) ) {
Log::error( 'Error updating Nonprofit Navigation: ' . $update->get_error_message() );
}
}
);
Expand Down

0 comments on commit 0eae952

Please sign in to comment.