Skip to content

Commit

Permalink
[#12] styling header navigation with logout button
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-schmidt-viget committed Dec 13, 2023
1 parent 028b599 commit 8666f07
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 5 deletions.
66 changes: 66 additions & 0 deletions client-mu-plugins/goodbids/src/classes/network/Sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct() {

// New Site Actions
$this->activate_child_theme_on_new_site();
$this->copy_logo_to_new_site();
}

/**
Expand Down Expand Up @@ -390,4 +391,69 @@ private function init_site_defaults( int $site_id ): void {

restore_current_blog();
}

/**
* Copies logo to the new site in the WordPress Multisite network
*
* @since 1.0.0
*
*/
private function copy_logo_to_new_site(): void {
add_action(
'goodbids_init_site',
function ( $site_id ) {

// switch to main site
switch_to_blog( get_main_site_id() );

$attachment_id = get_theme_mod( 'custom_logo' );

// get image path.
$file = wp_get_original_image_path( $attachment_id );

// exit the function if an attachment with this specific ID doesn't exist.
if ( ! $file ) {
return;
}

restore_current_blog();

$uploads = wp_upload_dir();

$filename = wp_unique_filename( $uploads['path'], basename( $file ) );
$new_file = $uploads['path'] . "/$filename";
$new_file_url = $uploads['url'] . "/$filename";

// copy the media file
$sideload = @copy( $file, $new_file );

if ( false === $sideload ) {
return;
}

// insert media file into the media gallery
$inserted_attachment_id = wp_insert_attachment(
array(
'guid' => $new_file_url,
'post_mime_type' => mime_content_type( $new_file ),
'post_title' => preg_replace( '/\.[^.]+$/', '', $filename ),
'post_content' => '',
'post_status' => 'inherit',
),
$new_file
);

// make sure this file is included, because wp_generate_attachment_metadata() depends on it
require_once ABSPATH . 'wp-admin/includes/image.php';
// update the attachment metadata.
wp_update_attachment_metadata(
$inserted_attachment_id,
wp_generate_attachment_metadata( $inserted_attachment_id, $new_file )
);

// update the site logo to the main site logo
update_option( 'site_logo', $inserted_attachment_id );
}
);
}
}
32 changes: 32 additions & 0 deletions themes/goodbids-nonprofit/assets/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,35 @@
background-color: var(--wp--preset--color--contrast);
color: var(--wp--preset--color--contrast-4);
}

/*TODO move this all to Tailwind once we set that up*/
.wp-button-custom > a {
background-color: var(--wp--preset--color--contrast);
color: var(--wp--preset--color--base-2);
font-size: var(--wp--preset--font-size--x-small);
font-weight: 500;
text-decoration: none;
border-color: var(--wp--preset--color--contrast);
border-radius: 100px;
border-width: 0;
padding-top: 0.8rem;
padding-right: 1.5rem;
padding-left: 1.5rem;
padding-bottom: 0.8rem;

&:hover {
background-color: var(--wp--preset--color--contrast-4);
border-color: var(--wp--preset--color--contrast);
color: var(--wp--preset--color--contrast);
}

&:focus {
background-color: var(--wp--preset--color--contrast-4);
border-color: var(--wp--preset--color--contrast);
color: var(--wp--preset--color--contrast);
outline-color: var(--wp--preset--color--contrast);
outline-offset: 2px;
outline-style: dotted;
outline-width: 1px;
}
}
17 changes: 13 additions & 4 deletions themes/goodbids-nonprofit/parts/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
style="padding-top:20px;padding-bottom:20px">
<!-- wp:group {"align":"wide","layout":{"type":"flex","justifyContent":"space-between","flexWrap":"wrap"}} -->
<div class="wp-block-group alignwide">
<!-- wp:group {"style":{"spacing":{"blockGap":"0.7rem"},"layout":{"selfStretch":"fit","flexSize":null}},"layout":{"type":"flex"}} -->
<!-- wp:group {"style":{"spacing":{"blockGap":"0.2rem"},"layout":{"selfStretch":"fit","flexSize":null}},"layout":{"type":"flex"}} -->
<div class="wp-block-group">
<!-- wp:site-logo {"width":160 } /-->

<!-- wp:site-logo {"width":160,"shouldSyncIcon":true,"style":{"spacing":{"margin":{"top":"0","bottom":"0","left":"0","right":"0.5rem"}}}} /-->

<!-- wp:group {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-group">
<!-- wp:paragraph {"style":{"layout":{"selfStretch":"fixed","flexSize":"25px"}},"fontSize":"x-small"} -->
<p class="has-x-small-font-size"><em>for</em></p>
<p class="has-x-small-font-size">for</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
Expand All @@ -23,7 +24,15 @@
</div>
<!-- /wp:group -->

<!-- wp:navigation {"ref":5,"layout":{"type":"flex","justifyContent":"right","orientation":"horizontal"},"style":{"spacing":{"margin":{"top":"0"},"blockGap":"var:preset|spacing|20"},"layout":{"selfStretch":"fit","flexSize":null}},"fontSize":"x-small"} /--> </div>
<!-- wp:group {"style":{"spacing":{"blockGap":"var:preset|spacing|20"}},"layout":{"type":"flex","flexWrap":"wrap"}} -->
<div class="wp-block-group">
<!-- wp:navigation {"ref":13,"layout":{"type":"flex","justifyContent":"right","orientation":"horizontal"},"style":{"spacing":{"margin":{"top":"0"},"blockGap":"var:preset|spacing|20"},"layout":{"selfStretch":"fit","flexSize":null}},"fontSize":"x-small"} /-->
<!-- wp:loginout {"className":"wp-button-custom","style":{"spacing":{"margin":{"top":"0"},"blockGap":"var:preset|spacing|20"},"layout":{"selfStretch":"fit","flexSize":null}},"textColor":"base-2","fontSize":"x-small"} /-->
</div>
<!-- /wp:group -->

</div>

<!-- /wp:group -->
</div>
<!-- /wp:group -->
2 changes: 1 addition & 1 deletion themes/goodbids-nonprofit/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Theme URI: https://goodbids.org
Author: Viget
Author URI: https://viget.com
Description: Twenty Twenty-Four child theme for GoodBids Nonprofit sites.
Version: 1.0
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: goodbids-nonprofit
Expand Down

0 comments on commit 8666f07

Please sign in to comment.